瀏覽代碼

指标懒加载

chenlei 8 月之前
父節點
當前提交
07f8fd2cf2
共有 1 個文件被更改,包括 16 次插入13 次删除
  1. 16 13
      src/views/dataEntry_manage/thirdBase/FwmtData.vue

+ 16 - 13
src/views/dataEntry_manage/thirdBase/FwmtData.vue

@@ -189,7 +189,7 @@ export default {
         if (res.Ret !== 200) return;
         this.classifyList = res.Data || [];
         this.select_classify = this.classifyList.length ? (this.classifyList[0].Child && this.classifyList[0].Child.length ? this.classifyList[0].Child[0].ClassifyId : this.classifyList[0].ClassifyId) : 0; // 获取classifyList中第一个元素的ClassifyId,如果该元素有子元素,则取第一个子元素的ClassifyId
-        this.defaultShowNodes = [this.classifyList[0].ClassifyId]
+        // this.defaultShowNodes = [this.classifyList[0].ClassifyId]
         this.$nextTick(() => { // 获取到节点后设置选中
           this.$refs.treeRef.setCurrentKey(this.select_classify)
         })
@@ -345,25 +345,29 @@ export default {
     //指标懒加载
     async getLazyTreeData(node,resolve){
       let arr=[]
-      if(node.level===2||node.data.ClassifyId === 0){
+      if(!node.data.Child && !node.data.isLeaf && node.data.ClassifyId){
         const res=await fwmtInterface.dataList({
           ClassifyId: node.data.ClassifyId
         })
         if(res.Ret===200){
           const temarr=res.Data||[]
-          arr=temarr.map((item, i)=>{
-            const classId = item.ClassifyId
-            delete item.ClassifyId
-            return {
-              ...item,
-              classId,
-              isLeaf:true
-            }
-          })
+          if (temarr.length > 0) {
+            arr=temarr.map((item, i)=>{
+              const classId = item.ClassifyId
+              delete item.ClassifyId
+              return {
+                ...item,
+                classId,
+                isLeaf: true
+              }
+            })
+          } else {
+            arr = []
+          }
         }
       }else{
         arr=node.data.Child||[]
-      }     
+      }
       resolve(arr)
     },
     // 树节点展开
@@ -513,7 +517,6 @@ export default {
   
     //改变选中节点
     nodeChangeHandle(data, node) {
-      console.log(data, node);
       this.classId = data.classId
       if (data.ClassifyId === this.repetition || data.IndexCode === this.repetition) return;
       this.select_classify = data.ClassifyId;