|
|
|
@ -195,6 +195,33 @@ export default { |
|
|
|
tTr, |
|
|
|
tTr, |
|
|
|
tTd, |
|
|
|
tTd, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 新增 watch 监听 |
|
|
|
|
|
|
|
watch: { |
|
|
|
|
|
|
|
// 监听报废数量的变化 |
|
|
|
|
|
|
|
'formData.scrapQty'(newVal) { |
|
|
|
|
|
|
|
// 确保有总数量数据,且报废数量是有效数字 |
|
|
|
|
|
|
|
if (this.tableObj.notWorkQty !== undefined && this.tableObj.notWorkQty !== null) { |
|
|
|
|
|
|
|
const totalQty = Number(this.tableObj.notWorkQty); |
|
|
|
|
|
|
|
const scrap = Number(newVal); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果报废数量是有效数字 |
|
|
|
|
|
|
|
if (!isNaN(scrap)) { |
|
|
|
|
|
|
|
// 计算剩余可合格数量:总数量 - 报废数量 |
|
|
|
|
|
|
|
let remainingQty = totalQty - scrap; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 防止出现负数,最小为0 |
|
|
|
|
|
|
|
if (remainingQty < 0) { |
|
|
|
|
|
|
|
remainingQty = 0; |
|
|
|
|
|
|
|
// 可选:如果报废超过总数,可以提示用户或强制修正报废数量 |
|
|
|
|
|
|
|
// uni.showToast({ title: '报废数量不能超过总数量', icon: 'none' }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新合格数量 |
|
|
|
|
|
|
|
this.formData.workQty = remainingQty; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
return { |
|
|
|
tableObj: {}, |
|
|
|
tableObj: {}, |
|
|
|
|