From 77ca1870d12e4fc3a74bcad5a86a27e254d8fb2d Mon Sep 17 00:00:00 2001 From: sunzehua Date: Wed, 2 Aug 2023 11:57:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/main/BookingLedger/detail/index.vue | 13 +- .../detail/modules/goodsTable.vue | 125 ++++++++++++++---- .../detail/modules/mailingInfo.vue | 12 +- src/views/system/ServiceBase/addForm.vue | 2 +- src/views/system/ServiceFlow/addForm.vue | 88 +++++++++--- 5 files changed, 184 insertions(+), 56 deletions(-) diff --git a/src/views/main/BookingLedger/detail/index.vue b/src/views/main/BookingLedger/detail/index.vue index a5dd9e1..0c163d7 100644 --- a/src/views/main/BookingLedger/detail/index.vue +++ b/src/views/main/BookingLedger/detail/index.vue @@ -83,6 +83,7 @@ :details="bookingDetails" :rules="tableRules" isParent="parent" + @changectnall="changectnall" @changeDetail="changeDetailFun" @changeTotal="changeTotalFun" @changeCtnInfo="changeCtnInfoFun"> @@ -1297,7 +1298,7 @@ export default { let tableErrTip = '' this.bookingDetails.ctnInputs.map((item, index) => { Object.keys(item).map((label, lindex) => { - if (this.tableRules[label] && this.tableRules[label].required && !item[label]) { + if (this.tableRules[label] && this.tableRules[label].required && item[label] === '') { tableErrTip = `${tableErrTip} 序号${index + 1}中${this.tableRules[label].title}未填写,` } }) @@ -1778,6 +1779,16 @@ export default { this.bookingDetails.totalno = enCapitalRes } }, + changectnall(arr) { + let str = '' + arr.forEach((item, index) => { + str += item.ctnall + '*' + item.ctnnum + if (index != arr.length - 1) { + str += '/' + } + }) + this.bookingDetails.cntrtotal = str + }, removeOrderFun() { DeleteBookingOrder(this.bookingDetails.id) .then(res => { diff --git a/src/views/main/BookingLedger/detail/modules/goodsTable.vue b/src/views/main/BookingLedger/detail/modules/goodsTable.vue index 2fd168b..f2842cf 100644 --- a/src/views/main/BookingLedger/detail/modules/goodsTable.vue +++ b/src/views/main/BookingLedger/detail/modules/goodsTable.vue @@ -188,6 +188,27 @@ export default { this.tableData[rowIndex].ctnall = data.name this.tableData[rowIndex].ctncode = data.code row['ctnall'] = data.name + var map = {}; + var dest = []; + for (var i = 0; i < this.tableData.length; i++) { + var ai = this.tableData[i]; + if (!map[ai.ctnall]) { + dest.push({ + ctnall: ai.ctnall, + ctnnum: ai.ctnnum + }); + map[ai.ctnall] = ai; + } else { + for (var j = 0; j < dest.length; j++) { + var dj = dest[j]; + if (dj.ctnall == ai.ctnall) { + dj.ctnnum = (parseFloat(dj.ctnnum) + parseFloat(ai.ctnnum)).toString(); + break; + } + } + } + }; + this.changeEmit1(dest) this.$forceUpdate() } else { row['ctnall'] = '' @@ -322,7 +343,7 @@ export default { } }) } - this.$emit('changeCtnInfo', { type: 'kindpkgs', val: row['kindpkgs'] }) + this.changeEmit(row) }} on-focus={(val) => { this.kindpkgsViewIndex = rowIndex @@ -798,6 +819,29 @@ export default { } } } + if (column.field === 'ctnnum') { + const map = {}; + const dest = []; + for (var i = 0; i < this.tableData.length; i++) { + var ai = this.tableData[i]; + if (!map[ai.ctnall]) { + dest.push({ + ctnall: ai.ctnall, + ctnnum: ai.ctnnum + }); + map[ai.ctnall] = ai; + } else { + for (var j = 0; j < dest.length; j++) { + var dj = dest[j]; + if (dj.ctnall == ai.ctnall) { + dj.ctnnum = (parseFloat(dj.ctnnum) + parseFloat(ai.ctnnum)).toString(); + break; + } + } + } + }; + this.changeEmit1(dest) + } }, cellValueChange: ({ row, column }) => { } }, @@ -1178,9 +1222,9 @@ export default { this.id = this.$route.query.id } - if (this.$route.name === 'BookingDetail') { + if (this.$route.name === 'BookingDetail') { this.init() - } + } } }, totalKgs() { @@ -1256,9 +1300,9 @@ export default { setTimeout(() => { if (document.getElementsByClassName('ve-table-cell-selection')) { const activeDom = document.getElementsByClassName('ve-table-cell-selection')[0].firstChild - if (this.isDOM(activeDom)) { - activeDom.click() - } + if (this.isDOM(activeDom)) { + activeDom.click() + } } }, 200) } @@ -1272,6 +1316,9 @@ export default { keydown(e) { console.log(e) }, + changeEmit(row) { + this.$emit('changeCtnInfo', { type: 'kindpkgs', val: row['kindpkgs'] }) + }, isDOM(item) { // 首先判断是否支持HTMLELement,如果支持,使用HTMLElement,如果不支持,通过判断DOM的特征,如果拥有这些特征说明就是ODM节点,特征使用的越多越准确 return typeof HTMLElement === 'function' @@ -1533,6 +1580,9 @@ export default { } this.childTableData.push(data) }, + changeEmit1(arr) { + this.$emit('changectnall', arr) + }, removeChildData() { this.selectChildArr.map((item, index) => { this.childTableData.map((oitem, oindex) => { @@ -1588,11 +1638,32 @@ export default { if (type) { const data = JSON.parse(res.data) if (data.length == this.tableData.length) { - console.log(this.tableData, data) data.forEach((item, index) => { this.tableData[index].sealno = item.SEALNO this.tableData[index].cntrno = item.CNTRNO + this.tableData[index].ctnnum = 1 }) + const map = {}; + const dest = []; + for (var i = 0; i < this.tableData.length; i++) { + var ai = this.tableData[i]; + if (!map[ai.ctnall]) { + dest.push({ + ctnall: ai.ctnall, + ctnnum: ai.ctnnum + }); + map[ai.ctnall] = ai; + } else { + for (var j = 0; j < dest.length; j++) { + var dj = dest[j]; + if (dj.ctnall == ai.ctnall) { + dj.ctnnum = (parseFloat(dj.ctnnum) + parseFloat(ai.ctnnum)).toString(); + break; + } + } + } + }; + this.changeEmit1(dest) } else { this.$message.error('箱量与场站不一致') } @@ -1622,27 +1693,27 @@ export default { const data = JSON.parse(res.data) const addTable = [] const cntrnoArr = [] - let kindpkgsOld = '' + const kindpkgsOld = '' this.tableData = [] const lastNum = this.tableData.length > 0 ? Number(this.tableData[this.tableData.length - 1].rowKey) + 1 : 0 data.map((item, index) => { - const _data = { - rowKey: lastNum + index, - ctnall: item.CTNALL, - ctnnum: '1', - cntrno: item.CNTRNO, - sealno: item.SEALNO, - ctncode: item.CtnCode, - pkgs: item.PKGS, - kindpkgs: kindpkgsOld || item.KINDPKGS, - kgs: item.KGS, - cbm: item.CBM, - tareweight: item.TAREWEIGHT, - weightype: '', - weighkgs: '', - weighdate: item.WEIGHDATE - } - addTable.push(_data) + const _data = { + rowKey: lastNum + index, + ctnall: item.CTNALL, + ctnnum: '1', + cntrno: item.CNTRNO, + sealno: item.SEALNO, + ctncode: item.CtnCode, + pkgs: item.PKGS, + kindpkgs: kindpkgsOld || item.KINDPKGS, + kgs: item.KGS, + cbm: item.CBM, + tareweight: item.TAREWEIGHT, + weightype: '', + weighkgs: '', + weighdate: item.WEIGHDATE + } + addTable.push(_data) }) this.tableData = [...this.tableData, ...addTable] @@ -1778,7 +1849,7 @@ export default { } else { cntrnoArr.push(this.tableData[i].cntrno) } - } + } const lastNum = this.tableData.length > 0 ? Number(this.tableData[this.tableData.length - 1].rowKey) + 1 : 0 data.map((item, index) => { if (cntrnoArr.includes(item.CNTRNO)) { @@ -1821,7 +1892,7 @@ export default { addTable.push(_data) } }) - console.log(this.tableData,addTable) + console.log(this.tableData, addTable) this.tableData = [...this.tableData, ...addTable] this.$forceUpdate() } else { diff --git a/src/views/main/BookingLedger/detail/modules/mailingInfo.vue b/src/views/main/BookingLedger/detail/modules/mailingInfo.vue index b0436f8..057fbcc 100644 --- a/src/views/main/BookingLedger/detail/modules/mailingInfo.vue +++ b/src/views/main/BookingLedger/detail/modules/mailingInfo.vue @@ -216,16 +216,16 @@ @getInputChange="inputChange" /> - + @@ -244,7 +244,7 @@ - +