From 0ba97131a8ed43f53dcc0a5846d520837113d907 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Fri, 6 Mar 2026 09:10:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=95=B0=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/production-inbound/inboundRegister.vue | 10 +++++----- src/views/modules/recv/recv.vue | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/views/modules/production-inbound/inboundRegister.vue b/src/views/modules/production-inbound/inboundRegister.vue index f88f0c5..2bfc90b 100644 --- a/src/views/modules/production-inbound/inboundRegister.vue +++ b/src/views/modules/production-inbound/inboundRegister.vue @@ -212,9 +212,9 @@ export default { totalQty() { // 使用整数运算避免浮点数精度问题 const sumInCents = this.handlingUnit.reduce((sum, item) => { - return sum + Math.round(Number(item.qty) * 100); + return sum + Math.round(Number(item.qty) * 10000); }, 0); - const sum = sumInCents / 100; + const sum = sumInCents / 10000; this.inboundItem.transQty = sum; return sum; }, @@ -432,8 +432,8 @@ export default { const packageQty = Math.floor(qtyToReceive / perQtyValue); // 使用整数运算避免浮点数精度问题 - const remainderInCents = Math.round(qtyToReceive * 100) - Math.round(perQtyValue * 100) * packageQty; - const remainder = remainderInCents / 100; + const remainderInCents = Math.round(qtyToReceive * 10000) - Math.round(perQtyValue * 10000) * packageQty; + const remainder = remainderInCents / 10000; this.handlingUnit = []; @@ -475,7 +475,7 @@ export default { return this.$message.warning("请填写有效的包装信息"); } // 使用整数运算避免浮点数精度问题 - const qty = Math.round(parseFloat(perQty) * 100) * parseInt(packageQty) / 100; + const qty = Math.round(parseFloat(perQty) * 10000) * parseInt(packageQty) / 10000; const code = String(this.handlingUnit.length + 1); const newItem = { ...this.hanlingItem, qty, code }; this.handlingUnit.push(newItem); diff --git a/src/views/modules/recv/recv.vue b/src/views/modules/recv/recv.vue index 6d13e9c..9a5466e 100644 --- a/src/views/modules/recv/recv.vue +++ b/src/views/modules/recv/recv.vue @@ -194,9 +194,9 @@ export default { totalQty() { // 使用整数运算避免浮点数精度问题 const sumInCents = this.handlingUnit.reduce((sum, item) => { - return sum + Math.round(Number(item.qty) * 100); + return sum + Math.round(Number(item.qty) * 10000); }, 0); - const sum = sumInCents / 100; + const sum = sumInCents / 10000; this.recvItem.transQty = sum; return sum; }, @@ -367,7 +367,7 @@ export default { if (qtyToReceive <= 0) { qtyToReceive = parseFloat(this.recvItem.qtyToReceive) || 0; } - + if (qtyToReceive <= 0) { this.$message.warning('待收数量为0,无法自动计算包装'); this.hanlingItem.perQty = ''; @@ -379,8 +379,8 @@ export default { // 计算需要多少个完整包装 const packageQty = Math.floor(qtyToReceive / perQtyValue); // 计算余数(最后一个包装的数量)- 使用整数运算避免浮点数精度问题 - const remainderInCents = Math.round(qtyToReceive * 100) - Math.round(perQtyValue * 100) * packageQty; - const remainder = remainderInCents / 100; + const remainderInCents = Math.round(qtyToReceive * 10000) - Math.round(perQtyValue * 10000) * packageQty; + const remainder = remainderInCents / 10000; // 清空现有的HU列表 this.handlingUnit = []; @@ -428,7 +428,7 @@ export default { return this.$message.warning("请填写有效的包装信息"); } // 使用整数运算避免浮点数精度问题 - const qty = Math.round(parseFloat(perQty) * 100) * parseInt(packageQty) / 100; + const qty = Math.round(parseFloat(perQty) * 10000) * parseInt(packageQty) / 10000; const code = String(this.handlingUnit.length + 1); const newItem = { ...this.hanlingItem, qty, code }; this.handlingUnit.push(newItem);