Browse Source

修改箱数自动计算毛重净重

java8
han\hanst 1 month ago
parent
commit
42c4c283de
  1. 81
      src/views/modules/ecss/components/PackingDetailTab.vue

81
src/views/modules/ecss/components/PackingDetailTab.vue

@ -448,7 +448,8 @@ export default {
box_qty: 1, box_qty: 1,
grossWeight: 0, grossWeight: 0,
netWeight: 0, netWeight: 0,
rolls: 0
rolls: 0,
boxWeight: 0 // (BOXWEIGHT)
}, },
editBoxSubmitting: false, editBoxSubmitting: false,
currentEditBox: null, currentEditBox: null,
@ -882,6 +883,7 @@ export default {
this.editBoxForm.grossWeight = boxRow.grossWeight; this.editBoxForm.grossWeight = boxRow.grossWeight;
this.editBoxForm.netWeight = boxRow.netWeight; this.editBoxForm.netWeight = boxRow.netWeight;
this.editBoxForm.rolls = boxRow.rolls; this.editBoxForm.rolls = boxRow.rolls;
this.editBoxForm.boxWeight = boxRow.boxWeight || 0; //
this.editBoxDialogVisible = true; this.editBoxDialogVisible = true;
}, },
@ -938,9 +940,10 @@ export default {
}, },
/** /**
* 箱数改变时自动计算净重
* 保持毛重不变重新计算净重
* 计算公式净重 = 毛重 - box_qty/2
* 箱数改变时自动计算毛重和净重
* 计算公式
* 1. 新毛重 = 物料箱重量(BOXWEIGHT) × 新箱数
* 2. 新净重 = 新毛重 - box_qty/2
*/ */
onBoxQtyChange(value) { onBoxQtyChange(value) {
// 使 // 使
@ -951,14 +954,24 @@ export default {
this._isCalculating = true; this._isCalculating = true;
try { try {
const boxQty = parseFloat(value) || 0;
const grossWeight = parseFloat(this.editBoxForm.grossWeight) || 0;
const newBoxQty = parseFloat(value) || 0;
const boxWeight = parseFloat(this.editBoxForm.boxWeight) || 0;
// = - box_qty/2
const netWeight = grossWeight - (boxQty / 2);
if (boxWeight <= 0) {
this.$message.warning('该物料未配置箱重量,无法自动计算毛重');
this._isCalculating = false;
return;
}
// 2
this.editBoxForm.netWeight = netWeight.toFixed(2);
// = ×
const newGrossWeight = boxWeight * newBoxQty;
// = - box_qty/2
const newNetWeight = newGrossWeight - (newBoxQty / 2);
// 3
this.editBoxForm.grossWeight = newGrossWeight.toFixed(3);
this.editBoxForm.netWeight = newNetWeight.toFixed(3);
} finally { } finally {
this._isCalculating = false; this._isCalculating = false;
} }
@ -1284,12 +1297,13 @@ export default {
}; };
}); });
// Box
// Box
this.batchEditOriginalData[this.getBoxRowKey(box)] = { this.batchEditOriginalData[this.getBoxRowKey(box)] = {
box_qty: box.box_qty, box_qty: box.box_qty,
grossWeight: box.grossWeight, grossWeight: box.grossWeight,
netWeight: box.netWeight, netWeight: box.netWeight,
rolls: box.rolls
rolls: box.rolls,
boxWeight: box.boxWeight || 0 // (BOXWEIGHT)
}; };
} else { } else {
// //
@ -1311,12 +1325,13 @@ export default {
}; };
tableData.push(rowData); tableData.push(rowData);
// Box
// Box
this.batchEditOriginalData[this.getBoxRowKey(box)] = { this.batchEditOriginalData[this.getBoxRowKey(box)] = {
box_qty: box.box_qty, box_qty: box.box_qty,
grossWeight: box.grossWeight, grossWeight: box.grossWeight,
netWeight: box.netWeight, netWeight: box.netWeight,
rolls: box.rolls
rolls: box.rolls,
boxWeight: box.boxWeight || 0 // (BOXWEIGHT)
}; };
} }
} }
@ -1375,31 +1390,51 @@ export default {
}, },
/** /**
* 批量编辑-箱数输入时联动计算净重
* 计算公式净重 = 毛重 - box_qty/2
* 批量编辑-箱数输入时联动计算毛重和净重
* 计算公式
* 1. 新毛重 = 物料箱重量(BOXWEIGHT) × 新箱数
* 2. 新净重 = 新毛重 - box_qty/2
*/ */
onBatchBoxQtyInput(row) { onBatchBoxQtyInput(row) {
if (this._isBatchCalculating) return; if (this._isBatchCalculating) return;
this._isBatchCalculating = true; this._isBatchCalculating = true;
try { try {
const boxQty = parseFloat(row.box_qty) || 0;
const grossWeight = parseFloat(row.grossWeight) || 0;
const boxKey = row._boxKey;
const newBoxQty = parseFloat(row.box_qty) || 0;
// = - box_qty/2
const netWeight = grossWeight - (boxQty / 2);
row.netWeight = netWeight.toFixed(2);
//
const originalData = this.batchEditOriginalData[boxKey];
if (!originalData) return;
const boxWeight = parseFloat(originalData.boxWeight) || 0;
if (boxWeight <= 0) {
this.$message.warning('该物料未配置箱重量,无法自动计算毛重');
return;
}
// = ×
const newGrossWeight = boxWeight * newBoxQty;
// = - box_qty/2
const newNetWeight = newGrossWeight - (newBoxQty / 2);
//
row.grossWeight = newGrossWeight.toFixed(3);
row.netWeight = newNetWeight.toFixed(3);
// Box // Box
const boxKey = row._boxKey;
this.batchEditTableData.forEach(r => { this.batchEditTableData.forEach(r => {
if (r._boxKey === boxKey) { if (r._boxKey === boxKey) {
r.box_qty = row.box_qty; r.box_qty = row.box_qty;
r.grossWeight = row.grossWeight;
r.netWeight = row.netWeight; r.netWeight = row.netWeight;
} }
}); });
//
//
this.onBatchBoxFieldChange(row, 'grossWeight');
this.onBatchBoxFieldChange(row, 'netWeight'); this.onBatchBoxFieldChange(row, 'netWeight');
} finally { } finally {
this._isBatchCalculating = false; this._isBatchCalculating = false;

Loading…
Cancel
Save