|
|
|
@ -448,7 +448,8 @@ export default { |
|
|
|
box_qty: 1, |
|
|
|
grossWeight: 0, |
|
|
|
netWeight: 0, |
|
|
|
rolls: 0 |
|
|
|
rolls: 0, |
|
|
|
boxWeight: 0 // 物料的箱重量(BOXWEIGHT) |
|
|
|
}, |
|
|
|
editBoxSubmitting: false, |
|
|
|
currentEditBox: null, |
|
|
|
@ -882,6 +883,7 @@ export default { |
|
|
|
this.editBoxForm.grossWeight = boxRow.grossWeight; |
|
|
|
this.editBoxForm.netWeight = boxRow.netWeight; |
|
|
|
this.editBoxForm.rolls = boxRow.rolls; |
|
|
|
this.editBoxForm.boxWeight = boxRow.boxWeight || 0; // 保存物料的箱重量 |
|
|
|
this.editBoxDialogVisible = true; |
|
|
|
}, |
|
|
|
|
|
|
|
@ -938,9 +940,10 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 箱数改变时自动计算净重 |
|
|
|
* 保持毛重不变,重新计算净重 |
|
|
|
* 计算公式:净重 = 毛重 - box_qty/2 |
|
|
|
* 箱数改变时自动计算毛重和净重 |
|
|
|
* 计算公式: |
|
|
|
* 1. 新毛重 = 物料箱重量(BOXWEIGHT) × 新箱数 |
|
|
|
* 2. 新净重 = 新毛重 - box_qty/2 |
|
|
|
*/ |
|
|
|
onBoxQtyChange(value) { |
|
|
|
// 防止循环触发,使用标志位 |
|
|
|
@ -951,14 +954,24 @@ export default { |
|
|
|
this._isCalculating = true; |
|
|
|
|
|
|
|
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 { |
|
|
|
this._isCalculating = false; |
|
|
|
} |
|
|
|
@ -1284,12 +1297,13 @@ export default { |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
// 保存Box原始数据 |
|
|
|
// 保存Box原始数据,包括物料的箱重量 |
|
|
|
this.batchEditOriginalData[this.getBoxRowKey(box)] = { |
|
|
|
box_qty: box.box_qty, |
|
|
|
grossWeight: box.grossWeight, |
|
|
|
netWeight: box.netWeight, |
|
|
|
rolls: box.rolls |
|
|
|
rolls: box.rolls, |
|
|
|
boxWeight: box.boxWeight || 0 // 物料的箱重量(BOXWEIGHT) |
|
|
|
}; |
|
|
|
} else { |
|
|
|
// 没有明细时,创建一行空明细的数据 |
|
|
|
@ -1311,12 +1325,13 @@ export default { |
|
|
|
}; |
|
|
|
tableData.push(rowData); |
|
|
|
|
|
|
|
// 保存Box原始数据 |
|
|
|
// 保存Box原始数据,包括物料的箱重量 |
|
|
|
this.batchEditOriginalData[this.getBoxRowKey(box)] = { |
|
|
|
box_qty: box.box_qty, |
|
|
|
grossWeight: box.grossWeight, |
|
|
|
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) { |
|
|
|
if (this._isBatchCalculating) return; |
|
|
|
this._isBatchCalculating = true; |
|
|
|
|
|
|
|
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的行 |
|
|
|
const boxKey = row._boxKey; |
|
|
|
this.batchEditTableData.forEach(r => { |
|
|
|
if (r._boxKey === boxKey) { |
|
|
|
r.box_qty = row.box_qty; |
|
|
|
r.grossWeight = row.grossWeight; |
|
|
|
r.netWeight = row.netWeight; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 触发净重的变化检测 |
|
|
|
// 触发毛重和净重的变化检测 |
|
|
|
this.onBatchBoxFieldChange(row, 'grossWeight'); |
|
|
|
this.onBatchBoxFieldChange(row, 'netWeight'); |
|
|
|
} finally { |
|
|
|
this._isBatchCalculating = false; |
|
|
|
|