|
@@ -21,14 +21,15 @@ export function arr2Tree(arr = [], parent = 'parentId', key = 'key', rootId = '-
|
21
|
21
|
// 挂载父子节点
|
22
|
22
|
const tree = [];
|
23
|
23
|
for (let item of arr) {
|
|
24
|
+ const node = dict[item[key]];
|
24
|
25
|
const parentNodeId = item[parent];
|
25
|
26
|
|
26
|
27
|
if (parentNodeId === rootId) {
|
27
|
|
- tree.push(dict[item[key]]);
|
|
28
|
+ tree.push(node);
|
28
|
29
|
} else {
|
29
|
30
|
const parentNode = dict[parentNodeId];
|
30
|
31
|
if (parentNode) {
|
31
|
|
- parentNode.children.push(item);
|
|
32
|
+ parentNode.children.push(node);
|
32
|
33
|
}
|
33
|
34
|
}
|
34
|
35
|
}
|