diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java index 4a59e402..a762704c 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java @@ -4,8 +4,10 @@ import java.io.Serializable; import java.util.List; import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonInclude; +import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.utils.StringUtils; /** * Treeselect树结构实体类 @@ -22,6 +24,9 @@ public class TreeSelect implements Serializable /** 节点名称 */ private String label; + /** 节点禁用 */ + private boolean disabled = false; + /** 子节点 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children; @@ -35,6 +40,7 @@ public class TreeSelect implements Serializable { 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 @@ public class TreeSelect implements Serializable this.label = label; } + public boolean isDisabled() + { + return disabled; + } + + public void setDisabled(boolean disabled) + { + this.disabled = disabled; + } + public List getChildren() { return children; diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index 6a0ffcf3..8ca9711f 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -105,7 +105,7 @@ - + @@ -230,8 +230,10 @@ export default { userList: null, // 弹出层标题 title: "", - // 部门树选项 + // 所有部门树选项 deptOptions: undefined, + // 过滤掉已禁用部门树选项 + enabledDeptOptions: undefined, // 是否显示弹出层 open: false, // 部门名称 @@ -343,6 +345,19 @@ export default { 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; }); }, // 筛选节点