From 36b909e117c3ccc22dd266a94479e2a02335d261 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 26 三月 2026 18:03:34 +0800
Subject: [PATCH] 军泰伟业 1.生产订单新增编辑逻辑重写

---
 src/views/productionManagement/processRoute/processRouteItem/index.vue |  235 +++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 148 insertions(+), 87 deletions(-)

diff --git a/src/views/productionManagement/processRoute/processRouteItem/index.vue b/src/views/productionManagement/processRoute/processRouteItem/index.vue
index 3aecfa0..f1d46fc 100644
--- a/src/views/productionManagement/processRoute/processRouteItem/index.vue
+++ b/src/views/productionManagement/processRoute/processRouteItem/index.vue
@@ -21,12 +21,20 @@
             <span class="info-value">{{ routeInfo.productName || '-' }}</span>
           </div>
         </div>
+				<div class="info-item">
+					<div class="info-label-wrapper">
+						<span class="info-label">鍥剧焊缂栧彿</span>
+					</div>
+					<div class="info-value-wrapper">
+						<span class="info-value">{{ routeInfo.model || '-' }}</span>
+					</div>
+				</div>
         <div class="info-item">
           <div class="info-label-wrapper">
-            <span class="info-label">瑙勬牸鍚嶇О</span>
+            <span class="info-label">瑙勬牸鍨嬪彿</span>
           </div>
           <div class="info-value-wrapper">
-            <span class="info-value">{{ routeInfo.model || '-' }}</span>
+            <span class="info-value">{{ routeInfo.drawingNumber || '-' }}</span>
           </div>
         </div>
         <div class="info-item">
@@ -55,11 +63,9 @@
         <el-button 
             icon="Grid" 
             @click="toggleView"
-            style="margin-right: 10px;"
         >
           鍗$墖瑙嗗浘
         </el-button>
-        <el-button type="primary" @click="handleAdd">鏂板</el-button>
       </div>
     </div>
     <el-table
@@ -79,12 +85,14 @@
           {{ getProcessName(scope.row.processId) || '-' }}
         </template>
       </el-table-column>
-      <el-table-column label="浜у搧鍚嶇О" prop="productName" min-width="160" />
-      <el-table-column label="瑙勬牸鍚嶇О" prop="model" min-width="140" />
-      <el-table-column label="鍗曚綅" prop="unit" width="100" />
       <el-table-column label="鏄惁璐ㄦ" prop="isQuality" width="100">
         <template #default="scope">
           {{scope.row.isQuality ? "鏄�" : "鍚�"}}
+        </template>
+      </el-table-column>
+      <el-table-column label="鎶ュ伐鏉冮檺" prop="userPower" min-width="200">
+        <template #default="scope">
+          {{ scope.row.userPower || '-' }}
         </template>
       </el-table-column>
       <el-table-column label="鎿嶄綔" align="center" fixed="right" width="150">
@@ -103,11 +111,9 @@
           <el-button 
               icon="Menu" 
               @click="toggleView"
-              style="margin-right: 10px;"
           >
             琛ㄦ牸瑙嗗浘
           </el-button>
-          <el-button type="primary" @click="handleAdd">鏂板</el-button>
         </div>
       </div>
       <div v-loading="tableLoading" class="card-container">
@@ -127,17 +133,8 @@
             <div class="card-process-name">{{ getProcessName(item.processId) || '-' }}</div>
           </div>
           
-          <!-- 浜у搧淇℃伅 -->
           <div class="card-content">
-            <div v-if="item.productName" class="product-info">
-              <div class="product-name">{{ item.productName }}</div>
-              <div v-if="item.model" class="product-model">
-                {{ item.model }}
-                <!-- <span v-if="item.unit" class="product-unit">{{ item.unit }}</span> -->
-              </div>
-              <el-tag type="primary" class="product-tag" v-if="item.isQuality">璐ㄦ</el-tag>
-            </div>
-            <div v-else class="product-info empty">鏆傛棤浜у搧淇℃伅</div>
+            <el-tag type="primary" class="product-tag" v-if="item.isQuality">璐ㄦ</el-tag>
           </div>
           
           <!-- 鎿嶄綔鎸夐挳 -->
@@ -179,25 +176,23 @@
           </el-select>
         </el-form-item>
 
-        <el-form-item label="浜у搧鍚嶇О" prop="productModelId">
-          <el-button type="primary" @click="showProductSelectDialog = true">
-            {{ form.productName && form.model 
-              ? `${form.productName} - ${form.model}` 
-              : '閫夋嫨浜у搧' }}
-          </el-button>
-        </el-form-item>
-
-        <el-form-item label="鍗曚綅" prop="unit">
-          <el-input 
-              v-model="form.unit" 
-              :placeholder="form.productModelId ? '鏍规嵁閫夋嫨鐨勪骇鍝佽嚜鍔ㄥ甫鍑�' : '璇峰厛閫夋嫨浜у搧'" 
-              clearable 
-              :disabled="true" 
-          />
-        </el-form-item>
-
         <el-form-item label="鏄惁璐ㄦ" prop="isQuality">
-          <el-switch v-model="form.isQuality" :active-value="true" inactive-value="false"/>
+          <el-switch v-model="form.isQuality" :active-value="true" :inactive-value="false"/>
+        </el-form-item>
+        <el-form-item label="鎶ュ伐鏉冮檺" prop="userPower" :rules="[{ required: true, message: '璇烽�夋嫨鎶ュ伐鏉冮檺', trigger: 'change' }]">
+          <el-tree-select
+            v-model="form.userPower"
+            :data="staffList"
+            :props="treeProps"
+            placeholder="璇烽�夋嫨浜哄憳"
+            multiple
+            show-checkbox
+            collapse-tags
+            collapse-tags-tooltip
+            style="width: 100%"
+            node-key="id"
+            :render-after-expand="false"
+          />
         </el-form-item>
       </el-form>
 
@@ -207,21 +202,15 @@
       </template>
     </el-dialog>
 
-    <!-- 浜у搧閫夋嫨瀵硅瘽妗� -->
-    <ProductSelectDialog
-        v-model="showProductSelectDialog"
-        @confirm="handleProductSelect"
-        single
-    />
   </div>
 </template>
 
 <script setup>
 import { ref, computed, getCurrentInstance, onMounted, onUnmounted, nextTick } from "vue";
-import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
 import { findProcessRouteItemList, addOrUpdateProcessRouteItem, sortProcessRouteItem, batchDeleteProcessRouteItem } from "@/api/productionManagement/processRouteItem.js";
 import { findProductProcessRouteItemList, deleteRouteItem, addRouteItem, addOrUpdateProductProcessRouteItem, sortRouteItem } from "@/api/productionManagement/productProcessRoute.js";
 import { processList } from "@/api/productionManagement/productionProcess.js";
+import { listDeptUserTree } from "@/api/basicData/productProcess.js";
 import { useRoute } from 'vue-router'
 import { ElMessageBox } from 'element-plus'
 import Sortable from 'sortablejs'
@@ -245,13 +234,20 @@
 const routeInfo = ref({
   processRouteCode: '',
   productName: '',
+  drawingNumber: '',
   model: '',
   bomNo: '',
   description: ''
 });
 
 const processOptions = ref([]);
-const showProductSelectDialog = ref(false);
+const staffList = ref([]);
+
+const treeProps = {
+  label: 'label',
+  children: 'children',
+};
+
 let tableSortable = null;
 let cardSortable = null;
 
@@ -268,16 +264,12 @@
   id: undefined,
   routeId: routeId.value,
   processId: undefined,
-  productModelId: undefined,
-  productName: "",
-  model: "",
-  unit: "",
   isQuality: false,
+  userPower: [],
 });
 
 const rules = {
   processId: [{ required: true, message: '璇烽�夋嫨宸ュ簭', trigger: 'change' }],
-  productModelId: [{ required: true, message: '璇烽�夋嫨浜у搧', trigger: 'change' }],
 };
 
 // 鏍规嵁宸ュ簭ID鑾峰彇宸ュ簭鍚嶇О
@@ -299,6 +291,7 @@
     .then(res => {
       tableData.value = res.data || [];
       tableLoading.value = false;
+      routeInfo.value = tableData.value[0] || {}
       // 鍒楄〃鍔犺浇瀹屾垚鍚庡垵濮嬪寲鎷栨嫿鎺掑簭
       nextTick(() => {
         initSortable();
@@ -327,6 +320,7 @@
   routeInfo.value = {
     processRouteCode: route.query.processRouteCode || '',
     productName: route.query.productName || '',
+    drawingNumber: route.query.drawingNumber || '',
     model: route.query.model || '',
     bomNo: route.query.bomNo || '',
     description: route.query.description || ''
@@ -343,17 +337,36 @@
 // 缂栬緫
 const handleEdit = (row) => {
   operationType.value = 'edit';
+  const userPowerNames = row.userPower ? row.userPower.split(',') : [];
+  const userPowerIds = userPowerNames.map(name => {
+    const user = findUserByName(name);
+    return user ? user.id : null;
+  }).filter(id => id !== null);
+  
   form.value = {
     id: row.id,
     routeId: routeId.value,
     processId: row.processId,
-    productModelId: row.productModelId,
-    productName: row.productName || "",
-    model: row.model || "",
-    unit: row.unit || "",
     isQuality: row.isQuality,
+    userPower: userPowerIds,
   };
   dialogVisible.value = true;
+};
+
+const findUserByName = (name) => {
+  const findInTree = (nodes) => {
+    for (const node of nodes) {
+      if (node.isUser && node.label === name) {
+        return node;
+      }
+      if (node.children && node.children.length > 0) {
+        const found = findInTree(node.children);
+        if (found) return found;
+      }
+    }
+    return null;
+  };
+  return findInTree(staffList.value);
 };
 
 // 鍒犻櫎
@@ -382,25 +395,13 @@
     .catch(() => {});
 };
 
-// 浜у搧閫夋嫨
-const handleProductSelect = (products) => {
-  if (products && products.length > 0) {
-    const product = products[0];
-    form.value.productModelId = product.id;
-    form.value.productName = product.productName;
-    form.value.model = product.model;
-    form.value.unit = product.unit || "";
-    showProductSelectDialog.value = false;
-    // 瑙﹀彂琛ㄥ崟楠岃瘉
-    formRef.value?.validateField('productModelId');
-  }
-};
-
 // 鎻愪氦
 const handleSubmit = () => {
   formRef.value.validate((valid) => {
     if (valid) {
       submitLoading.value = true;
+      
+      const userPowerNames = getAllUserNamesFromSelection(form.value.userPower);
       
       if (operationType.value === 'add') {
         // 鏂板锛氫紶鍗曚釜瀵硅薄锛屽寘鍚玠ragSort瀛楁
@@ -413,15 +414,15 @@
               productOrderId: orderId.value,
               productRouteId: routeId.value,
               processId: form.value.processId,
-              productModelId: form.value.productModelId,
               isQuality: form.value.isQuality,
+              userPower: userPowerNames.join(','),
               dragSort,
             })
           : addOrUpdateProcessRouteItem({
               routeId: routeId.value,
               processId: form.value.processId,
-              productModelId: form.value.productModelId,
               isQuality: form.value.isQuality,
+              userPower: userPowerNames.join(','),
               dragSort,
             });
 
@@ -445,15 +446,15 @@
           ? addOrUpdateProductProcessRouteItem({
               id: form.value.id,
               processId: form.value.processId,
-              productModelId: form.value.productModelId,
               isQuality: form.value.isQuality,
+              userPower: userPowerNames.join(','),
             })
           : addOrUpdateProcessRouteItem({
               routeId: routeId.value,
               processId: form.value.processId,
-              productModelId: form.value.productModelId,
               id: form.value.id,
               isQuality: form.value.isQuality,
+              userPower: userPowerNames.join(','),
             });
 
         updatePromise
@@ -479,10 +480,8 @@
     id: undefined,
     routeId: routeId.value,
     processId: undefined,
-    productModelId: undefined,
-    productName: "",
-    model: "",
-    unit: "",
+    isQuality: false,
+    userPower: [],
   };
   formRef.value?.resetFields();
 };
@@ -627,7 +626,69 @@
   getRouteInfo();
   getList();
   getProcessList();
+  getStaffList();
 });
+
+const getStaffList = () => {
+  listDeptUserTree().then(res => {
+    const buildTree = (nodes) => {
+      return nodes.map(node => {
+        const deptNode = {
+          id: `dept_${node.deptId}`,
+          label: node.deptName,
+          isUser: false,
+          children: []
+        };
+        
+        if (node.userList && node.userList.length > 0) {
+          node.userList.forEach(user => {
+            deptNode.children.push({
+              id: user.userId,
+              label: user.nickName || user.userName,
+              isUser: true,
+              userName: user.userName,
+              nickName: user.nickName
+            });
+          });
+        }
+        
+        if (node.childrenList && node.childrenList.length > 0) {
+          const childNodes = buildTree(node.childrenList);
+          deptNode.children = deptNode.children.concat(childNodes);
+        }
+        
+        return deptNode;
+      });
+    };
+    staffList.value = buildTree(res.data || []);
+  }).catch(() => {
+    staffList.value = [];
+  });
+};
+
+const getAllUserNamesFromSelection = (selectedIds) => {
+  const names = [];
+  const processNode = (node) => {
+    if (selectedIds.includes(node.id)) {
+      if (node.isUser) {
+        names.push(node.label);
+      } else {
+        if (node.children && node.children.length > 0) {
+          node.children.forEach(child => {
+            if (child.isUser) {
+              names.push(child.label);
+            }
+          });
+        }
+      }
+    }
+    if (node.children && node.children.length > 0) {
+      node.children.forEach(child => processNode(child));
+    }
+  };
+  staffList.value.forEach(node => processNode(node));
+  return [...new Set(names)];
+};
 
 onUnmounted(() => {
   destroySortable();
@@ -667,20 +728,20 @@
 
 .process-card {
   flex-shrink: 0;
-  width: 220px;
+  width: 160px;
   background: #fff;
+  border: 1px solid #e4e7ed;
   border-radius: 8px;
-  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
   padding: 16px;
   display: flex;
   flex-direction: column;
   cursor: move;
-  transition: all 0.3s;
+  transition: all 0.2s;
 }
 
 .process-card:hover {
-  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
-  transform: translateY(-2px);
+  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
 }
 
 .card-header {
@@ -689,20 +750,20 @@
 }
 
 .card-number {
-  width: 36px;
-  height: 36px;
-  line-height: 36px;
+  width: 28px;
+  height: 28px;
+  line-height: 28px;
   border-radius: 50%;
   background: #409eff;
   color: #fff;
   font-weight: bold;
-  font-size: 16px;
+  font-size: 13px;
   margin: 0 auto 8px;
 }
 
 .card-process-name {
   font-size: 14px;
-  color: #333;
+  color: #303133;
   font-weight: 500;
   word-break: break-all;
 }
@@ -710,7 +771,7 @@
 .card-content {
   flex: 1;
   margin-bottom: 12px;
-  min-height: 60px;
+  min-height: 40px;
   display: flex;
   align-items: center;
   justify-content: center;

--
Gitblit v1.9.3