From 46d5fc2f692b19538f2f7224f04096faececd38b Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 26 三月 2026 14:13:36 +0800
Subject: [PATCH] 军泰伟业 1.生产订单新增时展示工序和物料清单并可以修改

---
 src/views/productionManagement/productionOrder/New.vue    |  189 +++++++++++++++++++++++--------------
 src/views/productionManagement/productionOrder/index.vue  |   42 --------
 src/views/productionManagement/productionProcess/Edit.vue |   43 +++++++-
 3 files changed, 155 insertions(+), 119 deletions(-)

diff --git a/src/views/productionManagement/productionOrder/New.vue b/src/views/productionManagement/productionOrder/New.vue
index 395e2c8..329473a 100644
--- a/src/views/productionManagement/productionOrder/New.vue
+++ b/src/views/productionManagement/productionOrder/New.vue
@@ -40,18 +40,6 @@
               </el-form-item>
             </el-col>
             <el-col :span="12">
-              <el-form-item label="閿�鍞悎鍚屽彿" prop="salesContractNo">
-                <el-input v-model="formState.salesContractNo" placeholder="璇疯緭鍏ラ攢鍞悎鍚屽彿" />
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="20">
-            <el-col :span="12">
-              <el-form-item label="瀹㈡埛鍚嶇О" prop="customerName">
-                <el-input v-model="formState.customerName" placeholder="璇疯緭鍏ュ鎴峰悕绉�" />
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
               <el-form-item label="闇�姹傛暟閲�" prop="quantity">
                 <el-input-number v-model="formState.quantity" :step="1" :min="1" style="width: 100%" />
               </el-form-item>
@@ -116,7 +104,7 @@
           </el-button>
         </div>
         <div class="table-container">
-          <el-table :data="productionTaskList" border size="small" class="compact-table">
+          <el-table :data="processRouteItems" border size="small" class="compact-table">
         <el-table-column type="index" label="搴忓彿" width="60" />
         <el-table-column label="宸ュ簭鍚嶇О" min-width="150">
           <template #default="{ row }">
@@ -135,25 +123,44 @@
             </el-select>
           </template>
         </el-table-column>
-        <el-table-column label="璁″垝鏁�" min-width="120">
+        <el-table-column label="鎶ュ伐鏉冮檺" min-width="180">
           <template #default="{ row }">
-            <el-input-number v-model="row.planQuantity" :min="0" style="width: 100%" />
+            <el-select 
+              v-model="row.userPower" 
+              multiple 
+              collapse-tags 
+              collapse-tags-tooltip
+              placeholder="璇烽�夋嫨鎶ュ伐鏉冮檺" 
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in userOptions"
+                :key="item.userId"
+                :label="item.nickName"
+                :value="item.nickName"
+              />
+            </el-select>
           </template>
         </el-table-column>
-        <el-table-column label="鎶ュ伐鏉冮檺" min-width="150">
+        <el-table-column label="璁″垝鏁�" min-width="100">
           <template #default="{ row }">
-            <el-input v-model="row.reportPermission" placeholder="璇疯緭鍏ユ姤宸ユ潈闄�" />
+            <el-input-number v-model="row.planNum" :min="1" size="small" style="width: 100%" />
+          </template>
+        </el-table-column>
+        <el-table-column label="鏄惁璐ㄦ" min-width="100">
+          <template #default="{ row }">
+            <el-switch v-model="row.isQuality" :active-value="true" :inactive-value="false" size="small" />
           </template>
         </el-table-column>
         <el-table-column label="璁″垝寮�濮嬫椂闂�" min-width="180">
           <template #default="{ row }">
             <el-date-picker
                 v-model="row.planStartTime"
-                type="datetime"
+                type="date"
                 placeholder="閫夋嫨寮�濮嬫椂闂�"
                 style="width: 100%"
-                format="YYYY-MM-DD HH:mm"
-                value-format="YYYY-MM-DD HH:mm:ss"
+                format="YYYY-MM-DD"
+                value-format="YYYY-MM-DD"
             />
           </template>
         </el-table-column>
@@ -161,23 +168,23 @@
           <template #default="{ row }">
             <el-date-picker
                 v-model="row.planEndTime"
-                type="datetime"
+                type="date"
                 placeholder="閫夋嫨缁撴潫鏃堕棿"
                 style="width: 100%"
-                format="YYYY-MM-DD HH:mm"
-                value-format="YYYY-MM-DD HH:mm:ss"
+                format="YYYY-MM-DD"
+                value-format="YYYY-MM-DD"
             />
           </template>
         </el-table-column>
         <el-table-column label="鎿嶄綔" width="80" fixed="right" align="center">
           <template #default="{ $index }">
-            <el-button type="danger" link size="small" @click="removeProductionTask($index)">
+            <el-button type="danger" link size="small" @click="removeProcessRouteItem($index)">
               <el-icon><Delete /></el-icon>
             </el-button>
           </template>
         </el-table-column>
       </el-table>
-      <div v-if="productionTaskList.length === 0" class="empty-tip">
+      <div v-if="processRouteItems.length === 0" class="empty-tip">
         <el-empty description="鏆傛棤鐢熶骇浠诲姟锛岀偣鍑讳笂鏂规寜閽坊鍔�" :image-size="60" />
       </div>
         </div>
@@ -193,37 +200,37 @@
           </el-button>
         </div>
         <div class="table-container">
-          <el-table :data="materialList" border size="small" class="compact-table">
+          <el-table :data="productStructureRecords" border size="small" class="compact-table">
             <el-table-column type="index" label="搴忓彿" width="50" align="center" />
-            <el-table-column label="鍥剧焊缂栧彿" min-width="140">
-              <template #default="{ row }">
-                <el-input v-model="row.drawingNumber" placeholder="璇疯緭鍏ュ浘绾哥紪鍙�" size="small" />
-              </template>
-            </el-table-column>
-            <el-table-column label="浜у搧鍚嶇О" min-width="140">
-              <template #default="{ row }">
-                <el-input v-model="row.productName" placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�" size="small" />
-              </template>
-            </el-table-column>
-            <el-table-column label="鍗曚綅鐢ㄩ噺" min-width="100">
+            <el-table-column label="鍗曚綅浜у嚭闇�瑕佹暟閲�" min-width="140">
               <template #default="{ row }">
                 <el-input-number v-model="row.unitQuantity" :min="0" :precision="2" size="small" style="width: 100%" />
               </template>
             </el-table-column>
-            <el-table-column label="搴撳瓨鏁伴噺" min-width="100">
+            <el-table-column label="闇�姹傛暟閲�" min-width="120">
               <template #default="{ row }">
-                <el-input-number v-model="row.inventoryQuantity" :min="0" size="small" style="width: 100%" />
+                <el-input-number v-model="row.demandedQuantity" :min="0" :precision="2" size="small" style="width: 100%" />
+              </template>
+            </el-table-column>
+            <el-table-column label="鍗曚綅" min-width="80">
+              <template #default="{ row }">
+                <el-input v-model="row.unit" placeholder="璇疯緭鍏�" size="small" />
+              </template>
+            </el-table-column>
+            <el-table-column label="bomId" min-width="100">
+              <template #default="{ row }">
+                <el-input-number v-model="row.bomId" :min="0" size="small" style="width: 100%" />
               </template>
             </el-table-column>
             <el-table-column label="鎿嶄綔" width="80" fixed="right" align="center">
               <template #default="{ $index }">
-                <el-button type="danger" link size="small" @click="removeMaterialItem($index)">
+                <el-button type="danger" link size="small" @click="removeProductStructureRecord($index)">
                   <el-icon><Delete /></el-icon>
                 </el-button>
               </template>
             </el-table-column>
           </el-table>
-          <div v-if="materialList.length === 0" class="empty-tip">
+          <div v-if="productStructureRecords.length === 0" class="empty-tip">
             <el-empty description="鏆傛棤鐢ㄦ枡娓呭崟锛岀偣鍑讳笂鏂规寜閽坊鍔�" :image-size="60" />
           </div>
         </div>
@@ -245,6 +252,7 @@
 import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
 import {addProductOrder, listProcessRoute} from "@/api/productionManagement/productionOrder.js";
 import {list as listProcess} from "@/api/productionManagement/productionProcess.js";
+import {listDeptUserTree} from "@/api/basicData/productProcess.js";
 
 const props = defineProps({
   visible: {
@@ -271,19 +279,20 @@
   unit: "",
   drawingNumber: "",
   quantity: 0,
-  salesContractNo: "",
-  customerName: "",
   deliveryDate: "",
 });
 
-// 鐢熶骇浠诲姟鍒楄〃
-const productionTaskList = ref([]);
-
-// 鐢ㄦ枡娓呭崟鍒楄〃
-const materialList = ref([]);
+// 宸ュ簭璺嚎鏄庣粏鍒楄〃
+ const processRouteItems = ref([]);
+ 
+ // 鐗╂枡娓呭崟鍒楄〃
+ const productStructureRecords = ref([]);
 
 // 宸ュ簭鍒楄〃
 const processOptions = ref([]);
+
+// 鐢ㄦ埛鍒楄〃
+const userOptions = ref([]);
 
 // 鏂囦欢鍒楄〃
 const fileList = ref([]);
@@ -307,8 +316,33 @@
   });
 };
 
-// 缁勪欢鎸傝浇鏃惰幏鍙栧伐搴忓垪琛�
+// 鑾峰彇鐢ㄦ埛鍒楄〃
+const fetchUserOptions = () => {
+  listDeptUserTree().then(res => {
+    const users = [];
+    const extractUsers = (nodes) => {
+      nodes.forEach(node => {
+        if (node.userList && node.userList.length > 0) {
+          node.userList.forEach(user => {
+            users.push({
+              userId: user.userId,
+              nickName: user.nickName || user.userName
+            });
+          });
+        }
+        if (node.childrenList && node.childrenList.length > 0) {
+          extractUsers(node.childrenList);
+        }
+      });
+    };
+    extractUsers(res.data || []);
+    userOptions.value = users;
+  });
+};
+
+// 缁勪欢鎸傝浇鏃惰幏鍙栨暟鎹�
 fetchProcessOptions();
+fetchUserOptions();
 
 let { proxy } = getCurrentInstance()
 
@@ -323,13 +357,11 @@
     productModelName: "",
     unit: "",
     quantity: 0,
-    salesContractNo: "",
-    customerName: "",
     deliveryDate: "",
   };
-  // 閲嶇疆鐢熶骇浠诲姟鍜岀敤鏂欐竻鍗�
-  productionTaskList.value = [];
-  materialList.value = [];
+  // 閲嶇疆宸ュ簭璺嚎鏄庣粏鍜岀墿鏂欐竻鍗�
+  processRouteItems.value = [];
+  productStructureRecords.value = [];
   fileList.value = [];
   isShow.value = false;
 };
@@ -370,25 +402,34 @@
   if (selectedProcess) {
     row.processName = selectedProcess.name;
     row.processNo = selectedProcess.no;
+    row.isQuality = selectedProcess.isQuality || false;
+    // userPower鏄�楀彿鍒嗛殧鐨勭敤鎴峰悕锛岃浆鎹负鏁扮粍
+    if (selectedProcess.userPower) {
+      row.userPower = selectedProcess.userPower.split(',');
+    } else {
+      row.userPower = [];
+    }
   }
 };
 
 // 娣诲姞鐢熶骇浠诲姟
 const addProductionTask = () => {
-  productionTaskList.value.push({
+  processRouteItems.value.push({
     processId: undefined,
     processName: "",
     processNo: "",
-    planQuantity: 1,
-    reportPermission: "",
+    productModelId: undefined,
+    userPower: [],
     planStartTime: "",
     planEndTime: "",
+    planNum: 1,
+    isQuality: false,
   });
 };
 
-// 鍒犻櫎鐢熶骇浠诲姟
-const removeProductionTask = (index) => {
-  productionTaskList.value.splice(index, 1);
+// 鍒犻櫎宸ュ簭璺嚎鏄庣粏
+const removeProcessRouteItem = (index) => {
+  processRouteItems.value.splice(index, 1);
 };
 
 // 娣诲姞鐢ㄦ枡 - 寮瑰嚭浜у搧閫夋嫨妗�
@@ -400,22 +441,24 @@
 const handleMaterialProductSelect = (products) => {
   if (products && products.length > 0) {
     products.forEach(product => {
-      materialList.value.push({
+      productStructureRecords.value.push({
         productModelId: product.id,
-        drawingNumber: product.model,
-        productName: product.productName,
-        unit: product.unit,
+        parentId: undefined,
+        productOrderId: undefined,
+        processId: undefined,
         unitQuantity: 1,
-        inventoryQuantity: 0,
+        demandedQuantity: 1,
+        unit: product.unit,
+        bomId: undefined,
       });
     });
   }
   showMaterialProductDialog.value = false;
 };
 
-// 鍒犻櫎鐢ㄦ枡
-const removeMaterialItem = (index) => {
-  materialList.value.splice(index, 1);
+// 鍒犻櫎鐗╂枡娓呭崟
+const removeProductStructureRecord = (index) => {
+  productStructureRecords.value.splice(index, 1);
 };
 
 // 鏂囦欢涓婁紶鍙樻洿
@@ -436,11 +479,17 @@
         return;
       }
 
+      // 澶勭悊鎻愪氦鏁版嵁 - 灏唘serPower鏁扮粍杞崲涓洪�楀彿鍒嗛殧鐨勫瓧绗︿覆
+      const processedProcessRouteItems = processRouteItems.value.map(item => ({
+        ...item,
+        userPower: Array.isArray(item.userPower) ? item.userPower.join(',') : item.userPower
+      }));
+
       // 缁勮鎻愪氦鏁版嵁
       const submitData = {
         ...formState.value,
-        productionTasks: productionTaskList.value,
-        materials: materialList.value,
+        processRouteItems: processedProcessRouteItems,
+        productStructureRecords: productStructureRecords.value,
         files: fileList.value,
       };
 
diff --git a/src/views/productionManagement/productionOrder/index.vue b/src/views/productionManagement/productionOrder/index.vue
index f5823cf..a376df1 100644
--- a/src/views/productionManagement/productionOrder/index.vue
+++ b/src/views/productionManagement/productionOrder/index.vue
@@ -3,32 +3,8 @@
     <div class="search_form">
       <el-form :model="searchForm"
                :inline="true">
-        <el-form-item label="瀹㈡埛鍚嶇О:">
-          <el-input v-model="searchForm.customerName"
-                    placeholder="璇疯緭鍏�"
-                    clearable
-                    prefix-icon="Search"
-                    style="width: 160px;"
-                    @change="handleQuery" />
-        </el-form-item>
-        <el-form-item label="鍚堝悓鍙�:">
-          <el-input v-model="searchForm.salesContractNo"
-                    placeholder="璇疯緭鍏�"
-                    clearable
-                    prefix-icon="Search"
-                    style="width: 160px;"
-                    @change="handleQuery" />
-        </el-form-item>
         <el-form-item label="浜у搧鍚嶇О:">
           <el-input v-model="searchForm.productCategory"
-                    placeholder="璇疯緭鍏�"
-                    clearable
-                    prefix-icon="Search"
-                    style="width: 160px;"
-                    @change="handleQuery" />
-        </el-form-item>
-        <el-form-item label="瑙勬牸:">
-          <el-input v-model="searchForm.specificationModel"
                     placeholder="璇疯緭鍏�"
                     clearable
                     prefix-icon="Search"
@@ -126,16 +102,6 @@
       width: '120px',
     },
     {
-      label: "閿�鍞悎鍚屽彿",
-      prop: "salesContractNo",
-      width: '150px',
-    },
-    {
-      label: "瀹㈡埛鍚嶇О",
-      prop: "customerName",
-      width: '200px',
-    },
-    {
       label: "浜у搧鍚嶇О",
       prop: "productCategory",
       width: '120px',
@@ -144,11 +110,6 @@
       label: "鍥剧焊缂栧彿",
       prop: "specificationModel",
       width: '160px',
-    },
-    {
-      label: "瑙勬牸鍨嬪彿",
-      prop: "drawingNumber",
-      width: '120px',
     },
     {
       label: "宸ヨ壓璺嚎缂栧彿",
@@ -235,11 +196,8 @@
 
   const data = reactive({
     searchForm: {
-      customerName: "",
-      salesContractNo: "",
       projectName: "",
       productCategory: "",
-      specificationModel: "",
     },
   });
   const { searchForm } = toRefs(data);
diff --git a/src/views/productionManagement/productionProcess/Edit.vue b/src/views/productionManagement/productionProcess/Edit.vue
index 0920e4f..4434fa2 100644
--- a/src/views/productionManagement/productionProcess/Edit.vue
+++ b/src/views/productionManagement/productionProcess/Edit.vue
@@ -109,12 +109,6 @@
 // 鐩戝惉 record 鍙樺寲锛屾洿鏂拌〃鍗曟暟鎹�
 watch(() => props.record, (newRecord) => {
   if (newRecord && isShow.value) {
-    const userPowerNames = newRecord.userPower ? newRecord.userPower.split(',') : [];
-    const userPowerIds = userPowerNames.map(name => {
-      const user = findUserByName(name);
-      return user ? user.id : null;
-    }).filter(id => id !== null);
-    
     formState.value = {
       id: newRecord.id,
       name: newRecord.name || '',
@@ -122,11 +116,46 @@
       remark: newRecord.remark || '',
       salaryQuota: newRecord.salaryQuota || '',
       isQuality: newRecord.isQuality,
-      userPower: userPowerIds,
+      userPower: [],
     };
+    
+    // 绛夊緟 staffList 鍔犺浇瀹屾垚鍚庯紝鍐嶆煡鎵剧敤鎴稩D
+    if (staffList.value.length > 0) {
+      setUserPowerIds(newRecord.userPower);
+    } else {
+      // staffList 杩樻病鍔犺浇锛岀瓑寰呬竴涓嬪啀鏌ユ壘
+      const checkStaffList = () => {
+        if (staffList.value.length > 0) {
+          setUserPowerIds(newRecord.userPower);
+        } else {
+          setTimeout(checkStaffList, 100);
+        }
+      };
+      checkStaffList();
+    }
   }
 }, { immediate: true, deep: true });
 
+// 鏍规嵁鐢ㄦ埛鍚嶆煡鎵剧敤鎴稩D
+const setUserPowerIds = (userPowerStr) => {
+  const userPowerNames = userPowerStr ? userPowerStr.split(',') : [];
+  const userPowerIds = [];
+  const findUserIds = (nodes, targetName) => {
+    nodes.forEach(node => {
+      if (node.isUser && node.label === targetName) {
+        userPowerIds.push(node.id);
+      }
+      if (node.children && node.children.length > 0) {
+        findUserIds(node.children, targetName);
+      }
+    });
+  };
+  userPowerNames.forEach(name => {
+    findUserIds(staffList.value, name);
+  });
+  formState.value.userPower = userPowerIds;
+};
+
 let { proxy } = getCurrentInstance()
 
 const closeModal = () => {

--
Gitblit v1.9.3