|
|
|
@ -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; |
|
|
|
}, |
|
|
|
@ -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); |
|
|
|
|