修改在角色管理页修改菜单权限偶尔未选中问题

master
RuoYi 5 years ago
parent a5c170fa2a
commit 554beaf6e7
  1. 12
      ruoyi-ui/src/views/system/role/index.vue
  2. 6
      ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java
  3. 7
      ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java
  4. 8
      ruoyi/src/main/java/com/ruoyi/project/system/service/ISysMenuService.java
  5. 16
      ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java
  6. 2
      ruoyi/src/main/resources/mybatis/system/SysMenuMapper.xml

@ -369,15 +369,15 @@ export default {
/** 根据角色ID查询菜单树结构 */
getRoleMenuTreeselect(roleId) {
roleMenuTreeselect(roleId).then(response => {
this.getMenuTreeselect();
this.$refs.menu.setCheckedKeys(response.data);
this.menuOptions = response.menus;
this.$refs.menu.setCheckedKeys(response.checkedKeys);
});
},
/** 根据角色ID查询部门树结构 */
getRoleDeptTreeselect(roleId) {
roleDeptTreeselect(roleId).then(response => {
this.getDeptTreeselect();
this.$refs.dept.setCheckedKeys(response.data);
this.deptOptions = response.depts;
this.$refs.dept.setCheckedKeys(response.checkedKeys);
});
},
//
@ -407,8 +407,8 @@ export default {
},
//
reset() {
if (this.$refs.tree != undefined) {
this.$refs.tree.setCheckedKeys([]);
if (this.$refs.menu != undefined) {
this.$refs.menu.setCheckedKeys([]);
}
this.form = {
roleId: undefined,

@ -70,7 +70,11 @@ public class SysDeptController extends BaseController
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
{
return AjaxResult.success(deptService.selectDeptListByRoleId(roleId));
List<SysDept> depts = deptService.selectDeptList(new SysDept());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
return ajax;
}
/**

@ -80,7 +80,12 @@ public class SysMenuController extends BaseController
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
{
return AjaxResult.success(menuService.selectMenuListByRoleId(roleId));
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
return ajax;
}
/**

@ -13,6 +13,14 @@ import com.ruoyi.project.system.domain.vo.RouterVo;
*/
public interface ISysMenuService
{
/**
* 根据用户查询系统菜单列表
*
* @param userId 用户ID
* @return 菜单列表
*/
public List<SysMenu> selectMenuList(Long userId);
/**
* 根据用户查询系统菜单列表
*

@ -38,6 +38,18 @@ public class SysMenuServiceImpl implements ISysMenuService
@Autowired
private SysRoleMenuMapper roleMenuMapper;
/**
* 根据用户查询系统菜单列表
*
* @param userId 用户ID
* @return 菜单列表
*/
@Override
public List<SysMenu> selectMenuList(Long userId)
{
return selectMenuList(new SysMenu(), userId);
}
/**
* 查询系统菜单列表
*
@ -83,9 +95,9 @@ public class SysMenuServiceImpl implements ISysMenuService
}
/**
* 根据用户名称查询菜单
* 根据用户ID查询菜单
*
* @param username 用户名称
* @param userId 用户名称
* @return 菜单列表
*/
@Override

@ -117,7 +117,7 @@
update sys_menu
<set>
<if test="menuName != null and menuName != ''">menu_name = #{menuName},</if>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
<if test="path != null and path != ''">path = #{path},</if>
<if test="component != null and component != ''">component = #{component},</if>

Loading…
Cancel
Save