From f0d123e013ce534d392e54feb706c00af7c62e9d Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期二, 19 五月 2026 15:21:53 +0800
Subject: [PATCH] bom同一层级只能选一样的工序

---
 src/views/productionManagement/productStructure/Detail/index.vue       |   51 ++++++++++++-------------
 src/views/productionManagement/processRoute/processRouteItem/index.vue |   29 ++++++++++++++
 2 files changed, 53 insertions(+), 27 deletions(-)

diff --git a/src/views/productionManagement/processRoute/processRouteItem/index.vue b/src/views/productionManagement/processRoute/processRouteItem/index.vue
index 83ee60a..92a2fa1 100644
--- a/src/views/productionManagement/processRoute/processRouteItem/index.vue
+++ b/src/views/productionManagement/processRoute/processRouteItem/index.vue
@@ -1146,9 +1146,36 @@
     });
   };
 
+  const findSiblings = (items, tempId) => {
+    if (!items || items.length === 0) return null;
+    // 妫�鏌ュ綋鍓嶅眰绾�
+    if (items.some(item => item.tempId === tempId)) {
+      return items;
+    }
+    // 閫掑綊鏌ユ壘瀛愮骇
+    for (const item of items) {
+      if (item.children && item.children.length > 0) {
+        const result = findSiblings(item.children, tempId);
+        if (result) return result;
+      }
+    }
+    return null;
+  };
+
   const handleBomProcessChange = (row, value) => {
     row.processId = value || "";
     syncProcessOperationFields(row);
+    
+    // 鍚屼竴灞傜骇鍙兘閫変竴鏍风殑宸ュ簭
+    const siblings = findSiblings(bomDataValue.value.dataList, row.tempId);
+    if (siblings && value) {
+      siblings.forEach(sibling => {
+        if (sibling.tempId !== row.tempId) {
+          sibling.processId = value;
+          syncProcessOperationFields(sibling);
+        }
+      });
+    }
   };
 
   const openBomDialog = tempId => {
@@ -1692,4 +1719,4 @@
     line-height: 1.5;
     word-break: break-all;
   }
-</style>
+</style>
\ No newline at end of file
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index 0c326cc..76c67dc 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -333,24 +333,19 @@
   };
 
   const handleProcessChange = (row: any, value: any) => {
-    if (value) {
-      const siblings = findSiblings(dataValue.dataList, row.tempId);
-      if (siblings) {
-        const isDuplicate = siblings.some(
-          s => s.tempId !== row.tempId && s.processId === value
-        );
-        if (isDuplicate) {
-          const option = getProcessOptionById(value);
-          const processName = option?.name || "璇ュ伐搴�";
-          ElMessage.warning(`鍚屼竴灞傜骇涓嬩笉鑳介�夋嫨閲嶅鐨勬秷鑰楀伐搴忥細${processName}`);
-          row.processId = "";
-          syncProcessOperationFields(row);
-          return;
-        }
-      }
-    }
     row.processId = value || "";
     syncProcessOperationFields(row);
+    
+    // 鍚屼竴灞傜骇鍙兘閫変竴鏍风殑宸ュ簭
+    const siblings = findSiblings(dataValue.dataList, row.tempId);
+    if (siblings && value) {
+      siblings.forEach(sibling => {
+        if (sibling.tempId !== row.tempId) {
+          sibling.processId = value;
+          syncProcessOperationFields(sibling);
+        }
+      });
+    }
   };
 
   const handleUnitQuantityChange = () => {
@@ -463,23 +458,27 @@
   const validateAll = () => {
     let isValid = true;
 
-    // 鏍¢獙涓�缁勫厔寮熻妭鐐圭殑宸ュ簭鏄惁鍞竴
+    // 鏍¢獙涓�缁勫厔寮熻妭鐐圭殑宸ュ簭鏄惁閮界浉鍚�
     const checkProcessUniqueness = (items: any[]) => {
       if (!items || items.length === 0 || !isValid) return;
 
-      const processIds = new Set();
-      for (const item of items) {
-        if (item.processId) {
-          if (processIds.has(item.processId)) {
-            const option = getProcessOptionById(item.processId);
-            const processName = option?.name || item.processName || "鏈煡宸ュ簭";
+      // 鑾峰彇绗竴涓潪绌虹殑宸ュ簭ID浣滀负鍙傝��
+      const firstProcessId = items.find(item => item.processId)?.processId;
+      
+      // 濡傛灉鏈夊伐搴廔D锛屾鏌ユ墍鏈夐」鏄惁閮戒娇鐢ㄧ浉鍚岀殑宸ュ簭
+      if (firstProcessId) {
+        for (const item of items) {
+          if (item.processId && item.processId !== firstProcessId) {
+            const option1 = getProcessOptionById(firstProcessId);
+            const option2 = getProcessOptionById(item.processId);
+            const processName1 = option1?.name || "鏈煡宸ュ簭";
+            const processName2 = option2?.name || "鏈煡宸ュ簭";
             ElMessage.error(
-              `浜у搧銆�${item.productName}銆嶇殑娑堣�楀伐搴忋��${processName}銆嶅湪褰撳墠灞傜骇宸插瓨鍦紝璇峰嬁閲嶅璁剧疆`
+              `褰撳墠灞傜骇涓嬪伐搴忎笉涓�鑷达紝璇蜂娇鐢ㄧ浉鍚岀殑宸ュ簭銆傚瓨鍦ㄣ��${processName1}銆嶅拰銆�${processName2}銆峘
             );
             isValid = false;
             return;
           }
-          processIds.add(item.processId);
         }
       }
 
@@ -697,4 +696,4 @@
     await fetchProcessOptions();
     await fetchData();
   });
-</script>
+</script>
\ No newline at end of file

--
Gitblit v1.9.3