From 2781142ab67deba83925da706ca26b7f8ea1a759 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 04 九月 2025 15:42:24 +0800
Subject: [PATCH] 审批用户列表改为树形

---
 src/views/flowmgr/taskassigntemp.vue |  127 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 109 insertions(+), 18 deletions(-)

diff --git a/src/views/flowmgr/taskassigntemp.vue b/src/views/flowmgr/taskassigntemp.vue
index 0cce90c..e0d0c5c 100644
--- a/src/views/flowmgr/taskassigntemp.vue
+++ b/src/views/flowmgr/taskassigntemp.vue
@@ -8,7 +8,14 @@
 -->
 <template>
   <basic-container>
-    <avue-form ref="form" :option="attachOption" v-model="attachForm" @submit="formSubmit"></avue-form>
+    <avue-form ref="form" :option="attachOption" v-model="attachForm" @submit="formSubmit">
+      <template #machineCode="{}">
+        <el-tree-select ref="tree" filterable  v-model="attachForm.machineCode"
+         node-key="machineCode"
+          :data="treeData" :props="defaultProps">
+          </el-tree-select>
+      </template>
+    </avue-form>
   </basic-container>
 </template>
 
@@ -21,19 +28,19 @@
   watch: {
     'attachForm.drawingNo': function (val) {
       if(val && this.attachForm.processNo && this.attachForm.processEdition) {
-        this.attachForm.title = `${val}-${this.attachForm.processNo}-${this.attachForm.processEdition}-鏁版帶绋嬪簭缂栧埗`;
+        this.attachForm.title = `${val}-${this.attachForm.processNo}-${this.attachForm.processEdition}-鏁版帶绋嬪簭琛ュ厖`;
       }
     },
     'attachForm.processNo': function (val) {
       if(val && this.attachForm.drawingNo && this.attachForm.processEdition) {
         //this.attachForm.title = `${val}-${this.attachForm.processNo}-鏁版帶绋嬪簭缂栧埗`;
-		    this.attachForm.title = `${this.attachForm.drawingNo}-${val}-${this.attachForm.processEdition}-鏁版帶绋嬪簭缂栧埗`;
+		    this.attachForm.title = `${this.attachForm.drawingNo}-${val}-${this.attachForm.processEdition}-鏁版帶绋嬪簭琛ュ厖`;
       }
     },
     'attachForm.processEdition': function (val) {
       if(val && this.attachForm.drawingNo && this.attachForm.processNo ) {
         //this.attachForm.title = `${val}-${this.attachForm.processNo}-鏁版帶绋嬪簭缂栧埗`;
-		    this.attachForm.title = `${this.attachForm.drawingNo}-${this.attachForm.processNo} -${val}-鏁版帶绋嬪簭缂栧埗`;
+		    this.attachForm.title = `${this.attachForm.drawingNo}-${this.attachForm.processNo}-${val}-鏁版帶绋嬪簭琛ュ厖`;
       }
     },
   },
@@ -42,6 +49,13 @@
     var that = this;
     return {
       form: {},
+      treeData: [],
+      defaultProps: {
+        children: 'children',
+        label: 'name',
+        disabled: (data) => data.nodeType!=='machine',//浠呮満搴婅妭鐐瑰彲閫�
+        isLeaf: (data) => !data.hasChildren
+      },
       machineCodeList: [],
       attachOption: {
         labelWidth: 160,
@@ -55,7 +69,11 @@
             type: 'input',
             span: 24,
             dataType: 'string',
+            disabled:true,
             rules: [{ required: true, message: '蹇呭~', trigger: 'blur' }],
+            blur: (col) => {
+              this.handleTrim(col)
+            },
           },
           {
             label: '闆剁粍浠跺彿',
@@ -64,6 +82,9 @@
             span: 12,
             dataType: 'string',
             rules: [{ required: true, message: '蹇呭~', trigger: 'blur' }],
+            blur: (col) => {
+              this.handleTrim(col)
+            },
           },
           {
             label: '鍥惧彿鐗堟',
@@ -72,6 +93,9 @@
             span: 12,
             dataType: 'string',
             rules: [{ required: true, message: '蹇呭~', trigger: 'blur' }],
+            blur: (col) => {
+              this.handleTrim(col)
+            },
           },
           {
             label: '浜у搧鍨嬪彿',
@@ -80,6 +104,9 @@
             span: 12,
             dataType: 'string',
             rules: [{ required: true, message: '蹇呭~', trigger: 'blur' }],
+            blur: (col) => {
+              this.handleTrim(col)
+            },
           },
           {
             label: '宸ュ簭鍙�',
@@ -91,6 +118,9 @@
             dataType: 'string',
             max: 999,
             rules: [{ required: true, message: '蹇呭~', trigger: 'blur' }],
+            blur: (col) => {
+              this.handleTrim(col)
+            },
           },
           {
             label: '宸ュ簭鍚嶇О',
@@ -99,6 +129,9 @@
             span: 12,
             dataType: 'string',
             rules: [{ required: true, message: '蹇呭~', trigger: 'blur' }],
+            blur: (col) => {
+              this.handleTrim(col)
+            },
           },
           {
             label: '宸ュ簭鐗堟',
@@ -107,32 +140,28 @@
             span: 12,
             dataType: 'string',
             rules: [{ required: true, message: '蹇呭~', trigger: 'blur' }],
+            blur: (col) => {
+              this.handleTrim(col)
+            },
           },
           {
-            label: '宸ヨ壓鐗堟',
+            label: '鎵规鍙�',
             prop: 'craftEdition',
             placeholder:'濡�"A"',
             type: 'input',
             span: 12,
             dataType: 'string',
-            maxlength: 2,
-            rules: [{ required: true, message: '蹇呭~', trigger: 'blur' }],
+            maxlength: 10,
+            blur: (col) => {
+              this.handleTrim(col)
+            },
           },
           {
             label: '鍔犲伐鏈哄簥',
             prop: 'machineCode',
             type: 'select',
-			      filterable: true,
-            dicUrl: `/blade-mdm/machine/page?size=10000`,
-            dicFormatter: function (res) {
-              that.machineCodeList = res.data.records;
-              return res.data.records;
-            },
             rules: [{ required: true, message: '蹇呭~', trigger: 'blur' }],
-            props: {
-              label: 'code',
-              value: 'code',
-            },
+            
             span: 12
           },
           {
@@ -166,10 +195,68 @@
           }
         ],
       },
-      attachForm: {planLockDays:7},//榛樿7澶�
+      attachForm: {planLockDays:7,planStartTime: this.$dayjs().format('YYYY-MM-DD')},//榛樿7澶�
+      defaultForm: {planLockDays:7,planStartTime: this.$dayjs().format('YYYY-MM-DD')},
     };
   },
   methods: {
+    treeLoad () {
+      axios({
+        url: '/blade-mdm/gkw/node/load-tree',
+        method: 'get',
+      }).then(
+        res => {
+          this.treeData = this.filterTreeData(res.data.data);
+          var firstIndex = 0;
+          res.data.data.forEach((item,index)=> {
+            if(item.children.length != 0) {
+              firstIndex = index;
+            }
+          })
+          //defaultKeys.push(item.id);
+          this.defaultKeys = [res.data.data[firstIndex].id];
+        }
+      )
+    },
+    filterTreeData(oriTreeData){
+      var roots = [];
+      for(var i=0;i<oriTreeData.length;i++){
+        roots.push(this.filterTreeNodes(oriTreeData[i]));
+      }
+      return roots;
+    },
+    filterTreeNodes(node) {
+      // 濡傛灉褰撳墠鑺傜偣鐨刵odeType鏄�'machine'锛屽垯娓呴櫎鍏跺瓙鑺傜偣
+      if (node.nodeType === 'machine') {
+          // 鍒涘缓涓�涓柊瀵硅薄锛屽鍒跺綋鍓嶈妭鐐圭殑灞炴�э紝浣嗘竻闄hildren
+          return {
+              ...node,
+              children: []
+          };
+      }
+      
+      // 濡傛灉褰撳墠鑺傜偣鏈夊瓙鑺傜偣锛岄�掑綊澶勭悊姣忎釜瀛愯妭鐐�
+      if (node.children && node.children.length > 0) {
+          return {
+              ...node,
+              children: node.children.map(child => this.filterTreeNodes(child))
+          };
+      }
+      
+      // 濡傛灉鏃笉鏄痬achine鑺傜偣涔熸病鏈夊瓙鑺傜偣锛岀洿鎺ヨ繑鍥炲師鑺傜偣
+      return node;
+    },
+    handleTrim(col){
+      //console.log(col)
+      let value = this.attachForm[col.column.prop];
+      if (typeof value === 'string') {
+            const trimmedValue = value.trim();
+            // 鍙湁褰撳�肩‘瀹炲彂鐢熷彉鍖栨椂鎵嶆洿鏂�
+            if (trimmedValue !== value) {
+                this.attachForm[col.column.prop] = trimmedValue;
+            }
+        }
+    },
     formSubmit(form, done) {
       var form = { ...form };
       this.machineCodeList.forEach(item => {
@@ -189,6 +276,7 @@
             message: '鎿嶄綔鎴愬姛!',
           });
           this.$refs.form.resetForm();
+          this.attachForm = this.defaultForm;
           done();
         },
         error => {
@@ -198,6 +286,9 @@
       );
     }
   },
+   mounted() {
+    this.treeLoad();
+  },
 };
 </script>
 

--
Gitblit v1.9.3