浏览代码

设置层级后刷新树

duy 2 年之前
父节点
当前提交
586bb65402
共有 2 个文件被更改,包括 61 次插入7 次删除
  1. 26 3
      src/views/manager/archivetree.vue
  2. 35 4
      src/views/manager/projectinfo/archivetreeRule.vue

+ 26 - 3
src/views/manager/archivetree.vue

@@ -194,6 +194,8 @@
                     class="filter-tree"
                     show-checkbox :check-strictly="true"
                     @check="handleCheckChange"
+                    :default-expanded-keys="defaultExpandedKeys1"
+                    :current-node-key="curreenttid1"
                   >
                    <div class="custom-tree-node" slot-scope="{ node, data }"   @mouseover="mouseOver(data)"    style="flex: 1;width: 100%;justify-content: flex-start;"
                     @mouseleave="mouseLeave(data)">
@@ -212,7 +214,7 @@
                           <el-button
                             type="text"
                             size="mini"
-                            @click.stop="() => viewConfig(data)">
+                            @click.stop="() => viewConfig(data,node)">
                             查看配置
                           </el-button>
                           <el-link @click.stop="removeArchive(data)" type="danger" :underline="false" class="marleft10"><i class="el-icon-delete"></i></el-link>
@@ -956,8 +958,10 @@ export default {
       menuleft:20,
       menutop:0,
       defaultExpandedKeys:[],
+      defaultExpandedKeys1:[],
       expandName: this.$route.fullPath,
-      curreenttid:''
+      curreenttid:'',
+      curreenttid1:''
      
     }
   },
@@ -1043,8 +1047,10 @@ export default {
       return true;
     },
 
-    async viewConfig(data){
+    async viewConfig(data,node){
        console.log(data,'查看配置');
+       //获取节点展开路径
+       this.getExpandedKeys1(node);
        this.configInfo = null;
        const { data: res } = await  getArchiveAutoRule({
         nodeId:data.id,//归档树节点的id 或者 挂载wbs节点的ID(具体哪个ID待定)
@@ -1204,6 +1210,20 @@ export default {
       });
       //console.log(expandedKeys)
     },
+    getExpandedKeys1(node) {
+      //console.log(node)
+      let expandedKeys = [];
+      while (node.parent) {
+        expandedKeys.push(node.data.id);
+        node = node.parent;
+      }
+      setStore({
+        name: 'configkey',
+        content: expandedKeys,
+        type: true, //sessionStorage
+      });
+      //console.log(expandedKeys)
+    },
     nodeClick(data,node){
        //获取节点展开路径
        this.getExpandedKeys(node);
@@ -1676,6 +1696,7 @@ export default {
           type: 'success',
           message: '设置成功'
         })
+        this.treeIdChange(this.treeSelectId)
         this.highVisible = false;
       }
     },
@@ -1803,6 +1824,8 @@ export default {
       projectId:0
     })
     this.defaultExpandedKeys = getStore({ name: this.expandName });
+    this.defaultExpandedKeys1 = getStore({ name: 'configkey' });
+    this.curreenttid1= getStore({ name:'curreenttid1' });
     this.curreenttid= getStore({ name:'curreenttid' });
     console.log( this.curreenttid,' this.curreenttid');
     this.archiveTreetree4()//全加载左侧树

+ 35 - 4
src/views/manager/projectinfo/archivetreeRule.vue

@@ -196,6 +196,8 @@
                     class="filter-tree"
                     show-checkbox :check-strictly="true"
                     @check="handleCheckChange"
+                    :default-expanded-keys="defaultExpandedKeys1"
+                    :current-node-key="curreenttid1"
                   >
                    <div class="custom-tree-node" slot-scope="{ node, data }"   @mouseover="mouseOver(data)"    style="flex: 1;width: 100%;justify-content: flex-start;" 
                     @mouseleave="mouseLeave(data)">
@@ -214,7 +216,7 @@
                           <el-button
                             type="text"
                             size="mini"
-                            @click.stop="() => viewConfig(data)">
+                            @click.stop="() => viewConfig(data,node)">
                             查看配置
                           </el-button>
                           <el-link @click.stop="removeArchive(data)" type="danger" :underline="false" class="marleft10"><i class="el-icon-delete"></i></el-link>
@@ -957,8 +959,10 @@ export default {
       menuleft:20,
       menutop:0,
       defaultExpandedKeys:[],
+      defaultExpandedKeys1:[],
       expandName: this.$route.fullPath,
-      curreenttid:''
+      curreenttid:'',
+      curreenttid1:''
     }
   },
   computed:{
@@ -1032,8 +1036,14 @@ export default {
       return true;
     },
 
-    async viewConfig(data){
-       console.log(data,'查看配置');
+    async viewConfig(data,node){
+         //获取节点展开路径
+         this.getExpandedKeys1(node);
+        setStore({
+        name: 'curreenttid1',
+        content: data.id,
+        type: true, //sessionStorage
+      });
        this.configInfo = null;
        const { data: res } = await  getArchiveAutoRule({
         nodeId:data.id,//归档树节点的id 或者 挂载wbs节点的ID(具体哪个ID待定)
@@ -1195,6 +1205,20 @@ export default {
       });
       //console.log(expandedKeys)
     },
+    getExpandedKeys1(node) {
+      //console.log(node)
+      let expandedKeys = [];
+      while (node.parent) {
+        expandedKeys.push(node.data.id);
+        node = node.parent;
+      }
+      setStore({
+        name: 'configkey',
+        content: expandedKeys,
+        type: true, //sessionStorage
+      });
+      //console.log(expandedKeys)
+    },
     nodeClick(data,node){
        //获取节点展开路径
        this.getExpandedKeys(node);
@@ -1682,6 +1706,11 @@ export default {
           type: 'success',
           message: '设置成功'
         })
+        this.archiveTreetree({
+          token: this.token,
+          //disPlayTree: 1,
+          //nodeType: 2,
+        })
         this.highVisible = false;
       }
     },
@@ -1812,7 +1841,9 @@ export default {
 
     this.projectId = this.$route.query.projectId;
     this.defaultExpandedKeys = getStore({ name: this.expandName });
+    this.defaultExpandedKeys1 = getStore({ name: 'configkey' });
     this.curreenttid= getStore({ name:'curreenttid' });
+    this.curreenttid1= getStore({ name:'curreenttid1' });
 
     this.archiveTreetree({
       token: this.token,