diff --git a/src/views/mes/reportWork/index.vue b/src/views/mes/reportWork/index.vue index b582c183..253b3000 100644 --- a/src/views/mes/reportWork/index.vue +++ b/src/views/mes/reportWork/index.vue @@ -468,7 +468,9 @@ :label="item.title" :name="item.libId" > - @@ -515,7 +517,10 @@ :name="item.libId" > - + @@ -1278,9 +1283,45 @@ export default { console.log('row:',index, row); }, // 多选框选中数据 - pReportSelection(selection) { - this.pReportRows = this.pReportRows.concat(selection) + pReportSelection(selection,row) { + + const allRows = this.pReportRows.concat(selection) + this.pReportRows = allRows.reduce((acc, cur) => { + const hasDuplicate = acc.some(item => item.batch === cur.batch + && item.workorderCode === cur.workorderCode); + if (!hasDuplicate) { + acc.push(cur); + } + return acc; + }, []); + + // 当取消勾选时,selectedRows 会移除对应的行数据 + if (selection.indexOf(row) === -1) { + console.log('Row unchecked:', row); + console.log('过滤前:', this.pReportRows); + var newReportRows = []; + this.pReportRows.forEach(item=>{ + if (item.workorderCode!=row.workorderCode + || item.batch!=row.batch) { + newReportRows.push(item) + } + }) + this.pReportRows = newReportRows; + console.log('过滤后:', this.pReportRows); + } + }, + allReportSelection(selection){ + const allRows = this.pReportRows.concat(selection) + this.pReportRows = allRows.reduce((acc, cur) => { + const hasDuplicate = acc.some(item => item.batch === cur.batch + && item.workorderCode === cur.workorderCode); + if (!hasDuplicate) { + acc.push(cur); + } + return acc; + }, []); }, + submitReport() { this.reportRows = this.pReportRows; if ( this.reportRows==0) { @@ -1344,8 +1385,35 @@ export default { //}); }, - // 多选框选中数据 - pConsumeSelection(selection) { + // 多选框选中数据(报工物料消耗专用特殊逻辑,不准改zxl) + pConsumeSelection(selection, row) { + const allRows = this.pConsumeRows.concat(selection) + this.pConsumeRows = allRows.reduce((acc, cur) => { + const hasDuplicate = acc.some(item => item.materialCode === cur.materialCode + && item.workorderCode === cur.workorderCode); + if (!hasDuplicate) { + acc.push(cur); + } + return acc; + }, []); + + // 当取消勾选时,selectedRows 会移除对应的行数据 + if (selection.indexOf(row) === -1) { + console.log('Row unchecked:', row); + console.log('过滤前:', this.pConsumeRows); + var newPConsumeRows = []; + this.pConsumeRows.forEach(item=>{ + if (item.workorderCode!=row.workorderCode + || item.materialCode!=row.materialCode) { + newPConsumeRows.push(item) + } + }) + this.pConsumeRows = newPConsumeRows; + console.log('过滤后:', this.pConsumeRows); + } + }, + // 多选框选中all数据(报工物料消耗专用特殊逻辑,不准改zxl) + allConsumeSelection(selection, row) { const allRows = this.pConsumeRows.concat(selection) this.pConsumeRows = allRows.reduce((acc, cur) => { const hasDuplicate = acc.some(item => item.materialCode === cur.materialCode @@ -1364,7 +1432,8 @@ export default { this.consumeRows = this.pConsumeRows; if ( this.consumeRows==0) { - this.$modal.msgError(`请选择数据`); + this.$modal.msgError(`请选择要修改的物料数据!`); + this.loading = false; return false; }