Merge branch 'master' of https://gitee.com/y_project/RuoYi-Cloud
This commit is contained in:
commit
d881274be7
2
pom.xml
2
pom.xml
|
|
@ -27,7 +27,7 @@
|
||||||
<swagger.core.version>1.6.2</swagger.core.version>
|
<swagger.core.version>1.6.2</swagger.core.version>
|
||||||
<tobato.version>1.26.5</tobato.version>
|
<tobato.version>1.26.5</tobato.version>
|
||||||
<kaptcha.version>2.3.2</kaptcha.version>
|
<kaptcha.version>2.3.2</kaptcha.version>
|
||||||
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
|
<pagehelper.boot.version>1.3.1</pagehelper.boot.version>
|
||||||
<druid.version>1.2.6</druid.version>
|
<druid.version>1.2.6</druid.version>
|
||||||
<dynamic-ds.version>3.4.0</dynamic-ds.version>
|
<dynamic-ds.version>3.4.0</dynamic-ds.version>
|
||||||
<commons.io.version>2.10.0</commons.io.version>
|
<commons.io.version>2.10.0</commons.io.version>
|
||||||
|
|
|
||||||
|
|
@ -67,15 +67,18 @@ public class PageDomain
|
||||||
|
|
||||||
public void setIsAsc(String isAsc)
|
public void setIsAsc(String isAsc)
|
||||||
{
|
{
|
||||||
// 兼容前端排序类型
|
if (StringUtils.isNotEmpty(isAsc))
|
||||||
if ("ascending".equals(isAsc))
|
|
||||||
{
|
{
|
||||||
isAsc = "asc";
|
// 兼容前端排序类型
|
||||||
|
if ("ascending".equals(isAsc))
|
||||||
|
{
|
||||||
|
isAsc = "asc";
|
||||||
|
}
|
||||||
|
else if ("descending".equals(isAsc))
|
||||||
|
{
|
||||||
|
isAsc = "desc";
|
||||||
|
}
|
||||||
|
this.isAsc = isAsc;
|
||||||
}
|
}
|
||||||
else if ("descending".equals(isAsc))
|
|
||||||
{
|
|
||||||
isAsc = "desc";
|
|
||||||
}
|
|
||||||
this.isAsc = isAsc;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -246,4 +246,31 @@ public class SysUserController extends BaseController
|
||||||
user.setUpdateBy(SecurityUtils.getUsername());
|
user.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(userService.updateUserStatus(user));
|
return toAjax(userService.updateUserStatus(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户编号获取授权角色
|
||||||
|
*/
|
||||||
|
@PreAuthorize(hasPermi = "system:user:query")
|
||||||
|
@GetMapping("/authRole/{userId}")
|
||||||
|
public AjaxResult authRole(@PathVariable("userId") Long userId)
|
||||||
|
{
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
SysUser user = userService.selectUserById(userId);
|
||||||
|
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||||
|
ajax.put("user", user);
|
||||||
|
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户授权角色
|
||||||
|
*/
|
||||||
|
@PreAuthorize(hasPermi = "system:user:edit")
|
||||||
|
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||||
|
@PutMapping("/authRole")
|
||||||
|
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
||||||
|
{
|
||||||
|
userService.insertUserAuth(userId, roleIds);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,15 @@ public interface ISysRoleService
|
||||||
public List<SysRole> selectRoleList(SysRole role);
|
public List<SysRole> selectRoleList(SysRole role);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID查询角色
|
* 根据用户ID查询角色列表
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 角色列表
|
||||||
|
*/
|
||||||
|
public List<SysRole> selectRolesByUserId(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询角色权限
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 权限列表
|
* @return 权限列表
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,14 @@ public interface ISysUserService
|
||||||
*/
|
*/
|
||||||
public int updateUser(SysUser user);
|
public int updateUser(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户授权角色
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param roleIds 角色组
|
||||||
|
*/
|
||||||
|
public void insertUserAuth(Long userId, Long[] roleIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户状态
|
* 修改用户状态
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,31 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||||
return roleMapper.selectRoleList(role);
|
return roleMapper.selectRoleList(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询角色
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 角色列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysRole> selectRolesByUserId(Long userId)
|
||||||
|
{
|
||||||
|
List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId);
|
||||||
|
List<SysRole> roles = selectRoleAll();
|
||||||
|
for (SysRole role : roles)
|
||||||
|
{
|
||||||
|
for (SysRole userRole : userRoles)
|
||||||
|
{
|
||||||
|
if (role.getRoleId().longValue() == userRole.getRoleId().longValue())
|
||||||
|
{
|
||||||
|
role.setFlag(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID查询权限
|
* 根据用户ID查询权限
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -242,6 +242,18 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
return userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户授权角色
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param roleIds 角色组
|
||||||
|
*/
|
||||||
|
public void insertUserAuth(Long userId, Long[] roleIds)
|
||||||
|
{
|
||||||
|
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||||
|
insertUserRole(userId, roleIds);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户状态
|
* 修改用户状态
|
||||||
*
|
*
|
||||||
|
|
@ -356,6 +368,32 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户角色信息
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param roleIds 角色组
|
||||||
|
*/
|
||||||
|
public void insertUserRole(Long userId, Long[] roleIds)
|
||||||
|
{
|
||||||
|
if (StringUtils.isNotNull(roleIds))
|
||||||
|
{
|
||||||
|
// 新增用户与角色管理
|
||||||
|
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||||
|
for (Long roleId : roleIds)
|
||||||
|
{
|
||||||
|
SysUserRole ur = new SysUserRole();
|
||||||
|
ur.setUserId(userId);
|
||||||
|
ur.setRoleId(roleId);
|
||||||
|
list.add(ur);
|
||||||
|
}
|
||||||
|
if (list.size() > 0)
|
||||||
|
{
|
||||||
|
userRoleMapper.batchUserRole(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID删除用户
|
* 通过用户ID删除用户
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -108,3 +108,20 @@ export function uploadAvatar(data) {
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询授权角色
|
||||||
|
export function getAuthRole(userId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/authRole/' + userId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存授权角色
|
||||||
|
export function updateAuthRole(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/authRole',
|
||||||
|
method: 'put',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,13 @@
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: inherit;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.1;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
.el-dialog:not(.is-fullscreen){
|
.el-dialog:not(.is-fullscreen){
|
||||||
margin-top: 6vh !important;
|
margin-top: 6vh !important;
|
||||||
}
|
}
|
||||||
|
|
@ -120,6 +127,17 @@
|
||||||
width: inherit;
|
width: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 表格更多操作下拉样式 */
|
||||||
|
.el-table .el-dropdown-link {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #1890ff;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-table .el-dropdown, .el-icon-arrow-down {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.el-tree-node__content > .el-checkbox {
|
.el-tree-node__content > .el-checkbox {
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<template v-for="(item, index) in options">
|
||||||
|
<template v-if="values.includes(item.dictValue)">
|
||||||
|
<span
|
||||||
|
v-if="item.listClass == 'default' || item.listClass == ''"
|
||||||
|
:key="item.dictValue"
|
||||||
|
:index="index"
|
||||||
|
:class="item.cssClass"
|
||||||
|
>{{ item.dictLabel }}</span
|
||||||
|
>
|
||||||
|
<el-tag
|
||||||
|
v-else
|
||||||
|
:key="item.dictValue"
|
||||||
|
:index="index"
|
||||||
|
:type="item.listClass == 'primary' ? '' : item.listClass"
|
||||||
|
:class="item.cssClass"
|
||||||
|
>
|
||||||
|
{{ item.dictLabel }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "DictTag",
|
||||||
|
props: {
|
||||||
|
options: {
|
||||||
|
type: Array,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
value: [String, Array],
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
values() {
|
||||||
|
if (this.value) {
|
||||||
|
return Array.isArray(this.value) ? this.value : [this.value];
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.el-tag + .el-tag {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -19,9 +19,11 @@ import { getDicts } from "@/api/system/dict/data";
|
||||||
import { getConfigKey } from "@/api/system/config";
|
import { getConfigKey } from "@/api/system/config";
|
||||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
|
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
|
||||||
import Pagination from "@/components/Pagination";
|
import Pagination from "@/components/Pagination";
|
||||||
// 自定义表格工具扩展
|
// 自定义表格工具组件
|
||||||
import RightToolbar from "@/components/RightToolbar"
|
import RightToolbar from "@/components/RightToolbar"
|
||||||
// 头部标签插件
|
// 字典标签组件
|
||||||
|
import DictTag from '@/components/DictTag'
|
||||||
|
// 头部标签组件
|
||||||
import VueMeta from 'vue-meta'
|
import VueMeta from 'vue-meta'
|
||||||
|
|
||||||
// 全局方法挂载
|
// 全局方法挂载
|
||||||
|
|
@ -48,6 +50,7 @@ Vue.prototype.msgInfo = function (msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 全局组件挂载
|
// 全局组件挂载
|
||||||
|
Vue.component('DictTag', DictTag)
|
||||||
Vue.component('Pagination', Pagination)
|
Vue.component('Pagination', Pagination)
|
||||||
Vue.component('RightToolbar', RightToolbar)
|
Vue.component('RightToolbar', RightToolbar)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,19 @@ export const constantRoutes = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/auth',
|
||||||
|
component: Layout,
|
||||||
|
hidden: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'role/:userId(\\d+)',
|
||||||
|
component: (resolve) => require(['@/views/system/user/authRole'], resolve),
|
||||||
|
name: 'AuthRole',
|
||||||
|
meta: { title: '分配角色'}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/dict',
|
path: '/dict',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,19 @@
|
||||||
<el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<el-table-column label="字典编码" align="center" prop="dictCode" />
|
<el-table-column label="字典编码" align="center" prop="dictCode" />
|
||||||
<el-table-column label="字典标签" align="center" prop="dictLabel" />
|
<el-table-column label="字典标签" align="center" prop="dictLabel">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span v-if="scope.row.listClass == '' || scope.row.listClass == 'default'">{{scope.row.dictLabel}}</span>
|
||||||
|
<el-tag v-else :type="scope.row.listClass == 'primary' ? '' : scope.row.listClass">{{scope.row.dictLabel}}</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="字典键值" align="center" prop="dictValue" />
|
<el-table-column label="字典键值" align="center" prop="dictValue" />
|
||||||
<el-table-column label="字典排序" align="center" prop="dictSort" />
|
<el-table-column label="字典排序" align="center" prop="dictSort" />
|
||||||
<el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
|
<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="remark" :show-overflow-tooltip="true" />
|
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
|
@ -135,9 +144,22 @@
|
||||||
<el-form-item label="数据键值" prop="dictValue">
|
<el-form-item label="数据键值" prop="dictValue">
|
||||||
<el-input v-model="form.dictValue" placeholder="请输入数据键值" />
|
<el-input v-model="form.dictValue" placeholder="请输入数据键值" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="样式属性" prop="cssClass">
|
||||||
|
<el-input v-model="form.cssClass" placeholder="请输入样式属性" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="显示排序" prop="dictSort">
|
<el-form-item label="显示排序" prop="dictSort">
|
||||||
<el-input-number v-model="form.dictSort" controls-position="right" :min="0" />
|
<el-input-number v-model="form.dictSort" controls-position="right" :min="0" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="回显样式" prop="listClass">
|
||||||
|
<el-select v-model="form.listClass">
|
||||||
|
<el-option
|
||||||
|
v-for="item in listClassOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio
|
<el-radio
|
||||||
|
|
@ -187,6 +209,33 @@ export default {
|
||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
|
// 数据标签回显样式
|
||||||
|
listClassOptions: [
|
||||||
|
{
|
||||||
|
value: "default",
|
||||||
|
label: "默认"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "primary",
|
||||||
|
label: "主要"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "success",
|
||||||
|
label: "成功"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "info",
|
||||||
|
label: "信息"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "warning",
|
||||||
|
label: "警告"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "danger",
|
||||||
|
label: "危险"
|
||||||
|
}
|
||||||
|
],
|
||||||
// 状态数据字典
|
// 状态数据字典
|
||||||
statusOptions: [],
|
statusOptions: [],
|
||||||
// 类型数据字典
|
// 类型数据字典
|
||||||
|
|
@ -247,10 +296,6 @@ export default {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 数据状态字典翻译
|
|
||||||
statusFormat(row, column) {
|
|
||||||
return this.selectDictLabel(this.statusOptions, row.status);
|
|
||||||
},
|
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false;
|
this.open = false;
|
||||||
|
|
@ -262,6 +307,8 @@ export default {
|
||||||
dictCode: undefined,
|
dictCode: undefined,
|
||||||
dictLabel: undefined,
|
dictLabel: undefined,
|
||||||
dictValue: undefined,
|
dictValue: undefined,
|
||||||
|
cssClass: undefined,
|
||||||
|
listClass: 'default',
|
||||||
dictSort: 0,
|
dictSort: 0,
|
||||||
status: "0",
|
status: "0",
|
||||||
remark: undefined
|
remark: undefined
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,11 @@
|
||||||
</router-link>
|
</router-link>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
|
<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="remark" :show-overflow-tooltip="true" />
|
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
|
@ -254,10 +258,6 @@ export default {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
// 字典状态字典翻译
|
|
||||||
statusFormat(row, column) {
|
|
||||||
return this.selectDictLabel(this.statusOptions, row.status);
|
|
||||||
},
|
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false;
|
this.open = false;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<h4 class="form-header h4">基本信息</h4>
|
||||||
|
<el-form ref="form" :model="form" label-width="80px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8" :offset="2">
|
||||||
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
|
<el-input v-model="form.nickName" disabled />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8" :offset="2">
|
||||||
|
<el-form-item label="登录账号" prop="phonenumber">
|
||||||
|
<el-input v-model="form.userName" disabled />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<h4 class="form-header h4">角色信息</h4>
|
||||||
|
<el-table v-loading="loading" :row-key="getRowKey" @row-click="clickRow" ref="table" @selection-change="handleSelectionChange" :data="roles.slice((pageNum-1)*pageSize,pageNum*pageSize)">
|
||||||
|
<el-table-column label="序号" type="index" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column>
|
||||||
|
<el-table-column label="角色编号" align="center" prop="roleId" />
|
||||||
|
<el-table-column label="角色名称" align="center" prop="roleName" />
|
||||||
|
<el-table-column label="权限字符" align="center" prop="roleKey" />
|
||||||
|
<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="pageNum" :limit.sync="pageSize" />
|
||||||
|
|
||||||
|
<el-form label-width="100px">
|
||||||
|
<el-form-item style="text-align: center;margin-left:-120px;margin-top:30px;">
|
||||||
|
<el-button type="primary" @click="submitForm()">提交</el-button>
|
||||||
|
<el-button @click="close()">返回</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getAuthRole, updateAuthRole } from "@/api/system/user";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "AuthRole",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 分页信息
|
||||||
|
total: 0,
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
// 选中角色编号
|
||||||
|
roleIds:[],
|
||||||
|
// 角色信息
|
||||||
|
roles: [],
|
||||||
|
// 用户信息
|
||||||
|
form: {}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
const userId = this.$route.params && this.$route.params.userId;
|
||||||
|
if (userId) {
|
||||||
|
this.loading = true;
|
||||||
|
getAuthRole(userId).then((response) => {
|
||||||
|
this.form = response.user;
|
||||||
|
this.roles = response.roles;
|
||||||
|
this.total = this.roles.length;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.roles.forEach((row) => {
|
||||||
|
if (row.flag) {
|
||||||
|
this.$refs.table.toggleRowSelection(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 单击选中行数据 */
|
||||||
|
clickRow(row) {
|
||||||
|
this.$refs.table.toggleRowSelection(row);
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.roleIds = selection.map((item) => item.roleId);
|
||||||
|
},
|
||||||
|
// 保存选中的数据编号
|
||||||
|
getRowKey(row) {
|
||||||
|
return row.roleId;
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
const userId = this.form.userId;
|
||||||
|
const roleIds = this.roleIds.join(",");
|
||||||
|
updateAuthRole({ userId: userId, roleIds: roleIds }).then((response) => {
|
||||||
|
this.msgSuccess("授权成功");
|
||||||
|
this.close();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 关闭按钮 */
|
||||||
|
close() {
|
||||||
|
this.$store.dispatch("tagsView/delView", this.$route);
|
||||||
|
this.$router.push({ path: "/system/user" });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
@ -174,21 +174,19 @@
|
||||||
@click="handleUpdate(scope.row)"
|
@click="handleUpdate(scope.row)"
|
||||||
v-hasPermi="['system:user:edit']"
|
v-hasPermi="['system:user:edit']"
|
||||||
>修改</el-button>
|
>修改</el-button>
|
||||||
<el-button
|
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)">
|
||||||
v-if="scope.row.userId !== 1"
|
<span class="el-dropdown-link">
|
||||||
size="mini"
|
<i class="el-icon-d-arrow-right el-icon--right"></i>更多操作
|
||||||
type="text"
|
</span>
|
||||||
icon="el-icon-delete"
|
<el-dropdown-menu slot="dropdown">
|
||||||
@click="handleDelete(scope.row)"
|
<el-dropdown-item command="handleDelete" v-if="scope.row.userId !== 1" icon="el-icon-delete"
|
||||||
v-hasPermi="['system:user:remove']"
|
v-hasPermi="['system:user:remove']">删除用户</el-dropdown-item>
|
||||||
>删除</el-button>
|
<el-dropdown-item command="handleResetPwd" icon="el-icon-key"
|
||||||
<el-button
|
v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item>
|
||||||
size="mini"
|
<el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check"
|
||||||
type="text"
|
v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item>
|
||||||
icon="el-icon-key"
|
</el-dropdown-menu>
|
||||||
@click="handleResetPwd(scope.row)"
|
</el-dropdown>
|
||||||
v-hasPermi="['system:user:resetPwd']"
|
|
||||||
>重置</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -209,7 +207,7 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="用户昵称" prop="nickName">
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
<el-input v-model="form.nickName" placeholder="请输入用户昵称" />
|
<el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
|
|
@ -233,12 +231,12 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName">
|
<el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName">
|
||||||
<el-input v-model="form.userName" placeholder="请输入用户名称" />
|
<el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
|
<el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
|
||||||
<el-input v-model="form.password" placeholder="请输入用户密码" type="password" />
|
<el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
@ -437,7 +435,8 @@ export default {
|
||||||
{ required: true, message: "用户昵称不能为空", trigger: "blur" }
|
{ required: true, message: "用户昵称不能为空", trigger: "blur" }
|
||||||
],
|
],
|
||||||
password: [
|
password: [
|
||||||
{ required: true, message: "用户密码不能为空", trigger: "blur" }
|
{ required: true, message: "用户密码不能为空", trigger: "blur" },
|
||||||
|
{ min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
email: [
|
email: [
|
||||||
{
|
{
|
||||||
|
|
@ -557,6 +556,22 @@ 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 "handleDelete":
|
||||||
|
this.handleDelete(row);
|
||||||
|
break;
|
||||||
|
case "handleResetPwd":
|
||||||
|
this.handleResetPwd(row);
|
||||||
|
break;
|
||||||
|
case "handleAuthRole":
|
||||||
|
this.handleAuthRole(row);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
@ -589,13 +604,21 @@ export default {
|
||||||
handleResetPwd(row) {
|
handleResetPwd(row) {
|
||||||
this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
|
this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消"
|
cancelButtonText: "取消",
|
||||||
|
closeOnClickModal: false,
|
||||||
|
inputPattern: /^.{5,20}$/,
|
||||||
|
inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
|
||||||
}).then(({ value }) => {
|
}).then(({ value }) => {
|
||||||
resetUserPwd(row.userId, value).then(response => {
|
resetUserPwd(row.userId, value).then(response => {
|
||||||
this.msgSuccess("修改成功,新密码是:" + value);
|
this.msgSuccess("修改成功,新密码是:" + value);
|
||||||
});
|
});
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
},
|
},
|
||||||
|
/** 分配角色操作 */
|
||||||
|
handleAuthRole: function(row) {
|
||||||
|
const userId = row.userId;
|
||||||
|
this.$router.push("/auth/role/" + userId);
|
||||||
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm: function() {
|
submitForm: function() {
|
||||||
this.$refs["form"].validate(valid => {
|
this.$refs["form"].validate(valid => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<el-form ref="form" :model="user" :rules="rules" label-width="80px">
|
<el-form ref="form" :model="user" :rules="rules" label-width="80px">
|
||||||
<el-form-item label="用户昵称" prop="nickName">
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
<el-input v-model="user.nickName" />
|
<el-input v-model="user.nickName" maxlength="30" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="手机号码" prop="phonenumber">
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
<el-input v-model="user.phonenumber" maxlength="11" />
|
<el-input v-model="user.phonenumber" maxlength="11" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue