소스 검색

fix: 点击图表展开目录后的异常展开问题

Karsa 1 년 전
부모
커밋
9da4d20c37
1개의 변경된 파일25개의 추가작업 그리고 66개의 파일을 삭제
  1. 25 66
      src/views/dataEntry_manage/chartSetting.vue

+ 25 - 66
src/views/dataEntry_manage/chartSetting.vue

@@ -893,9 +893,6 @@ export default {
         let [search_obj] = this.searchOptions.filter(
         let [search_obj] = this.searchOptions.filter(
           (item) => item.ChartInfoId === newval
           (item) => item.ChartInfoId === newval
         );
         );
-        // 查找图表的父级id
-        let arr = this.findParentNodeHandle(this.treeData,search_obj.ChartClassifyId);
-        this.defaultShowNodes = arr;
         this.select_node = search_obj.UniqueCode;
         this.select_node = search_obj.UniqueCode;
       
       
         this.selected_chartClassify = search_obj.ChartClassifyId; //图表所属分类
         this.selected_chartClassify = search_obj.ChartClassifyId; //图表所属分类
@@ -908,24 +905,6 @@ export default {
         this.select_date = [search_obj.StartDate, search_obj.EndDate];
         this.select_date = [search_obj.StartDate, search_obj.EndDate];
         this.selected_chartType = search_obj.ChartType; //图表类型
         this.selected_chartType = search_obj.ChartType; //图表类型
         this.selected_chartid = newval;
         this.selected_chartid = newval;
-
-         //滚动到高亮节点位置
-        setTimeout(() => {
-          this.$refs.treeRef.setCurrentKey(this.select_node);
-          let node = document.getElementById(`node${this.select_node}`);
-          let parent = document.getElementsByClassName('tree-cont')[0];
-
-          //parent可视区间:[scrollTop,scrollTop+offsetHeight]
-          //node位置:node.offsetTop
-          const overTop = node.offsetTop+node.clientHeight+15<parent.scrollTop
-          const overBottom = node.offsetTop+node.clientHeight+15>parent.scrollTop+parent.offsetHeight
-          if(overTop){
-              parent.scrollTop = node.offsetTop-30
-          }
-          if(overBottom){
-            parent.scrollTop =  node.offsetTop - parent.offsetHeight/2
-          }
-        },400)
       }
       }
     },
     },
 
 
@@ -1452,18 +1431,10 @@ export default {
     // 树节点展开
     // 树节点展开
     handleNodeExpand(data) {
     handleNodeExpand(data) {
       // 保存当前展开的节点
       // 保存当前展开的节点
-      let flag = false;
-      this.defaultShowNodes.some((item) => {
-        if (item === data.UniqueCode) {
-          // 判断当前节点是否存在, 存在不做处理
-          flag = true;
-          return true;
-        }
-      });
-      if (!flag) {
-        // 不存在则存到数组里
-        this.defaultShowNodes.push(data.UniqueCode);
-      }
+      let flag = this.defaultShowNodes.some((item) => item === data.UniqueCode);
+			if (!flag) { // 不存在则存到数组里
+				this.defaultShowNodes.push(data.UniqueCode)
+			}
     },
     },
     // 树节点关闭
     // 树节点关闭
     handleNodeCollapse(data) {
     handleNodeCollapse(data) {
@@ -1473,7 +1444,6 @@ export default {
           this.defaultShowNodes.length = index;
           this.defaultShowNodes.length = index;
         }
         }
       });
       });
-      // console.log(this.defaultShowNodes)
     },
     },
 
 
     // 懒加载tree
     // 懒加载tree
@@ -1580,8 +1550,28 @@ export default {
       //将指标添加进标签列表中
       //将指标添加进标签列表中
       const {ChartNameEn,ChartName,ChartInfoId,UniqueCode,ChartClassifyId}=res.Data.ChartInfo
       const {ChartNameEn,ChartName,ChartInfoId,UniqueCode,ChartClassifyId}=res.Data.ChartInfo
       this.addLabel({code:UniqueCode,id:ChartInfoId,classifyId:ChartClassifyId,EdbName:ChartName,EdbNameEn:ChartNameEn,chartData:res.Data.ChartInfo})
       this.addLabel({code:UniqueCode,id:ChartInfoId,classifyId:ChartClassifyId,EdbName:ChartName,EdbNameEn:ChartNameEn,chartData:res.Data.ChartInfo})
-      this.defaultShowNodes=this.findParentNodeHandle(this.treeData,ChartClassifyId)
+      this.defaultShowNodes=this.findParentNodeHandle(this.treeData,ChartClassifyId).reverse();
       this.changeTreeNode()
       this.changeTreeNode()
+
+
+      //滚动到高亮节点位置
+      this.$refs.treeRef.setCurrentKey(this.select_node);
+      setTimeout(() => {
+        let node = document.getElementById(`node${this.select_node}`);
+        let parent = document.getElementsByClassName('tree-cont')[0];
+
+        //parent可视区间:[scrollTop,scrollTop+offsetHeight]
+        //node位置:node.offsetTop
+        const overTop = node.offsetTop+node.clientHeight+15<parent.scrollTop
+        const overBottom = node.offsetTop+node.clientHeight+15>parent.scrollTop+parent.offsetHeight
+        console.log(overBottom)
+        if(overTop){
+            parent.scrollTop = node.offsetTop-30
+        }
+        if(overBottom){
+          parent.scrollTop =  node.offsetTop - parent.offsetHeight/2
+        }
+      },400)
     },
     },
 
 
     /* 设置默认时间选中项 */
     /* 设置默认时间选中项 */
@@ -2043,8 +2033,6 @@ export default {
       // 查找选中的节点信息
       // 查找选中的节点信息
       let select_obj = chartData?chartData:await this.findNode(deep_arr, id);
       let select_obj = chartData?chartData:await this.findNode(deep_arr, id);
       // 查找图表的分类父级id
       // 查找图表的分类父级id
-      let arr = this.findParentNodeHandle(this.treeData,select_obj.ChartClassifyId); // 父的父的父-父的父-父
-      this.defaultShowNodes = arr;
       this.select_node = code;
       this.select_node = code;
       
       
       // 重置筛选状态
       // 重置筛选状态
@@ -2055,23 +2043,6 @@ export default {
       this.select_date = [select_obj.StartDate, select_obj.EndDate]; //曲线日期选择
       this.select_date = [select_obj.StartDate, select_obj.EndDate]; //曲线日期选择
       this.selected_chartType = select_obj.ChartType;
       this.selected_chartType = select_obj.ChartType;
       this.selected_chartid = id;
       this.selected_chartid = id;
-
-      //滚动到高亮节点位置
-        setTimeout(() => {
-            this.$refs.treeRef.setCurrentKey(this.select_node);
-            let node = document.getElementById(`node${this.select_node}`);
-            let parent = document.getElementsByClassName('tree-cont')[0];
-            //parent可视区间:[scrollTop,scrollTop+offsetHeight]
-            //node位置:node.offsetTop
-            const overTop = node.offsetTop+node.clientHeight+15<parent.scrollTop
-            const overBottom = node.offsetTop+node.clientHeight+15>parent.scrollTop+parent.offsetHeight
-            if(overTop){
-                parent.scrollTop = node.offsetTop-30
-            }
-            if(overBottom){
-                parent.scrollTop =  node.offsetTop - parent.offsetHeight/2
-            }
-        },400)
     },
     },
     
     
     /* 根据图表id 查找对象 */
     /* 根据图表id 查找对象 */
@@ -2105,12 +2076,6 @@ export default {
         this.expandKey.length && this.expandKey[0] === row.EdbCode
         this.expandKey.length && this.expandKey[0] === row.EdbCode
           ? []
           ? []
           : [row.EdbCode];
           : [row.EdbCode];
-      //曲线图点击行 自动置底
-      // if (this.selected_chartType === 1) {
-      //   this.$nextTick(() => {
-      //     $('.chart-min-cont')[0].scrollTop = 10000;
-      //   });
-      // }
     },
     },
     
     
     /* 设置row-key */
     /* 设置row-key */
@@ -2123,12 +2088,6 @@ export default {
         this.expandKey.length && this.expandKey[0] === row.EdbCode
         this.expandKey.length && this.expandKey[0] === row.EdbCode
           ? []
           ? []
           : [row.EdbCode];
           : [row.EdbCode];
-      //曲线图点击行 自动置底
-      // if (this.selected_chartType === 1) {
-      //   this.$nextTick(() => {
-      //     $('.chart-min-cont')[0].scrollTop = 10000;
-      //   });
-      // }
       this.$refs.tableRef.setCurrentRow(row);
       this.$refs.tableRef.setCurrentRow(row);
     },
     },
     // 查找树节点所有父节点
     // 查找树节点所有父节点