基础数据-计算公式-新增排序/权限

dev-scheduling
ysn 1 month ago
parent d9662e1482
commit 68921e53f3
  1. 193
      src/views/basicData/calculationFormula/tankDosing.vue
  2. 220
      src/views/basicData/calculationFormula/theoreticalValue.vue

@ -15,17 +15,28 @@
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
@sort-change="sortChange"s
:permission="permissionList"
>
<template #menu-left>
<el-button type="primary" @click="addEdit">新增 </el-button>
<el-button type="danger" @click="handleDelete()"
<el-button type="primary" v-if="permission.calculationFormula1_add" @click="addEdit"
>新增
</el-button>
<el-button type="danger" v-if="permission.calculationFormula1_del" @click="handleDelete()"
>删除
</el-button>
</template>
<template #menu-right> </template>
<template #menu="scope">
<el-button type="text" @click="editFn(scope.row)">修改 </el-button>
<el-button type="text" @click="handleDelete(scope.row)">删除 </el-button>
<el-button type="text" v-if="permission.calculationFormula1_edit" @click="editFn(scope.row)"
>修改
</el-button>
<el-button
type="text"
v-if="permission.calculationFormula1_del"
@click="handleDelete(scope.row)"
>删除
</el-button>
</template>
<template #produceTsTarget="scope"> </template>
</avue-crud>
@ -44,9 +55,15 @@
</div>
</template>
<script>
import addEditDosing from "./components/addEditDosing.vue";
import workCenterSet from "./components/workCenterSet.vue";
import {getList,addFormula,deleteFormula,userListpage} from "@/api/basicData/calculationFormula"
import addEditDosing from './components/addEditDosing.vue';
import workCenterSet from './components/workCenterSet.vue';
import {
getList,
addFormula,
deleteFormula,
userListpage,
} from '@/api/basicData/calculationFormula';
import { mapGetters } from 'vuex';
export default {
components: {
addEditDosing,
@ -55,12 +72,12 @@ export default {
data() {
return {
selectionList: [],
loading:false,
query:{},
loading: false,
query: {},
userListData: [],
userListLoaded: false,
option: {
height: "auto",
height: 'auto',
calcHeight: 32,
tip: false,
// size: "medium",
@ -77,11 +94,11 @@ export default {
delBtn: false,
addBtn: false,
editBtn: false,
editBtnText: "修改",
viewBtnIcon: " ",
delBtnIcon: " ",
editBtnIcon: " ",
viewBtnText: "详情",
editBtnText: '修改',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
viewBtnText: '详情',
labelWidth: 120,
menuWidth: 100,
dialogWidth: 640,
@ -94,51 +111,51 @@ export default {
excelBtn: true,
columnSort: true,
showOverflowTooltip: true,
searchLabelPosition: "left",
searchLabelPosition: "left",
searchLabelPosition: 'left',
searchLabelPosition: 'left',
searchGutter: 24,
searchSpan: 6,
menuAlign: "center",
menuAlign: 'center',
gridBtn: false,
searchMenuPosition: "right",
addBtnIcon: " ",
viewBtnIcon: " ",
delBtnIcon: " ",
editBtnIcon: " ",
align: "center",
searchMenuPosition: 'right',
addBtnIcon: ' ',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
align: 'center',
column: [
{
label: "公式名称",
prop: "name",
sortable: true,
label: '公式名称',
prop: 'name',
sortable: 'custom',
filter: true,
span: 24,
search: true,
},
{
label: "公式内容",
prop: "content",
sortable: true,
label: '公式内容',
prop: 'content',
sortable: 'custom',
filter: true,
span: 24,
search: false,
},
{
label: "操作人",
prop: "updateUser",
sortable: true,
label: '操作人',
prop: 'updateUser',
sortable: 'custom',
filter: true,
span: 24,
search: false,
display: true,
formatter: (row) => {
formatter: row => {
return this.userMapObj[row.updateUser] || row.updateUser || '-';
},
},
{
label: "更新时间",
prop: "updateTime",
sortable: true,
label: '更新时间',
prop: 'updateTime',
sortable: 'custom',
filter: true,
span: 24,
search: false,
@ -146,7 +163,7 @@ export default {
},
],
},
checkRow:{},
checkRow: {},
form: {},
page: {
pageSize: 10,
@ -158,6 +175,14 @@ export default {
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.calculationFormula1_add, false),
editBtn: this.validData(this.permission.calculationFormula1_edit, false),
delBtn: this.validData(this.permission.calculationFormula1_del, false),
};
},
userMapObj() {
const map = {};
this.userListData.forEach(user => {
@ -169,20 +194,21 @@ export default {
},
},
methods: {
loadUserList() {
return new Promise((resolve) => {
userListpage(1, 99999).then(res => {
return new Promise(resolve => {
userListpage(1, 99999)
.then(res => {
if (res.data.code == 200) {
const users = res.data.data;
this.userListData = users.map(user => ({
label: user.realName || user.name,
value: String(user.id)
value: String(user.id),
}));
this.userListLoaded = true;
}
resolve();
}).catch(error => {
})
.catch(error => {
console.error('获取用户列表失败', error);
resolve();
});
@ -199,7 +225,7 @@ export default {
closeDialog(val) {
this.isOpen = false;
this.isWorkOpen = false;
if(val){
if (val) {
this.onLoad();
}
},
@ -239,58 +265,69 @@ export default {
// });
},
handleDelete(row) {
console.log('row---------',row)
console.log('row---------', row);
if (!row && this.selectionList.length === 0) {
this.$message.error('请选择至少一条数据');
return;
}
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
if(row){
deleteFormula({ids:row.id}).then(res => {
if(res.data.code == 200){
this.$message.success('删除成功')
this.onLoad()
if (row) {
deleteFormula({ ids: row.id }).then(res => {
if (res.data.code == 200) {
this.$message.success('删除成功');
this.onLoad();
}
});
}else{
} else {
deleteFormula({
ids:this.selectionList.map(item => item.id).join(',')
}).then(res =>{
if(res.data.code == 200){
this.$message.success('删除成功')
this.onLoad()
ids: this.selectionList.map(item => item.id).join(','),
}).then(res => {
if (res.data.code == 200) {
this.$message.success('删除成功');
this.onLoad();
}
})
});
}
});
},
searchChange(params, done){
searchChange(params, done) {
this.page.currentPage = 1;
this.query = params;
this.onLoad()
this.onLoad();
done();
},
searchReset(){
searchReset() {
this.query = {};
this.onLoad()
this.onLoad();
},
currentChange(currentPage){
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize){
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange(){
this.onLoad()
refreshChange() {
this.onLoad();
},
//
selectionChange(list) {
this.selectionList = list;
},
//
sortChange({ prop, order }) {
this.query.descs = undefined;
this.query.ascs = undefined;
let orderByFieldKey = order === 'descending' ? 'descs' : 'ascs';
this.query[orderByFieldKey] = !prop
? undefined
: prop.replace(/([a-z])([A-Z0-9])/g, '$1_$2').toUpperCase();
// //
this.onLoad(this.page, this.query);
},
async onLoad() {
this.loading = true;
//
@ -298,15 +335,15 @@ export default {
await this.loadUserList();
}
getList({
current:this.page.currentPage,
size:this.page.pageSize,
formulaType:1,
...this.query
}).then(res =>{
this.data = res.data.data.records
this.page.total = res.data.data.total
this.loading = false
})
current: this.page.currentPage,
size: this.page.pageSize,
formulaType: 1,
...this.query,
}).then(res => {
this.data = res.data.data.records;
this.page.total = res.data.data.total;
this.loading = false;
});
// this.data = [
// {
// area: null,

@ -1,43 +1,68 @@
<template>
<div>
<avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page" ref="crud"
@row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
@selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
@refresh-change="refreshChange" @on-load="onLoad">
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model="form"
v-model:page="page"
ref="crud"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"s
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
@sort-change="sortChange"
:permission="permissionList"
>
<template #menu-left>
<el-button type="primary" @click="addEdit">新增
<el-button type="primary" v-if="permission.calculationFormula2_add" @click="addEdit"
>新增
</el-button>
<el-button type="danger" @click="handleDelete()">删除
<el-button type="danger" v-if="permission.calculationFormula2_del" @click="handleDelete()"
>删除
</el-button>
</template>
<template #menu-right>
</template>
<template #menu-right> </template>
<template #menu="scope">
<el-button type="text" @click="editFn(scope.row)">修改
<el-button type="text" v-if="permission.calculationFormula2_edit" @click="editFn(scope.row)"
>修改
</el-button>
<el-button type="text" @click="handleDelete(scope.row)">删除
<el-button
type="text"
v-if="permission.calculationFormula2_del"
@click="handleDelete(scope.row)"
>删除
</el-button>
</template>
<template #produceTsTarget="scope">
</template>
<template #produceTsTarget="scope"> </template>
</avue-crud>
<addEditDosing v-if="isOpen" :showDialog="isOpen"
<addEditDosing
v-if="isOpen"
:showDialog="isOpen"
:formulaType="2"
:checkRow="checkRow" @closeDialog="closeDialog"></addEditDosing>
<workCenterSet v-if="isWorkOpen" :showDialog="isWorkOpen" @closeDialog="closeDialog"></workCenterSet>
:checkRow="checkRow"
@closeDialog="closeDialog"
></addEditDosing>
<workCenterSet
v-if="isWorkOpen"
:showDialog="isWorkOpen"
@closeDialog="closeDialog"
></workCenterSet>
</div>
</template>
<script>
import addEditDosing from './components/addEditDosing.vue'
import workCenterSet from './components/workCenterSet.vue'
import {getList,deleteFormula,userListpage} from "@/api/basicData/calculationFormula"
import addEditDosing from './components/addEditDosing.vue';
import workCenterSet from './components/workCenterSet.vue';
import { getList, deleteFormula, userListpage } from '@/api/basicData/calculationFormula';
import { mapGetters } from 'vuex';
export default {
components: {
addEditDosing,
workCenterSet
workCenterSet,
},
data() {
return {
@ -81,13 +106,13 @@ export default {
excelBtn: true,
columnSort: true,
showOverflowTooltip: true,
searchLabelPosition:'left',
searchLabelPosition:'left',
searchGutter:24,
searchSpan:6,
searchLabelPosition: 'left',
searchLabelPosition: 'left',
searchGutter: 24,
searchSpan: 6,
menuAlign: 'left',
gridBtn:false,
searchMenuPosition:'right',
gridBtn: false,
searchMenuPosition: 'right',
addBtnIcon: ' ',
viewBtnIcon: ' ',
delBtnIcon: ' ',
@ -98,7 +123,7 @@ export default {
{
label: '公式名称',
prop: 'name',
sortable: true,
sortable: 'custom',
filter: true,
span: 24,
search: true,
@ -106,7 +131,7 @@ export default {
{
label: '公式内容',
prop: 'content',
sortable: true,
sortable: 'custom',
filter: true,
span: 24,
search: false,
@ -114,29 +139,27 @@ export default {
{
label: '操作人',
prop: 'updateUser',
sortable: true,
sortable: 'custom',
filter: true,
span: 24,
search: false,
display: true,
formatter: (row) => {
formatter: row => {
return this.userMapObj[row.updateUser] || row.updateUser || '-';
},
},
{
label: '更新时间',
prop: 'updateTime',
sortable: true,
sortable: 'custom',
filter: true,
span: 24,
search: false,
display: true,
},
]
},
form: {
],
},
form: {},
page: {
pageSize: 10,
currentPage: 1,
@ -144,10 +167,18 @@ export default {
},
isOpen: false,
isWorkOpen: false,
checkRow:{}
}
checkRow: {},
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.calculationFormula2_add, false),
editBtn: this.validData(this.permission.calculationFormula2_edit, false),
delBtn: this.validData(this.permission.calculationFormula2_del, false),
};
},
userMapObj() {
const map = {};
this.userListData.forEach(user => {
@ -160,36 +191,38 @@ export default {
},
methods: {
loadUserList() {
return new Promise((resolve) => {
userListpage(1, 99999).then(res => {
return new Promise(resolve => {
userListpage(1, 99999)
.then(res => {
if (res.data.code == 200) {
const users = res.data.data;
this.userListData = users.map(user => ({
label: user.realName || user.name,
value: String(user.id)
value: String(user.id),
}));
this.userListLoaded = true;
}
resolve();
}).catch(error => {
})
.catch(error => {
console.error('获取用户列表失败', error);
resolve();
});
});
},
addEdit() {
this.checkRow = {}
this.isOpen = true
this.checkRow = {};
this.isOpen = true;
},
editFn(row) {
this.isOpen = true
this.checkRow = row
this.isOpen = true;
this.checkRow = row;
},
closeDialog(val) {
this.isOpen = false
this.isWorkOpen = false
if(val) {
this.onLoad()
this.isOpen = false;
this.isWorkOpen = false;
if (val) {
this.onLoad();
}
},
maintenanceClick() {
@ -237,68 +270,79 @@ export default {
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
if(row){
if (row) {
deleteFormula({
ids:row.id
}).then(res =>{
if(res.data.code == 200){
this.$message.success('删除成功')
this.onLoad()
ids: row.id,
}).then(res => {
if (res.data.code == 200) {
this.$message.success('删除成功');
this.onLoad();
}
})
}else{
});
} else {
deleteFormula({
ids:this.selectionList.map(item => item.id).join(',')
}).then(res =>{
if(res.data.code == 200){
this.$message.success('删除成功')
this.onLoad()
ids: this.selectionList.map(item => item.id).join(','),
}).then(res => {
if (res.data.code == 200) {
this.$message.success('删除成功');
this.onLoad();
}
})
});
}
})
});
},
searchChange(params, done){
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad()
this.onLoad();
done();
},
searchReset(){
this.query = {}
this.onLoad()
searchReset() {
this.query = {};
this.onLoad();
},
currentChange(currentPage){
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize){
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange(){
this.onLoad()
refreshChange() {
this.onLoad();
},
//
selectionChange(list) {
this.selectionList = list;
},
//
sortChange({ prop, order }) {
this.query.descs = undefined;
this.query.ascs = undefined;
let orderByFieldKey = order === 'descending' ? 'descs' : 'ascs';
this.query[orderByFieldKey] = !prop
? undefined
: prop.replace(/([a-z])([A-Z0-9])/g, '$1_$2').toUpperCase();
// //
this.onLoad(this.page, this.query);
},
async onLoad() {
this.loading = true
this.loading = true;
//
if (!this.userListLoaded) {
await this.loadUserList();
}
getList({
current:this.page.currentPage,
size:this.page.pageSize,
formulaType:2,
...this.query
}).then(res =>{
this.data = res.data.data.records
this.page.total = res.data.data.total
this.loading = false
})
}
}
}
current: this.page.currentPage,
size: this.page.pageSize,
formulaType: 2,
...this.query,
}).then(res => {
this.data = res.data.data.records;
this.page.total = res.data.data.total;
this.loading = false;
});
},
},
};
</script>
<style lang="scss" scoped></style>
Loading…
Cancel
Save