parent
d9662e1482
commit
68921e53f3
2 changed files with 462 additions and 381 deletions
@ -1,304 +1,348 @@ |
|||||||
<template> |
<template> |
||||||
<div> |
<div> |
||||||
<avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page" ref="crud" |
<avue-crud |
||||||
@row-del="rowDel" @search-change="searchChange" @search-reset="searchReset" |
:option="option" |
||||||
@selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange" |
:table-loading="loading" |
||||||
@refresh-change="refreshChange" @on-load="onLoad"> |
:data="data" |
||||||
<template #menu-left> |
v-model="form" |
||||||
<el-button type="primary" @click="addEdit">新增 |
v-model:page="page" |
||||||
</el-button> |
ref="crud" |
||||||
<el-button type="danger" @click="handleDelete()">删除 |
@row-del="rowDel" |
||||||
</el-button> |
@search-change="searchChange" |
||||||
</template> |
@search-reset="searchReset"s |
||||||
<template #menu-right> |
@selection-change="selectionChange" |
||||||
|
@current-change="currentChange" |
||||||
</template> |
@size-change="sizeChange" |
||||||
<template #menu="scope"> |
@refresh-change="refreshChange" |
||||||
<el-button type="text" @click="editFn(scope.row)">修改 |
@on-load="onLoad" |
||||||
</el-button> |
@sort-change="sortChange" |
||||||
<el-button type="text" @click="handleDelete(scope.row)">删除 |
:permission="permissionList" |
||||||
</el-button> |
> |
||||||
</template> |
<template #menu-left> |
||||||
<template #produceTsTarget="scope"> |
<el-button type="primary" v-if="permission.calculationFormula2_add" @click="addEdit" |
||||||
|
>新增 |
||||||
</template> |
</el-button> |
||||||
|
<el-button type="danger" v-if="permission.calculationFormula2_del" @click="handleDelete()" |
||||||
</avue-crud> |
>删除 |
||||||
<addEditDosing v-if="isOpen" :showDialog="isOpen" |
</el-button> |
||||||
:formulaType="2" |
</template> |
||||||
:checkRow="checkRow" @closeDialog="closeDialog"></addEditDosing> |
<template #menu-right> </template> |
||||||
<workCenterSet v-if="isWorkOpen" :showDialog="isWorkOpen" @closeDialog="closeDialog"></workCenterSet> |
<template #menu="scope"> |
||||||
</div> |
<el-button type="text" v-if="permission.calculationFormula2_edit" @click="editFn(scope.row)" |
||||||
|
>修改 |
||||||
|
</el-button> |
||||||
|
<el-button |
||||||
|
type="text" |
||||||
|
v-if="permission.calculationFormula2_del" |
||||||
|
@click="handleDelete(scope.row)" |
||||||
|
>删除 |
||||||
|
</el-button> |
||||||
|
</template> |
||||||
|
<template #produceTsTarget="scope"> </template> |
||||||
|
</avue-crud> |
||||||
|
<addEditDosing |
||||||
|
v-if="isOpen" |
||||||
|
:showDialog="isOpen" |
||||||
|
:formulaType="2" |
||||||
|
:checkRow="checkRow" |
||||||
|
@closeDialog="closeDialog" |
||||||
|
></addEditDosing> |
||||||
|
<workCenterSet |
||||||
|
v-if="isWorkOpen" |
||||||
|
:showDialog="isWorkOpen" |
||||||
|
@closeDialog="closeDialog" |
||||||
|
></workCenterSet> |
||||||
|
</div> |
||||||
</template> |
</template> |
||||||
<script> |
<script> |
||||||
import addEditDosing from './components/addEditDosing.vue' |
import addEditDosing from './components/addEditDosing.vue'; |
||||||
import workCenterSet from './components/workCenterSet.vue' |
import workCenterSet from './components/workCenterSet.vue'; |
||||||
import {getList,deleteFormula,userListpage} from "@/api/basicData/calculationFormula" |
import { getList, deleteFormula, userListpage } from '@/api/basicData/calculationFormula'; |
||||||
|
import { mapGetters } from 'vuex'; |
||||||
export default { |
export default { |
||||||
components: { |
components: { |
||||||
addEditDosing, |
addEditDosing, |
||||||
workCenterSet |
workCenterSet, |
||||||
}, |
}, |
||||||
data() { |
data() { |
||||||
return { |
return { |
||||||
selectionList: [], |
selectionList: [], |
||||||
loading: false, |
loading: false, |
||||||
query: {}, |
query: {}, |
||||||
userListData: [], |
userListData: [], |
||||||
userListLoaded: false, |
userListLoaded: false, |
||||||
option: { |
option: { |
||||||
height: 'auto', |
height: 'auto', |
||||||
calcHeight: 32, |
calcHeight: 32, |
||||||
tip: false, |
tip: false, |
||||||
// size: 'medium', |
// size: 'medium', |
||||||
simplePage: true, |
simplePage: true, |
||||||
searchShow: true, |
searchShow: true, |
||||||
searchMenuSpan: 18, |
searchMenuSpan: 18, |
||||||
searchIcon: true, |
searchIcon: true, |
||||||
searchIndex: 3, |
searchIndex: 3, |
||||||
tree: false, |
tree: false, |
||||||
border: true, |
border: true, |
||||||
index: false, |
index: false, |
||||||
selection: true, |
selection: true, |
||||||
viewBtn: false, |
viewBtn: false, |
||||||
delBtn: false, |
delBtn: false, |
||||||
addBtn: false, |
addBtn: false, |
||||||
editBtn: false, |
editBtn: false, |
||||||
editBtnText: '修改', |
editBtnText: '修改', |
||||||
viewBtnIcon: ' ', |
viewBtnIcon: ' ', |
||||||
delBtnIcon: ' ', |
delBtnIcon: ' ', |
||||||
editBtnIcon: ' ', |
editBtnIcon: ' ', |
||||||
viewBtnText: '详情', |
viewBtnText: '详情', |
||||||
labelWidth: 120, |
labelWidth: 120, |
||||||
menuWidth: 100, |
menuWidth: 100, |
||||||
dialogWidth: 640, |
dialogWidth: 640, |
||||||
dialogClickModal: false, |
dialogClickModal: false, |
||||||
searchEnter: true, |
searchEnter: true, |
||||||
excelBtn: false, |
excelBtn: false, |
||||||
filterBtn: true, |
filterBtn: true, |
||||||
searchShowBtn: false, |
searchShowBtn: false, |
||||||
columnSort: true, |
columnSort: true, |
||||||
excelBtn: true, |
excelBtn: true, |
||||||
columnSort: true, |
columnSort: true, |
||||||
showOverflowTooltip: true, |
showOverflowTooltip: true, |
||||||
searchLabelPosition:'left', |
searchLabelPosition: 'left', |
||||||
searchLabelPosition:'left', |
searchLabelPosition: 'left', |
||||||
searchGutter:24, |
searchGutter: 24, |
||||||
searchSpan:6, |
searchSpan: 6, |
||||||
menuAlign: 'left', |
menuAlign: 'left', |
||||||
gridBtn:false, |
gridBtn: false, |
||||||
searchMenuPosition:'right', |
searchMenuPosition: 'right', |
||||||
addBtnIcon: ' ', |
addBtnIcon: ' ', |
||||||
viewBtnIcon: ' ', |
viewBtnIcon: ' ', |
||||||
delBtnIcon: ' ', |
delBtnIcon: ' ', |
||||||
editBtnIcon: ' ', |
editBtnIcon: ' ', |
||||||
align: 'center', |
align: 'center', |
||||||
|
|
||||||
column: [ |
|
||||||
{ |
|
||||||
label: '公式名称', |
|
||||||
prop: 'name', |
|
||||||
sortable: true, |
|
||||||
filter: true, |
|
||||||
span: 24, |
|
||||||
search: true, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '公式内容', |
|
||||||
prop: 'content', |
|
||||||
sortable: true, |
|
||||||
filter: true, |
|
||||||
span: 24, |
|
||||||
search: false, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '操作人', |
|
||||||
prop: 'updateUser', |
|
||||||
sortable: true, |
|
||||||
filter: true, |
|
||||||
span: 24, |
|
||||||
search: false, |
|
||||||
display: true, |
|
||||||
formatter: (row) => { |
|
||||||
return this.userMapObj[row.updateUser] || row.updateUser || '-'; |
|
||||||
}, |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '更新时间', |
|
||||||
prop: 'updateTime', |
|
||||||
sortable: true, |
|
||||||
filter: true, |
|
||||||
span: 24, |
|
||||||
search: false, |
|
||||||
display: true, |
|
||||||
}, |
|
||||||
] |
|
||||||
}, |
|
||||||
form: { |
|
||||||
|
|
||||||
|
column: [ |
||||||
|
{ |
||||||
|
label: '公式名称', |
||||||
|
prop: 'name', |
||||||
|
sortable: 'custom', |
||||||
|
filter: true, |
||||||
|
span: 24, |
||||||
|
search: true, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '公式内容', |
||||||
|
prop: 'content', |
||||||
|
sortable: 'custom', |
||||||
|
filter: true, |
||||||
|
span: 24, |
||||||
|
search: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '操作人', |
||||||
|
prop: 'updateUser', |
||||||
|
sortable: 'custom', |
||||||
|
filter: true, |
||||||
|
span: 24, |
||||||
|
search: false, |
||||||
|
display: true, |
||||||
|
formatter: row => { |
||||||
|
return this.userMapObj[row.updateUser] || row.updateUser || '-'; |
||||||
}, |
}, |
||||||
page: { |
}, |
||||||
pageSize: 10, |
{ |
||||||
currentPage: 1, |
label: '更新时间', |
||||||
total: 0, |
prop: 'updateTime', |
||||||
}, |
sortable: 'custom', |
||||||
isOpen: false, |
filter: true, |
||||||
isWorkOpen: false, |
span: 24, |
||||||
checkRow:{} |
search: false, |
||||||
} |
display: true, |
||||||
|
}, |
||||||
|
], |
||||||
|
}, |
||||||
|
form: {}, |
||||||
|
page: { |
||||||
|
pageSize: 10, |
||||||
|
currentPage: 1, |
||||||
|
total: 0, |
||||||
|
}, |
||||||
|
isOpen: false, |
||||||
|
isWorkOpen: false, |
||||||
|
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), |
||||||
|
}; |
||||||
}, |
}, |
||||||
computed: { |
userMapObj() { |
||||||
userMapObj() { |
const map = {}; |
||||||
const map = {}; |
this.userListData.forEach(user => { |
||||||
this.userListData.forEach(user => { |
map[user.value] = user.label; |
||||||
map[user.value] = user.label; |
map[String(user.value)] = user.label; |
||||||
map[String(user.value)] = user.label; |
map[Number(user.value)] = user.label; |
||||||
map[Number(user.value)] = user.label; |
}); |
||||||
}); |
return map; |
||||||
return map; |
|
||||||
}, |
|
||||||
}, |
}, |
||||||
methods: { |
}, |
||||||
loadUserList() { |
methods: { |
||||||
return new Promise((resolve) => { |
loadUserList() { |
||||||
userListpage(1, 99999).then(res => { |
return new Promise(resolve => { |
||||||
if (res.data.code == 200) { |
userListpage(1, 99999) |
||||||
const users = res.data.data; |
.then(res => { |
||||||
this.userListData = users.map(user => ({ |
if (res.data.code == 200) { |
||||||
label: user.realName || user.name, |
const users = res.data.data; |
||||||
value: String(user.id) |
this.userListData = users.map(user => ({ |
||||||
})); |
label: user.realName || user.name, |
||||||
this.userListLoaded = true; |
value: String(user.id), |
||||||
} |
})); |
||||||
resolve(); |
this.userListLoaded = true; |
||||||
}).catch(error => { |
|
||||||
console.error('获取用户列表失败', error); |
|
||||||
resolve(); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}, |
|
||||||
addEdit() { |
|
||||||
this.checkRow = {} |
|
||||||
this.isOpen = true |
|
||||||
}, |
|
||||||
editFn(row) { |
|
||||||
this.isOpen = true |
|
||||||
this.checkRow = row |
|
||||||
}, |
|
||||||
closeDialog(val) { |
|
||||||
this.isOpen = false |
|
||||||
this.isWorkOpen = false |
|
||||||
if(val) { |
|
||||||
this.onLoad() |
|
||||||
} |
} |
||||||
}, |
resolve(); |
||||||
maintenanceClick() { |
}) |
||||||
// this.$refs.myTable.fullValidate((errMap) => { |
.catch(error => { |
||||||
// if (errMap) { |
console.error('获取用户列表失败', error); |
||||||
// return; |
resolve(); |
||||||
// } |
}); |
||||||
// const dataList = this.$refs.myTable.getRecordset().updateRecords; |
}); |
||||||
// this.$ajax |
}, |
||||||
// .post('oemMerits/maintenance', { |
addEdit() { |
||||||
// dataList, |
this.checkRow = {}; |
||||||
// status: 2, |
this.isOpen = true; |
||||||
// type: 'produce' |
}, |
||||||
// }) |
editFn(row) { |
||||||
// .then((res) => { |
this.isOpen = true; |
||||||
// if (res.code === 0) { |
this.checkRow = row; |
||||||
// this.$message.success('维护成功'); |
}, |
||||||
// this.queryTable(); |
closeDialog(val) { |
||||||
// } |
this.isOpen = false; |
||||||
// }); |
this.isWorkOpen = false; |
||||||
// }); |
if (val) { |
||||||
}, |
this.onLoad(); |
||||||
proofreadClick() { |
} |
||||||
// const dataList = this.$refs.myTable.getTableData().tableData; |
}, |
||||||
// this.$ajax |
maintenanceClick() { |
||||||
// .post('oemMerits/proofread', { |
// this.$refs.myTable.fullValidate((errMap) => { |
||||||
// dataList, |
// if (errMap) { |
||||||
// status: 3, |
// return; |
||||||
// type: 'produce' |
// } |
||||||
// }) |
// const dataList = this.$refs.myTable.getRecordset().updateRecords; |
||||||
// .then((res) => { |
// this.$ajax |
||||||
// if (res.code === 0) { |
// .post('oemMerits/maintenance', { |
||||||
// this.$message.success('校对成功'); |
// dataList, |
||||||
// this.queryTable(); |
// status: 2, |
||||||
// } |
// type: 'produce' |
||||||
// }); |
// }) |
||||||
}, |
// .then((res) => { |
||||||
handleDelete(row) { |
// if (res.code === 0) { |
||||||
if (!row && this.selectionList.length === 0) { |
// this.$message.success('维护成功'); |
||||||
this.$message.error('请选择至少一条数据'); |
// this.queryTable(); |
||||||
return; |
// } |
||||||
|
// }); |
||||||
|
// }); |
||||||
|
}, |
||||||
|
proofreadClick() { |
||||||
|
// const dataList = this.$refs.myTable.getTableData().tableData; |
||||||
|
// this.$ajax |
||||||
|
// .post('oemMerits/proofread', { |
||||||
|
// dataList, |
||||||
|
// status: 3, |
||||||
|
// type: 'produce' |
||||||
|
// }) |
||||||
|
// .then((res) => { |
||||||
|
// if (res.code === 0) { |
||||||
|
// this.$message.success('校对成功'); |
||||||
|
// this.queryTable(); |
||||||
|
// } |
||||||
|
// }); |
||||||
|
}, |
||||||
|
handleDelete(row) { |
||||||
|
if (!row && this.selectionList.length === 0) { |
||||||
|
this.$message.error('请选择至少一条数据'); |
||||||
|
return; |
||||||
|
} |
||||||
|
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(); |
||||||
} |
} |
||||||
this.$confirm('确定将选择数据删除?', { |
}); |
||||||
confirmButtonText: '确定', |
} else { |
||||||
cancelButtonText: '取消', |
deleteFormula({ |
||||||
type: 'warning', |
ids: this.selectionList.map(item => item.id).join(','), |
||||||
}).then(() => { |
}).then(res => { |
||||||
if(row){ |
if (res.data.code == 200) { |
||||||
deleteFormula({ |
this.$message.success('删除成功'); |
||||||
ids:row.id |
this.onLoad(); |
||||||
}).then(res =>{ |
|
||||||
if(res.data.code == 200){ |
|
||||||
this.$message.success('删除成功') |
|
||||||
this.onLoad() |
|
||||||
} |
|
||||||
}) |
|
||||||
}else{ |
|
||||||
deleteFormula({ |
|
||||||
ids:this.selectionList.map(item => item.id).join(',') |
|
||||||
}).then(res =>{ |
|
||||||
if(res.data.code == 200){ |
|
||||||
this.$message.success('删除成功') |
|
||||||
this.onLoad() |
|
||||||
} |
|
||||||
}) |
|
||||||
} |
|
||||||
}) |
|
||||||
}, |
|
||||||
searchChange(params, done){ |
|
||||||
this.query = params; |
|
||||||
this.page.currentPage = 1; |
|
||||||
this.onLoad() |
|
||||||
done(); |
|
||||||
}, |
|
||||||
searchReset(){ |
|
||||||
this.query = {} |
|
||||||
this.onLoad() |
|
||||||
}, |
|
||||||
currentChange(currentPage){ |
|
||||||
this.page.currentPage = currentPage; |
|
||||||
}, |
|
||||||
sizeChange(pageSize){ |
|
||||||
this.page.pageSize = pageSize; |
|
||||||
}, |
|
||||||
refreshChange(){ |
|
||||||
this.onLoad() |
|
||||||
}, |
|
||||||
// 多选 |
|
||||||
selectionChange(list) { |
|
||||||
this.selectionList = list; |
|
||||||
}, |
|
||||||
async onLoad() { |
|
||||||
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 |
|
||||||
}) |
|
||||||
} |
} |
||||||
} |
}); |
||||||
} |
}, |
||||||
|
searchChange(params, done) { |
||||||
|
this.query = params; |
||||||
|
this.page.currentPage = 1; |
||||||
|
this.onLoad(); |
||||||
|
done(); |
||||||
|
}, |
||||||
|
searchReset() { |
||||||
|
this.query = {}; |
||||||
|
this.onLoad(); |
||||||
|
}, |
||||||
|
currentChange(currentPage) { |
||||||
|
this.page.currentPage = currentPage; |
||||||
|
}, |
||||||
|
sizeChange(pageSize) { |
||||||
|
this.page.pageSize = pageSize; |
||||||
|
}, |
||||||
|
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; |
||||||
|
// 确保用户列表先加载完成 |
||||||
|
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; |
||||||
|
}); |
||||||
|
}, |
||||||
|
}, |
||||||
|
}; |
||||||
</script> |
</script> |
||||||
<style lang="scss" scoped></style> |
<style lang="scss" scoped></style> |
||||||
Loading…
Reference in new issue