From 3af257341cbb3fca05b7a457648485084ea41d62 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期五, 12 六月 2026 15:42:38 +0800
Subject: [PATCH] fix: 修复生产报工的待生产数量精度问题
---
src/views/productionManagement/workOrderManagement/index.vue | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/views/productionManagement/workOrderManagement/index.vue b/src/views/productionManagement/workOrderManagement/index.vue
index 44be8b7..a9cf39d 100644
--- a/src/views/productionManagement/workOrderManagement/index.vue
+++ b/src/views/productionManagement/workOrderManagement/index.vue
@@ -133,7 +133,7 @@
<el-input v-model.number="reportForm.quantity"
type="number"
min="0"
- step="0.1"
+ step="0.0001"
style="width: 300px"
placeholder="璇疯緭鍏ョ敓浜у悎鏍兼暟閲�"
@input="handleQuantityInput" />
@@ -143,7 +143,7 @@
<el-input v-model.number="reportForm.scrapQty"
type="number"
min="0"
- step="0.1"
+ step="0.0001"
style="width: 300px"
placeholder="璇疯緭鍏ユ姤搴熸暟閲�"
@input="handleScrapQtyInput" />
@@ -529,6 +529,12 @@
if (n >= 100) return 100;
return Math.round(n);
};
+ const subtractQuantity = (minuend, subtrahend, precision = 4) => {
+ const factor = 10 ** precision;
+ const a = Math.round((Number(minuend) || 0) * factor);
+ const b = Math.round((Number(subtrahend) || 0) * factor);
+ return Math.max(0, (a - b) / factor);
+ };
const progressColor = percentage => {
const p = toProgressPercentage(percentage);
if (p < 30) return "#f56c6c";
@@ -651,10 +657,10 @@
}
}
currentReportRowData.value = row;
- const planQuantity = Number(row.planQuantity || 0);
- const completeQuantity = Number(row.completeQuantity || 0);
- const remainingQuantity = Math.max(0, planQuantity - completeQuantity);
- reportForm.planQuantity = remainingQuantity;
+ reportForm.planQuantity = subtractQuantity(
+ row.planQuantity,
+ row.completeQuantity
+ );
reportForm.quantity =
row.quantity !== undefined && row.quantity !== null ? row.quantity : null;
reportForm.productProcessRouteItemId = row.productProcessRouteItemId;
--
Gitblit v1.9.3