From f67930941fa8fbcedb26c56b803c90da0f47dac4 Mon Sep 17 00:00:00 2001 From: lb Date: Mon, 5 Feb 2024 16:12:31 +0800 Subject: [PATCH] before change table --- .../maintain/WaitingList--add--unplanned.vue | 24 +- .../specialEquipment/maintain/WaitingList.vue | 243 +++++++++++------- 2 files changed, 163 insertions(+), 104 deletions(-) diff --git a/src/views/specialEquipment/maintain/WaitingList--add--unplanned.vue b/src/views/specialEquipment/maintain/WaitingList--add--unplanned.vue index fd013986..b4d9d4ca 100644 --- a/src/views/specialEquipment/maintain/WaitingList--add--unplanned.vue +++ b/src/views/specialEquipment/maintain/WaitingList--add--unplanned.vue @@ -16,12 +16,12 @@ @@ -102,13 +102,13 @@ - + - + @@ -116,12 +116,12 @@ { - return index % 2 == 0; - }, + // prop: '_selection', + // label: '批量选择', + width: 48, subcomponent: { - render: (h, { row, index }) => { - return

hello

; - // return + props: ['injectData'], + data() { + return { + outside: false, + selected: false, + }; + }, + watch: { + selected(val) { + if (!this.outside) { + console.log("emit row-selected...") + this.$emit('emitData', { + action: 'row-selected', + value: { + row: this.injectData, + selected: val, + }, + }); + } + }, + injectData: { + deep: true, + immediate: true, + handler: function (val) { + this.outside = true; + this.selected = !!((val._selection & 0b01) != 0); + this.$nextTick(() => { + this.outside = false; + }) + }, + }, + }, + render(h) { + const enabled = 0b10 & this.injectData._selection; + // return this.injectData?._selection ? h('h1', null, 'hello') : h('h1', null, '1'); + return ( +
+ {this.selected} + +
+ ); }, }, }, @@ -397,6 +433,15 @@ export default { allSpecialEquipments: [], }; }, + watch: { + tobeConfirmedIdList: { + handler(val) { + if (val.length == this.list.length) { + this.$refs['table'].toggleAllSelection(); + } + }, + }, + }, created() { this.initSearchBar(); // if (this.$route.query) { @@ -426,7 +471,31 @@ export default { }, methods: { handleSelectionChange(list) { - console.log('handleSelectionChange', list); + if (this.tobeConfirmedIdList.length) { + this.tobeConfirmedIdList = []; + this.list.forEach((item) => { + this.handleEmitFun({ + action: 'row-selected', + value: { row: item, selected: false }, + }); + }); + console.log( + '清空选择列表', + this.list.map((item) => item._selection) + ); + } else { + this.tobeConfirmedIdList = list.map((item) => item.id); + this.list.forEach((item) => { + this.handleEmitFun({ + action: 'row-selected', + value: { row: item, selected: true }, + }); + }); + console.log( + '全选', + this.list.map((item) => item._selection) + ); + } }, handleEmitFun({ action, value }) { @@ -441,6 +510,18 @@ export default { }); }); break; + case 'row-selected': + if (value.selected) { + this.tobeConfirmedIdList.push(value.row.id); + value.row._selection = 0b11; + } else { + const index = this.tobeConfirmedIdList.indexOf(value.row.id); + if (index != -1) { + this.tobeConfirmedIdList.splice(index, 1); + } + } + console.log('tobeConfirmedIdList', this.tobeConfirmedIdList); + break; } }, @@ -455,16 +536,6 @@ export default { ); } }, - // setSearchBarEquipmentList(eqList) { - // this.$set( - // this.searchBarFormConfig[1], - // 'selectOptions', - // eqList.map((item) => ({ - // name: item.name, - // id: item.id, - // })) - // ); - // }, initSearchBar() { // this.http('/base/core-equipment/listAll', 'get').then(({ data }) => { // this.allSpecialEquipments = data.filter((item) => item.special); @@ -490,28 +561,20 @@ export default { getList() { this.loading = true; // 执行查询 - this.recv({ ...this.queryParams, special: true, confirmed: false }).then( - (response) => { - this.list = - // [ - // { - // id: 213, - // maintainOrderNumber: 123, - // planName: 'hhh', - // departmentName: 'asdf', - // lineName: 456, - // planStartTime: '2024-01-01', - // planEndTime: '2024-01-01', - // startTime: '2024-01-01', - // endTime: '2024-01-01', - // relatePlan: 1, - // }, - // ]; - response.data.list; - this.total = response.data.total; - this.loading = false; - } - ); + this.recv({ + ...this.queryParams, + special: true, + relatePlan: 2, + confirmed: false, + }).then((response) => { + this.list = response.data.list.map((item) => ({ + ...item, + planName: '---', + _selection: 0b10, + })); + this.total = response.data.total; + this.loading = false; + }); }, /** 取消按钮 */ cancel() { @@ -524,22 +587,13 @@ export default { this.form = { id: null, relatePlan: null, - maintainPlanId: null, - equipmentId: null, maintainWorker: [], maintainOrderNumber: null, + departmentId: null, + lineId: null, startTime: null, endTime: null, - timeUsed: null, remark: null, - maintenanceDes: null, - files: [ - // { - // fileName: '', - // fileType: '', - // fileUrl: '', - // }, - ], }; this.resetForm('form'); }, @@ -556,32 +610,32 @@ export default { /** 新增按钮操作 */ handleAdd() { this.reset(); - if (this.$route.query.addRecord) { - // 赋值 - const tempRow = this.$route.query.row; - this.form.equipmentId = tempRow.equipmentId; - this.form.relatePlan = tempRow.nextMaintainTime ? 1 : 2; - this.form.startTime = tempRow.nextMaintainTime; - this.form.maintainPlanId = tempRow.id; - // await (() => { - // return new Promise((acpt, rejt) => { - // this.form.relatePlan = - // this.$route.query.relatePlan || - // (tempRow.nextMaintainTime ? 1 : 2); - // this.form.startTime = tempRow.nextMaintainTime; - // acpt(); - // }); - // })(); - // this.$nextTick(() => { - // this.form.maintainPlanId = tempRow.id; - // this.form.equipmentId = tempRow.equipmentId; - // }); - } - if (this.$route.query.isAdd) { - // 赋值 - this.form.equipmentId = this.$route.query.equipmentId; - this.form.maintainPlanId = this.$route.query.maintainPlanId; - } + // if (this.$route.query.addRecord) { + // // 赋值 + // const tempRow = this.$route.query.row; + // this.form.equipmentId = tempRow.equipmentId; + // this.form.relatePlan = tempRow.nextMaintainTime ? 1 : 2; + // this.form.startTime = tempRow.nextMaintainTime; + // this.form.maintainPlanId = tempRow.id; + // // await (() => { + // // return new Promise((acpt, rejt) => { + // // this.form.relatePlan = + // // this.$route.query.relatePlan || + // // (tempRow.nextMaintainTime ? 1 : 2); + // // this.form.startTime = tempRow.nextMaintainTime; + // // acpt(); + // // }); + // // })(); + // // this.$nextTick(() => { + // // this.form.maintainPlanId = tempRow.id; + // // this.form.equipmentId = tempRow.equipmentId; + // // }); + // } + // if (this.$route.query.isAdd) { + // // 赋值 + // this.form.equipmentId = this.$route.query.equipmentId; + // this.form.maintainPlanId = this.$route.query.maintainPlanId; + // } this.open = true; this.title = '添加待确认保养记录'; }, @@ -607,6 +661,8 @@ export default { this.put({ ...this.form, maintainWorker: this.form.maintainWorker.join(','), + special: true, + relatePlan: 2, }).then((response) => { this.$modal.msgSuccess('修改成功'); this.open = false; @@ -618,24 +674,27 @@ export default { this.post({ ...this.form, maintainWorker: this.form.maintainWorker.join(','), + special: true, + relatePlan: 2, }).then((response) => { this.$modal.msgSuccess('新增成功'); // 跳转至 备品备件 保养 - const toSparePartsMaintain = () => { - this.open = false; - // 没有备品备件保养模块。。。 - }; + // const toSparePartsMaintain = () => { + // this.open = false; + // }; - this.$confirm('是否有备品备件更换?', '提示', { - confirmButtonText: '有', - cancelButtonText: '没有', - }) - .then(toSparePartsMaintain) - .catch(() => { - this.open = false; - this.getList(); - }); + // this.$confirm('是否有备品备件更换?', '提示', { + // confirmButtonText: '有', + // cancelButtonText: '没有', + // }) + // .then(toSparePartsMaintain) + // .catch(() => { + // this.open = false; + // this.getList(); + // }); + this.open = false; + this.getList(); }); }); },