From 9581c0ae9f0d9a2e92744f3dca78960780b9a2df Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 18 五月 2026 17:42:21 +0800
Subject: [PATCH] 附件

---
 src/pages/qualityManagement/finalInspection/add.vue |  143 ++++++++++++++++++++++++++---------------------
 1 files changed, 78 insertions(+), 65 deletions(-)

diff --git a/src/pages/qualityManagement/finalInspection/add.vue b/src/pages/qualityManagement/finalInspection/add.vue
index a56b388..c297bbc 100644
--- a/src/pages/qualityManagement/finalInspection/add.vue
+++ b/src/pages/qualityManagement/finalInspection/add.vue
@@ -67,14 +67,32 @@
                   placeholder="璇疯緭鍏ュ崟浣�"
                   disabled />
       </up-form-item>
-      <up-form-item label="鏁伴噺"
+      <up-form-item label="鎬绘暟閲�"
                     prop="quantity"
                     required
                     border-bottom>
         <up-input v-model="form.quantity"
                   type="number"
-                  placeholder="璇疯緭鍏ユ暟閲�"
+                  placeholder="璇疯緭鍏ユ�绘暟閲�"
                   :disabled="processQuantityDisabled" />
+      </up-form-item>
+      <up-form-item label="鍚堟牸鏁伴噺"
+                    prop="qualifiedQuantity"
+                    required
+                    border-bottom>
+        <up-input v-model="form.qualifiedQuantity"
+                  type="number"
+                  placeholder="璇疯緭鍏ュ悎鏍兼暟閲�"
+                  clearable />
+      </up-form-item>
+      <up-form-item label="涓嶅悎鏍兼暟閲�"
+                    prop="unqualifiedQuantity"
+                    required
+                    border-bottom>
+        <up-input v-model="form.unqualifiedQuantity"
+                  type="number"
+                  placeholder="璇疯緭鍏ヤ笉鍚堟牸鏁伴噺"
+                  clearable />
       </up-form-item>
       <up-form-item label="妫�娴嬪崟浣�"
                     prop="checkCompany"
@@ -82,19 +100,6 @@
         <up-input v-model="form.checkCompany"
                   placeholder="璇疯緭鍏ユ娴嬪崟浣�"
                   clearable />
-      </up-form-item>
-      <up-form-item label="妫�娴嬬粨鏋�"
-                    prop="checkResult"
-                    required
-                    border-bottom>
-        <up-input v-model="form.checkResult"
-                  placeholder="璇烽�夋嫨妫�娴嬬粨鏋�"
-                  readonly
-                  @click="showResultSheet" />
-        <template #right>
-          <up-icon @click="showResultSheet = true"
-                   name="arrow-right" />
-        </template>
       </up-form-item>
       <up-form-item label="妫�楠屽憳"
                     prop="checkName"
@@ -207,12 +212,6 @@
                      @select="selectModel"
                      @close="showModelSheet = false"
                      title="閫夋嫨瑙勬牸鍨嬪彿" />
-    <!-- 妫�娴嬬粨鏋滈�夋嫨 -->
-    <up-action-sheet :show="showResultSheet"
-                     :actions="resultSheetOptions"
-                     @select="selectResult"
-                     @close="showResultSheet = false"
-                     title="閫夋嫨妫�娴嬬粨鏋�" />
     <!-- 妫�楠屽憳閫夋嫨 -->
     <up-action-sheet :show="showInspectorSheet"
                      :actions="userSheetOptions"
@@ -302,7 +301,7 @@
 
 <script setup>
   import { ref, computed, onMounted, nextTick } from "vue";
-  import { onShow } from "@dcloudio/uni-app";
+  import { onShow, onLoad } from "@dcloudio/uni-app";
   import PageHeader from "@/components/PageHeader.vue";
   import dayjs from "dayjs";
   import { getOptions } from "@/api/procurementManagement/procurementLedger.js";
@@ -339,8 +338,6 @@
   const showProductTree = ref(false);
   // 瑙勬牸鍨嬪彿閫夋嫨
   const showModelSheet = ref(false);
-  // 妫�娴嬬粨鏋滈�夋嫨
-  const showResultSheet = ref(false);
   // 妫�楠屽憳閫夋嫨
   const showInspectorSheet = ref(false);
   // 鎸囨爣閫夋嫨
@@ -358,8 +355,9 @@
     testStandardId: "",
     unit: "",
     quantity: "",
+    qualifiedQuantity: "",
+    unqualifiedQuantity: "",
     checkCompany: "",
-    checkResult: "",
     productMainId: null,
     purchaseLedgerId: null,
   });
@@ -379,11 +377,6 @@
   const modelOptions = ref([]);
   // 妫�楠屽憳鍒楄〃
   const userList = ref([]);
-  // 妫�娴嬬粨鏋滈�夐」
-  const resultOptions = ref([
-    { label: "鍚堟牸", value: "鍚堟牸" },
-    { label: "涓嶅悎鏍�", value: "涓嶅悎鏍�" },
-  ]);
   // 鎸囨爣閫夐」
   const testStandardOptions = ref([]);
   // 褰撳墠浜у搧ID
@@ -408,13 +401,6 @@
     return modelOptions.value.map(item => ({
       name: item.model,
       value: item.id,
-    }));
-  });
-
-  const resultSheetOptions = computed(() => {
-    return resultOptions.value.map(item => ({
-      name: item.label,
-      value: item.value,
     }));
   });
 
@@ -446,15 +432,18 @@
     ],
     unit: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
     quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-    checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
-    checkResult: [
-      { required: true, message: "璇烽�夋嫨妫�娴嬬粨鏋�", trigger: "change" },
+    qualifiedQuantity: [
+      { required: true, message: "璇疯緭鍏ュ悎鏍兼暟閲�", trigger: "blur" },
     ],
+    unqualifiedQuantity: [
+      { required: true, message: "璇疯緭鍏ヤ笉鍚堟牸鏁伴噺", trigger: "blur" },
+    ],
+    checkCompany: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
   };
 
   // 鏄惁涓虹紪杈戞ā寮�
   const isEdit = computed(() => {
-    const id = getPageId();
+    const id = optionsId.value;
     return !!id;
   });
 
@@ -463,13 +452,6 @@
     const v = form.value || {};
     return !!(v.productMainId != null || v.purchaseLedgerId != null);
   });
-
-  // 鑾峰彇椤甸潰ID
-  const getPageId = () => {
-    const pages = getCurrentPages();
-    const currentPage = pages[pages.length - 1];
-    return currentPage.options.id;
-  };
 
   // 杩斿洖涓婁竴椤�
   const goBack = () => {
@@ -561,12 +543,6 @@
       modelOptions.value.find(item => item.id == value)?.model || "";
     form.value.unit =
       modelOptions.value.find(item => item.id == value)?.unit || "";
-  };
-
-  // 閫夋嫨妫�娴嬬粨鏋�
-  const selectResult = e => {
-    form.value.checkResult = e.value;
-    showResultSheet.value = false;
   };
 
   // 閫夋嫨妫�楠屽憳
@@ -690,16 +666,41 @@
       //   showToast("璇烽�夋嫨宸ュ簭");
       //   return;
       // }
-      if (!form.value.quantity) {
-        showToast("璇疯緭鍏ユ暟閲�");
+      if (!form.value.quantity && form.value.quantity !== 0) {
+        showToast("璇疯緭鍏ユ�绘暟閲�");
+        return;
+      }
+      if (
+        form.value.qualifiedQuantity === "" ||
+        form.value.qualifiedQuantity === undefined
+      ) {
+        showToast("璇疯緭鍏ュ悎鏍兼暟閲�");
+        return;
+      }
+      if (
+        form.value.unqualifiedQuantity === "" ||
+        form.value.unqualifiedQuantity === undefined
+      ) {
+        showToast("璇疯緭鍏ヤ笉鍚堟牸鏁伴噺");
+        return;
+      }
+      const qty = Number(form.value.quantity);
+      const qf = Number(form.value.qualifiedQuantity);
+      const uq = Number(form.value.unqualifiedQuantity);
+      if (Number.isNaN(qty) || qty < 0) {
+        showToast("鎬绘暟閲忔牸寮忎笉姝g‘");
+        return;
+      }
+      if (Number.isNaN(qf) || qf < 0 || Number.isNaN(uq) || uq < 0) {
+        showToast("鍚堟牸/涓嶅悎鏍兼暟閲忔牸寮忎笉姝g‘");
+        return;
+      }
+      if (qf + uq !== qty) {
+        showToast("鍚堟牸鏁伴噺涓庝笉鍚堟牸鏁伴噺涔嬪拰椤荤瓑浜庢�绘暟閲�");
         return;
       }
       if (!form.value.productId) {
         showToast("璇烽�夋嫨浜у搧");
-        return;
-      }
-      if (!form.value.checkResult) {
-        showToast("璇烽�夋嫨妫�娴嬬粨鏋�");
         return;
       }
 
@@ -713,7 +714,9 @@
       }
 
       const data = { ...form.value, qualityInspectParams: tableData.value };
-      data.quantity = Number(data.quantity);
+      data.quantity = qty;
+      data.qualifiedQuantity = qf;
+      data.unqualifiedQuantity = uq;
       if (isEdit.value) {
         const res = await qualityInspectUpdate(data);
         showToast("淇濆瓨鎴愬姛");
@@ -737,7 +740,7 @@
 
   // 鍒濆鍖栬〃鍗�
   const initForm = async () => {
-    const id = getPageId();
+    const id = optionsId.value;
     if (id) {
       // 缂栬緫妯″紡锛屽姞杞芥暟鎹�
       // 鍏堥噸缃〃鍗曟暟鎹�
@@ -752,8 +755,9 @@
         testStandardId: "",
         unit: "",
         quantity: "",
+        qualifiedQuantity: "",
+        unqualifiedQuantity: "",
         checkCompany: "",
-        checkResult: "",
         productMainId: null,
         purchaseLedgerId: null,
       };
@@ -774,8 +778,9 @@
         testStandardId: "1",
         unit: "kg",
         quantity: 1000,
+        qualifiedQuantity: 1000,
+        unqualifiedQuantity: 0,
         checkCompany: "绗笁鏂规娴嬫満鏋�",
-        checkResult: "鍚堟牸",
         productMainId: null,
         purchaseLedgerId: null,
       };
@@ -854,8 +859,9 @@
         testStandardId: "",
         unit: "",
         quantity: "",
+        qualifiedQuantity: "",
+        unqualifiedQuantity: "",
         checkCompany: "",
-        checkResult: "",
         productMainId: null,
         purchaseLedgerId: null,
       };
@@ -890,6 +896,13 @@
   onShow(() => {
     initForm();
   });
+
+  const optionsId = ref("");
+  onLoad(options => {
+    optionsId.value = options.id || "";
+    console.log(optionsId.value, "========");
+    initForm();
+  });
 </script>
 
 <style scoped lang="scss">

--
Gitblit v1.9.3