|
|
|
@ -89,7 +89,7 @@ |
|
|
|
<el-input v-model="splitQuantity" placeholder="请输入每张数量" type="number" class="split-input inlineNumber numInput"/> |
|
|
|
</div> |
|
|
|
<div class="split-info-row" v-if="splitCount > 0 && splitQuantity > 0"> |
|
|
|
<span class="split-info-text">拆分后:原标签剩余 {{ calculateRemainingQty }} 个,新增 {{ splitCount }} 张标签,每张 {{ splitQuantity }} 个</span> |
|
|
|
<span class="split-info-text">拆分后:原标签剩余 {{ calculateRemainingQty }} 个,新增 {{ splitCount }} 张标签,每张 {{ formatDisplayQty(splitQuantity) }} 个</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
@ -215,10 +215,7 @@ export default { |
|
|
|
confirmSplit() { |
|
|
|
if (this.isSplitting) return; |
|
|
|
|
|
|
|
const splitCnt = parseInt(this.splitCount); |
|
|
|
const splitQty = parseFloat(this.splitQuantity); |
|
|
|
const currentQty = parseFloat(this.currentLabel.qtyOnHand); |
|
|
|
const totalSplitQty = splitCnt * splitQty; |
|
|
|
const { splitCnt, splitQty, currentQty, remainingQty } = this.getSplitCalculation(); |
|
|
|
|
|
|
|
if (!splitCnt || splitCnt <= 0) { |
|
|
|
this.$message.warning('请输入有效的拆分张数'); |
|
|
|
@ -228,7 +225,7 @@ export default { |
|
|
|
this.$message.warning('请输入有效的每张数量'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (totalSplitQty >= currentQty) { |
|
|
|
if (remainingQty <= 0) { |
|
|
|
this.$message.warning('拆分总数量必须小于当前数量'); |
|
|
|
return; |
|
|
|
} |
|
|
|
@ -505,25 +502,41 @@ export default { |
|
|
|
// 执行打印 |
|
|
|
LODOP.PRINT(); |
|
|
|
} |
|
|
|
}, |
|
|
|
formatDisplayQty(value) { |
|
|
|
const num = Number(value); |
|
|
|
if (!Number.isFinite(num)) { |
|
|
|
return '0'; |
|
|
|
} |
|
|
|
// 保留最多6位小数并去除末尾0,避免展示浮点尾差 |
|
|
|
return Number(num.toFixed(6)).toString(); |
|
|
|
}, |
|
|
|
getSplitCalculation() { |
|
|
|
const splitCnt = parseInt(this.splitCount, 10) || 0; |
|
|
|
const splitQty = parseFloat(this.splitQuantity) || 0; |
|
|
|
const currentQty = parseFloat(this.currentLabel.qtyOnHand) || 0; |
|
|
|
const totalSplitQty = this.decimalUtil.mul(splitCnt, splitQty); |
|
|
|
const remainingQty = this.decimalUtil.sub(currentQty, totalSplitQty); |
|
|
|
return { |
|
|
|
splitCnt, |
|
|
|
splitQty, |
|
|
|
currentQty, |
|
|
|
totalSplitQty, |
|
|
|
remainingQty |
|
|
|
}; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
computed: { |
|
|
|
// 计算拆分后剩余数量 |
|
|
|
calculateRemainingQty() { |
|
|
|
const currentQty = parseFloat(this.currentLabel.qtyOnHand) || 0; |
|
|
|
const splitCnt = parseInt(this.splitCount) || 0; |
|
|
|
const splitQty = parseFloat(this.splitQuantity) || 0; |
|
|
|
const totalSplitQty = splitCnt * splitQty; |
|
|
|
return currentQty - totalSplitQty; |
|
|
|
const { remainingQty } = this.getSplitCalculation(); |
|
|
|
return this.formatDisplayQty(remainingQty); |
|
|
|
}, |
|
|
|
// 判断是否可以拆分 |
|
|
|
canSplit() { |
|
|
|
const splitCnt = parseInt(this.splitCount) || 0; |
|
|
|
const splitQty = parseFloat(this.splitQuantity) || 0; |
|
|
|
const currentQty = parseFloat(this.currentLabel.qtyOnHand) || 0; |
|
|
|
const totalSplitQty = splitCnt * splitQty; |
|
|
|
return splitCnt > 0 && splitQty > 0 && totalSplitQty < currentQty; |
|
|
|
const { splitCnt, splitQty, remainingQty } = this.getSplitCalculation(); |
|
|
|
return splitCnt > 0 && splitQty > 0 && remainingQty > 0; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|