|
|
|
@ -112,17 +112,17 @@ |
|
|
|
<el-row :gutter="20"> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="箱数" prop="box_qty"> |
|
|
|
<el-input v-model="editBoxForm.box_qty" :min="1" :precision="0" style="width: 100%"></el-input> |
|
|
|
<el-input v-model="editBoxForm.box_qty" @input="onBoxQtyChange" :min="1" :precision="0" style="width: 100%"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="毛重" prop="grossWeight"> |
|
|
|
<el-input v-model="editBoxForm.grossWeight" :min="0" :precision="2" style="width: 100%"></el-input> |
|
|
|
<el-input v-model="editBoxForm.grossWeight" @input="onGrossWeightChange" :min="0" :precision="2" style="width: 100%"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="净重" prop="netWeight"> |
|
|
|
<el-input v-model="editBoxForm.netWeight" :min="0" :precision="2" style="width: 100%"></el-input> |
|
|
|
<el-input v-model="editBoxForm.netWeight" @input="onNetWeightChange" :min="0" :precision="2" style="width: 100%"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
@ -611,6 +611,85 @@ export default { |
|
|
|
this.editDetailDialogVisible = true; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 箱数改变时自动计算净重 |
|
|
|
* 保持毛重不变,重新计算净重 |
|
|
|
* 计算公式:净重 = 毛重 - box_qty/2 |
|
|
|
*/ |
|
|
|
onBoxQtyChange(value) { |
|
|
|
// 防止循环触发,使用标志位 |
|
|
|
if (this._isCalculating) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this._isCalculating = true; |
|
|
|
|
|
|
|
try { |
|
|
|
const boxQty = parseFloat(value) || 0; |
|
|
|
const grossWeight = parseFloat(this.editBoxForm.grossWeight) || 0; |
|
|
|
|
|
|
|
// 计算净重:净重 = 毛重 - box_qty/2 |
|
|
|
const netWeight = grossWeight - (boxQty / 2); |
|
|
|
|
|
|
|
// 保留2位小数 |
|
|
|
this.editBoxForm.netWeight = netWeight.toFixed(2); |
|
|
|
} finally { |
|
|
|
this._isCalculating = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 毛重改变时自动计算净重 |
|
|
|
* 计算公式:净重 = 毛重 - box_qty/2 |
|
|
|
*/ |
|
|
|
onGrossWeightChange(value) { |
|
|
|
// 防止循环触发,使用标志位 |
|
|
|
if (this._isCalculating) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this._isCalculating = true; |
|
|
|
|
|
|
|
try { |
|
|
|
const grossWeight = parseFloat(value) || 0; |
|
|
|
const boxQty = parseFloat(this.editBoxForm.box_qty) || 0; |
|
|
|
|
|
|
|
// 计算净重:净重 = 毛重 - box_qty/2 |
|
|
|
const netWeight = grossWeight - (boxQty / 2); |
|
|
|
|
|
|
|
// 保留2位小数 |
|
|
|
this.editBoxForm.netWeight = netWeight.toFixed(2); |
|
|
|
} finally { |
|
|
|
this._isCalculating = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 净重改变时自动计算毛重 |
|
|
|
* 反向计算公式:毛重 = 净重 + box_qty/2 |
|
|
|
*/ |
|
|
|
onNetWeightChange(value) { |
|
|
|
// 防止循环触发,使用标志位 |
|
|
|
if (this._isCalculating) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this._isCalculating = true; |
|
|
|
|
|
|
|
try { |
|
|
|
const netWeight = parseFloat(value) || 0; |
|
|
|
const boxQty = parseFloat(this.editBoxForm.box_qty) || 0; |
|
|
|
|
|
|
|
// 反向计算毛重:毛重 = 净重 + box_qty/2 |
|
|
|
const grossWeight = netWeight + (boxQty / 2); |
|
|
|
|
|
|
|
// 保留2位小数 |
|
|
|
this.editBoxForm.grossWeight = grossWeight.toFixed(2); |
|
|
|
} finally { |
|
|
|
this._isCalculating = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 提交修改箱信息 |
|
|
|
submitEditBox() { |
|
|
|
this.$refs.editBoxForm.validate(valid => { |
|
|
|
|