Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
90c41d49
Commit
90c41d49
authored
Jul 05, 2021
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
角色管理新增分配用户功能
parent
ce6bea4b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
681 additions
and
7 deletions
+681
-7
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
...va/com/ruoyi/web/controller/system/SysRoleController.java
+57
-0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
...ain/java/com/ruoyi/common/core/domain/entity/SysUser.java
+13
-0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
.../src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
+16
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java
...c/main/java/com/ruoyi/system/service/ISysRoleService.java
+27
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
...c/main/java/com/ruoyi/system/service/ISysUserService.java
+16
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
...ava/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
+48
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
...ava/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+27
-0
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
...system/src/main/resources/mapper/system/SysUserMapper.xml
+35
-0
ruoyi-ui/src/api/system/role.js
ruoyi-ui/src/api/system/role.js
+45
-0
ruoyi-ui/src/router/index.js
ruoyi-ui/src/router/index.js
+13
-0
ruoyi-ui/src/views/system/role/authUser.vue
ruoyi-ui/src/views/system/role/authUser.vue
+213
-0
ruoyi-ui/src/views/system/role/index.vue
ruoyi-ui/src/views/system/role/index.vue
+29
-7
ruoyi-ui/src/views/system/role/selectUser.vue
ruoyi-ui/src/views/system/role/selectUser.vue
+142
-0
No files found.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
View file @
90c41d49
...
@@ -17,6 +17,7 @@ import com.ruoyi.common.constant.UserConstants;
...
@@ -17,6 +17,7 @@ import com.ruoyi.common.constant.UserConstants;
import
com.ruoyi.common.core.controller.BaseController
;
import
com.ruoyi.common.core.controller.BaseController
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.domain.entity.SysRole
;
import
com.ruoyi.common.core.domain.entity.SysRole
;
import
com.ruoyi.common.core.domain.entity.SysUser
;
import
com.ruoyi.common.core.domain.model.LoginUser
;
import
com.ruoyi.common.core.domain.model.LoginUser
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.common.enums.BusinessType
;
import
com.ruoyi.common.enums.BusinessType
;
...
@@ -26,6 +27,7 @@ import com.ruoyi.common.utils.StringUtils;
...
@@ -26,6 +27,7 @@ import com.ruoyi.common.utils.StringUtils;
import
com.ruoyi.common.utils.poi.ExcelUtil
;
import
com.ruoyi.common.utils.poi.ExcelUtil
;
import
com.ruoyi.framework.web.service.SysPermissionService
;
import
com.ruoyi.framework.web.service.SysPermissionService
;
import
com.ruoyi.framework.web.service.TokenService
;
import
com.ruoyi.framework.web.service.TokenService
;
import
com.ruoyi.system.domain.SysUserRole
;
import
com.ruoyi.system.service.ISysRoleService
;
import
com.ruoyi.system.service.ISysRoleService
;
import
com.ruoyi.system.service.ISysUserService
;
import
com.ruoyi.system.service.ISysUserService
;
...
@@ -179,4 +181,59 @@ public class SysRoleController extends BaseController
...
@@ -179,4 +181,59 @@ public class SysRoleController extends BaseController
{
{
return
AjaxResult
.
success
(
roleService
.
selectRoleAll
());
return
AjaxResult
.
success
(
roleService
.
selectRoleAll
());
}
}
/**
* 查询已分配用户角色列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:role:list')"
)
@GetMapping
(
"/authUser/allocatedList"
)
public
TableDataInfo
allocatedList
(
SysUser
user
)
{
startPage
();
List
<
SysUser
>
list
=
userService
.
selectAllocatedList
(
user
);
return
getDataTable
(
list
);
}
/**
* 查询未分配用户角色列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:role:list')"
)
@GetMapping
(
"/authUser/unallocatedList"
)
public
TableDataInfo
unallocatedList
(
SysUser
user
)
{
startPage
();
List
<
SysUser
>
list
=
userService
.
selectUnallocatedList
(
user
);
return
getDataTable
(
list
);
}
/**
* 取消授权用户
*/
@PreAuthorize
(
"@ss.hasPermi('system:role:edit')"
)
@Log
(
title
=
"角色管理"
,
businessType
=
BusinessType
.
GRANT
)
@PutMapping
(
"/authUser/cancel"
)
public
AjaxResult
cancelAuthUser
(
@RequestBody
SysUserRole
userRole
)
{
return
toAjax
(
roleService
.
deleteAuthUser
(
userRole
));
}
/**
* 批量取消授权用户
*/
@Log
(
title
=
"角色管理"
,
businessType
=
BusinessType
.
GRANT
)
@PutMapping
(
"/authUser/cancelAll"
)
public
AjaxResult
cancelAuthUserAll
(
Long
roleId
,
Long
[]
userIds
)
{
return
toAjax
(
roleService
.
deleteAuthUsers
(
roleId
,
userIds
));
}
/**
* 批量选择用户授权
*/
@Log
(
title
=
"角色管理"
,
businessType
=
BusinessType
.
GRANT
)
@PutMapping
(
"/authUser/selectAll"
)
public
AjaxResult
selectAuthUserAll
(
Long
roleId
,
Long
[]
userIds
)
{
return
toAjax
(
roleService
.
insertAuthUsers
(
roleId
,
userIds
));
}
}
}
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
View file @
90c41d49
...
@@ -92,6 +92,9 @@ public class SysUser extends BaseEntity
...
@@ -92,6 +92,9 @@ public class SysUser extends BaseEntity
/** 岗位组 */
/** 岗位组 */
private
Long
[]
postIds
;
private
Long
[]
postIds
;
/** 角色ID */
private
Long
roleId
;
public
SysUser
()
public
SysUser
()
{
{
...
@@ -300,6 +303,16 @@ public class SysUser extends BaseEntity
...
@@ -300,6 +303,16 @@ public class SysUser extends BaseEntity
this
.
postIds
=
postIds
;
this
.
postIds
=
postIds
;
}
}
public
Long
getRoleId
()
{
return
roleId
;
}
public
void
setRoleId
(
Long
roleId
)
{
this
.
roleId
=
roleId
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
...
...
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
View file @
90c41d49
...
@@ -19,6 +19,22 @@ public interface SysUserMapper
...
@@ -19,6 +19,22 @@ public interface SysUserMapper
*/
*/
public
List
<
SysUser
>
selectUserList
(
SysUser
sysUser
);
public
List
<
SysUser
>
selectUserList
(
SysUser
sysUser
);
/**
* 根据条件分页查询未已配用户角色列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
public
List
<
SysUser
>
selectAllocatedList
(
SysUser
user
);
/**
* 根据条件分页查询未分配用户角色列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
public
List
<
SysUser
>
selectUnallocatedList
(
SysUser
user
);
/**
/**
* 通过用户名查询用户
* 通过用户名查询用户
*
*
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java
View file @
90c41d49
...
@@ -3,6 +3,7 @@ package com.ruoyi.system.service;
...
@@ -3,6 +3,7 @@ package com.ruoyi.system.service;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
import
com.ruoyi.common.core.domain.entity.SysRole
;
import
com.ruoyi.common.core.domain.entity.SysRole
;
import
com.ruoyi.system.domain.SysUserRole
;
/**
/**
* 角色业务层
* 角色业务层
...
@@ -136,4 +137,30 @@ public interface ISysRoleService
...
@@ -136,4 +137,30 @@ public interface ISysRoleService
* @return 结果
* @return 结果
*/
*/
public
int
deleteRoleByIds
(
Long
[]
roleIds
);
public
int
deleteRoleByIds
(
Long
[]
roleIds
);
/**
* 取消授权用户角色
*
* @param userRole 用户和角色关联信息
* @return 结果
*/
public
int
deleteAuthUser
(
SysUserRole
userRole
);
/**
* 批量取消授权用户角色
*
* @param roleId 角色ID
* @param userIds 需要取消授权的用户数据ID
* @return 结果
*/
public
int
deleteAuthUsers
(
Long
roleId
,
Long
[]
userIds
);
/**
* 批量选择授权用户角色
*
* @param roleId 角色ID
* @param userIds 需要删除的用户数据ID
* @return 结果
*/
public
int
insertAuthUsers
(
Long
roleId
,
Long
[]
userIds
);
}
}
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
View file @
90c41d49
...
@@ -18,6 +18,22 @@ public interface ISysUserService
...
@@ -18,6 +18,22 @@ public interface ISysUserService
*/
*/
public
List
<
SysUser
>
selectUserList
(
SysUser
user
);
public
List
<
SysUser
>
selectUserList
(
SysUser
user
);
/**
* 根据条件分页查询已分配用户角色列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
public
List
<
SysUser
>
selectAllocatedList
(
SysUser
user
);
/**
* 根据条件分页查询未分配用户角色列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
public
List
<
SysUser
>
selectUnallocatedList
(
SysUser
user
);
/**
/**
* 通过用户名查询用户
* 通过用户名查询用户
*
*
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
View file @
90c41d49
...
@@ -16,6 +16,7 @@ import com.ruoyi.common.utils.StringUtils;
...
@@ -16,6 +16,7 @@ import com.ruoyi.common.utils.StringUtils;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.system.domain.SysRoleDept
;
import
com.ruoyi.system.domain.SysRoleDept
;
import
com.ruoyi.system.domain.SysRoleMenu
;
import
com.ruoyi.system.domain.SysRoleMenu
;
import
com.ruoyi.system.domain.SysUserRole
;
import
com.ruoyi.system.mapper.SysRoleDeptMapper
;
import
com.ruoyi.system.mapper.SysRoleDeptMapper
;
import
com.ruoyi.system.mapper.SysRoleMapper
;
import
com.ruoyi.system.mapper.SysRoleMapper
;
import
com.ruoyi.system.mapper.SysRoleMenuMapper
;
import
com.ruoyi.system.mapper.SysRoleMenuMapper
;
...
@@ -350,4 +351,51 @@ public class SysRoleServiceImpl implements ISysRoleService
...
@@ -350,4 +351,51 @@ public class SysRoleServiceImpl implements ISysRoleService
roleDeptMapper
.
deleteRoleDept
(
roleIds
);
roleDeptMapper
.
deleteRoleDept
(
roleIds
);
return
roleMapper
.
deleteRoleByIds
(
roleIds
);
return
roleMapper
.
deleteRoleByIds
(
roleIds
);
}
}
/**
* 取消授权用户角色
*
* @param userRole 用户和角色关联信息
* @return 结果
*/
@Override
public
int
deleteAuthUser
(
SysUserRole
userRole
)
{
return
userRoleMapper
.
deleteUserRoleInfo
(
userRole
);
}
/**
* 批量取消授权用户角色
*
* @param roleId 角色ID
* @param userIds 需要取消授权的用户数据ID
* @return 结果
*/
@Override
public
int
deleteAuthUsers
(
Long
roleId
,
Long
[]
userIds
)
{
return
userRoleMapper
.
deleteUserRoleInfos
(
roleId
,
userIds
);
}
/**
* 批量选择授权用户角色
*
* @param roleId 角色ID
* @param userIds 需要删除的用户数据ID
* @return 结果
*/
@Override
public
int
insertAuthUsers
(
Long
roleId
,
Long
[]
userIds
)
{
// 新增用户与角色管理
List
<
SysUserRole
>
list
=
new
ArrayList
<
SysUserRole
>();
for
(
Long
userId
:
userIds
)
{
SysUserRole
ur
=
new
SysUserRole
();
ur
.
setUserId
(
userId
);
ur
.
setRoleId
(
roleId
);
list
.
add
(
ur
);
}
return
userRoleMapper
.
batchUserRole
(
list
);
}
}
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
View file @
90c41d49
...
@@ -66,6 +66,32 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -66,6 +66,32 @@ public class SysUserServiceImpl implements ISysUserService
return
userMapper
.
selectUserList
(
user
);
return
userMapper
.
selectUserList
(
user
);
}
}
/**
* 根据条件分页查询已分配用户角色列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
@Override
@DataScope
(
deptAlias
=
"d"
,
userAlias
=
"u"
)
public
List
<
SysUser
>
selectAllocatedList
(
SysUser
user
)
{
return
userMapper
.
selectAllocatedList
(
user
);
}
/**
* 根据条件分页查询未分配用户角色列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
@Override
@DataScope
(
deptAlias
=
"d"
,
userAlias
=
"u"
)
public
List
<
SysUser
>
selectUnallocatedList
(
SysUser
user
)
{
return
userMapper
.
selectUnallocatedList
(
user
);
}
/**
/**
* 通过用户名查询用户
* 通过用户名查询用户
*
*
...
@@ -248,6 +274,7 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -248,6 +274,7 @@ public class SysUserServiceImpl implements ISysUserService
* @param userId 用户ID
* @param userId 用户ID
* @param roleIds 角色组
* @param roleIds 角色组
*/
*/
@Override
public
void
insertUserAuth
(
Long
userId
,
Long
[]
roleIds
)
public
void
insertUserAuth
(
Long
userId
,
Long
[]
roleIds
)
{
{
userRoleMapper
.
deleteUserRoleByUserId
(
userId
);
userRoleMapper
.
deleteUserRoleByUserId
(
userId
);
...
...
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
View file @
90c41d49
...
@@ -81,6 +81,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -81,6 +81,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope}
${params.dataScope}
</select>
</select>
<select
id=
"selectAllocatedList"
parameterType=
"SysUser"
resultMap=
"SysUserResult"
>
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
where u.del_flag = '0' and r.role_id = #{roleId}
<if
test=
"userName != null and userName != ''"
>
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if
test=
"phonenumber != null and phonenumber != ''"
>
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select
id=
"selectUnallocatedList"
parameterType=
"SysUser"
resultMap=
"SysUserResult"
>
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
<if
test=
"userName != null and userName != ''"
>
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if
test=
"phonenumber != null and phonenumber != ''"
>
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select
id=
"selectUserByUserName"
parameterType=
"String"
resultMap=
"SysUserResult"
>
<select
id=
"selectUserByUserName"
parameterType=
"String"
resultMap=
"SysUserResult"
>
<include
refid=
"selectUserVo"
/>
<include
refid=
"selectUserVo"
/>
where u.user_name = #{userName}
where u.user_name = #{userName}
...
...
ruoyi-ui/src/api/system/role.js
View file @
90c41d49
...
@@ -72,4 +72,49 @@ export function exportRole(query) {
...
@@ -72,4 +72,49 @@ export function exportRole(query) {
method
:
'
get
'
,
method
:
'
get
'
,
params
:
query
params
:
query
})
})
}
// 查询角色已授权用户列表
export
function
allocatedUserList
(
query
)
{
return
request
({
url
:
'
/system/role/authUser/allocatedList
'
,
method
:
'
get
'
,
params
:
query
})
}
// 查询角色未授权用户列表
export
function
unallocatedUserList
(
query
)
{
return
request
({
url
:
'
/system/role/authUser/unallocatedList
'
,
method
:
'
get
'
,
params
:
query
})
}
// 取消用户授权角色
export
function
authUserCancel
(
data
)
{
return
request
({
url
:
'
/system/role/authUser/cancel
'
,
method
:
'
put
'
,
data
:
data
})
}
// 批量取消用户授权角色
export
function
authUserCancelAll
(
data
)
{
return
request
({
url
:
'
/system/role/authUser/cancelAll
'
,
method
:
'
put
'
,
params
:
data
})
}
// 授权用户选择
export
function
authUserSelectAll
(
data
)
{
return
request
({
url
:
'
/system/role/authUser/selectAll
'
,
method
:
'
put
'
,
params
:
data
})
}
}
\ No newline at end of file
ruoyi-ui/src/router/index.js
View file @
90c41d49
...
@@ -93,6 +93,19 @@ export const constantRoutes = [
...
@@ -93,6 +93,19 @@ export const constantRoutes = [
}
}
]
]
},
},
{
path
:
'
/auth
'
,
component
:
Layout
,
hidden
:
true
,
children
:
[
{
path
:
'
user/:roleId(
\\
d+)
'
,
component
:
(
resolve
)
=>
require
([
'
@/views/system/role/authUser
'
],
resolve
),
name
:
'
AuthUser
'
,
meta
:
{
title
:
'
分配用户
'
}
}
]
},
{
{
path
:
'
/dict
'
,
path
:
'
/dict
'
,
component
:
Layout
,
component
:
Layout
,
...
...
ruoyi-ui/src/views/system/role/authUser.vue
0 → 100644
View file @
90c41d49
<
template
>
<div
class=
"app-container"
>
<el-form
:model=
"queryParams"
ref=
"queryForm"
v-show=
"showSearch"
:inline=
"true"
>
<el-form-item
label=
"用户名称"
prop=
"userName"
>
<el-input
v-model=
"queryParams.userName"
placeholder=
"请输入用户名称"
clearable
size=
"small"
style=
"width: 240px"
@
keyup.enter.native=
"handleQuery"
/>
</el-form-item>
<el-form-item
label=
"手机号码"
prop=
"phonenumber"
>
<el-input
v-model=
"queryParams.phonenumber"
placeholder=
"请输入手机号码"
clearable
size=
"small"
style=
"width: 240px"
@
keyup.enter.native=
"handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button
type=
"primary"
icon=
"el-icon-search"
size=
"mini"
@
click=
"handleQuery"
>
搜索
</el-button>
<el-button
icon=
"el-icon-refresh"
size=
"mini"
@
click=
"resetQuery"
>
重置
</el-button>
</el-form-item>
</el-form>
<el-row
:gutter=
"10"
class=
"mb8"
>
<el-col
:span=
"1.5"
>
<el-button
type=
"primary"
plain
icon=
"el-icon-plus"
size=
"mini"
@
click=
"openSelectUser"
v-hasPermi=
"['system:role:add']"
>
添加用户
</el-button>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"danger"
plain
icon=
"el-icon-circle-close"
size=
"mini"
:disabled=
"multiple"
@
click=
"cancelAuthUserAll"
v-hasPermi=
"['system:role:remove']"
>
批量取消授权
</el-button>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"warning"
plain
icon=
"el-icon-close"
size=
"mini"
@
click=
"handleClose"
>
关闭
</el-button>
</el-col>
<right-toolbar
:showSearch.sync=
"showSearch"
@
queryTable=
"getList"
></right-toolbar>
</el-row>
<el-table
v-loading=
"loading"
:data=
"userList"
@
selection-change=
"handleSelectionChange"
>
<el-table-column
type=
"selection"
width=
"55"
align=
"center"
/>
<el-table-column
label=
"用户名称"
prop=
"userName"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"用户昵称"
prop=
"nickName"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"邮箱"
prop=
"email"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"手机"
prop=
"phonenumber"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"状态"
align=
"center"
prop=
"status"
>
<template
slot-scope=
"scope"
>
<dict-tag
:options=
"statusOptions"
:value=
"scope.row.status"
/>
</
template
>
</el-table-column>
<el-table-column
label=
"创建时间"
align=
"center"
prop=
"createTime"
width=
"180"
>
<
template
slot-scope=
"scope"
>
<span>
{{
parseTime
(
scope
.
row
.
createTime
)
}}
</span>
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
align=
"center"
class-name=
"small-padding fixed-width"
>
<
template
slot-scope=
"scope"
>
<el-button
size=
"mini"
type=
"text"
icon=
"el-icon-circle-close"
@
click=
"cancelAuthUser(scope.row)"
v-hasPermi=
"['system:role:remove']"
>
取消授权
</el-button>
</
template
>
</el-table-column>
</el-table>
<pagination
v-show=
"total>0"
:total=
"total"
:page.sync=
"queryParams.pageNum"
:limit.sync=
"queryParams.pageSize"
@
pagination=
"getList"
/>
<select-user
ref=
"select"
:roleId=
"queryParams.roleId"
@
ok=
"handleQuery"
/>
</div>
</template>
<
script
>
import
{
allocatedUserList
,
authUserCancel
,
authUserCancelAll
}
from
"
@/api/system/role
"
;
import
selectUser
from
"
./selectUser
"
;
export
default
{
name
:
"
AuthUser
"
,
components
:
{
selectUser
},
data
()
{
return
{
// 遮罩层
loading
:
true
,
// 选中用户组
userIds
:
[],
// 非多个禁用
multiple
:
true
,
// 显示搜索条件
showSearch
:
true
,
// 总条数
total
:
0
,
// 用户表格数据
userList
:
[],
// 状态数据字典
statusOptions
:
[],
// 查询参数
queryParams
:
{
pageNum
:
1
,
pageSize
:
10
,
roleId
:
undefined
,
userName
:
undefined
,
phonenumber
:
undefined
}
};
},
created
()
{
const
roleId
=
this
.
$route
.
params
&&
this
.
$route
.
params
.
roleId
;
if
(
roleId
)
{
this
.
queryParams
.
roleId
=
roleId
;
this
.
getList
();
this
.
getDicts
(
"
sys_normal_disable
"
).
then
(
response
=>
{
this
.
statusOptions
=
response
.
data
;
});
}
},
methods
:
{
/** 查询授权用户列表 */
getList
()
{
this
.
loading
=
true
;
allocatedUserList
(
this
.
queryParams
).
then
(
response
=>
{
this
.
userList
=
response
.
rows
;
this
.
total
=
response
.
total
;
this
.
loading
=
false
;
}
);
},
// 返回按钮
handleClose
()
{
this
.
$store
.
dispatch
(
"
tagsView/delView
"
,
this
.
$route
);
this
.
$router
.
push
({
path
:
"
/system/role
"
});
},
/** 搜索按钮操作 */
handleQuery
()
{
this
.
queryParams
.
pageNum
=
1
;
this
.
getList
();
},
/** 重置按钮操作 */
resetQuery
()
{
this
.
resetForm
(
"
queryForm
"
);
this
.
handleQuery
();
},
// 多选框选中数据
handleSelectionChange
(
selection
)
{
this
.
userIds
=
selection
.
map
(
item
=>
item
.
userId
)
this
.
multiple
=
!
selection
.
length
},
/** 打开授权用户表弹窗 */
openSelectUser
()
{
this
.
$refs
.
select
.
show
();
},
/** 取消授权按钮操作 */
cancelAuthUser
(
row
)
{
const
roleId
=
this
.
queryParams
.
roleId
;
this
.
$confirm
(
'
确认要取消该用户"
'
+
row
.
userName
+
'
"角色吗?
'
,
"
警告
"
,
{
confirmButtonText
:
"
确定
"
,
cancelButtonText
:
"
取消
"
,
type
:
"
warning
"
}).
then
(
function
()
{
return
authUserCancel
({
userId
:
row
.
userId
,
roleId
:
roleId
});
}).
then
(()
=>
{
this
.
getList
();
this
.
msgSuccess
(
"
取消授权成功
"
);
}).
catch
(()
=>
{});
},
/** 批量取消授权按钮操作 */
cancelAuthUserAll
(
row
)
{
const
roleId
=
this
.
queryParams
.
roleId
;
const
userIds
=
this
.
userIds
.
join
(
"
,
"
);
this
.
$confirm
(
'
是否取消选中用户授权数据项?
'
,
"
警告
"
,
{
confirmButtonText
:
"
确定
"
,
cancelButtonText
:
"
取消
"
,
type
:
"
warning
"
}).
then
(()
=>
{
return
authUserCancelAll
({
roleId
:
roleId
,
userIds
:
userIds
});
}).
then
(()
=>
{
this
.
getList
();
this
.
msgSuccess
(
"
取消授权成功
"
);
}).
catch
(()
=>
{});
}
}
};
</
script
>
\ No newline at end of file
ruoyi-ui/src/views/system/role/index.vue
View file @
90c41d49
...
@@ -132,13 +132,6 @@
...
@@ -132,13 +132,6 @@
@
click=
"handleUpdate(scope.row)"
@
click=
"handleUpdate(scope.row)"
v-hasPermi=
"['system:role:edit']"
v-hasPermi=
"['system:role:edit']"
>
修改
</el-button>
>
修改
</el-button>
<el-button
size=
"mini"
type=
"text"
icon=
"el-icon-circle-check"
@
click=
"handleDataScope(scope.row)"
v-hasPermi=
"['system:role:edit']"
>
数据权限
</el-button>
<el-button
<el-button
size=
"mini"
size=
"mini"
type=
"text"
type=
"text"
...
@@ -146,6 +139,17 @@
...
@@ -146,6 +139,17 @@
@
click=
"handleDelete(scope.row)"
@
click=
"handleDelete(scope.row)"
v-hasPermi=
"['system:role:remove']"
v-hasPermi=
"['system:role:remove']"
>
删除
</el-button>
>
删除
</el-button>
<el-dropdown
size=
"mini"
@
command=
"(command) => handleCommand(command, scope.row)"
>
<span
class=
"el-dropdown-link"
>
<i
class=
"el-icon-d-arrow-right el-icon--right"
></i>
更多
</span>
<el-dropdown-menu
slot=
"dropdown"
>
<el-dropdown-item
command=
"handleDataScope"
icon=
"el-icon-circle-check"
v-hasPermi=
"['system:role:edit']"
>
数据权限
</el-dropdown-item>
<el-dropdown-item
command=
"handleAuthUser"
icon=
"el-icon-user"
v-hasPermi=
"['system:role:edit']"
>
分配用户
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
</el-table>
</el-table>
...
@@ -469,6 +473,19 @@ export default {
...
@@ -469,6 +473,19 @@ export default {
this
.
single
=
selection
.
length
!=
1
this
.
single
=
selection
.
length
!=
1
this
.
multiple
=
!
selection
.
length
this
.
multiple
=
!
selection
.
length
},
},
// 更多操作触发
handleCommand
(
command
,
row
)
{
switch
(
command
)
{
case
"
handleDataScope
"
:
this
.
handleDataScope
(
row
);
break
;
case
"
handleAuthUser
"
:
this
.
handleAuthUser
(
row
);
break
;
default
:
break
;
}
},
// 树权限(展开/折叠)
// 树权限(展开/折叠)
handleCheckedTreeExpand
(
value
,
type
)
{
handleCheckedTreeExpand
(
value
,
type
)
{
if
(
type
==
'
menu
'
)
{
if
(
type
==
'
menu
'
)
{
...
@@ -548,6 +565,11 @@ export default {
...
@@ -548,6 +565,11 @@ export default {
this
.
title
=
"
分配数据权限
"
;
this
.
title
=
"
分配数据权限
"
;
});
});
},
},
/** 分配用户操作 */
handleAuthUser
:
function
(
row
)
{
const
roleId
=
row
.
roleId
;
this
.
$router
.
push
(
"
/auth/user/
"
+
roleId
);
},
/** 提交按钮 */
/** 提交按钮 */
submitForm
:
function
()
{
submitForm
:
function
()
{
this
.
$refs
[
"
form
"
].
validate
(
valid
=>
{
this
.
$refs
[
"
form
"
].
validate
(
valid
=>
{
...
...
ruoyi-ui/src/views/system/role/selectUser.vue
0 → 100644
View file @
90c41d49
<
template
>
<!-- 授权用户 -->
<el-dialog
title=
"选择用户"
:visible.sync=
"visible"
width=
"800px"
top=
"5vh"
append-to-body
>
<el-form
:model=
"queryParams"
ref=
"queryForm"
:inline=
"true"
>
<el-form-item
label=
"用户名称"
prop=
"userName"
>
<el-input
v-model=
"queryParams.userName"
placeholder=
"请输入用户名称"
clearable
size=
"small"
@
keyup.enter.native=
"handleQuery"
/>
</el-form-item>
<el-form-item
label=
"手机号码"
prop=
"phonenumber"
>
<el-input
v-model=
"queryParams.phonenumber"
placeholder=
"请输入手机号码"
clearable
size=
"small"
@
keyup.enter.native=
"handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button
type=
"primary"
icon=
"el-icon-search"
size=
"mini"
@
click=
"handleQuery"
>
搜索
</el-button>
<el-button
icon=
"el-icon-refresh"
size=
"mini"
@
click=
"resetQuery"
>
重置
</el-button>
</el-form-item>
</el-form>
<el-row>
<el-table
@
row-click=
"clickRow"
ref=
"table"
:data=
"userList"
@
selection-change=
"handleSelectionChange"
height=
"260px"
>
<el-table-column
type=
"selection"
width=
"55"
></el-table-column>
<el-table-column
label=
"用户名称"
prop=
"userName"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"用户昵称"
prop=
"nickName"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"邮箱"
prop=
"email"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"手机"
prop=
"phonenumber"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"状态"
align=
"center"
prop=
"status"
>
<template
slot-scope=
"scope"
>
<dict-tag
:options=
"statusOptions"
:value=
"scope.row.status"
/>
</
template
>
</el-table-column>
<el-table-column
label=
"创建时间"
align=
"center"
prop=
"createTime"
width=
"180"
>
<
template
slot-scope=
"scope"
>
<span>
{{
parseTime
(
scope
.
row
.
createTime
)
}}
</span>
</
template
>
</el-table-column>
</el-table>
<pagination
v-show=
"total>0"
:total=
"total"
:page.sync=
"queryParams.pageNum"
:limit.sync=
"queryParams.pageSize"
@
pagination=
"getList"
/>
</el-row>
<div
slot=
"footer"
class=
"dialog-footer"
>
<el-button
type=
"primary"
@
click=
"handleSelectUser"
>
确 定
</el-button>
<el-button
@
click=
"visible = false"
>
取 消
</el-button>
</div>
</el-dialog>
</template>
<
script
>
import
{
unallocatedUserList
,
authUserSelectAll
}
from
"
@/api/system/role
"
;
export
default
{
props
:
{
// 角色编号
roleId
:
{
type
:
Number
}
},
data
()
{
return
{
// 遮罩层
visible
:
false
,
// 选中数组值
userIds
:
[],
// 总条数
total
:
0
,
// 未授权用户数据
userList
:
[],
// 状态数据字典
statusOptions
:
[],
// 查询参数
queryParams
:
{
pageNum
:
1
,
pageSize
:
10
,
roleId
:
undefined
,
userName
:
undefined
,
phonenumber
:
undefined
}
};
},
created
()
{
this
.
getDicts
(
"
sys_normal_disable
"
).
then
(
response
=>
{
this
.
statusOptions
=
response
.
data
;
});
},
methods
:
{
// 显示弹框
show
()
{
this
.
queryParams
.
roleId
=
this
.
roleId
;
this
.
getList
();
this
.
visible
=
true
;
},
clickRow
(
row
)
{
this
.
$refs
.
table
.
toggleRowSelection
(
row
);
},
// 多选框选中数据
handleSelectionChange
(
selection
)
{
this
.
userIds
=
selection
.
map
(
item
=>
item
.
userId
);
},
// 查询表数据
getList
()
{
unallocatedUserList
(
this
.
queryParams
).
then
(
res
=>
{
this
.
userList
=
res
.
rows
;
this
.
total
=
res
.
total
;
});
},
/** 搜索按钮操作 */
handleQuery
()
{
this
.
queryParams
.
pageNum
=
1
;
this
.
getList
();
},
/** 重置按钮操作 */
resetQuery
()
{
this
.
resetForm
(
"
queryForm
"
);
this
.
handleQuery
();
},
/** 选择授权用户操作 */
handleSelectUser
()
{
const
roleId
=
this
.
queryParams
.
roleId
;
const
userIds
=
this
.
userIds
.
join
(
"
,
"
);
authUserSelectAll
({
roleId
:
roleId
,
userIds
:
userIds
}).
then
(
res
=>
{
this
.
msgSuccess
(
res
.
msg
);
if
(
res
.
code
===
200
)
{
this
.
visible
=
false
;
this
.
$emit
(
"
ok
"
);
}
});
}
}
};
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment