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/productionProcess/New.vue |  126 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 122 insertions(+), 4 deletions(-)

diff --git a/src/views/productionManagement/productionProcess/New.vue b/src/views/productionManagement/productionProcess/New.vue
index a73a755..db69fbc 100644
--- a/src/views/productionManagement/productionProcess/New.vue
+++ b/src/views/productionManagement/productionProcess/New.vue
@@ -22,8 +22,29 @@
             ]">
           <el-input v-model="formState.name" />
         </el-form-item>
-        <el-form-item label="宸ヨ祫瀹氶" prop="salaryQuota">
-          <el-input v-model="formState.salaryQuota" type="number" :step="0.001" />
+        <el-form-item label="宸ュ簭缂栧彿" prop="no">
+          <el-input v-model="formState.no"  />
+        </el-form-item>
+<!--        <el-form-item label="宸ヨ祫瀹氶" prop="salaryQuota">-->
+<!--          <el-input v-model="formState.salaryQuota" type="number" :step="0.001" />-->
+<!--        </el-form-item>-->
+        <el-form-item label="鏄惁璐ㄦ" prop="isQuality">
+          <el-switch v-model="formState.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="formState.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-item label="澶囨敞" prop="remark">
           <el-input v-model="formState.remark" type="textarea" />
@@ -40,8 +61,9 @@
 </template>
 
 <script setup>
-import { ref, computed, getCurrentInstance } from "vue";
+import { ref, computed, getCurrentInstance, onMounted } from "vue";
 import {add} from "@/api/productionManagement/productionProcess.js";
+import { listDeptUserTree } from "@/api/basicData/productProcess.js";
 
 const props = defineProps({
   visible: {
@@ -57,7 +79,16 @@
   name: '',
   remark: '',
   salaryQuota:  '',
+  isQuality: false,
+  userPower: [],
 });
+
+const staffList = ref([]);
+
+const treeProps = {
+  label: 'label',
+  children: 'children',
+};
 
 const isShow = computed({
   get() {
@@ -77,7 +108,13 @@
 const handleSubmit = () => {
   proxy.$refs["formRef"].validate(valid => {
     if (valid) {
-      add(formState.value).then(res => {
+      const userPowerNames = getAllUserNamesFromSelection(formState.value.userPower);
+      
+      const submitData = {
+        ...formState.value,
+        userPower: userPowerNames.join(',')
+      };
+      add(submitData).then(res => {
         // 鍏抽棴妯℃�佹
         isShow.value = false;
         // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
@@ -88,6 +125,87 @@
   })
 };
 
+const findUserById = (userId) => {
+  const findInTree = (nodes) => {
+    for (const node of nodes) {
+      if (node.id === userId) {
+        return node;
+      }
+      if (node.children && node.children.length > 0) {
+        const found = findInTree(node.children);
+        if (found) return found;
+      }
+    }
+    return null;
+  };
+  return findInTree(staffList.value);
+};
+
+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)];
+};
+
+onMounted(() => {
+  getStaffList();
+});
+
 defineExpose({
   closeModal,
   handleSubmit,

--
Gitblit v1.9.3