From c89ba258bcea60f6bb7c6bceb782495b7e1a1a40 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期三, 11 十二月 2024 11:20:59 +0800
Subject: [PATCH] 用户管理过滤掉已禁用部门(IB5H7F)

---
 src/views/system/user/index.vue |   31 +++++++++++++++++++++++--------
 1 files 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 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="褰掑睘閮ㄩ棬" prop="deptId">
-              <el-tree-select v-model="form.deptId" :data="deptOptions" :props="{ value: 'id', label: 'label', children: 'children' }" value-key="id" placeholder="璇烽�夋嫨褰掑睘閮ㄩ棬" check-strictly />
+              <el-tree-select v-model="form.deptId" :data="enabledDeptOptions" :props="{ value: 'id', label: 'label', children: 'children' }" value-key="id" placeholder="璇烽�夋嫨褰掑睘閮ㄩ棬" check-strictly />
             </el-form-item>
           </el-col>
         </el-row>
@@ -237,6 +237,7 @@
 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 @@
   proxy.$refs["deptTreeRef"].filter(val);
 });
 
-/** 鏌ヨ閮ㄩ棬涓嬫媺鏍戠粨鏋� */
-function getDeptTree() {
-  deptTreeSelect().then(response => {
-    deptOptions.value = response.data;
-  });
-};
-
 /** 鏌ヨ鐢ㄦ埛鍒楄〃 */
 function getList() {
   loading.value = true;
@@ -315,6 +309,27 @@
   });
 };
 
+/** 鏌ヨ閮ㄩ棬涓嬫媺鏍戠粨鏋� */
+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;

--
Gitblit v1.9.3