From 7216b56a5617fea1a1d451d578e7b2b3429e8368 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Wed, 11 Dec 2024 11:43:00 +0800
Subject: [PATCH] 用户管理过滤掉已禁用部门
---
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TreeSelect.java | 16 ++++++++++++++++
ruoyi-ui/src/views/system/user/index.vue | 19 +++++++++++++++++--
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TreeSelect.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TreeSelect.java
index 9dc1426..e3986d0 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TreeSelect.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TreeSelect.java
@@ -4,6 +4,8 @@
import java.util.List;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.ruoyi.common.core.constant.UserConstants;
+import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.domain.SysMenu;
@@ -22,6 +24,9 @@
/** 节点名称 */
private String label;
+ /** 节点禁用 */
+ private boolean disabled = false;
+
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
@@ -35,6 +40,7 @@
{
this.id = dept.getDeptId();
this.label = dept.getDeptName();
+ this.disabled = StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus());
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
@@ -65,6 +71,16 @@
this.label = label;
}
+ public boolean isDisabled()
+ {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled)
+ {
+ this.disabled = disabled;
+ }
+
public List<TreeSelect> getChildren()
{
return children;
diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue
index 6a0ffcf..8ca9711 100644
--- a/ruoyi-ui/src/views/system/user/index.vue
+++ b/ruoyi-ui/src/views/system/user/index.vue
@@ -105,7 +105,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="归属部门" prop="deptId">
- <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
+ <treeselect v-model="form.deptId" :options="enabledDeptOptions" :show-count="true" placeholder="请选择归属部门" />
</el-form-item>
</el-col>
</el-row>
@@ -230,8 +230,10 @@
userList: null,
// 弹出层标题
title: "",
- // 部门树选项
+ // 所有部门树选项
deptOptions: undefined,
+ // 过滤掉已禁用部门树选项
+ enabledDeptOptions: undefined,
// 是否显示弹出层
open: false,
// 部门名称
@@ -343,6 +345,19 @@
getDeptTree() {
deptTreeSelect().then(response => {
this.deptOptions = response.data;
+ this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data)));
+ });
+ },
+ // 过滤禁用的部门
+ filterDisabledDept(deptList) {
+ return deptList.filter(dept => {
+ if (dept.disabled) {
+ return false;
+ }
+ if (dept.children && dept.children.length) {
+ dept.children = this.filterDisabledDept(dept.children);
+ }
+ return true;
});
},
// 筛选节点
--
Gitblit v1.9.3