|
|
|
|
@ -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> |