From c89ba258bcea60f6bb7c6bceb782495b7e1a1a40 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 11 Dec 2024 11:20:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E6=8E=89=E5=B7=B2=E7=A6=81=E7=94=A8=E9=83=A8=E9=97=A8?= =?UTF-8?q?(IB5H7F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/user/index.vue | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index f5fdcaf..4144812 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -112,7 +112,7 @@ - + @@ -237,6 +237,7 @@ const title = ref(""); const dateRange = ref([]); const deptName = ref(""); const deptOptions = ref(undefined); +const enabledDeptOptions = ref(undefined); const initPassword = ref(undefined); const postOptions = ref([]); const roleOptions = ref([]); @@ -298,13 +299,6 @@ watch(deptName, val => { proxy.$refs["deptTreeRef"].filter(val); }); -/** 查询部门下拉树结构 */ -function getDeptTree() { - deptTreeSelect().then(response => { - deptOptions.value = response.data; - }); -}; - /** 查询用户列表 */ function getList() { loading.value = true; @@ -315,6 +309,27 @@ function getList() { }); }; +/** 查询部门下拉树结构 */ +function getDeptTree() { + deptTreeSelect().then(response => { + deptOptions.value = response.data; + enabledDeptOptions.value = filterDisabledDept(JSON.parse(JSON.stringify(response.data))); + }); +}; + +/** 过滤禁用的部门 */ +function filterDisabledDept(deptList) { + return deptList.filter(dept => { + if (dept.disabled) { + return false; + } + if (dept.children && dept.children.length) { + dept.children = filterDisabledDept(dept.children); + } + return true; + }); +}; + /** 节点单击事件 */ function handleNodeClick(data) { queryParams.value.deptId = data.id;