🐛 修复组织级联回显时递归取整棵树导致栈溢出

This commit is contained in:
2026-11-05 19:19:35 +08:00
parent 8734c27fd3
commit 6e48fa50cf
+3 -1
View File
@@ -143,7 +143,9 @@ export default {
for (const node of tree || []) {
const path = [...parents, String(node.id)];
if (String(node.id) === String(target)) return path;
const matched = this.findOrgPath(target, node.children, path);
// 必须显式传 node.children || []:叶节点的 children 是 undefined,
// 传 undefined 会触发默认参数重新拿到整棵树,逐层重复扫描直到爆栈
const matched = this.findOrgPath(target, node.children || [], path);
if (matched) return matched;
}
return null;