From 87fad7bc1681b9bc59ee7187d669c65270c4b638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Fri, 17 Apr 2026 16:08:05 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=20=E9=83=A8=E9=97=A8=E6=A0=91=20=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=A6=81=E7=94=A8=E9=83=A8=E9=97=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/user/index.vue | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index e65a6cd..5df98e5 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -612,17 +612,18 @@ const getDeptTree = async () => { enabledDeptOptions.value = filterDisabledDept(res.data); }; -/** 过滤禁用的部门 */ -const filterDisabledDept = (deptList: DeptTreeVO[]) => { - return deptList.filter(dept => { +/** 过滤禁用的部门,并返回独立的新树,避免污染左侧完整部门树 */ +const filterDisabledDept = (deptList: DeptTreeVO[]): DeptTreeVO[] => { + return deptList.reduce((result, dept) => { if (dept.disabled) { - return false; + return result; } - if (dept.children && dept.children.length) { - dept.children = filterDisabledDept(dept.children); - } - return true; - }); + result.push({ + ...dept, + children: dept.children?.length ? filterDisabledDept(dept.children) : [] + }); + return result; + }, []); }; /** 节点单击事件 */