ruoyi-ui/src/store/modules/tagsView.js
@@ -38,6 +38,7 @@ }) }, DEL_OTHERS_CACHED_VIEWS: (state, view) => { const index = state.cachedViews.indexOf(view.name) if (index > -1) { state.cachedViews = state.cachedViews.slice(index, index + 1) } else { ruoyi/src/main/java/com/ruoyi/common/constant/UserConstants.java
@@ -19,13 +19,16 @@ public static final String EXCEPTION = "1"; /** 用户封禁状态 */ public static final String USER_BLOCKED = "1"; public static final String USER_DISABLE = "1"; /** 角色封禁状态 */ public static final String ROLE_BLOCKED = "1"; public static final String ROLE_DISABLE = "1"; /** 部门正常状态 */ public static final String DEPT_NORMAL = "0"; /** 部门停用状态 */ public static final String DEPT_DISABLE = "1"; /** 字典正常状态 */ public static final String DICT_NORMAL = "0"; ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.enums.BusinessType; import com.ruoyi.framework.web.controller.BaseController; @@ -109,6 +110,11 @@ { return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) { return AjaxResult.error("该部门包含未停用的子部门!"); } dept.setUpdateBy(SecurityUtils.getUsername()); return toAjax(deptService.updateDept(dept)); } ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java
@@ -44,6 +44,14 @@ public List<SysDept> selectChildrenDeptById(Long deptId); /** * 根据ID查询所有子部门(正常状态) * * @param deptId 部门ID * @return 子部门数 */ public int selectNormalChildrenDeptById(Long deptId); /** * 是否存在子节点 * * @param deptId 部门ID ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDeptService.java
@@ -52,6 +52,14 @@ public SysDept selectDeptById(Long deptId); /** * 根据ID查询所有子部门(正常状态) * * @param deptId 部门ID * @return 子部门数 */ public int selectNormalChildrenDeptById(Long deptId); /** * 是否存在部门子节点 * * @param deptId 部门ID ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java
@@ -109,6 +109,17 @@ } /** * 根据ID查询所有子部门(正常状态) * * @param deptId 部门ID * @return 子部门数 */ public int selectNormalChildrenDeptById(Long deptId) { return deptMapper.selectNormalChildrenDeptById(deptId); } /** * 是否存在子节点 * * @param deptId 部门ID ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml
@@ -71,6 +71,10 @@ select * from sys_dept where find_in_set(#{deptId}, ancestors) </select> <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="java.lang.Integer"> select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) </select> <select id="checkDeptNameUnique" resultMap="SysDeptResult"> <include refid="selectDeptVo"/> where dept_name=#{deptName} and parent_id = #{parentId}