Selaa lähdekoodia

用户管理过滤掉已禁用部门

RuoYi 1 vuosi sitten
vanhempi
commit
7216b56a56

+ 16 - 0
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TreeSelect.java

@@ -4,6 +4,8 @@ import java.io.Serializable;
4 4
 import java.util.List;
5 5
 import java.util.stream.Collectors;
6 6
 import com.fasterxml.jackson.annotation.JsonInclude;
7
+import com.ruoyi.common.core.constant.UserConstants;
8
+import com.ruoyi.common.core.utils.StringUtils;
7 9
 import com.ruoyi.system.api.domain.SysDept;
8 10
 import com.ruoyi.system.domain.SysMenu;
9 11
 
@@ -22,6 +24,9 @@ public class TreeSelect implements Serializable
22 24
     /** 节点名称 */
23 25
     private String label;
24 26
 
27
+    /** 节点禁用 */
28
+    private boolean disabled = false;
29
+
25 30
     /** 子节点 */
26 31
     @JsonInclude(JsonInclude.Include.NON_EMPTY)
27 32
     private List<TreeSelect> children;
@@ -35,6 +40,7 @@ public class TreeSelect implements Serializable
35 40
     {
36 41
         this.id = dept.getDeptId();
37 42
         this.label = dept.getDeptName();
43
+        this.disabled = StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus());
38 44
         this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
39 45
     }
40 46
 
@@ -65,6 +71,16 @@ public class TreeSelect implements Serializable
65 71
         this.label = label;
66 72
     }
67 73
 
74
+    public boolean isDisabled()
75
+    {
76
+        return disabled;
77
+    }
78
+
79
+    public void setDisabled(boolean disabled)
80
+    {
81
+        this.disabled = disabled;
82
+    }
83
+
68 84
     public List<TreeSelect> getChildren()
69 85
     {
70 86
         return children;

+ 17 - 2
ruoyi-ui/src/views/system/user/index.vue

@@ -105,7 +105,7 @@
105 105
           </el-col>
106 106
           <el-col :span="12">
107 107
             <el-form-item label="归属部门" prop="deptId">
108
-              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
108
+              <treeselect v-model="form.deptId" :options="enabledDeptOptions" :show-count="true" placeholder="请选择归属部门" />
109 109
             </el-form-item>
110 110
           </el-col>
111 111
         </el-row>
@@ -230,8 +230,10 @@ export default {
230 230
       userList: null,
231 231
       // 弹出层标题
232 232
       title: "",
233
-      // 部门树选项
233
+      // 所有部门树选项
234 234
       deptOptions: undefined,
235
+      // 过滤掉已禁用部门树选项
236
+      enabledDeptOptions: undefined,
235 237
       // 是否显示弹出层
236 238
       open: false,
237 239
       // 部门名称
@@ -343,6 +345,19 @@ export default {
343 345
     getDeptTree() {
344 346
       deptTreeSelect().then(response => {
345 347
         this.deptOptions = response.data;
348
+        this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data)));
349
+      });
350
+    },
351
+    // 过滤禁用的部门
352
+    filterDisabledDept(deptList) {
353
+      return deptList.filter(dept => {
354
+        if (dept.disabled) {
355
+          return false;
356
+        }
357
+        if (dept.children && dept.children.length) {
358
+          dept.children = this.filterDisabledDept(dept.children);
359
+        }
360
+        return true;
346 361
       });
347 362
     },
348 363
     // 筛选节点