From 6b35989783d91899169f89e21a7d3734d8cadc1d Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 04 一月 2026 15:19:54 +0800
Subject: [PATCH] 1.海川开心

---
 src/views/qualityManagement/finalInspection/components/formDia.vue |   98 ++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 77 insertions(+), 21 deletions(-)

diff --git a/src/views/qualityManagement/finalInspection/components/formDia.vue b/src/views/qualityManagement/finalInspection/components/formDia.vue
index 2ab020d..3285750 100644
--- a/src/views/qualityManagement/finalInspection/components/formDia.vue
+++ b/src/views/qualityManagement/finalInspection/components/formDia.vue
@@ -4,6 +4,7 @@
         v-model="dialogFormVisible"
         :title="operationType === 'add' ? '鏂板鍑哄巶妫�楠�' : '缂栬緫鍑哄巶妫�楠�'"
         width="70%"
+				draggable
         @close="closeDia"
     >
       <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
@@ -31,7 +32,10 @@
         <el-row :gutter="30">
           <el-col :span="12">
             <el-form-item label="鍗曚綅锛�" prop="unit">
-              <el-input v-model="form.unit" placeholder="璇疯緭鍏�" clearable/>
+              <el-select v-model="form.unit" placeholder="璇烽�夋嫨" clearable style="width: 100%">
+                <el-option label="绠�" value="绠�" />
+                <el-option label="鎻�" value="鎻�" />
+              </el-select>
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -99,7 +103,7 @@
 </template>
 
 <script setup>
-import {ref, computed} from "vue";
+import {ref, computed, reactive, toRefs, getCurrentInstance} from "vue";
 import dayjs from "dayjs";
 import useUserStore from "@/store/modules/user.js";
 import {getOptions} from "@/api/procurementManagement/procurementLedger.js";
@@ -184,22 +188,26 @@
 	let userLists = await userListNoPage();
 	userList.value = userLists.data;
 	form.value = {}
-  getProductOptions();
   if (operationType.value === 'edit') {
     form.value = {...row}
-		currentProductId.value = row.productId || 0
-		// 鍔犺浇褰撳墠浜у搧涓嬬殑瑙勬牸鍒楄〃锛屽苟鏍规嵁鍚庣杩斿洖鐨� model 鍙嶆煡骞惰缃� modelId锛屽疄鐜拌鏍间笅鎷夋鍙嶆樉
-		if (currentProductId.value) {
-			modelList({ id: currentProductId.value }).then((res) => {
-				modelOptions.value = res;
-				const target = res.find((item) => item.model === row.model);
-				if (target) {
-					form.value.modelId = target.id;
-				}
-			});
-		}
-		getQualityInspectParamList(row.id)
+    currentProductId.value = row.productId || 0
+    // 鍔犺浇褰撳墠浜у搧涓嬬殑瑙勬牸鍒楄〃锛屽苟鏍规嵁鍚庣杩斿洖鐨� model 鍙嶆煡骞惰缃� modelId锛屽疄鐜拌鏍间笅鎷夋鍙嶆樉
+    if (currentProductId.value) {
+      modelList({ id: currentProductId.value }).then((res) => {
+        modelOptions.value = res;
+        const target = res.find((item) => item.model === row.model);
+        if (target) {
+          form.value.modelId = target.id;
+        }
+      });
+    }
+    getQualityInspectParamList(row.id)
+  } else {
+    // 鏂板鏃惰缃粯璁ゅ��
+    form.value.unit = "绠�"; // 鍗曚綅榛樿涓虹
+    form.value.checkResult = "鍚堟牸"; // 妫�楠岀粨鏋滈粯璁や负鍚堟牸
   }
+  await getProductOptions();
 	// 榛樿妫�楠屽憳涓哄綋鍓嶇櫥褰曚汉锛屾娴嬫棩鏈熼粯璁や负褰撳ぉ锛堢┖鏃跺~鍏咃級
 	if (currentUserName.value && !form.value.checkName) {
 		form.value.checkName = currentUserName.value;
@@ -208,10 +216,52 @@
 		form.value.checkTime = getToday();
 	}
 }
-const getProductOptions = () => {
-  productTreeList({productName: '璐ㄩ噺'}).then((res) => {
-    productOptions.value = convertIdToValue(res);
-  });
+const findNodeByLabel = (nodes, label) => {
+  for (let i = 0; i < nodes.length; i++) {
+    // 鍏堝皾璇曠簿纭尮閰�
+    if (nodes[i].label === label) {
+      return nodes[i].value; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣鐨剉alue
+    }
+    // 濡傛灉绮剧‘鍖归厤澶辫触锛屽皾璇曟ā绯婂尮閰嶏紙鍖呭惈鍏抽敭璇嶏級
+    if (nodes[i].label && nodes[i].label.includes(label)) {
+      return nodes[i].value;
+    }
+    if (nodes[i].children && nodes[i].children.length > 0) {
+      const foundValue = findNodeByLabel(nodes[i].children, label);
+      if (foundValue) {
+        return foundValue; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐圭殑value
+      }
+    }
+  }
+  return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
+};
+
+const getProductOptions = async () => {
+  const res = await productTreeList({productName: '璐ㄩ噺'});
+  productOptions.value = convertIdToValue(res);
+  // 鏂板妯″紡涓嬶紝榛樿閫夋嫨"鎴愬搧妫�楠�"
+  if (operationType.value === 'add') {
+    const finishedProductId = findNodeByLabel(productOptions.value, '鎴愬搧妫�楠�');
+    if (finishedProductId) {
+      form.value.productId = finishedProductId;
+      // 鎵惧埌瀵瑰簲鐨勮妭鐐癸紝浣跨敤瀹為檯鐨� label 浣滀负 productName
+      const findNode = (nodes, value) => {
+        for (let i = 0; i < nodes.length; i++) {
+          if (nodes[i].value === value) {
+            return nodes[i];
+          }
+          if (nodes[i].children && nodes[i].children.length > 0) {
+            const found = findNode(nodes[i].children, value);
+            if (found) return found;
+          }
+        }
+        return null;
+      };
+      const node = findNode(productOptions.value, finishedProductId);
+      form.value.productName = node ? node.label : '鎴愬搧妫�楠�';
+      getModels(finishedProductId);
+    }
+  }
 };
 const getModels = (value) => {
 	currentProductId.value = value
@@ -287,12 +337,18 @@
 }
 const getList = () => {
 	qualityInspectDetailByProductId(currentProductId.value).then(res => {
-		tableData.value = res.data;
+		tableData.value = res.data.map(item => ({
+			...item,
+			testValue: item.testValue ?? 0
+		}));
 	})
 }
 const getQualityInspectParamList = (id) => {
 	qualityInspectParamInfo(id).then(res => {
-		tableData.value = res.data;
+		tableData.value = res.data.map(item => ({
+			...item,
+			testValue: item.testValue ?? 0
+		}));
 	})
 }
 // 鍏抽棴寮规

--
Gitblit v1.9.3