From 4c401da83881a20c89cfb0fe40e48733827004f2 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Mon, 9 Feb 2026 11:56:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=BA=93=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/modules/recv/recv.vue | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/views/modules/recv/recv.vue b/src/views/modules/recv/recv.vue index 6a2b699..492960c 100644 --- a/src/views/modules/recv/recv.vue +++ b/src/views/modules/recv/recv.vue @@ -91,7 +91,8 @@ autocorrect="off" spellcheck="false" /> - + + 回退 保存 @@ -191,7 +192,11 @@ export default { }, computed: { totalQty() { - const sum = this.handlingUnit.reduce((sum, item) => sum + Number(item.qty), 0); + // 使用整数运算避免浮点数精度问题 + const sumInCents = this.handlingUnit.reduce((sum, item) => { + return sum + Math.round(Number(item.qty) * 100); + }, 0); + const sum = sumInCents / 100; this.recvItem.transQty = sum; return sum; }, @@ -300,10 +305,14 @@ export default { let site = this.site; let partNo = row.partNo; let height = ''; + let locationNo = ''; try { const { data } = await getPartAttributeInfo({ site, partNo }); if (data.code === 0) { height = data.data.height; + if (data.partDefLoc && data.partDefLoc.length > 0) { + locationNo = data.partDefLoc[0].warehouse==='INK'?data.partDefLoc[0].locationNo:''; + } } } catch (error) { console.error('获取物料高度失败:', error); @@ -321,6 +330,7 @@ export default { supplierBatchNo: '', wdr:"*", height: height, + locationNo: locationNo }; this.processFlag = 2; }, @@ -364,8 +374,9 @@ export default { // 计算需要多少个完整包装 const packageQty = Math.floor(qtyToReceive / perQtyValue); - // 计算余数(最后一个包装的数量) - const remainder = qtyToReceive - (packageQty * perQtyValue); + // 计算余数(最后一个包装的数量)- 使用整数运算避免浮点数精度问题 + const remainderInCents = Math.round(qtyToReceive * 100) - Math.round(perQtyValue * 100) * packageQty; + const remainder = remainderInCents / 100; // 清空现有的HU列表 this.handlingUnit = []; @@ -412,7 +423,8 @@ export default { if (!perQty || !packageQty || isNaN(perQty) || isNaN(packageQty)) { return this.$message.warning("请填写有效的包装信息"); } - const qty = parseFloat(perQty) * parseInt(packageQty); + // 使用整数运算避免浮点数精度问题 + const qty = Math.round(parseFloat(perQty) * 100) * parseInt(packageQty) / 100; const code = String(this.handlingUnit.length + 1); const newItem = { ...this.hanlingItem, qty, code }; this.handlingUnit.push(newItem);