From bbb3d35e4e0500d681e66116561df89965bd8c91 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Fri, 4 Dec 2026 16:02:27 +0800 Subject: [PATCH] convFactor --- src/views/modules/recv/qualifiedStorage.vue | 12 +++++++++--- src/views/modules/recv/recv.vue | 10 +++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/views/modules/recv/qualifiedStorage.vue b/src/views/modules/recv/qualifiedStorage.vue index 5c04b1d..ae97523 100644 --- a/src/views/modules/recv/qualifiedStorage.vue +++ b/src/views/modules/recv/qualifiedStorage.vue @@ -350,6 +350,12 @@ export default { }); }, + purchaseQtyOfLabels() { + const total = this.scannedItems.reduce((sum, item) => sum + (parseFloat(item.qty) || 0), 0); + const factor = Number(this.selectedReceipt && this.selectedReceipt.convFactor); + if (!Number.isFinite(factor) || factor <= 0 || factor === 1) return total; + return Math.round(total / factor * 1000000) / 1000000; + }, // 计算可用数量 getAvailableQty() { if (!this.selectedReceipt.qtyArrived) return 0; @@ -536,8 +542,8 @@ export default { return; } - // 计算HandlingUnit总数量 - const totalScannedQty = this.scannedItems.reduce((sum, item) => sum + (parseFloat(item.qty) || 0), 0); + // 标签数量已是库存单位,到货可用数量是采购单位,比较前除回 convFactor。 + const totalScannedQty = this.purchaseQtyOfLabels(); const availableQty = this.getAvailableQty(); if (totalScannedQty > availableQty) { @@ -578,7 +584,7 @@ export default { uom: this.selectedReceipt.uom || '', toLocationNo: this.targetLocationId, qtyToMove: totalQty, - // 后端用该因子把源数量换算成库存单位数量:ifsInQtyToMove = ifsSourceQtyToMove * convFactor + // 标签数量已乘过该因子。后端用它把扫描数量除回采购单位,再作为 IFS 源数量。 convFactor: this.selectedReceipt.convFactor != null && this.selectedReceipt.convFactor !== '' ? this.selectedReceipt.convFactor : 1, diff --git a/src/views/modules/recv/recv.vue b/src/views/modules/recv/recv.vue index 1d17cb7..88dfa68 100644 --- a/src/views/modules/recv/recv.vue +++ b/src/views/modules/recv/recv.vue @@ -226,9 +226,9 @@ export default { totalQty() { // 使用整数运算避免浮点数精度问题 const sumInCents = this.handlingUnit.reduce((sum, item) => { - return sum + Math.round(Number(item.qty) * 10000); + return sum + Math.round(Number(item.qty) * 1000000); }, 0); - const sum = sumInCents / 10000; + const sum = sumInCents / 1000000; this.recvItem.transQty = sum; return sum; }, @@ -482,8 +482,8 @@ export default { // 计算需要多少个完整包装 const packageQty = Math.floor(qtyToReceive / perQtyValue); // 计算余数(最后一个包装的数量)- 使用整数运算避免浮点数精度问题 - const remainderInCents = Math.round(qtyToReceive * 10000) - Math.round(perQtyValue * 10000) * packageQty; - const remainder = remainderInCents / 10000; + const remainderInCents = Math.round(qtyToReceive * 1000000) - Math.round(perQtyValue * 1000000) * packageQty; + const remainder = remainderInCents / 1000000; // 清空现有的HU列表 this.handlingUnit = []; @@ -531,7 +531,7 @@ export default { return this.$message.warning("请填写有效的包装信息"); } // 使用整数运算避免浮点数精度问题 - const qty = Math.round(parseFloat(perQty) * 10000) * parseInt(packageQty) / 10000; + const qty = Math.round(parseFloat(perQty) * 1000000) * parseInt(packageQty) / 1000000; const code = String(this.handlingUnit.length + 1); const newItem = { ...this.hanlingItem, qty, code }; this.handlingUnit.push(newItem);