From e62bbded9ae11eb3fc42df8170f87d17a2d32c44 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期三, 25 三月 2026 17:24:50 +0800
Subject: [PATCH] 编辑成品检验时,需加上不良数量,合格数量字段。页面列表也需要加上不良数量、合格数量字段。不良数量可以手填,合格数量、数量都置灰。根据不良数量+合格数量=数量这一逻辑计算。若不填默认不良数量为0。数量是订单本次生产数量-报废数量

---
 src/views/qualityManagement/finalInspection/components/formDia.vue |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/src/views/qualityManagement/finalInspection/components/formDia.vue b/src/views/qualityManagement/finalInspection/components/formDia.vue
index 6a3e774..b850af3 100644
--- a/src/views/qualityManagement/finalInspection/components/formDia.vue
+++ b/src/views/qualityManagement/finalInspection/components/formDia.vue
@@ -2,7 +2,7 @@
   <div>
     <el-dialog
         v-model="dialogFormVisible"
-        :title="operationType === 'add' ? '鏂板鍑哄巶妫�楠�' : '缂栬緫鍑哄巶妫�楠�'"
+        :title="operationType === 'add' ? '鏂板鎴愬搧妫�楠�' : '缂栬緫鎴愬搧妫�楠�'"
         width="70%"
         @close="closeDia"
     >
@@ -49,6 +49,11 @@
               </el-select>
             </el-form-item>
           </el-col>
+          <el-col :span="12">
+            <el-form-item label="鏁伴噺锛�" prop="quantity">
+              <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.quantity" placeholder="璇疯緭鍏�" clearable :precision="2" :disabled="quantityDisabled"/>
+            </el-form-item>
+          </el-col>
         </el-row>
         <el-row :gutter="30">
           <el-col :span="12">
@@ -57,8 +62,23 @@
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="鏁伴噺锛�" prop="quantity">
-              <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.quantity" placeholder="璇疯緭鍏�" clearable :precision="2"/>
+            <el-form-item label="涓嶈壇鏁伴噺锛�" prop="defectiveQuantity">
+              <el-input v-model="form.defectiveQuantity" placeholder="璇疯緭鍏�" clearable/>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="30">
+          <el-col :span="12">
+            <el-form-item label="涓嶈壇鍘熷洜锛�" prop="defectiveReason">
+              <el-select v-model="form.defectiveReason" placeholder="璇烽�夋嫨" clearable style="width: 100%">
+                <el-option :label="item.label" :value="item.value" v-for="(item,index) in defective_reason" :key="index" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="12">
+            <el-form-item label="鍚堟牸鏁伴噺锛�" prop="qualifiedQuantity">
+              <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.qualifiedQuantity" placeholder="璇疯緭鍏�" clearable :precision="2" disabled/>
             </el-form-item>
           </el-col>
         </el-row>
@@ -123,7 +143,7 @@
 </template>
 
 <script setup>
-import {ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
+import {ref, reactive, toRefs, computed, getCurrentInstance, nextTick} from "vue";
 import {getOptions} from "@/api/procurementManagement/procurementLedger.js";
 import {modelList, productTreeList} from "@/api/basicData/product.js";
 import {qualityInspectAdd, qualityInspectUpdate} from "@/api/qualityManagement/rawMaterialInspection.js";
@@ -145,7 +165,9 @@
     productModelId: "",
     model: "",
     testStandardId: "",
+    defectiveReason: undefined,
     unit: "",
+    qualifiedQuantity: "",
     quantity: "",
     checkCompany: "",
     checkResult: "",
@@ -164,8 +186,14 @@
   },
 });
 const { form, rules } = toRefs(data);
+// 缂栬緫鏃讹細productMainId 鎴� purchaseLedgerId 浠讳竴鏈夊�煎垯鏁伴噺缃伆
+const quantityDisabled = computed(() => {
+  const v = form.value || {};
+  return !!(v.productMainId != null || v.purchaseLedgerId != null);
+});
 const supplierList = ref([]);
 const productOptions = ref([]);
+const { defective_reason } = proxy.useDict("defective_reason");
 const tableColumn = ref([
 	{
 		label: "鎸囨爣",
@@ -197,6 +225,29 @@
 const testStandardOptions = ref([]); // 鎸囨爣閫夋嫨涓嬫媺妗嗘暟鎹�
 const modelOptions = ref([]);
 
+// 鐩戝惉涓嶈壇鏁伴噺鍙樺寲锛岃嚜鍔ㄦ洿鏂版暟閲�
+// 褰� defectiveQuantity 澧炲姞鏃讹紝quantity 鍑忓皯锛涘綋 defectiveQuantity 鍑忓皯鏃讹紝quantity 澧炲姞
+watch(() => form.value.defectiveQuantity, (newVal, oldVal) => {
+  if (newVal > form.value.quantity) {
+    form.value.defectiveQuantity = form.value.quantity;
+  }
+  form.value.qualifiedQuantity = Number((form.value.quantity - newVal).toFixed(2));
+});
+
+// 鐩戝惉鎬绘暟閲忓彉鍖栵紝鑷姩鏇存柊鍚堟牸鏁伴噺
+watch(() => form.value.quantity, (newVal, oldVal) => {
+  const totalQty = Number(newVal) || 0;
+  const defectiveQty = Number(form.value.defectiveQuantity) || 0;
+
+  // 纭繚涓嶈壇鏁伴噺涓嶈秴杩囨�绘暟閲�
+  if (defectiveQty > totalQty) {
+    form.value.defectiveQuantity = totalQty;
+  }
+
+  // 璁$畻鍚堟牸鏁伴噺
+  form.value.qualifiedQuantity = Number((totalQty - defectiveQty).toFixed(2));
+});
+
 // 鎵撳紑寮规
 const openDialog = async (type, row) => {
   operationType.value = type;

--
Gitblit v1.9.3