|
@@ -238,17 +238,18 @@
|
|
|
},
|
|
},
|
|
|
/* 递归过滤树节点 */
|
|
/* 递归过滤树节点 */
|
|
|
filterTreeByCode(list, code) {
|
|
filterTreeByCode(list, code) {
|
|
|
- return list.reduce((acc, node) => {
|
|
|
|
|
- if (node.code === code) {
|
|
|
|
|
- acc.push(node);
|
|
|
|
|
- } else if (node.children && node.children.length) {
|
|
|
|
|
- const filteredChildren = this.filterTreeByCode(node.children, code);
|
|
|
|
|
- if (filteredChildren.length) {
|
|
|
|
|
- acc.push({ ...node, children: filteredChildren });
|
|
|
|
|
|
|
+ const result = [];
|
|
|
|
|
+ const walk = (nodes) => {
|
|
|
|
|
+ for (const node of nodes) {
|
|
|
|
|
+ if (node.code === code) {
|
|
|
|
|
+ result.push(node);
|
|
|
|
|
+ } else if (node.children && node.children.length) {
|
|
|
|
|
+ walk(node.children);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return acc;
|
|
|
|
|
- }, []);
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+ walk(list);
|
|
|
|
|
+ return result;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/* 刷新表格 */
|
|
/* 刷新表格 */
|