|
|
|
@ -356,12 +356,12 @@ |
|
|
|
</el-col> |
|
|
|
<el-col :span="6"> |
|
|
|
<el-form-item label="毛重"> |
|
|
|
<el-input v-model="palletModelData.grossWeight" type="number" placeholder="自动计算"></el-input> |
|
|
|
<el-input v-model="palletModelData.grossWeight" type="number" placeholder="自动计算" @input="onPalletGrossWeightChange"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="6"> |
|
|
|
<el-form-item label="净重"> |
|
|
|
<el-input v-model="palletModelData.netWeight" type="number" placeholder="自动计算"></el-input> |
|
|
|
<el-input v-model="palletModelData.netWeight" type="number" placeholder="自动计算" @input="onPalletNetWeightChange"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="6"> |
|
|
|
@ -2750,6 +2750,68 @@ |
|
|
|
this.palletModelData.grossWeight = parseFloat(grossWeight.toFixed(2)); |
|
|
|
this.palletModelData.netWeight = parseFloat(netWeight.toFixed(2)); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 毛重改变时自动计算净重 |
|
|
|
* 计算公式:净重 = 毛重 - (箱数 / 2) |
|
|
|
*/ |
|
|
|
onPalletGrossWeightChange(value) { |
|
|
|
// 防止循环触发,使用标志位 |
|
|
|
if (this._isPalletWeightCalculating) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this._isPalletWeightCalculating = true; |
|
|
|
|
|
|
|
try { |
|
|
|
const grossWeight = parseFloat(value) || 0; |
|
|
|
const boxQty = parseFloat(this.palletModelData.boxQty) || 0; |
|
|
|
|
|
|
|
if (grossWeight <= 0) { |
|
|
|
this.palletModelData.netWeight = ''; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 计算净重:净重 = 毛重 - (箱数 / 2) |
|
|
|
const netWeight = grossWeight - (boxQty / 2); |
|
|
|
|
|
|
|
// 保留2位小数 |
|
|
|
this.palletModelData.netWeight = parseFloat(netWeight.toFixed(2)); |
|
|
|
} finally { |
|
|
|
this._isPalletWeightCalculating = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 净重改变时自动计算毛重 |
|
|
|
* 反向计算公式:毛重 = 净重 + (箱数 / 2) |
|
|
|
*/ |
|
|
|
onPalletNetWeightChange(value) { |
|
|
|
// 防止循环触发,使用标志位 |
|
|
|
if (this._isPalletWeightCalculating) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this._isPalletWeightCalculating = true; |
|
|
|
|
|
|
|
try { |
|
|
|
const netWeight = parseFloat(value) || 0; |
|
|
|
const boxQty = parseFloat(this.palletModelData.boxQty) || 0; |
|
|
|
|
|
|
|
if (netWeight <= 0) { |
|
|
|
this.palletModelData.grossWeight = ''; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 反向计算毛重:毛重 = 净重 + (箱数 / 2) |
|
|
|
const grossWeight = netWeight + (boxQty / 2); |
|
|
|
|
|
|
|
// 保留2位小数 |
|
|
|
this.palletModelData.grossWeight = parseFloat(grossWeight.toFixed(2)); |
|
|
|
} finally { |
|
|
|
this._isPalletWeightCalculating = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
savePalletHeader(type) { |
|
|
|
// 过滤出 useQty > 0 的行 |
|
|
|
const selectedRows = this.dataList8.filter(item => item.useQty && item.useQty > 0); |
|
|
|
|