|
|
@@ -76,15 +76,6 @@ export default {
|
|
|
console.warn('需求树数据有误,树高度错误');
|
|
|
}
|
|
|
if (!item.parentId) rootNode = item;
|
|
|
- // if (item.parent) {
|
|
|
- // const tempParent = nodeMap.get(item.parent);
|
|
|
- // if (!tempParent.childs) {
|
|
|
- // tempParent.childs = [];
|
|
|
- // }
|
|
|
- // tempParent.childs.push(item);
|
|
|
- // } else {
|
|
|
- // rootNode = item;
|
|
|
- // }
|
|
|
});
|
|
|
// 计算一个节点包含他的后代所需要的空间
|
|
|
const calculateNodeContentHeight = (node) => {
|
|
|
@@ -92,7 +83,10 @@ export default {
|
|
|
node.contentHeight = 1;
|
|
|
return 1;
|
|
|
}
|
|
|
- node.contentHeight = node.childs.reduce((total, current) => total + calculateNodeContentHeight(current), 0);
|
|
|
+ node.contentHeight = node.childs.reduce(
|
|
|
+ (total, current) => total + calculateNodeContentHeight(current),
|
|
|
+ 0,
|
|
|
+ );
|
|
|
return node.contentHeight;
|
|
|
};
|
|
|
calculateNodeContentHeight(rootNode);
|