Просмотр исходного кода

江南MES自检请托默认部门

695593266@qq.com 5 месяцев назад
Родитель
Сommit
378cd28d8c

+ 4 - 2
src/api/requirementListOrder/index.js

@@ -1,8 +1,10 @@
 import request from '@/utils/request';
 
 // 获取需求列表计划
-export async function getRequirementListOrder(data) {
-  const res = await request.get('/mes/mesmaterialrequirements/page', data);
+export async function getRequirementListOrder(params) {
+  const res = await request.get('/mes/mesmaterialrequirements/page', {
+    params
+  });
   if (res.data.code == 0) {
     return res.data.data;
   }

+ 48 - 0
src/components/CommomSelect/dept-select.vue

@@ -54,6 +54,54 @@
           val,
           this.$refs.treeSelect.getNodeByValue(val)
         );
+      },
+      async locateByName(name) {
+        await this.getData();
+        const res = this.findNodesByNameWithPath(this.treeData, name);
+
+        console.log(res);
+        if (!res.length) return;
+
+        const { node, path } = res[0];
+
+        this.$nextTick(() => {
+          // 设置选中
+          this.updateValue(node.id);
+          this.changeChoose(node.id);
+
+          // 展开树路径
+          const tree = this.$refs.treeSelect?.$refs?.tree;
+          if (!tree) return;
+
+          path.forEach((p) => {
+            const treeNode = tree.store.nodesMap[p.id];
+            treeNode && treeNode.expand();
+          });
+        });
+      },
+
+      findNodesByNameWithPath(tree, name) {
+        const result = [];
+
+        function dfs(list, path = []) {
+          list.forEach((node) => {
+            const currentPath = [...path, node];
+
+            if (node.name === name) {
+              result.push({
+                node,
+                path: currentPath
+              });
+            }
+
+            if (node.children?.length) {
+              dfs(node.children, currentPath);
+            }
+          });
+        }
+
+        dfs(tree);
+        return result;
       }
     }
   };

+ 34 - 68
src/views/produce/components/qualityInspection/components/selfInspectionRequest.vue

@@ -35,31 +35,18 @@
           </el-form-item>
         </el-col>
 
-        <el-col
-          :lg="8"
-          :md="12"
-          :sm="12"
-          :xl="8"
-          :xs="12"
-          v-if="clientEnvironmentId != 9"
-        >
+        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
           <el-form-item label="执行部门:" prop="beEntrustedDeptId">
             <deptSelect
+              ref="deptSelect"
               v-model="form.beEntrustedDeptId"
               @changeGroup="beEntrustedDeptIdChange"
             />
           </el-form-item>
         </el-col>
 
-        <el-col
-          :lg="8"
-          :md="12"
-          :sm="12"
-          :xl="8"
-          :xs="12"
-          v-if="clientEnvironmentId != 9"
-        >
-          <el-form-item label="执行人员:" prop="executeUserId">
+        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
+          <el-form-item label="执行人员:">
             <el-select
               style="width: 100%"
               v-model="form.executeUserId"
@@ -235,32 +222,34 @@
   import deptSelect from '@/components/CommomSelect/dept-select.vue';
   import { getTemplateById } from '@/api/produce/bom.js';
   import inspectionTemplatePop from '@/views/produce/components/bom/qualityTesting/inspectionTemplate.vue';
+
+  const initForm = () => ({
+    order: '',
+    endDate: '',
+    name: '',
+    applyDeptId: '',
+    applyDeptName: '',
+    priority: '',
+    beEntrustedDeptId: '',
+    executeUserId: '',
+    beEntrustedDeptName: '',
+    executeUserName: '',
+    id: '',
+    itemIds: [],
+    clientEnvironmentId: ''
+  });
   export default {
     components: { deptSelect, inspectionTemplatePop },
 
     data() {
       return {
-        form: {
-          order: '',
-          endDate: '',
-          name: '',
-          applyDeptId: '',
-          applyDeptName: '',
-          priority: '',
-          beEntrustedDeptId: '',
-          executeUserId: '',
-          beEntrustedDeptName: '',
-          executeUserName: '',
-          id: '',
-          itemIds: [],
-          clientEnvironmentId: ''
-        },
+        form: initForm(),
         rules: {
           name: [{ required: true, message: '请输入', trigger: 'change' }],
 
-          executeUserId: [
-            { required: true, message: '请选择', trigger: 'change' }
-          ],
+          // executeUserId: [
+          //   { required: true, message: '请选择', trigger: 'change' }
+          // ],
           beEntrustedDeptId: [
             { required: true, message: '请选择', trigger: 'change' }
           ],
@@ -284,6 +273,7 @@
             value: 2
           }
         ],
+        treeData: [],
         isAdd: false
       };
     },
@@ -348,13 +338,21 @@
     },
 
     methods: {
-      open(item) {
+      async open(item) {
         this.visible = true;
+        this.form = initForm();
         this.clientEnvironmentId =
           this.$store.state.user.info.clientEnvironmentId;
+
         this.isAdd = false;
         this.item = this.deepCopy(item);
         this.getData();
+
+        if (this.clientEnvironmentId == 9) {
+          this.$nextTick(() => {
+            this.$refs.deptSelect?.locateByName('综合管理室');
+          });
+        }
       },
 
       cancel() {
@@ -466,38 +464,6 @@
           console.log(e);
         }
       }
-
-      // submitSelf() {
-      //   this.$refs.form.validate((valid) => {
-      //     if (!valid) {
-      //       return false;
-      //     }
-
-      //     if (this.selection.length == 0) {
-      //       return this.$message.warning('请选择需要请托的质检项');
-      //     }
-
-      //     const userData = this.userList.find(
-      //       (item) => item.id == this.form.executeUserId
-      //     );
-
-      //     this.form.executeUserName = userData.name;
-      //     this.form.applyDeptId = this.$store.state.user.info.groupId;
-      //     this.form.applyDeptName = this.$store.state.user.info.groupName;
-
-      //     this.form.id = this.item.id;
-
-      //     this.form.itemIds = this.selection.map((item) => {
-      //       return item.id;
-      //     });
-
-      //     inspectionRequest(this.form).then((res) => {
-      //       this.$message.success('请托成功');
-      //       this.cancel();
-      //       this.$emit('refreshData');
-      //     });
-      //   });
-      // }
     }
   };
 </script>