From fc7f59bcd94cebfcc3b2a1278984a3bb7b39edaa Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期二, 22 十月 2024 18:12:20 +0800
Subject: [PATCH] 功能模板树节点操作后局部刷新

---
 Source/plt-web/plt-web-ui/src/views/systemModel/businessModel/index.vue |   42 +++++++++++++++++++++++++++++-------------
 1 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/Source/plt-web/plt-web-ui/src/views/systemModel/businessModel/index.vue b/Source/plt-web/plt-web-ui/src/views/systemModel/businessModel/index.vue
index a36c78d..cb210be 100644
--- a/Source/plt-web/plt-web-ui/src/views/systemModel/businessModel/index.vue
+++ b/Source/plt-web/plt-web-ui/src/views/systemModel/businessModel/index.vue
@@ -2,8 +2,8 @@
   <el-container v-loading="createdLoading">
     <el-aside>
       <basic-container>
-        <div style="max-height: calc(100vh - 170px);overflow: auto">
-          <avue-tree :key="refresh" ref="tree" :data="treeData" :option="treeOption" @node-click="nodeClick">
+        <div style="max-height: calc(100vh - 150px);overflow: auto">
+          <avue-tree :key="refresh" node-key="id" ref="tree" :data="treeData" :option="treeOption" @node-click="nodeClick">
           <span slot-scope="{ node, data }" class="el-tree-node__label">
            <span style="font-size: 15px">
               <i class="el-icon-s-promotion"></i>
@@ -17,7 +17,7 @@
 
     <el-main>
       <basic-container>
-        <el-form ref="form" :model="form" label-width="85px" style="height: 79vh">
+        <el-form ref="form" :model="form" label-width="85px" style="max-height: calc(100vh - 180px);overflow: auto;">
           <span v-if="form.childType !== 0">
             <el-form-item label="妯″潡鍚嶏細">
             <el-input v-model="form.name" placeholder="璇疯緭鍏ユā鍧楀悕"></el-input>
@@ -202,6 +202,7 @@
       addStatus: false,
       editStatus: false,
       nodeRow: {},
+      currentClickNode:null,
       form: {},
       treeData: [],
       treeOption: {
@@ -255,9 +256,10 @@
   },
   methods: {
     // 鏍戣鐐瑰嚮
-    nodeClick(row) {
+    nodeClick(row,node) {
       this.form = {...row};
       this.nodeRow = {...row};
+      this.currentClickNode=node;
       this.addStatus = false;
       this.editStatus = false;
     },
@@ -312,7 +314,7 @@
           this.addStatus = false;
           // this.resetFormValue();
           this.form.childType = null;
-          this.refresh = Math.random(); // 鍒锋柊宸︿晶鏍�
+          this.handleRefreshTree('add')
         }
       })
     },
@@ -356,7 +358,7 @@
           this.editStatus = false;
           // this.resetFormValue();
           this.form.childType = null;
-          this.refresh = Math.random(); // 鍒锋柊宸︿晶鏍�
+          this.handleRefreshTree('edit')
         }
       })
     },
@@ -371,7 +373,7 @@
         delModule(this.form).then(res => {
           if (res.data.code === 200) {
             this.$message.success(res.data.msg);
-            this.resetFormValue();
+            this.handleRefreshTree('del')
             this.addStatus = false;
             this.editStatus = false;
           }
@@ -389,8 +391,6 @@
       exportFunctionSql({isFunction: true}).then(res => {
         func.downloadFileByBlobHandler(res);
         this.$message.success('瀵煎嚭鎴愬姛');
-      }).catch(err => {
-        this.$message.error(err);
       });
     },
 
@@ -425,12 +425,11 @@
         }
       })
       addOperationType(list).then(res => {
-        console.log(res)
         if (res.data.code === 200) {
           this.methodsVisble = false;
           this.$message.success(res.data.msg);
           this.form.childType = null;
-          this.refresh = Math.random(); // 鍒锋柊宸︿晶鏍�
+          this.handleRefreshTree('add') // 鍒锋柊宸︿晶鏍�
         }
       })
     },
@@ -460,7 +459,7 @@
       updateAlias(params).then(res => {
         if (res.data.code === 200) {
           this.$message.success(res.data.msg);
-          this.refresh = Math.random(); // 鍒锋柊宸︿晶鏍�
+          this.handleRefreshTree('edit')
         }
       })
     },
@@ -480,7 +479,7 @@
           console.log(res);
           if (res.data.code === 200) {
             this.$message.success(res.data.msg);
-            this.resetFormValue();
+            this.handleRefreshTree('del');
           }
         })
       }).catch(() => {
@@ -506,6 +505,23 @@
     // 瀵煎叆
     upLoadClickHandler() {
       this.$refs.upload.visible = true;
+    },
+    handleRefreshTree(type) {
+      //type:add\edit\del
+      if(type=="del"){
+        this.$refs.tree.remove(this.currentClickNode);
+        this.currentClickNode=null;
+        this.form={};
+      }else{
+        if (this.currentClickNode) {
+          let node = this.currentClickNode.parent;
+          node.loaded = false;
+          node.expand();
+          this.$refs.tree.setCurrentNode(this.currentClickNode);
+        }else {
+          this.refresh = Math.random(); // 鍒锋柊宸︿晶鏍�
+        }
+      }
     }
   }
 }

--
Gitblit v1.9.3