From 919a94bfe3e75aeda7a45f95952c933b66de73bd Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Fri, 12 Dec 2025 11:13:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AF=9B=E9=87=8D=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=AE=A1=E7=AE=97=E5=87=80=E9=87=8D=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=87=80=E9=87=8D=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=AF=9B=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/modules/ecss/codelnotifyConfirm.vue | 66 ++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/src/views/modules/ecss/codelnotifyConfirm.vue b/src/views/modules/ecss/codelnotifyConfirm.vue index 919ae86..83b3222 100644 --- a/src/views/modules/ecss/codelnotifyConfirm.vue +++ b/src/views/modules/ecss/codelnotifyConfirm.vue @@ -356,12 +356,12 @@ - + - + @@ -2750,6 +2750,68 @@ this.palletModelData.grossWeight = parseFloat(grossWeight.toFixed(2)); this.palletModelData.netWeight = parseFloat(netWeight.toFixed(2)); }, + + /** + * 毛重改变时自动计算净重 + * 计算公式:净重 = 毛重 - (箱数 / 2) + */ + onPalletGrossWeightChange(value) { + // 防止循环触发,使用标志位 + if (this._isPalletWeightCalculating) { + return; + } + + this._isPalletWeightCalculating = true; + + try { + const grossWeight = parseFloat(value) || 0; + const boxQty = parseFloat(this.palletModelData.boxQty) || 0; + + if (grossWeight <= 0) { + this.palletModelData.netWeight = ''; + return; + } + + // 计算净重:净重 = 毛重 - (箱数 / 2) + const netWeight = grossWeight - (boxQty / 2); + + // 保留2位小数 + this.palletModelData.netWeight = parseFloat(netWeight.toFixed(2)); + } finally { + this._isPalletWeightCalculating = false; + } + }, + + /** + * 净重改变时自动计算毛重 + * 反向计算公式:毛重 = 净重 + (箱数 / 2) + */ + onPalletNetWeightChange(value) { + // 防止循环触发,使用标志位 + if (this._isPalletWeightCalculating) { + return; + } + + this._isPalletWeightCalculating = true; + + try { + const netWeight = parseFloat(value) || 0; + const boxQty = parseFloat(this.palletModelData.boxQty) || 0; + + if (netWeight <= 0) { + this.palletModelData.grossWeight = ''; + return; + } + + // 反向计算毛重:毛重 = 净重 + (箱数 / 2) + const grossWeight = netWeight + (boxQty / 2); + + // 保留2位小数 + this.palletModelData.grossWeight = parseFloat(grossWeight.toFixed(2)); + } finally { + this._isPalletWeightCalculating = false; + } + }, savePalletHeader(type) { // 过滤出 useQty > 0 的行 const selectedRows = this.dataList8.filter(item => item.useQty && item.useQty > 0);