Browse Source

convFactor

master
han\hanst 16 hours ago
parent
commit
bbb3d35e4e
  1. 12
      src/views/modules/recv/qualifiedStorage.vue
  2. 10
      src/views/modules/recv/recv.vue

12
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,

10
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);

Loading…
Cancel
Save