From 8682d24dfc6a962f5dc8566857e8760bac838cc9 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 15 一月 2026 13:34:02 +0800
Subject: [PATCH] fix: 完成工艺路线变更

---
 src/views/productionManagement/processRoute/processRouteItem/index.vue |  147 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 105 insertions(+), 42 deletions(-)

diff --git a/src/views/productionManagement/processRoute/processRouteItem/index.vue b/src/views/productionManagement/processRoute/processRouteItem/index.vue
index fa6fbad..bbce4ef 100644
--- a/src/views/productionManagement/processRoute/processRouteItem/index.vue
+++ b/src/views/productionManagement/processRoute/processRouteItem/index.vue
@@ -4,9 +4,9 @@
       <template #right-button>
         <el-button
             type="primary"
-            @click="isShowProductSelectDialog = true"
+            @click="isShowProcessSelectDialog = true"
         >
-          閫夋嫨浜у搧
+          閫夋嫨宸ュ簭
         </el-button>
         <el-button type="primary" @click="handleSubmit">纭</el-button>
         <el-switch
@@ -59,18 +59,7 @@
 
         <template #default="scope" v-else>
           <template v-if="item.prop === 'processId'">
-            <el-select
-                v-model="scope.row[item.prop]"
-                style="width: 100%;"
-                @mousedown.stop
-            >
-              <el-option
-                  v-for="process in processOptions"
-                  :key="process.id"
-                  :label="process.name"
-                  :value="process.id"
-              />
-            </el-select>
+            {{ getProcessName(scope.row.processId) || '-' }}
           </template>
           <template v-else>
             {{ scope.row[item.prop] || '-' }}
@@ -106,6 +95,7 @@
                   v-model="item.processId"
                   style="width: 100%;"
                   @mousedown.stop
+                  :disabled="true"
               >
                 <el-option
                     v-for="process in processOptions"
@@ -114,6 +104,14 @@
                     :value="process.id"
                 />
               </el-select>
+              <el-button
+                  type="primary"
+                  size="small"
+                  style="margin-top: 8px; width: 100%;"
+                  @click.stop="handleSelectProductForRow(item)"
+              >
+                閫夋嫨浜у搧
+              </el-button>
             </div>
             <template #footer>
               <div class="step-card-footer">
@@ -125,9 +123,38 @@
       </div>
     </div>
 
+    <!-- 宸ュ簭閫夋嫨瀵硅瘽妗� -->
+    <el-dialog
+        v-model="isShowProcessSelectDialog"
+        title="閫夋嫨宸ュ簭"
+        width="400px"
+    >
+      <el-select
+          v-model="selectedProcessId"
+          placeholder="璇烽�夋嫨宸ュ簭锛堝彲澶氶�夛級"
+          style="width: 100%"
+          multiple
+          collapse-tags
+          collapse-tags-tooltip
+      >
+        <el-option
+            v-for="process in processOptions"
+            :key="process.id"
+            :label="process.name"
+            :value="process.id"
+        />
+      </el-select>
+      <template #footer>
+        <el-button @click="isShowProcessSelectDialog = false">鍙栨秷</el-button>
+        <el-button type="primary" @click="handleSelectProcess">纭畾</el-button>
+      </template>
+    </el-dialog>
+
+    <!-- 浜у搧閫夋嫨瀵硅瘽妗� -->
     <ProductSelectDialog
         v-model="isShowProductSelectDialog"
-        @confirm="handelSelectProducts"
+        @confirm="handleSelectProductForCurrentRow"
+        single
     />
   </div>
 </template>
@@ -143,6 +170,9 @@
 const processOptions = ref([]);
 const tableLoading = ref(false);
 const isShowProductSelectDialog = ref(false);
+const isShowProcessSelectDialog = ref(false);
+const selectedProcessId = ref([]);
+const currentSelectRow = ref(null);
 const routeItems = ref([]);
 let tableSortable = null;
 let stepsSortable = null;
@@ -164,17 +194,26 @@
 
 
 const tableColumn = ref([
+{ label: "宸ュ簭鍚嶇О", prop: "processId", width: 200 },
   { label: "浜у搧鍚嶇О", prop: "productName"},
   { label: "瑙勬牸鍚嶇О", prop: "model" },
   { label: "鍗曚綅", prop: "unit" },
-  { label: "宸ュ簭鍚嶇О", prop: "processId", width: 200 },
   {
     dataType: "action",
     label: "鎿嶄綔",
     align: "center",
     fixed: "right",
-    width: 100,
+    width: 180,
     operation: [
+      {
+        name: "閫夋嫨浜у搧",
+        type: "primary",
+        link: true,
+        clickFun: (row) => {
+          currentSelectRow.value = row;
+          isShowProductSelectDialog.value = true;
+        }
+      },
       {
         name: "鍒犻櫎",
         type: "danger",
@@ -190,6 +229,13 @@
   }
 ]);
 
+// 鏍规嵁宸ュ簭ID鑾峰彇宸ュ簭鍚嶇О
+const getProcessName = (processId) => {
+  if (!processId) return '';
+  const process = processOptions.value.find(p => p.id === processId);
+  return process ? process.name : '';
+};
+
 const removeItem = (index) => {
   routeItems.value.splice(index, 1);
   nextTick(() => initSortable());
@@ -203,36 +249,53 @@
   }
 };
 
-const handelSelectProducts = (products) => {
-  destroySortable();
-
-  const newData = products.map(({ id, ...product }) => ({
-    ...product,
-    productModelId: id,
+// 閫夋嫨宸ュ簭 - 鏂板澶氭潯璁板綍
+const handleSelectProcess = () => {
+  if (!selectedProcessId.value || selectedProcessId.value.length === 0) {
+    proxy?.$modal?.msgWarning("璇烽�夋嫨宸ュ簭");
+    return;
+  }
+  
+  // 涓烘瘡涓�変腑鐨勫伐搴忓垱寤轰竴鏉¤褰�
+  const newItems = selectedProcessId.value.map(processId => ({
+    processId: processId,
+    productName: "",
+    model: "",
+    unit: "",
+    productModelId: undefined,
     routeId: routeId.value,
-    id: `${Date.now()}-${Math.random().toString(36).slice(2)}`,
-    processId: undefined
+    id: `${Date.now()}-${Math.random().toString(36).slice(2)}-${processId}`,
   }));
-
-  console.log('閫夋嫨浜у搧鍓嶆暟缁�:', routeItems.value);
-  routeItems.value.push(...newData);
-  routeItems.value = [...routeItems.value];
-  console.log('閫夋嫨浜у搧鍚庢暟缁�:', routeItems.value);
-
+  
+  routeItems.value.push(...newItems);
+  
   // 寤惰繜鍒濆鍖栵紝纭繚DOM瀹屽叏娓叉煋
   nextTick(() => {
-    // 寮哄埗閲嶆柊娓叉煋缁勪欢
-    if (proxy?.$forceUpdate) {
-      proxy.$forceUpdate();
-    }
-
-    const temp = [...routeItems.value];
-    routeItems.value = [];
-    nextTick(() => {
-      routeItems.value = temp;
-      initSortable();
-    });
+    initSortable();
   });
+  
+  isShowProcessSelectDialog.value = false;
+  selectedProcessId.value = [];
+};
+
+// 涓烘寚瀹氳閫夋嫨浜у搧
+const handleSelectProductForRow = (row) => {
+  currentSelectRow.value = row;
+  isShowProductSelectDialog.value = true;
+};
+
+// 澶勭悊褰撳墠琛岀殑浜у搧閫夋嫨
+const handleSelectProductForCurrentRow = (products) => {
+  if (products && products.length > 0 && currentSelectRow.value) {
+    const product = products[0];
+    // 鏇存柊褰撳墠琛岀殑浜у搧淇℃伅
+    currentSelectRow.value.productName = product.productName;
+    currentSelectRow.value.model = product.model;
+    currentSelectRow.value.unit = product.unit || "";
+    currentSelectRow.value.productModelId = product.id;
+    isShowProductSelectDialog.value = false;
+    currentSelectRow.value = null;
+  }
 };
 
 const findProcessRouteItems = () => {

--
Gitblit v1.9.3