中航光电热表web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

304 lines
10 KiB

<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">
<template #menu-left>
<el-button type="primary" icon="el-icon-plus" @click="addEdit">新增
</el-button>
<el-button type="danger" icon="el-icon-delete" @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>
</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>
<script>
import addEditDosing from './components/addEditDosing.vue'
import workCenterSet from './components/workCenterSet.vue'
import {getList,deleteFormula,userListpage} from "@/api/basicData/calculationFormula"
export default {
components: {
addEditDosing,
workCenterSet
},
data() {
return {
selectionList: [],
loading: false,
query: {},
userListData: [],
userListLoaded: false,
option: {
height: 'auto',
calcHeight: 32,
tip: false,
// size: 'medium',
simplePage: true,
searchShow: true,
searchMenuSpan: 18,
searchIcon: true,
searchIndex: 3,
tree: false,
border: true,
index: false,
selection: true,
viewBtn: false,
delBtn: false,
addBtn: false,
editBtn: false,
editBtnText: '修改',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
viewBtnText: '详情',
labelWidth: 120,
menuWidth: 100,
dialogWidth: 640,
dialogClickModal: false,
searchEnter: true,
excelBtn: false,
filterBtn: true,
searchShowBtn: false,
columnSort: true,
excelBtn: true,
columnSort: true,
showOverflowTooltip: true,
searchLabelPosition:'left',
searchLabelPosition:'left',
searchGutter:24,
searchSpan:6,
menuAlign: 'left',
gridBtn:false,
searchMenuPosition:'right',
addBtnIcon: ' ',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
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: {
},
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
isOpen: false,
isWorkOpen: false,
checkRow:{}
}
},
computed: {
userMapObj() {
const map = {};
this.userListData.forEach(user => {
map[user.value] = user.label;
map[String(user.value)] = user.label;
map[Number(user.value)] = user.label;
});
return map;
},
},
methods: {
loadUserList() {
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)
}));
this.userListLoaded = true;
}
resolve();
}).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()
}
},
maintenanceClick() {
// this.$refs.myTable.fullValidate((errMap) => {
// if (errMap) {
// return;
// }
// const dataList = this.$refs.myTable.getRecordset().updateRecords;
// this.$ajax
// .post('oemMerits/maintenance', {
// dataList,
// status: 2,
// type: 'produce'
// })
// .then((res) => {
// if (res.code === 0) {
// this.$message.success('维护成功');
// this.queryTable();
// }
// });
// });
},
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()
}
})
}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
})
}
}
}
</script>
<style lang="scss" scoped></style>