From 9ea88ab0fee4fb6aee731977de624a8046a2997e Mon Sep 17 00:00:00 2001 From: zhangdi <1104545947@qq.com> Date: Tue, 21 Apr 2026 13:40:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=BA=8F=E6=8A=A5=E5=B7=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/plan/workReport.vue | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pages/plan/workReport.vue b/pages/plan/workReport.vue index 21b9715..b0c73f7 100644 --- a/pages/plan/workReport.vue +++ b/pages/plan/workReport.vue @@ -244,6 +244,33 @@ export default { twoInputFcous: true, }; }, + // 新增 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; + } + } + } + }, methods: {}, onNavigationBarButtonTap(btn) { this.$refs.ifrm.topMenuClick(btn);