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 |  247 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 176 insertions(+), 71 deletions(-)

diff --git a/src/views/productionManagement/productionOrder/New.vue b/src/views/productionManagement/productionOrder/New.vue
index 07295d7..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>
@@ -100,6 +88,12 @@
           single
       />
 
+      <!-- 鐢ㄦ枡浜у搧閫夋嫨寮圭獥 -->
+      <ProductSelectDialog
+          v-model="showMaterialProductDialog"
+          @confirm="handleMaterialProductSelect"
+      />
+
       <!-- 鐢熶骇浠诲姟 -->
       <div class="section-card">
         <div class="section-header">
@@ -110,32 +104,63 @@
           </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 }">
-            <el-input v-model="row.processName" placeholder="璇疯緭鍏ュ伐搴忓悕绉�" />
+            <el-select 
+              v-model="row.processId" 
+              placeholder="璇烽�夋嫨宸ュ簭" 
+              style="width: 100%"
+              @change="(val) => handleProcessChange(val, row)"
+            >
+              <el-option
+                v-for="item in processOptions"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              />
+            </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>
@@ -143,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>
@@ -175,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>
@@ -226,6 +251,8 @@
 import { Plus, Delete, Upload } from '@element-plus/icons-vue';
 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: {
@@ -252,16 +279,20 @@
   unit: "",
   drawingNumber: "",
   quantity: 0,
-  salesContractNo: "",
-  customerName: "",
   deliveryDate: "",
 });
 
-// 鐢熶骇浠诲姟鍒楄〃
-const productionTaskList = ref([]);
+// 宸ュ簭璺嚎鏄庣粏鍒楄〃
+ const processRouteItems = ref([]);
+ 
+ // 鐗╂枡娓呭崟鍒楄〃
+ const productStructureRecords = ref([]);
 
-// 鐢ㄦ枡娓呭崟鍒楄〃
-const materialList = ref([]);
+// 宸ュ簭鍒楄〃
+const processOptions = ref([]);
+
+// 鐢ㄦ埛鍒楄〃
+const userOptions = ref([]);
 
 // 鏂囦欢鍒楄〃
 const fileList = ref([]);
@@ -276,6 +307,42 @@
 });
 
 const showProductSelectDialog = ref(false);
+const showMaterialProductDialog = ref(false);
+
+// 鑾峰彇宸ュ簭鍒楄〃
+const fetchProcessOptions = () => {
+  listProcess().then(res => {
+    processOptions.value = res.data || [];
+  });
+};
+
+// 鑾峰彇鐢ㄦ埛鍒楄〃
+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()
 
@@ -290,13 +357,11 @@
     productModelName: "",
     unit: "",
     quantity: 0,
-    salesContractNo: "",
-    customerName: "",
     deliveryDate: "",
   };
-  // 閲嶇疆鐢熶骇浠诲姟鍜岀敤鏂欐竻鍗�
-  productionTaskList.value = [];
-  materialList.value = [];
+  // 閲嶇疆宸ュ簭璺嚎鏄庣粏鍜岀墿鏂欐竻鍗�
+  processRouteItems.value = [];
+  productStructureRecords.value = [];
   fileList.value = [];
   isShow.value = false;
 };
@@ -331,35 +396,69 @@
   })
 }
 
+// 宸ュ簭閫夋嫨鍙樺寲澶勭悊
+const handleProcessChange = (processId, row) => {
+  const selectedProcess = processOptions.value.find(item => item.id === processId);
+  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: "",
-    planQuantity: 0,
-    reportPermission: "",
+    processNo: "",
+    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);
 };
 
-// 娣诲姞鐢ㄦ枡
+// 娣诲姞鐢ㄦ枡 - 寮瑰嚭浜у搧閫夋嫨妗�
 const addMaterialItem = () => {
-  materialList.value.push({
-    drawingNumber: "",
-    productName: "",
-    unitQuantity: 0,
-    inventoryQuantity: 0,
-  });
+  showMaterialProductDialog.value = true;
 };
 
-// 鍒犻櫎鐢ㄦ枡
-const removeMaterialItem = (index) => {
-  materialList.value.splice(index, 1);
+// 澶勭悊鐢ㄦ枡浜у搧閫夋嫨
+const handleMaterialProductSelect = (products) => {
+  if (products && products.length > 0) {
+    products.forEach(product => {
+      productStructureRecords.value.push({
+        productModelId: product.id,
+        parentId: undefined,
+        productOrderId: undefined,
+        processId: undefined,
+        unitQuantity: 1,
+        demandedQuantity: 1,
+        unit: product.unit,
+        bomId: undefined,
+      });
+    });
+  }
+  showMaterialProductDialog.value = false;
+};
+
+// 鍒犻櫎鐗╂枡娓呭崟
+const removeProductStructureRecord = (index) => {
+  productStructureRecords.value.splice(index, 1);
 };
 
 // 鏂囦欢涓婁紶鍙樻洿
@@ -380,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,
       };
 

--
Gitblit v1.9.3