fix 修复用户管理 部门树 不显示禁用部门问题
This commit is contained in:
@@ -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;
|
||||||
|
}, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 节点单击事件 */
|
/** 节点单击事件 */
|
||||||
|
|||||||
Reference in New Issue
Block a user