mirror of https://gitee.com/y_project/RuoYi.git
用户分配角色不允许选择超级管理员角色
parent
18a7915079
commit
23b98a3ef8
|
@ -24,7 +24,6 @@ import com.ruoyi.framework.shiro.service.SysPasswordService;
|
|||
import com.ruoyi.framework.util.ShiroUtils;
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import com.ruoyi.system.service.ISysPostService;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
@ -212,9 +211,9 @@ public class SysUserController extends BaseController
|
|||
{
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
// 获取用户所属的角色列表
|
||||
List<SysUserRole> userRoles = userService.selectUserRoleByUserId(userId);
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
mmap.put("user", user);
|
||||
mmap.put("userRoles", userRoles);
|
||||
mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
return prefix + "/authRole";
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ var table = {
|
|||
clickToSelect: false,
|
||||
singleSelect: false,
|
||||
mobileResponsive: true,
|
||||
maintainSelected: false,
|
||||
rememberSelected: false,
|
||||
fixedColumns: false,
|
||||
fixedNumber: 0,
|
||||
|
@ -119,6 +120,7 @@ var table = {
|
|||
onDblClickCell: options.onDblClickCell, // 双击某格触发的事件
|
||||
onEditableSave: options.onEditableSave, // 行内编辑保存的事件
|
||||
onExpandRow: options.onExpandRow, // 点击详细视图的事件
|
||||
maintainSelected: options.maintainSelected, // 前端翻页时保留所选行
|
||||
rememberSelected: options.rememberSelected, // 启用翻页记住前面的选择
|
||||
fixedColumns: options.fixedColumns, // 是否启用冻结列(左侧)
|
||||
fixedNumber: options.fixedNumber, // 列冻结的个数(左侧)
|
||||
|
|
|
@ -47,36 +47,42 @@
|
|||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var prefix = ctx + "system/user/authRole";
|
||||
var userRoles = [[${userRoles}]]
|
||||
var roles = [[${roles}]]
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
url: ctx + "system/role/list",
|
||||
data: roles,
|
||||
sidePagination: "client",
|
||||
sortName: "roleSort",
|
||||
showSearch: false,
|
||||
showRefresh: false,
|
||||
showToggle: false,
|
||||
showColumns: false,
|
||||
clickToSelect: true,
|
||||
maintainSelected: true,
|
||||
columns: [{
|
||||
checkbox: true,
|
||||
formatter:function (value, row, index) {
|
||||
for (var i = 0; i < userRoles.length; i++) {
|
||||
if (userRoles[i].roleId == row.roleId) {
|
||||
return { checked: true };
|
||||
if($.common.isEmpty(value)) {
|
||||
return { checked: row.flag };
|
||||
} else {
|
||||
return { checked: value }
|
||||
}
|
||||
}
|
||||
return { checked: false };
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'roleId',
|
||||
title: '角色编号'
|
||||
},
|
||||
{
|
||||
field: 'roleSort',
|
||||
title: '排序',
|
||||
sortable: true,
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
field: 'roleName',
|
||||
title: '角色名称',
|
||||
sortable: true
|
||||
title: '角色名称'
|
||||
},
|
||||
{
|
||||
field: 'roleKey',
|
||||
|
|
Loading…
Reference in New Issue