From 09ce99b6d33ec58d462da5b5fd65927d7ef98f60 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期五, 03 四月 2026 09:15:00 +0800
Subject: [PATCH] fix: 终检表单优化检验用粉剂/液数据加载

---
 src/views/qualityManagement/finalInspection/components/formDia.vue |   66 +++++++++++++++++++++------------
 1 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/src/views/qualityManagement/finalInspection/components/formDia.vue b/src/views/qualityManagement/finalInspection/components/formDia.vue
index d9a7651..c94f061 100644
--- a/src/views/qualityManagement/finalInspection/components/formDia.vue
+++ b/src/views/qualityManagement/finalInspection/components/formDia.vue
@@ -168,6 +168,14 @@
             </el-form-item>
           </el-col>
           <el-col :span="6">
+            <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="inspectProductModelId">
+              <el-select v-model="form.inspectProductModelId" placeholder="璇烽�夋嫨" clearable
+                         filterable readonly @change="handleChangeModels">
+                <el-option v-for="item in inspectProductModel" :key="item.id" :label="item.model" :value="item.id" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
             <el-form-item label="鎵瑰彿锛堟柊锛夛細" prop="inspectBatchNo">
               <el-select
                   v-model="form.inspectBatchNo"
@@ -183,14 +191,6 @@
                     :label="item.batchNo"
                     :value="item.batchNo"
                 />
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="6">
-            <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="inspectProductModelId">
-              <el-select v-model="form.inspectProductModelId" placeholder="璇烽�夋嫨" clearable
-                         filterable readonly @change="handleChangeModels">
-                <el-option v-for="item in inspectProductModel" :key="item.id" :label="item.model" :value="item.id" />
               </el-select>
             </el-form-item>
           </el-col>
@@ -502,9 +502,14 @@
           // 缂栬緫鍦烘櫙淇濈暀宸叉湁妫�楠屽�硷紝鐩存帴鎷夊彇鍘熷弬鏁版暟鎹�
           getQualityInspectParamList(row.id);
         });
+
+        // 缂栬緫妯″紡涓嬶紝鍔犺浇妫�楠岀敤绮夊墏/娑茬浉鍏虫暟鎹�
+        loadInspectMaterialData();
       });
     } else {
       getQualityInspectParamList(row.id);
+      // 鍗充娇娌℃湁涓讳骇鍝侊紝涔熷皾璇曞姞杞芥楠岀敤绮夊墏/娑叉暟鎹�
+      loadInspectMaterialData();
     }
   }
 }
@@ -652,31 +657,45 @@
   }
 };
 
+// 鍔犺浇妫�楠岀敤绮夊墏/娑叉儏鍐电浉鍏虫暟鎹紙缂栬緫妯″紡鍥炴樉鐢級
+const loadInspectMaterialData = () => {
+  // 濡傛灉鏈夋楠岀敤绮夊墏/娑蹭骇鍝両D锛屽姞杞藉搴旂殑瑙勬牸鍨嬪彿
+  if (form.value.inspectMaterialConditionId) {
+    modelList({ id: form.value.inspectMaterialConditionId }).then((res) => {
+      inspectProductModel.value = res || [];
+      // 濡傛灉鏈夎鏍煎瀷鍙稩D锛屽姞杞芥壒鍙峰垪琛�
+      if (form.value.inspectProductModelId && inspectProductModel.value.length > 0) {
+        const selectedModel = inspectProductModel.value.find(item => item.id == form.value.inspectProductModelId);
+        if (selectedModel) {
+          form.value.inspectProductModel = selectedModel.model || '';
+        }
+        // 鏍规嵁瑙勬牸鍨嬪彿鏌ヨ鎵瑰彿鍒楄〃
+        getStockInventoryListPage({
+          model: form.value.inspectProductModel,
+          pageNum: 1,
+          pageSize: -1
+        }).then((res) => {
+          inspectBatchOptions.value = res.data.records || [];
+        });
+      }
+    });
+  }
+};
+
 // 閫夋嫨妫�楠岀敤绮夊墏/娑叉儏鍐靛悗锛屾牴鎹骇鍝両D鏌ヨ搴撳瓨鎵瑰彿鍒楄〃
 const handleInspectMaterialChange = (productId) => {
   inspectBatchOptions.value = [];
   form.value.inspectBatchNo = "";
   form.value.inspectProductModel = "";
+  form.value.inspectProductModelId = "";
   form.value.inspectProductionDate = "";
   form.value.inspectValidityDate = "";
   form.value.inspectValidityPeriod = "";
-  // let productName = findNodeById(productOptions.value, productId);
+  form.value.inspectMaterialCondition = findNodeById(productOptions.value, productId);
 
   modelList({ id: productId }).then((res) => {
     inspectProductModel.value = res;
   })
-  /*getStockInventoryListPage({
-    productName: productName,
-    pageNum: 1,
-    pageSize: -1
-  }).then(res => {
-    inspectBatchOptions.value = res.data || []
-    // 娓呯┖宸查�夋嫨鐨勬壒鍙峰拰鏂板瓧娈�
-    form.value.inspectBatchNo = "";
-    form.value.inspectProductModel = "";
-    form.value.inspectProductionDate = "";
-    form.value.inspectValidityDate = "";
-  });*/
 };
 
 const handleChangeModels = (value) => {
@@ -687,13 +706,12 @@
     pageNum: 1,
     pageSize: -1
   }).then(res => {
-    inspectBatchOptions.value = res.data || []
+    inspectBatchOptions.value = res.data.records || []
     // 娓呯┖宸查�夋嫨鐨勬壒鍙峰拰鏂板瓧娈�
     form.value.inspectBatchNo = "";
     form.value.inspectProductionDate = "";
     form.value.inspectValidityDate = "";
   });
-
   if (form.value.productionDate) {
     calculateInspectValidityDate();
   }
@@ -709,7 +727,7 @@
   const selectedModel = inspectProductModel.value.find(item => item.id == form.value.inspectProductModelId);
   if (selectedModel && selectedModel.validityPeriod) {
     const inspectProductionDate = new Date(form.value.inspectProductionDate);
-    const validityPeriod = parseFloat(selectedModel.inspectValidityDate);
+    const validityPeriod = parseFloat(selectedModel.validityPeriod);
     const validityDate = new Date(inspectProductionDate);
     validityDate.setFullYear(validityDate.getFullYear() + Math.floor(validityPeriod));
     validityDate.setMonth(validityDate.getMonth() + Math.round((validityPeriod % 1) * 12));

--
Gitblit v1.9.3