From 5470429a79313630a7ddef601de1d89e7dada754 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期五, 22 五月 2026 09:14:12 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_NEW_pro' into dev-new_pro_OA

---
 src/views/productionManagement/productStructure/Detail/index.vue |   70 +++++++++++++++++++++++++++++++++-
 1 files changed, 67 insertions(+), 3 deletions(-)

diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index a7f6b6b..5cb08e8 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -316,9 +316,36 @@
     });
   };
 
+  const findSiblings = (items: any[], tempId: string): any[] | null => {
+    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 handleProcessChange = (row: any, value: any) => {
     row.processId = value || "";
     syncProcessOperationFields(row);
+    
+    // 妫�鏌ュ悓涓�灞傜骇鏄惁宸茬粡鏈夊叾浠栦笉鍚岀殑宸ュ簭琚�変腑
+    const siblings = findSiblings(dataValue.dataList, row.tempId);
+    if (siblings && value) {
+      const hasDifferentProcess = siblings.some(sibling => {
+        return sibling.tempId !== row.tempId && sibling.processId && sibling.processId !== value;
+      });
+      if (hasDifferentProcess) {
+        ElMessage.warning("鍚屼竴灞傜骇宸插瓨鍦ㄤ笉鍚岀殑宸ュ簭锛岃鍏堢粺涓�宸ュ簭鍚庡啀杩涜淇敼");
+      }
+    }
   };
 
   const handleUnitQuantityChange = () => {
@@ -431,8 +458,41 @@
   const validateAll = () => {
     let isValid = true;
 
+    // 鏍¢獙涓�缁勫厔寮熻妭鐐圭殑宸ュ簭鏄惁閮界浉鍚�
+    const checkProcessUniqueness = (items: any[]) => {
+      if (!items || items.length === 0 || !isValid) return;
+
+      // 鑾峰彇绗竴涓潪绌虹殑宸ュ簭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(
+              `褰撳墠灞傜骇涓嬪伐搴忎笉涓�鑷达紝璇蜂娇鐢ㄧ浉鍚岀殑宸ュ簭銆傚瓨鍦ㄣ��${processName1}銆嶅拰銆�${processName2}銆峘
+            );
+            isValid = false;
+            return;
+          }
+        }
+      }
+
+      // 閫掑綊鏍¢獙瀛愮骇鐨勫厔寮熻妭鐐�
+      for (const item of items) {
+        if (item.children && item.children.length > 0) {
+          checkProcessUniqueness(item.children);
+        }
+      }
+    };
+
     // 鏍¢獙鍑芥暟
     const validateItem = (item: any, isTopLevel = false) => {
+      if (!isValid) return;
       // 鏍¢獙褰撳墠椤圭殑蹇呭~瀛楁
       if (!item.model) {
         ElMessage.error("璇烽�夋嫨瑙勬牸");
@@ -460,7 +520,7 @@
       //   return;
       // }
 
-      // 閫掑綊鏍¢獙瀛愰」
+      // 閫掑綊鏍¢獙瀛愰」瀛楁
       if (item.children && item.children.length > 0) {
         item.children.forEach(child => {
           validateItem(child, false);
@@ -468,7 +528,11 @@
       }
     };
 
-    // 閬嶅巻鎵�鏈夐《灞傞」
+    // 1. 棣栧厛鏍¢獙鍚屼竴鐖剁骇涓嬬殑鍚屽眰娑堣�楀伐搴忔槸鍚﹀敮涓�
+    checkProcessUniqueness(dataValue.dataList);
+    if (!isValid) return false;
+
+    // 2. 鐒跺悗閬嶅巻鏍¢獙鎵�鏈夐《灞傞」鐨勫瓧娈靛繀濉儏鍐�
     dataValue.dataList.forEach(item => {
       validateItem(item, true);
     });
@@ -632,4 +696,4 @@
     await fetchProcessOptions();
     await fetchData();
   });
-</script>
+</script>
\ No newline at end of file

--
Gitblit v1.9.3