Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
7199172c
提交
7199172c
authored
2月 24, 2021
作者:
fit2cloud-chenyw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 用户管理
上级
1e5b9778
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
521 行增加
和
10 行删除
+521
-10
ExtSysRoleMapper.java
...in/java/io/dataease/base/mapper/ext/ExtSysRoleMapper.java
+3
-0
ExtSysRoleMapper.xml
...ain/java/io/dataease/base/mapper/ext/ExtSysRoleMapper.xml
+10
-0
ExtSysUserMapper.xml
...ain/java/io/dataease/base/mapper/ext/ExtSysUserMapper.xml
+17
-7
SysRoleController.java
...in/java/io/dataease/controller/sys/SysRoleController.java
+7
-0
RoleUserItem.java
...ava/io/dataease/controller/sys/response/RoleUserItem.java
+13
-0
SysUserDept.java
...java/io/dataease/controller/sys/response/SysUserDept.java
+15
-0
SysUserGridResponse.java
...dataease/controller/sys/response/SysUserGridResponse.java
+6
-2
SysUserRole.java
...java/io/dataease/controller/sys/response/SysUserRole.java
+13
-0
SysRoleService.java
...src/main/java/io/dataease/service/sys/SysRoleService.java
+5
-0
SysUserService.java
...src/main/java/io/dataease/service/sys/SysUserService.java
+6
-1
router.js
frontend/src/business/components/settings/router.js
+5
-0
user.vue
frontend/src/business/components/settings/sys/user.vue
+421
-0
没有找到文件。
backend/src/main/java/io/dataease/base/mapper/ext/ExtSysRoleMapper.java
浏览文件 @
7199172c
...
@@ -2,6 +2,7 @@ package io.dataease.base.mapper.ext;
...
@@ -2,6 +2,7 @@ package io.dataease.base.mapper.ext;
import
io.dataease.controller.sys.request.RoleGridRequest
;
import
io.dataease.controller.sys.request.RoleGridRequest
;
import
io.dataease.controller.sys.response.RoleNodeResponse
;
import
io.dataease.controller.sys.response.RoleNodeResponse
;
import
io.dataease.controller.sys.response.RoleUserItem
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
...
@@ -16,4 +17,6 @@ public interface ExtSysRoleMapper {
...
@@ -16,4 +17,6 @@ public interface ExtSysRoleMapper {
int
deleteRoleMenu
(
@Param
(
"roleId"
)
Long
roleId
);
int
deleteRoleMenu
(
@Param
(
"roleId"
)
Long
roleId
);
int
batchInsertRoleMenu
(
@Param
(
"maps"
)
List
<
Map
<
String
,
Long
>>
maps
);
int
batchInsertRoleMenu
(
@Param
(
"maps"
)
List
<
Map
<
String
,
Long
>>
maps
);
List
<
RoleUserItem
>
queryAll
();
}
}
backend/src/main/java/io/dataease/base/mapper/ext/ExtSysRoleMapper.xml
浏览文件 @
7199172c
...
@@ -11,6 +11,11 @@
...
@@ -11,6 +11,11 @@
</collection>
</collection>
</resultMap>
</resultMap>
<resultMap
id=
"roleItemMap"
type=
"io.dataease.controller.sys.response.RoleUserItem"
>
<id
property=
"id"
column=
"id"
/>
<result
property=
"name"
column=
"name"
/>
</resultMap>
<select
id=
"query"
resultMap=
"BaseResultMap"
>
<select
id=
"query"
resultMap=
"BaseResultMap"
>
select r.*, m.menu_id
select r.*, m.menu_id
from sys_role r left join sys_roles_menus m on r.role_id = m.role_id
from sys_role r left join sys_roles_menus m on r.role_id = m.role_id
...
@@ -34,5 +39,10 @@
...
@@ -34,5 +39,10 @@
</foreach>
</foreach>
</insert>
</insert>
<select
id=
"queryAll"
resultMap=
"roleItemMap"
>
select role_id as id, name from sys_role
</select>
</mapper>
</mapper>
backend/src/main/java/io/dataease/base/mapper/ext/ExtSysUserMapper.xml
浏览文件 @
7199172c
...
@@ -2,18 +2,28 @@
...
@@ -2,18 +2,28 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"io.dataease.base.mapper.ext.ExtSysUserMapper"
>
<mapper
namespace=
"io.dataease.base.mapper.ext.ExtSysUserMapper"
>
<resultMap
id=
"sysUserDept"
type=
"io.dataease.controller.sys.response.SysUserDept"
>
<id
column=
"dept_id"
property=
"deptId"
></id>
<result
column=
"pid"
property=
"pid"
></result>
<result
column=
"dept_name"
property=
"deptName"
></result>
</resultMap>
<resultMap
id=
"sysUserRole"
type=
"io.dataease.controller.sys.response.SysUserRole"
>
<result
column=
"role_id"
property=
"roleId"
></result>
<result
column=
"role_name"
property=
"roleName"
></result>
</resultMap>
<resultMap
id=
"BaseResultMap"
type=
"io.dataease.controller.sys.response.SysUserGridResponse"
extends=
"io.dataease.base.mapper.SysUserMapper.BaseResultMap"
>
<resultMap
id=
"BaseResultMap"
type=
"io.dataease.controller.sys.response.SysUserGridResponse"
extends=
"io.dataease.base.mapper.SysUserMapper.BaseResultMap"
>
<result
column=
"roleIds"
property=
"role_ids"
/>
<result
property=
"id"
column=
"id"
></result>
<collection
property=
"roleIds"
ofType=
"long"
>
<association
property=
"dept"
column=
"dept_id"
javaType=
"io.dataease.controller.sys.response.SysUserDept"
resultMap=
"sysUserDept"
/>
<constructor>
<collection
property=
"roles"
column=
"role_id"
javaType=
"io.dataease.controller.sys.response.SysUserRole"
resultMap=
"sysUserRole"
/>
<arg
column=
"role_id"
/>
</constructor>
</collection>
</resultMap>
</resultMap>
<select
id=
"query"
resultMap=
"BaseResultMap"
>
<select
id=
"query"
resultMap=
"BaseResultMap"
>
select u.*,
ur.role_id
select u.*,
u.user_id as id, r.role_id,r.name as role_name , d.pid, d.name as dept_name
from sys_user u left join sys_users_roles ur on u.user_id = ur.user_id
from sys_user u left join sys_users_roles ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
left join sys_dept d on d.dept_id = u.dept_id
<where>
<where>
<if
test=
"request.name != null"
>
<if
test=
"request.name != null"
>
AND u.name like CONCAT('%', #{request.name},'%')
AND u.name like CONCAT('%', #{request.name},'%')
...
...
backend/src/main/java/io/dataease/controller/sys/SysRoleController.java
浏览文件 @
7199172c
...
@@ -9,6 +9,7 @@ import io.dataease.commons.utils.Pager;
...
@@ -9,6 +9,7 @@ import io.dataease.commons.utils.Pager;
import
io.dataease.controller.sys.request.RoleGridRequest
;
import
io.dataease.controller.sys.request.RoleGridRequest
;
import
io.dataease.controller.sys.request.RoleMenusRequest
;
import
io.dataease.controller.sys.request.RoleMenusRequest
;
import
io.dataease.controller.sys.response.RoleNodeResponse
;
import
io.dataease.controller.sys.response.RoleNodeResponse
;
import
io.dataease.controller.sys.response.RoleUserItem
;
import
io.dataease.service.sys.SysRoleService
;
import
io.dataease.service.sys.SysRoleService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -59,4 +60,10 @@ public class SysRoleController {
...
@@ -59,4 +60,10 @@ public class SysRoleController {
public
void
saveRolesMenus
(
@RequestBody
RoleMenusRequest
request
){
public
void
saveRolesMenus
(
@RequestBody
RoleMenusRequest
request
){
sysRoleService
.
batchSaveRolesMenus
(
request
);
sysRoleService
.
batchSaveRolesMenus
(
request
);
}
}
@PostMapping
(
"/all"
)
public
List
<
RoleUserItem
>
all
(){
return
sysRoleService
.
allRoles
();
}
}
}
backend/src/main/java/io/dataease/controller/sys/response/RoleUserItem.java
0 → 100644
浏览文件 @
7199172c
package
io
.
dataease
.
controller
.
sys
.
response
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
RoleUserItem
implements
Serializable
{
private
Long
id
;
private
String
name
;
}
backend/src/main/java/io/dataease/controller/sys/response/SysUserDept.java
0 → 100644
浏览文件 @
7199172c
package
io
.
dataease
.
controller
.
sys
.
response
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
SysUserDept
implements
Serializable
{
private
Long
deptId
;
private
Long
pid
;
private
String
deptName
;
}
backend/src/main/java/io/dataease/controller/sys/response/SysUserGridResponse.java
浏览文件 @
7199172c
package
io
.
dataease
.
controller
.
sys
.
response
;
package
io
.
dataease
.
controller
.
sys
.
response
;
import
io.dataease.base.domain.SysUser
;
import
io.dataease.base.domain.SysUser
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.List
;
@Data
@Data
public
class
SysUserGridResponse
extends
SysUser
{
public
class
SysUserGridResponse
extends
SysUser
{
private
Long
id
;
private
List
<
SysUserRole
>
roles
;
private
SysUserDept
dept
;
private
List
<
Long
>
roleIds
;
}
}
backend/src/main/java/io/dataease/controller/sys/response/SysUserRole.java
0 → 100644
浏览文件 @
7199172c
package
io
.
dataease
.
controller
.
sys
.
response
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
SysUserRole
implements
Serializable
{
private
Long
roleId
;
private
String
roleName
;
}
backend/src/main/java/io/dataease/service/sys/SysRoleService.java
浏览文件 @
7199172c
...
@@ -9,6 +9,7 @@ import io.dataease.base.mapper.ext.ExtSysRoleMapper;
...
@@ -9,6 +9,7 @@ import io.dataease.base.mapper.ext.ExtSysRoleMapper;
import
io.dataease.controller.sys.request.RoleGridRequest
;
import
io.dataease.controller.sys.request.RoleGridRequest
;
import
io.dataease.controller.sys.request.RoleMenusRequest
;
import
io.dataease.controller.sys.request.RoleMenusRequest
;
import
io.dataease.controller.sys.response.RoleNodeResponse
;
import
io.dataease.controller.sys.response.RoleNodeResponse
;
import
io.dataease.controller.sys.response.RoleUserItem
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -74,5 +75,9 @@ public class SysRoleService {
...
@@ -74,5 +75,9 @@ public class SysRoleService {
return
extSysRoleMapper
.
batchInsertRoleMenu
(
maps
);
return
extSysRoleMapper
.
batchInsertRoleMenu
(
maps
);
}
}
public
List
<
RoleUserItem
>
allRoles
(){
return
extSysRoleMapper
.
queryAll
();
}
}
}
backend/src/main/java/io/dataease/service/sys/SysUserService.java
浏览文件 @
7199172c
...
@@ -14,6 +14,7 @@ import io.dataease.controller.sys.request.UserGridRequest;
...
@@ -14,6 +14,7 @@ import io.dataease.controller.sys.request.UserGridRequest;
import
io.dataease.controller.sys.response.SysUserGridResponse
;
import
io.dataease.controller.sys.response.SysUserGridResponse
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -46,7 +47,11 @@ public class SysUserService {
...
@@ -46,7 +47,11 @@ public class SysUserService {
user
.
setCreateTime
(
now
);
user
.
setCreateTime
(
now
);
user
.
setUpdateTime
(
now
);
user
.
setUpdateTime
(
now
);
user
.
setIsAdmin
(
false
);
user
.
setIsAdmin
(
false
);
user
.
setPassword
(
CodingUtil
.
md5
(
DEFAULT_PWD
));
if
(
ObjectUtils
.
isEmpty
(
user
.
getPassword
())
||
StringUtils
.
equals
(
user
.
getPassword
(),
DEFAULT_PWD
)){
user
.
setPassword
(
CodingUtil
.
md5
(
DEFAULT_PWD
));
}
else
{
user
.
setPassword
(
CodingUtil
.
md5
(
user
.
getPassword
()));
}
int
insert
=
sysUserMapper
.
insert
(
user
);
int
insert
=
sysUserMapper
.
insert
(
user
);
SysUser
dbUser
=
findOne
(
user
);
SysUser
dbUser
=
findOne
(
user
);
saveUserRoles
(
dbUser
.
getUserId
(),
request
.
getRoleIds
());
//插入用户角色关联
saveUserRoles
(
dbUser
.
getUserId
(),
request
.
getRoleIds
());
//插入用户角色关联
...
...
frontend/src/business/components/settings/router.js
浏览文件 @
7199172c
...
@@ -32,6 +32,11 @@ export default {
...
@@ -32,6 +32,11 @@ export default {
component
:
()
=>
import
(
'@/business/components/settings/sys/role'
),
component
:
()
=>
import
(
'@/business/components/settings/sys/role'
),
meta
:
{
system
:
true
,
title
:
'commons.role'
}
meta
:
{
system
:
true
,
title
:
'commons.role'
}
},
},
{
path
:
'sysuser'
,
component
:
()
=>
import
(
'@/business/components/settings/sys/user'
),
meta
:
{
system
:
true
,
title
:
'commons.user'
}
},
// {
// {
// path: 'systemworkspace',
// path: 'systemworkspace',
// component: () => import('@/business/components/settings/system/SystemWorkspace'),
// component: () => import('@/business/components/settings/system/SystemWorkspace'),
...
...
frontend/src/business/components/settings/sys/user.vue
0 → 100644
浏览文件 @
7199172c
<
template
>
<div
v-loading=
"result.loading"
>
<el-card
class=
"table-card"
>
<template
v-slot:header
>
<ms-table-header
:condition
.
sync=
"condition"
@
search=
"search"
@
create=
"create"
:create-tip=
"$t('user.create')"
:title=
"$t('commons.user')"
/>
</
template
>
<el-table
border
class=
"adjust-table"
:data=
"tableData"
style=
"width: 100%"
>
<el-table-column
prop=
"username"
label=
"ID"
/>
<el-table-column
prop=
"nickName"
:label=
"$t('commons.name')"
width=
"200"
/>
<el-table-column
prop=
"gender"
label=
"性别"
/>
<el-table-column
:show-overflow-tooltip=
"true"
prop=
"phone"
width=
"100"
label=
"电话"
/>
<el-table-column
:show-overflow-tooltip=
"true"
width=
"135"
prop=
"email"
:label=
"$t('commons.email')"
/>
<el-table-column
:show-overflow-tooltip=
"true"
prop=
"dept"
:label=
"$t('commons.organization')"
>
<
template
slot-scope=
"scope"
>
<div>
{{
scope
.
row
.
dept
.
name
}}
</div>
</
template
>
</el-table-column>
<el-table-column
prop=
"status"
:label=
"$t('commons.status')"
width=
"120"
>
<
template
v-slot:default=
"scope"
>
<el-switch
v-model=
"scope.row.enabled"
inactive-color=
"#DCDFE6"
@
change=
"changeSwitch(scope.row)"
/>
</
template
>
</el-table-column>
<el-table-column
prop=
"createTime"
:label=
"$t('commons.create_time')"
>
<
template
v-slot:default=
"scope"
>
<span>
{{
scope
.
row
.
createTime
|
timestampFormatDate
}}
</span>
</
template
>
</el-table-column>
<!-- <el-table-column prop="source" :label="$t('user.source')"/> -->
<el-table-column
:label=
"$t('commons.operating')"
min-width=
"120px"
>
<
template
v-slot:default=
"scope"
>
<ms-table-operator
@
editClick=
"edit(scope.row)"
@
deleteClick=
"del(scope.row)"
>
<template
v-slot:behind
>
<ms-table-operator-button
:tip=
"$t('member.edit_password')"
icon=
"el-icon-s-tools"
type=
"success"
@
exec=
"editPassword(scope.row)"
v-if=
"scope.row.isLocalUser"
/>
</
template
>
</ms-table-operator>
</template>
</el-table-column>
</el-table>
<ms-table-pagination
:change=
"search"
:current-page
.
sync=
"currentPage"
:page-size
.
sync=
"pageSize"
:total=
"total"
/>
</el-card>
<el-dialog
append-to-body
:close-on-click-modal=
"false"
:title=
"$t('user.create')"
:visible
.
sync=
"dialogVisible"
width=
"570px"
@
closed=
"handleClose"
:destroy-on-close=
"true"
>
<el-form
ref=
"createUserForm"
:inline=
"true"
:model=
"form"
:rules=
"rule"
size=
"small"
label-width=
"66px"
>
<el-form-item
label=
"用户名"
prop=
"username"
>
<el-input
v-model=
"form.username"
/>
</el-form-item>
<el-form-item
label=
"电话"
prop=
"phone"
>
<el-input
v-model
.
number=
"form.phone"
/>
</el-form-item>
<el-form-item
label=
"昵称"
prop=
"nickName"
>
<el-input
v-model=
"form.nickName"
/>
</el-form-item>
<el-form-item
label=
"邮箱"
prop=
"email"
>
<el-input
v-model=
"form.email"
/>
</el-form-item>
<!-- <el-form-item :label="$t('commons.password')" prop="password" >
<el-input v-model="form.password" autocomplete="new-password" show-password
:placeholder="$t('user.input_password')" style="width: 175px;"/>
</el-form-item> -->
<el-form-item
label=
"性别"
>
<el-radio-group
v-model=
"form.gender"
style=
"width: 178px"
>
<el-radio
label=
"男"
>
男
</el-radio>
<el-radio
label=
"女"
>
女
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label=
"状态"
>
<el-radio-group
v-model=
"form.enabled"
style=
"width: 140px"
>
<el-radio
:label=
'true'
>
启用
</el-radio>
<el-radio
:label=
'false'
>
停用
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label=
"部门"
prop=
"dept"
>
<treeselect
v-model=
"form.deptId"
:options=
"depts"
:load-options=
"loadDepts"
style=
"width: 430px"
placeholder=
"选择部门"
/>
</el-form-item>
<el-form-item
style=
"margin-bottom: 0;"
label=
"角色"
prop=
"roles"
>
<el-select
v-model=
"roleDatas"
style=
"width: 430px"
multiple
placeholder=
"请选择"
@
remove-tag=
"deleteTag"
@
change=
"changeRole"
>
<el-option
v-for=
"item in roles"
:key=
"item.name"
:label=
"item.name"
:value=
"item.id"
/>
</el-select>
</el-form-item>
</el-form>
<
template
v-slot:footer
>
<ms-dialog-footer
@
cancel=
"dialogVisible = false"
@
confirm=
"createUser('createUserForm')"
/>
</
template
>
</el-dialog>
<!--Changing user password in system settings-->
<el-dialog
:close-on-click-modal=
"false"
:title=
"$t('member.edit_password')"
:visible
.
sync=
"editPasswordVisible"
width=
"30%"
:destroy-on-close=
"true"
@
close=
"handleClose"
left
>
<el-form
:model=
"ruleForm"
label-position=
"right"
label-width=
"120px"
size=
"small"
:rules=
"rule"
ref=
"editPasswordForm"
class=
"demo-ruleForm"
>
<el-form-item
:label=
"$t('member.new_password')"
prop=
"newpassword"
>
<el-input
type=
"password"
v-model=
"ruleForm.newpassword"
autocomplete=
"off"
show-password
></el-input>
</el-form-item>
<el-form-item>
<el-input
v-model=
"ruleForm.id"
autocomplete=
"off"
:disabled=
"true"
style=
"display:none"
/>
</el-form-item>
</el-form>
<span
slot=
"footer"
class=
"dialog-footer"
>
<ms-dialog-footer
@
cancel=
"editPasswordVisible = false"
@
confirm=
"editUserPassword('editPasswordForm')"
/>
</span>
</el-dialog>
</div>
</template>
<
script
>
import
MsCreateBox
from
"../CreateBox"
;
import
MsTablePagination
from
"../../common/pagination/TablePagination"
;
import
MsTableHeader
from
"../../common/components/MsTableHeader"
;
import
MsTableOperator
from
"../../common/components/MsTableOperator"
;
import
MsDialogFooter
from
"../../common/components/MsDialogFooter"
;
import
MsTableOperatorButton
from
"../../common/components/MsTableOperatorButton"
;
import
{
hasRole
,
listenGoBack
,
removeGoBackListener
}
from
"@/common/js/utils"
;
import
{
ROLE_ADMIN
}
from
"@/common/js/constants"
;
import
{
getCurrentUser
}
from
"../../../../common/js/utils"
;
import
{
PHONE_REGEX
}
from
"@/common/js/regex"
;
import
{
LOAD_CHILDREN_OPTIONS
,
LOAD_ROOT_OPTIONS
}
from
'@riophae/vue-treeselect'
import
Treeselect
from
'@riophae/vue-treeselect'
import
'@riophae/vue-treeselect/dist/vue-treeselect.css'
export
default
{
name
:
"MsUser"
,
components
:
{
MsCreateBox
,
MsTablePagination
,
MsTableHeader
,
MsTableOperator
,
MsDialogFooter
,
MsTableOperatorButton
,
Treeselect
},
data
()
{
return
{
queryPath
:
'/api/user/userGrid'
,
deletePath
:
'/api/user/delete/'
,
createPath
:
'/api/user/create'
,
updatePath
:
'/api/user/update'
,
editPasswordPath
:
'/api/user/password'
,
result
:
{},
dialogVisible
:
false
,
editPasswordVisible
:
false
,
multipleSelection
:
[],
currentPage
:
1
,
pageSize
:
10
,
total
:
0
,
condition
:
{},
tableData
:
[],
form
:
{
roles
:
[{
id
:
''
}]
},
checkPasswordForm
:
{},
ruleForm
:
{},
rule
:
{
id
:
[
{
required
:
true
,
message
:
this
.
$t
(
'user.input_id'
),
trigger
:
'blur'
},
{
min
:
1
,
max
:
50
,
message
:
this
.
$t
(
'commons.input_limit'
,
[
1
,
50
]),
trigger
:
'blur'
},
{
required
:
true
,
pattern
:
'^[^
\
u4e00-
\
u9fa5]+$'
,
message
:
this
.
$t
(
'user.special_characters_are_not_supported'
),
trigger
:
'blur'
}
],
name
:
[
{
required
:
true
,
message
:
this
.
$t
(
'user.input_name'
),
trigger
:
'blur'
},
{
min
:
2
,
max
:
50
,
message
:
this
.
$t
(
'commons.input_limit'
,
[
2
,
50
]),
trigger
:
'blur'
},
{
required
:
true
,
message
:
this
.
$t
(
'user.special_characters_are_not_supported'
),
trigger
:
'blur'
}
],
phone
:
[
{
pattern
:
PHONE_REGEX
,
message
:
this
.
$t
(
'user.mobile_number_format_is_incorrect'
),
trigger
:
'blur'
}
],
email
:
[
{
required
:
true
,
message
:
this
.
$t
(
'user.input_email'
),
trigger
:
'blur'
},
{
required
:
true
,
pattern
:
/^
[
a-zA-Z0-9_._-
]
+@
[
a-zA-Z0-9_-
]
+
(\.[
a-zA-Z0-9_-
]
+
)
+$/
,
message
:
this
.
$t
(
'user.email_format_is_incorrect'
),
trigger
:
'blur'
}
],
password
:
[
{
required
:
true
,
message
:
this
.
$t
(
'user.input_password'
),
trigger
:
'blur'
},
{
required
:
true
,
pattern
:
/^
(?=
.*
[
a-z
])(?=
.*
[
A-Z
])(?=
.*
\d)[^]{8,30}
$/
,
message
:
this
.
$t
(
'member.password_format_is_incorrect'
),
trigger
:
'blur'
}
],
newpassword
:
[
{
required
:
true
,
message
:
this
.
$t
(
'user.input_password'
),
trigger
:
'blur'
},
{
required
:
true
,
pattern
:
/^
(?=
.*
[
a-z
])(?=
.*
[
A-Z
])(?=
.*
\d)[^]{8,30}
$/
,
message
:
this
.
$t
(
'member.password_format_is_incorrect'
),
trigger
:
'blur'
}
]
},
defaultForm
:
{
id
:
null
,
username
:
null
,
nickName
:
null
,
gender
:
'男'
,
email
:
null
,
enabled
:
true
,
dept
:
null
,
phone
:
null
},
depts
:
null
,
roles
:
[],
roleDatas
:
[],
userRoles
:
[]
}
},
activated
()
{
//this.form = Object.assign({}, this.defaultForm);
this
.
allRoles
()
this
.
search
()
},
methods
:
{
create
()
{
this
.
form
=
Object
.
assign
({},
this
.
defaultForm
);
this
.
dialogVisible
=
true
;
listenGoBack
(
this
.
handleClose
);
},
edit
(
row
)
{
this
.
dialogVisible
=
true
;
this
.
form
=
Object
.
assign
({},
row
);
listenGoBack
(
this
.
handleClose
);
},
editPassword
(
row
)
{
this
.
editPasswordVisible
=
true
;
this
.
ruleForm
=
Object
.
assign
({},
row
);
listenGoBack
(
this
.
handleClose
);
},
del
(
row
)
{
this
.
$confirm
(
this
.
$t
(
'user.delete_confirm'
),
''
,
{
confirmButtonText
:
this
.
$t
(
'commons.confirm'
),
cancelButtonText
:
this
.
$t
(
'commons.cancel'
),
type
:
'warning'
}).
then
(()
=>
{
this
.
result
=
this
.
$get
(
this
.
deletePath
+
encodeURIComponent
(
row
.
userId
),
()
=>
{
this
.
$success
(
this
.
$t
(
'commons.delete_success'
));
this
.
search
();
});
}).
catch
(()
=>
{
this
.
$info
(
this
.
$t
(
'commons.delete_cancel'
));
});
},
createUser
(
createUserForm
)
{
this
.
$refs
[
createUserForm
].
validate
(
valid
=>
{
if
(
valid
)
{
this
.
result
=
this
.
$post
(
this
.
createPath
,
this
.
form
,
()
=>
{
this
.
$success
(
this
.
$t
(
'commons.save_success'
));
this
.
search
();
this
.
dialogVisible
=
false
;
});
}
else
{
return
false
;
}
})
},
updateUser
(
updateUserForm
)
{
this
.
$refs
[
updateUserForm
].
validate
(
valid
=>
{
if
(
valid
)
{
this
.
result
=
this
.
$post
(
this
.
updatePath
,
this
.
form
,
()
=>
{
this
.
$success
(
this
.
$t
(
'commons.modify_success'
));
this
.
dialogVisible
=
false
;
this
.
search
();
});
}
else
{
return
false
;
}
})
},
editUserPassword
(
editPasswordForm
)
{
this
.
$refs
[
editPasswordForm
].
validate
(
valid
=>
{
if
(
valid
)
{
this
.
result
=
this
.
$post
(
this
.
editPasswordPath
,
this
.
ruleForm
,
()
=>
{
this
.
$success
(
this
.
$t
(
'commons.modify_success'
));
this
.
editPasswordVisible
=
false
;
this
.
search
();
window
.
location
.
reload
();
});
}
else
{
return
false
;
}
})
},
search
()
{
this
.
result
=
this
.
$post
(
this
.
buildPagePath
(
this
.
queryPath
),
this
.
condition
,
response
=>
{
let
data
=
response
.
data
;
this
.
total
=
data
.
itemCount
;
this
.
tableData
=
data
.
listObject
;
// let url = "/user/special/user/role";
// for (let i = 0; i
<
this
.
tableData
.
length
;
i
++
)
{
// if (this.tableData[i].id) {
// this.$get(url + '/' + encodeURIComponent(this.tableData[i].id), result => {
// let data = result.data;
// let roles = data.roles;
// // let userRoles = result.userRoles;
// this.$set(this.tableData[i], "roles", roles);
// this.$set(this.tableData[i], "isLocalUser", this.tableData[i].source === 'LOCAL');
// });
// }
// }
})
},
handleClose
()
{
this
.
form
=
{};
removeGoBackListener
(
this
.
handleClose
);
this
.
editPasswordVisible
=
false
;
this
.
dialogVisible
=
false
;
},
changeSwitch
(
row
)
{
this
.
$post
(
'/api/user/update_status'
,
row
,
()
=>
{
this
.
$success
(
this
.
$t
(
'commons.modify_success'
));
})
},
buildPagePath
(
path
)
{
return
path
+
"/"
+
this
.
currentPage
+
"/"
+
this
.
pageSize
;
},
handleSelectionChange
(
val
)
{
this
.
multipleSelection
=
val
;
},
// 获取弹窗内部门数据
loadDepts
({
action
,
parentNode
,
callback
})
{
if
(
action
===
LOAD_ROOT_OPTIONS
)
{
let
_self
=
this
;
!
this
.
depts
&&
this
.
$post
(
"api/dept/childNodes/0"
,
null
,
(
res
)
=>
{
_self
.
depts
=
res
.
data
.
map
(
node
=>
_self
.
normalizer
(
node
))
callback
()
})
}
if
(
action
===
LOAD_CHILDREN_OPTIONS
)
{
let
_self
=
this
;
this
.
$post
(
"api/dept/childNodes/"
+
parentNode
.
id
,
null
,
(
res
)
=>
{
parentNode
.
children
=
res
.
data
.
map
(
function
(
obj
)
{
return
_self
.
normalizer
(
obj
)
})
callback
()
})
}
},
normalizer
(
node
)
{
if
(
node
.
hasChildren
){
node
.
children
=
null
}
return
{
id
:
node
.
deptId
,
label
:
node
.
name
,
children
:
node
.
children
}
},
deleteTag
(
value
)
{
this
.
userRoles
.
forEach
(
function
(
data
,
index
)
{
if
(
data
.
id
===
value
)
{
this
.
userRoles
.
splice
(
index
,
value
)
}
})
},
changeRole
(
value
)
{
this
.
userRoles
=
[]
value
.
forEach
(
function
(
data
,
index
)
{
const
role
=
{
id
:
data
}
this
.
userRoles
.
push
(
role
)
})
},
allRoles
(){
this
.
$post
(
"/api/role/all"
,
null
,
res
=>
{
this
.
roles
=
res
.
data
})
}
}
}
</
script
>
<
style
scoped
>
</
style
>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论