yusheng 1 год назад
Родитель
Сommit
37f3385e95
2 измененных файлов с 18 добавлено и 24 удалено
  1. 6 24
      src/components/AssetTree/index.vue
  2. 12 0
      src/views/BOMmanage/ProjectDetailDialog.vue

+ 6 - 24
src/components/AssetTree/index.vue

@@ -108,14 +108,14 @@
         return this.$refs.tree;
       },
       // 获取树结构数据
-      async getTreeData(id) {
+      async getTreeData(id, defChecked) {
         try {
           this.treeLoading = true;
 
           const res = this.isProjects
             ? await getProjectAndCategoryLevelTree()
             : await getTreeByPid(id);
-    
+
           this.treeLoading = false;
           if (res?.code === '0') {
             this.treeList = res.data;
@@ -124,6 +124,9 @@
               this.treeList = this.treeFormate(this.treeList);
             }
             this.$nextTick(() => {
+              if(this.isProjects){
+                this.setCurrentKey(defChecked);
+              }
               // 默认高亮第一级树节点
               if (this.treeList[0] && this.isFirstRefreshTable) {
                 this.setCurrentKey(this.treeList[0].id);
@@ -135,30 +138,9 @@
             });
             return this.treeList;
           }
-        } catch (error) {
-          console.error(error);
-        }
+        } catch (error) {}
         this.treeLoading = false;
       },
-      // 递归 - 往树children里面添加parentName
-      // _setParentName (tree) {
-      //   let data = tree;
-      //   for (let i = 0; i < data.length; i++) {
-      //     if (data[i].parentId === '0') {
-      //       this.parentName = data[i].name;
-      //       originId = data[i].id;
-      //       originType = data[i].type;
-      //     }
-
-      //     data[i]['originId'] = originId;
-      //     data[i]['originType'] = originType;
-      //     data[i]['parentId'] = data[i]['parentId'];
-      //     if (data[i].children && data[i].children.length > 0) {
-      //       this._setParentName(data[i].children);
-      //     }
-      //   }
-      //   return data;
-      // },
 
       handleNodeClick(data, node) {
         this.$emit('handleNodeClick', data, node);

+ 12 - 0
src/views/BOMmanage/ProjectDetailDialog.vue

@@ -16,6 +16,7 @@
             :isProjects="true"
             :isFirstRefreshTable="false"
             ref="treeList"
+            :init="false"
           />
         </el-card>
         <!-- <div style="padding: 5px;">
@@ -1123,6 +1124,9 @@
         this.rowData = row;
         this.visible = true;
         if (this.rowData.id) {
+          this.$nextTick(()=>{
+            this.$refs.treeList.getTreeData('',this.rowData.id)
+          })
           this.initData();
           this.dialogType = this.rowData.type;
         }
@@ -1460,6 +1464,14 @@
         } catch (error) {}
         this.treeLoading = false;
       },
+      async handleNodeClick1(data){
+        if(data.type==''){
+
+        }
+        this.rowData=this.dialogForm = await projectsGetByIdDetailsAPI(data.id);
+        this.getTreeData()
+
+      },
       getIconClass(node, data) {
         switch (data.type) {
           case 2: