فهرست منبع

刷新页面树节点定位

duy 2 ماه پیش
والد
کامیت
4ac74a0338
1فایلهای تغییر یافته به همراه34 افزوده شده و 2 حذف شده
  1. 34 2
      src/views/codeRule/ruleManage.vue

+ 34 - 2
src/views/codeRule/ruleManage.vue

@@ -13,6 +13,8 @@
                         @node-click="handleNodeClick"
                         :props="defaultProps"
                         :expand-on-click-node="false"
+                         :default-expanded-keys="defaultExpandedKeys"
+                          :current-node-key="curreenttid"
                         highlight-current
                         node-key="id"
                         ref="tree"
@@ -394,6 +396,7 @@ import ConditionsSet from './ConditionsSet.vue'
 import LinkEle from "./LinkEle.vue";
 import PreviewResult from './PreviewResult.vue'
 import {getPage,getById,add} from "@/api/ruleManage/fileRule.js";
+import { getStore, setStore } from "@/util/store";
   export default {
   components: {
     ConditionsSet,
@@ -415,6 +418,9 @@ import {getPage,getById,add} from "@/api/ruleManage/fileRule.js";
             return !data.hasChildren || (data.isExistForm==1);
             },
         },
+        defaultExpandedKeys: [],
+        curreenttid: '',
+         expandName: this.$route.fullPath,
         ruleItemOptions:[
           
          
@@ -500,7 +506,12 @@ import {getPage,getById,add} from "@/api/ruleManage/fileRule.js";
         this.parentId = 0;
         this.tenant_id = tenant_id;
         this.projectid = projectid;
-  
+        this.defaultExpandedKeys = getStore({ name: this.expandName });
+        this.curreenttid= getStore({ name:'curreenttid' });
+        if (this.curreenttid) {
+          this.treeId = this.curreenttid;
+          this.getRuleItemOptions();
+        } 
     },
     methods: {
       //获取规范文件夹数据
@@ -527,12 +538,33 @@ import {getPage,getById,add} from "@/api/ruleManage/fileRule.js";
         });
       },
 
-      handleNodeClick(data) {
+      handleNodeClick(data,node) {
        
         this.treeId = data.id;
         
         this.getRuleItemOptions()
+          //获取节点展开路径
+        this.getExpandedKeys(node);
+        setStore({
+          name: 'curreenttid',
+          content: data.id,
+          type: true, //sessionStorage
+        });
       },
+     getExpandedKeys(node) {
+      //console.log(node)
+      let expandedKeys = [];
+      while (node.parent) {
+        expandedKeys.push(node.data.id);
+        node = node.parent;
+      }
+      setStore({
+        name: this.expandName,
+        content: expandedKeys,
+        type: true, //sessionStorage
+      });
+      //console.log(expandedKeys)
+    },
       loadNode(node, resolve) {
                 let pid = 0;
                 if (node.level != 0) {