From 53b8636d68a46f8ac62aa803b5ccb6fbddab0b08 Mon Sep 17 00:00:00 2001 From: xielue Date: Sat, 17 Jun 2023 18:28:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=83=E4=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/editors/MkFormDataSelector.vue | 17 + .../MesProductionOrder/voucher.vue | 297 ++++++++++++++++-- 2 files changed, 289 insertions(+), 25 deletions(-) diff --git a/src/application/mk/components/editors/MkFormDataSelector.vue b/src/application/mk/components/editors/MkFormDataSelector.vue index 92f12a6..b10b8a4 100644 --- a/src/application/mk/components/editors/MkFormDataSelector.vue +++ b/src/application/mk/components/editors/MkFormDataSelector.vue @@ -167,11 +167,17 @@ export default { this.textboxValue = this.getShowValue({ obj: this.value, path: params.textField }); } } + else if (params && params.dataType == 'mapper') { + this.textboxValue = this.row[params.showField]; + } else if (this.value && this.value[1]) { this.textboxValue = this.value[1]; } else { this.textboxValue = ""; } + + + let f = params.listdataFieldName || "Records"; this.getData().then(data => { if('Total' in data){ @@ -318,6 +324,12 @@ export default { else if (params.dataType == "object") { this.$emit('input', e.row); } + + else if (params.dataType == 'mapper') { + if(params.showField){ + this.$emit('input', e.row[params.showField]); + } + } else { this.$emit('input', [e.row.ID, e.row[textField]]); } @@ -345,6 +357,11 @@ export default { else if (params.dataType == "object") { this.$emit('input', selectedRow); } + else if (params.dataType == 'mapper') { + if(params.showField){ + this.$emit('input', selectedRow[params.showField]); + } + } else { this.$emit('input', [selectedRow.ID, selectedRow[textField]]); } diff --git a/src/pages/Middle/Mes/MesProductionOrder/MesProductionOrder/voucher.vue b/src/pages/Middle/Mes/MesProductionOrder/MesProductionOrder/voucher.vue index 1d42217..72140f8 100644 --- a/src/pages/Middle/Mes/MesProductionOrder/MesProductionOrder/voucher.vue +++ b/src/pages/Middle/Mes/MesProductionOrder/MesProductionOrder/voucher.vue @@ -23,9 +23,9 @@ 删除 完成 - + 关闭 - + 导出 打印 @@ -67,7 +67,13 @@ - + + + + + + + + + + + + @@ -117,14 +161,23 @@ export default { nextId: null, table1Height: 400, - detailsSourceData: [ - ], + table2Height: 400, detailsData: [ ], deletedDetailsData: [ ], + currentRow :null, + showProcesses:false, + + detailsData2: [ + ], + deletedDetailsData2: [ + + ], + + pageStatus: '', editorMaterials: { dataType: "mapper", @@ -143,6 +196,21 @@ export default { page: () => import("../../MesMaterials/MesMaterials/List") } }, + editorProcesses: { + dataType: "mapper", + mapper: [ + { field: "step_id", fromField: "id" }, + { field: "step_name", fromField: "name" } + ], + showField: "step_name", + valueField: "id", + textField: "name", + listdataFieldName: 'MesProcesses', + dataUrl: `${BASE_URL.BASE_URL}/MesProcesses/v1/mes/processes/list`, + popup: { + page: () => import("../../MesProcesses/MesProcesses/List") + } + }, editor_process_route: { dataType: "string", valueField: "name", @@ -198,7 +266,7 @@ export default { if (this.$route.params.id) { this.dataId = this.$route.params.id; } - }, + }, // 函数 methods: { @@ -339,7 +407,7 @@ export default { this.pageStatus = 'approved'; } - this.detailsData = JSON.parse(JSON.stringify(a.data[detailDataFieldName].production_order_materials || [])) ; + this.detailsData = JSON.parse(JSON.stringify(a.data[detailDataFieldName].production_order_materials || [])); this.detailsDataInit(); this.$forceUpdate() @@ -367,6 +435,11 @@ export default { this.detailsData.push({}); } }, + detailsDataInit2() { + for (let i = this.detailsData2.length; i < 50; i++) { + this.detailsData2.push({}); + } + }, // 获取路由的id参数 getDataId() { @@ -415,7 +488,7 @@ export default { postdata.id = this.getDataId_BigInt(); } - let ds = JSONbig.parse(JSONbig.stringify(this.detailsData)); + let ds = JSONbig.parse(JSONbig.stringify(this.detailsData)); ds = ds.filter(item => item.materials_id); if (!ds.length) { @@ -430,10 +503,10 @@ export default { } delete item._X_ROW_KEY; - if(item.id){ + if (item.id) { item.id = this.$mk.toBigInt(item.id); } - + item.materials_id = this.$mk.toBigInt(item.materials_id); item.production_num = parseInt(item.production_num); item.batch_num = parseInt(item.batch_num); @@ -444,28 +517,28 @@ export default { if (this.dataId) { - postdata.production_order_materials = { - insertList:[], - updateList:[], - deleteList:[] + postdata.production_order_materials = { + insertList: [], + updateList: [], + deleteList: [] }; - ds.forEach(item=>{ - if(item.id){ + ds.forEach(item => { + if (item.id) { postdata.production_order_materials.updateList.push(item); } - else{ + else { postdata.production_order_materials.insertList.push(item); } }); - this.deletedDetailsData.forEach(item=>{ + this.deletedDetailsData.forEach(item => { postdata.production_order_materials.deleteList.push(item); }) - + } else { - postdata.production_order_materials = ds; + postdata.production_order_materials = ds; } @@ -478,7 +551,7 @@ export default { delete postdata.audit_staff_appoint; - + // 格式化提交的数据 this.$mk.formatFormData({ data: postdata, rules: this.options.formOptions.items }); @@ -499,7 +572,7 @@ export default { this.dataId = a.data.id; } - + this.pageInit(); } else { this.$mk.error(a.msg || "保存失败"); // 显示错误信息 @@ -677,7 +750,7 @@ export default { width: width * 0.9, height: height * 0.9, callback: ({ data }) => { - console.log(data) + console.log(data) } }) } @@ -709,7 +782,50 @@ export default { }); }, + pageShowProcesses({row}){ + this.currentRow = row; + console.log(row) + if(!this.dataId){ + return; + } + if(!row.materials_id){ + this.$mk.error("未设置料品"); + return; + } + this.$mk.post({ + url: `${BASE_URL.BASE_URL}/MesProductionOrder/v1/production/order/processes/list`, + loading: "加载中...", + data: { + "page": 1, + "limit": 10000, + "start_time": 0, + "end_time": 0, + "search_rules": [ + { + column: "materials_id", + mode: "=", + value: row.materials_id.toString() + }, + { + column: "production_order_id", + mode: "=", + value: this.dataId.toString() + } + ], + "order_bys": [ + ] + } + }).then(a => { + + this.deletedDetailsData2 = []; + this.detailsData2 = a.data.ProductionOrderProcesses || []; + + this.showProcesses = true; + this.detailsDataInit2(); + }); + + }, pageAdd(row) { const $table = this.$refs.xTable @@ -732,7 +848,7 @@ export default { }, beforeEditMethod({ column, row }) { - if(this.pageStatus == "approved"){ + if (this.pageStatus == "approved") { return false; } if (row.SourceTableID && column.field != "Quantity") { @@ -751,7 +867,7 @@ export default { } }, beforeEditEvent({ column, row }) { - if(this.pageStatus == "approved"){ + if (this.pageStatus == "approved") { return false; } if (row.SourceTableID && column.field != "Quantity") { @@ -794,8 +910,139 @@ export default { } + + + }, + + + pageAdd2(row) { + const $table = this.$refs.xTable2 + const record = { + } + if (row) { + + this.detailsData2.splice($table.getRowSeq(row), 0, record); + } else { + this.detailsData2.push(record) + } + }, + + pageDelete2(row) { + const $table = this.$refs.xTable2; + if (row.id) { + this.deletedDetailsData2.push(this.$mk.toBigInt(row.id)) + } + this.detailsData2.splice($table.getRowSeq(row) - 1, 1); + }, + beforeEditMethod2({ column, row }) { + + if (this.pageStatus == "approved") { + return false; + } + if (row.SourceTableID && column.field != "Quantity") { + return false; + } + return true; + }, + afterEditEvent2({ column, row }) { + if (column.field == "Quantity" || column.field == "Price") { + row.Amount = parseInt(row.Quantity || 0) * parseFloat(row.Price || 0); + + } + + if (column.field == "specification") { + row.specification = this.specification; + } + }, + beforeEditEvent2({ column, row }) { + if (this.pageStatus == "approved") { + return false; + } + if (row.SourceTableID && column.field != "Quantity") { + return false; + } + if (column.field == "specification") { + this.specification = row.specification; + } + }, + + onPulldownSelected2({ row, name, params }) { + if (name == 'ag_inventory') { + this.updateToGrid(row, this.detailsData[params.$rowIndex]); + + setTimeout(() => { + this.$refs.xTable.clearEdit(); + }, 50); + } + + }, + onPopupSelected2({ rows, name, params }) { + console.log(rows, name, params); + if (name == 'ag_inventory') { + + for (let i = params.$rowIndex, ri = 0; i < params.$rowIndex + rows.length; i++, ri++) { + if (i == this.detailsData.length) { + let newrow = { + }; + this.detailsData.push(newrow); + } + let inv = rows[ri]; + + this.updateToGrid(inv, this.detailsData[i]); + } + + setTimeout(() => { + this.$refs.xTable.clearEdit(); + }, 50); + + + } + }, + + confirmProcesses(){ + let ds = this.detailsData2.filter(a=>a.step_id); + + var postdata = { + insertList: [], + updateList: [], + deleteList: this.deletedDetailsData + }; + + ds.forEach(item => { + delete item._X_ROW_KEY; + + item.production_order_id = this.getDataId_BigInt(); + item.materials_id = this.$mk.toBigInt(this.currentRow.materials_id); + + if (item.id) { + item.id = this.$mk.toBigInt(item.id); + postdata.updateList.push(item); + } else { + postdata.insertList.push(item); + } + }) + this.$mk.post({ + url: `${BASE_URL.BASE_URL}/MesProductionOrder/v1/production/order/processes/batchUpdate`, + data: postdata, + useBigInt: true + }).then(a => { + if (a.code == "200") { + + this.$mk.success("保存成功"); + + + } else { + this.$mk.error(a.message); + } + + + }).catch((a) => { + this.$mk.error(a.data.msg); + }); + + } }, // 监听属性 watch: {