Procházet zdrojové kódy

fix:树布局算法计算节点positionY时,更换父节点后要将累计高度清零

Cyt928 před 5 roky
rodič
revize
80b28ef5a8
1 změnil soubory, kde provedl 6 přidání a 0 odebrání
  1. 6 0
      src/components/Tree.vue

+ 6 - 0
src/components/Tree.vue

@@ -100,7 +100,12 @@ export default {
       rootNode.positionY = 0;
       for (let i = 1; i < TREE_MAX_HEIGHT; i += 1) {
         let sum = 0;
+        let tempParent = colList[0][0].id;
         colList[i].forEach((item) => {
+          if (item.parentId !== tempParent) {
+            sum = 0;
+            tempParent = item.parentId;
+          }
           item.positionY = nodeMap.get(item.parentId).positionY + sum;
           sum += item.contentHeight;
         });
@@ -121,6 +126,7 @@ export default {
       });
       this.drawLine((maxPositionY * 140 + 100).toFixed(0));
       // 返回col
+      console.warn(colList);
       return colList;
     },
   },