Parcourir la source

元素库树形节点选中

duy il y a 2 ans
Parent
commit
fc9ebf62fc
1 fichiers modifiés avec 48 ajouts et 22 suppressions
  1. 48 22
      src/views/manager/wbsinfo/element.vue

+ 48 - 22
src/views/manager/wbsinfo/element.vue

@@ -1001,32 +1001,58 @@ export default {
           this.$refs.crud.toggleSelection();
         });
     },
-    //刷新左边树形数据
-    refreshTreeData(){
-      const parentId =12345678910
-      tabTypeLazyTreeAll({parentId,current:1,siez:1000}).then(res => {
-        this.treeData=res.data.data.records;
-          this.$nextTick(()=>{
-          //树默认展开
-          if(this.curNode.level===1){
-             this.treeOption.defaultExpandedKeys.push(this.curNode.data.id);
-             this.$refs.avueTree.setCurrentKey(this.curNode.data.id)
-           
-          }else{
-             this.treeOption.defaultExpandedKeys.push(this.curNode.data.parentId);
-              // 设置选中的节点
-              this.treeOption.currentNode =this.curNode.data.id
-              this.$refs.avueTree.setCurrentKey(this.curNode.data.id)
-              
-             
-          }
+    // //刷新左边树形数据
+    // refreshTreeData(){
+    //   const parentId =12345678910
+    //   tabTypeLazyTreeAll({parentId,current:1,siez:1000}).then(res => {
+    //     this.treeData=res.data.data.records;
+    //       this.$nextTick(()=>{
+    //       //树默认展开
+    //       if(this.curNode.level===1){
+    //          this.treeOption.defaultExpandedKeys.push(this.curNode.data.id);
+    //          this.$refs.avueTree.setCurrentKey(this.curNode.data.id)
            
+    //       }else{
+    //          this.treeOption.defaultExpandedKeys.push(this.curNode.data.parentId);
+    //           // 设置选中的节点
+    //           this.treeOption.currentNode =this.curNode.data.id
+    //           this.$refs.avueTree.setCurrentKey(this.curNode.data.id)      
+    //       }   
           
-        })
-      });
+    //     })
+    //   });
+    // },
+        //刷新左边树形数据
+      refreshTreeData(){
+        //刷新左边树形数据
+      if(this.curNode.level===1){
+         const parentId =12345678910 
+        tabTypeLazyTreeAll({parentId,current:1,size:1000}).then(res => {
+            this.data=res.data.data.records;
+             this.$nextTick(()=>{
+              this.defaultExpandKey.push(this.curNode.data.id);
+              this.$refs.avueTree.setCurrentKey(this.curNode.data.id);
+            
+            })
+          
+          });
+      }else{
+
+        this.updateTreeNewNode()
+      }
     },
     //编辑元素表单信息
-
+    updateTreeNewNode() {
+      tabTypeLazyTreeAll(
+       {parentId:this.curTreeData.parentId,current:1,size:1000}
+      ).then((res) => {
+        this.$refs.trees.updateKeyChildren(
+         this.curTreeData.parentId,
+         res.data.data.records
+        );
+        this.$refs.avueTree.setCurrentKey(this.curNode.data.id);
+      });
+    },
     editElement (row) {
       console.log(row,'row');
       this.curEleTable = row;