fix 修复用户管理 部门树 不显示禁用部门问题

This commit is contained in:
疯狂的狮子Li
2026-04-17 16:08:05 +08:00
parent c7bcf52f03
commit 87fad7bc16
+10 -9
View File
@@ -612,17 +612,18 @@ const getDeptTree = async () => {
enabledDeptOptions.value = filterDisabledDept(res.data); enabledDeptOptions.value = filterDisabledDept(res.data);
}; };
/** 过滤禁用的部门 */ /** 过滤禁用的部门,并返回独立的新树,避免污染左侧完整部门树 */
const filterDisabledDept = (deptList: DeptTreeVO[]) => { const filterDisabledDept = (deptList: DeptTreeVO[]): DeptTreeVO[] => {
return deptList.filter(dept => { return deptList.reduce<DeptTreeVO[]>((result, dept) => {
if (dept.disabled) { if (dept.disabled) {
return false; return result;
} }
if (dept.children && dept.children.length) { result.push({
dept.children = filterDisabledDept(dept.children); ...dept,
} children: dept.children?.length ? filterDisabledDept(dept.children) : []
return true; });
}); return result;
}, []);
}; };
/** 节点单击事件 */ /** 节点单击事件 */