Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-system
/
system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b71d9b4d
authored
Oct 24, 2020
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交用户和角色接口逻辑
1 parent
c224df34
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
405 additions
and
149 deletions
src/components/rule-form/index.vue
src/config/config.js
src/services/menu.js
src/services/role.js
src/services/user.js
src/utils/constants.js
src/views/menuManage/index.vue
src/views/role/index.vue
src/views/user/index.vue
src/components/rule-form/index.vue
View file @
b71d9b4
...
...
@@ -41,6 +41,7 @@
<el-select
v-model=
"ruleForm[item.prop]"
:placeholder=
"item.placeholder || '请选择'"
:filterable=
"item.filterable || false"
@
change=
"selectChange"
>
<el-option
...
...
@@ -64,7 +65,7 @@
<el-radio
v-for=
"(child,childIndex) in item.children"
:key=
"childIndex"
:label=
"child"
:label=
"child
Index
"
>
{{
child
}}
</el-radio>
</el-radio-group>
<el-select
...
...
@@ -83,11 +84,11 @@
</el-option>
</el-select>
</
template
>
<
template
v-else-if=
"item.type == 'customize'"
name=
"form-slot
"
>
<slot
:scope=
"scope"
>
<
template
v-else-if=
"item.type == 'customize'"
>
<slot
:scope=
"scope
"
:name=
"item.slotName"
>
</slot>
</
template
>
</template>
...
...
@@ -140,6 +141,8 @@ export default {
default
:
'100px'
}
},
mounted
()
{
},
methods
:
{
selectChange
(
val
)
{
// console.log(val ,'selectChange')
...
...
src/config/config.js
View file @
b71d9b4
...
...
@@ -20,12 +20,27 @@ const API = {
const
USER_API
=
{
USER_SEARCH
:
BASE_URL
+
'/usercenter/user/search'
,
USER_SUPER
:
BASE_URL
+
'/usercenter/user/suitableSuperUsers'
,
USER_ADD
:
BASE_URL
+
'/usercenter/user/add'
USER_ADD
:
BASE_URL
+
'/usercenter/user/add'
,
USER_EDIT
:
BASE_URL
+
'/usercenter/user/edit'
,
USER_INFO
:
BASE_URL
+
'/usercenter/user/info'
,
USER_DELETE
:
BASE_URL
+
'/usercenter/user/delete'
,
ROLE_SIMPLELIST
:
BASE_URL
+
'/usercenter/role/simplelist'
}
const
ROLE_API
=
{
ROLE_SEARCH
:
{
apiUrl
:
BASE_URL
+
'/usercenter/role/search'
}
ROLE_SEARCH
:
BASE_URL
+
'/usercenter/role/search'
,
ROLE_INFO
:
BASE_URL
+
'/usercenter/role/info'
,
TENANT_SIMPLELIST
:
BASE_URL
+
'/usercenter/tenant/simplelist'
,
ROLE_ADD
:
BASE_URL
+
'/usercenter/role/add'
,
ROLE_EDIT
:
BASE_URL
+
'/usercenter/role/edit'
,
ROLE_DELETE
:
BASE_URL
+
'/usercenter/role/delete'
}
const
MENU_API
=
{
MENU_SEARCH
:
BASE_URL
+
'/usercenter/menu/search'
,
MENU_CHILDREN
:
BASE_URL
+
'/usercenter/menu/children'
,
MENU_ADD
:
BASE_URL
+
'/usercenter/menu/add'
,
MENU_EDIT
:
BASE_URL
+
'/usercenter/menu/edit'
,
MENU_DELETE
:
BASE_URL
+
'/usercenter/menu/delete'
,
MENU_INFO
:
BASE_URL
+
'/usercenter/menu/info'
}
const
ORGINIZA_API
=
{
ORGINIZA_SEARCH
:
BASE_URL
+
'/usercenter/organization/rootList'
,
...
...
@@ -48,4 +63,4 @@ const WORKLOG_API = {
WORKLOG_SEARCH
:
BASE_URL
+
'/loggincenter/loggin/search'
,
WORKLOG_EXPORT
:
BASE_URL
+
'/loggincenter/loggin/export'
}
export
{
API
,
USER_API
,
ROLE_API
,
ORGINIZA_API
,
DICT_API
,
WORKLOG_API
}
export
{
API
,
USER_API
,
ROLE_API
,
ORGINIZA_API
,
DICT_API
,
WORKLOG_API
,
MENU_API
}
src/services/menu.js
0 → 100644
View file @
b71d9b4
import
{
MENU_API
}
from
'@/config/config'
import
request
from
'@/services/request'
// 获取菜单列表
function
getMenuList
(
params
)
{
const
url
=
MENU_API
.
MENU_SEARCH
return
request
(
params
,
url
)
}
// 根据菜单根节点获取子节点
function
getMenuChildren
(
params
)
{
const
url
=
MENU_API
.
MENU_CHILDREN
return
request
(
params
,
url
)
}
// 添加菜单
function
addMenu
(
params
)
{
const
url
=
MENU_API
.
MENU_ADD
return
request
(
params
,
url
,
'post'
)
}
// 编辑菜单
function
editMenu
(
params
)
{
const
url
=
MENU_API
.
MENU_EDIT
return
request
(
params
,
url
,
'post'
)
}
// 删除菜单
function
deleteMenu
(
params
)
{
const
url
=
MENU_API
.
MENU_DELETE
return
request
(
params
,
url
)
}
// 获取菜单列表
function
menuInfo
(
params
)
{
const
url
=
MENU_API
.
MENU_INFO
return
request
(
params
,
url
)
}
export
{
getMenuList
,
getMenuChildren
,
addMenu
,
editMenu
,
menuInfo
,
deleteMenu
}
src/services/role.js
View file @
b71d9b4
import
HTTP
from
'@/utils/http'
import
{
ROLE_API
}
from
'@/config/config'
import
request
from
'@/services/request'
export
default
class
RoleService
extends
HTTP
{
// 获取用户列表
function
getRoleList
(
params
)
{
const
url
=
ROLE_API
.
ROLE_SEARCH
return
request
(
params
,
url
)
}
// 获取用户详情
function
roleInfo
(
params
)
{
const
url
=
ROLE_API
.
ROLE_INFO
return
request
(
params
,
url
)
}
// 获取租户列表
function
getTenantList
(
params
)
{
const
url
=
ROLE_API
.
TENANT_SIMPLELIST
return
request
(
params
,
url
)
}
// 获取用户列表
function
addRole
(
params
)
{
const
url
=
ROLE_API
.
ROLE_ADD
return
request
(
params
,
url
,
'post'
)
}
// 获取用户列表
function
editRole
(
params
)
{
const
url
=
ROLE_API
.
ROLE_EDIT
return
request
(
params
,
url
,
'post'
)
}
// 获取用户列表
function
deleteRole
(
params
)
{
const
url
=
ROLE_API
.
ROLE_DELETE
return
request
(
params
,
url
)
}
export
{
getRoleList
,
roleInfo
,
getTenantList
,
addRole
,
editRole
,
deleteRole
}
src/services/user.js
View file @
b71d9b4
import
{
USER_API
}
from
'@/config/config'
import
{
USER_API
}
from
'@/config/config'
import
request
from
'@/services/request'
// 获取用户列表
...
...
@@ -14,7 +14,26 @@ function getSuperUser (params) {
// 新增用户
function
addUser
(
params
)
{
const
url
=
USER_API
.
USER_ADD
return
request
(
params
,
url
,
'post'
)
}
// 编辑用户
function
editUser
(
params
)
{
const
url
=
USER_API
.
USER_EDIT
return
request
(
params
,
url
,
'post'
)
}
// 用户详情
function
detailUser
(
params
)
{
const
url
=
USER_API
.
USER_INFO
return
request
(
params
,
url
)
}
export
{
getUserList
,
getSuperUser
,
addUser
}
// 删除用户
function
deleteUser
(
params
)
{
const
url
=
USER_API
.
USER_DELETE
return
request
(
params
,
url
)
}
// 下拉角色列表
function
roleList
(
params
)
{
const
url
=
USER_API
.
ROLE_SIMPLELIST
return
request
(
params
,
url
)
}
export
{
getUserList
,
getSuperUser
,
addUser
,
editUser
,
detailUser
,
deleteUser
,
roleList
}
src/utils/constants.js
View file @
b71d9b4
const
Constants
=
{
// 用户状态
USER_STATUS
:
{
'
0
'
:
'正常, green'
,
'
-1
'
:
'停用, red'
'
1
'
:
'正常, green'
,
'
2
'
:
'停用, red'
},
// 角色数据权限
ROLE_AUTH
:
{
...
...
@@ -14,9 +14,20 @@ const Constants = {
},
// 租户可见度
ROLE_VISIBLE
:
{
'0'
:
'共享'
,
'1'
:
'仅系统管理员'
,
'2'
:
'可见租户'
0
:
'共享'
,
1
:
'仅系统管理员'
,
2
:
'可见租户'
},
// 菜单类型
MENU_TYPE
:
{
1
:
'目录'
,
2
:
'菜单'
,
3
:
'按钮'
},
// 菜单状态
MENU_STATUS
:
{
1
:
'正常, green'
,
2
:
'不显示, gray'
},
// 组织状态
ORGINIZA_STATUS
:
{
...
...
src/views/menuManage/index.vue
View file @
b71d9b4
...
...
@@ -4,19 +4,20 @@
<search-form
class=
"searchTop border-shadow"
:formModel=
"searchForm"
:formList=
"
user
FormList"
:formList=
"
menu
FormList"
>
<slot
name=
"form-slot"
>
<el-button
type=
"primary"
:size=
"btn_size"
icon=
"el-icon-search"
:id=
"tableParams.btnId
"
@
click=
"search
"
>
搜索
</el-button>
<el-button
type=
"primary"
:size=
"btn_size"
icon=
"el-icon-refresh"
@
click=
"refresh"
>
重置
</el-button>
</slot>
</search-form>
...
...
@@ -29,24 +30,14 @@
>
新增
</el-button>
</div>
<el-table
v-loading=
"loading"
align=
"center"
ref=
"multipleTable"
:data=
"listData"
tooltip-effect=
"dark"
:data=
"menuTableData"
style=
"width: 100%"
@
row-click=
"rowClick"
:header-cell-style=
"
{background:'#f5f7fa'}"
row-key=
"id"
border
lazy
:load=
"load"
:tree-props=
"
{children: 'children', hasChildren: 'hasChildren'}"
>
<table-tree-column
ref=
'OrgiSort'
@
table-click=
"tableClick"
prop=
"departmentName"
header-align=
"center"
treeKey=
"id"
width=
"300"
label=
"组织名称"
></table-tree-column>
<el-table-column
v-for=
"(item,index) in listHeadData"
:key=
"index"
...
...
@@ -58,13 +49,12 @@
show-overflow-tooltip
>
<template
slot-scope=
"scope"
>
<template
v-if=
"item.prop === 'orgStatus'"
>
dfs
<!--
<span
<template
v-if=
"item.prop === 'enableStatus'"
>
<span
class=
"dot"
:class=
"
ORGINIZASTATUS[scope.row[item.prop]].split(',')[1]
"
:class=
"
scope.row.enableStatus ? MENUSTATUS[scope.row.enableStatus].split(',')[1] : ''
"
></span>
<span
class=
"statusText"
>
{{
ORGINIZASTATUS
[
scope
.
row
[
item
.
prop
]].
split
(
','
)[
0
]
}}
</span>
--
>
<span
class=
"statusText"
>
{{
scope
.
row
.
enableStatus
?
MENUSTATUS
[
scope
.
row
.
enableStatus
].
split
(
','
)[
0
]
:
'--'
}}
</span
>
</
template
>
<
template
v-else
>
{{
scope
.
row
[
item
.
prop
]?
scope
.
row
[
item
.
prop
]:
'--'
}}
...
...
@@ -85,23 +75,34 @@
:type=
"j.type"
size=
"mini"
plain
@
click=
"btnClick(j.pType, scope.
scope
)"
@
click=
"btnClick(j.pType, scope.
row
)"
>
{{
j
.
name
}}
</el-button>
</
template
>
</el-table-column>
</el-table>
<!-- <el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.pageNum"
:page-sizes="[10,20,30,40]"
:page-size="page.pageSize"
:total="getListApi ? total : tableTotal"
layout="sizes,total,->,prev,pager,next,jumper"
>
</el-pagination> -->
<basic-dialog
:title=
"
user
DialogTitle"
:isVisible=
"
user
Visible"
:title=
"
menu
DialogTitle"
:isVisible=
"
menu
Visible"
@
confirmDialog=
"handleConfirm"
@
closeDialog=
"handleClose"
>
<slot>
<rule-form
:ruleForm=
"
user
Form"
:rules=
"
user
Rules"
:ruleData=
"
user
Data"
ref=
'
user
Form'
:ruleForm=
"
menu
Form"
:rules=
"
menu
Rules"
:ruleData=
"
menu
Data"
ref=
'
menu
Form'
></rule-form>
</slot>
</basic-dialog>
...
...
@@ -134,39 +135,46 @@
</div>
</template>
<
script
>
import
OrginizaService
from
'services/orginizaManage'
;
const
orginizaService
=
new
OrginizaService
();
import
{
getMenuList
,
getMenuChildren
,
addMenu
,
editMenu
,
menuInfo
,
deleteMenu
}
from
'services/menu'
;
export
default
{
data
()
{
return
{
ORGINIZASTATUS
:
this
.
$Constants
.
ORGINIZA
STATUS
,
MENUSTATUS
:
this
.
$Constants
.
MENU_
STATUS
,
searchForm
:
{},
user
FormList
:
[
menu
FormList
:
[
{
type
:
'input'
,
inputType
:
'text'
,
prop
:
'organizationName'
,
placeholder
:
'请输入
组织
名称'
placeholder
:
'请输入
菜单
名称'
},
{
type
:
'select'
,
prop
:
'enableStatus'
,
placeholder
:
'请选择
组织
状态'
,
placeholder
:
'请选择
菜单
状态'
,
options
:
[{
value
:
'
0
'
,
value
:
'
1
'
,
label
:
'正常'
},
{
value
:
'
1
'
,
label
:
'
停用
'
value
:
'
2
'
,
label
:
'
不显示
'
}]
}
],
listHeadData
:
[
// 列表 头部设置 数据
menuTableData
:
[],
// 列表 头部设置 数据
listHeadData
:
[
{
prop
:
'menuName'
,
label
:
'菜单名称'
},
{
prop
:
'orderNum'
,
label
:
'排序'
},
{
prop
:
'frontRoute'
,
label
:
'请求地址'
},
{
prop
:
'enableStatus'
,
label
:
'状态'
},
{
prop
:
'
createTime'
,
label
:
'创建时间
'
}
{
prop
:
'
permissionTag'
,
label
:
'权限标识
'
}
],
page
:
{
pageNum
:
10
,
pageSize
:
1
},
total
:
10
,
tableParams
:
{
tableOption
:
{
btnList
:
[
...
...
@@ -189,24 +197,30 @@ export default {
}
},
// 弹窗数据
userDialogTitle
:
'新增用户'
,
userVisible
:
false
,
userForm
:
{
account
:
''
,
departmentId
:
''
,
superiorId
:
''
,
menuDialogTitle
:
'新增菜单'
,
menuVisible
:
false
,
menuForm
:
{
parentName
:
''
,
enableStatus
:
true
},
userData
:
[
{
label
:
'组织名称'
,
prop
:
'account'
,
type
:
'input'
},
{
label
:
'显示排序'
,
prop
:
'departmentId'
,
type
:
'input'
},
{
label
:
'组织状态'
,
prop
:
'superiorId'
,
type
:
'input'
}
menuData
:
[
{
label
:
'菜单类型'
,
prop
:
'type'
,
type
:
'radio'
,
children
:
this
.
$Constants
.
MENU_TYPE
},
{
label
:
'上级菜单'
,
prop
:
'parentName'
,
type
:
'input'
,
readonly
:
true
,
clickFunc
:
this
.
selectSuperior
},
{
label
:
'菜单名称'
,
prop
:
'menuName'
,
type
:
'input'
},
{
label
:
'权限标识'
,
prop
:
'permissionTag'
,
type
:
'input'
},
{
label
:
'前端路由'
,
prop
:
'frontRoute'
,
type
:
'input'
},
{
label
:
'显示排序'
,
prop
:
'orderNum'
,
type
:
'input'
},
{
label
:
'显示状态'
,
prop
:
'enableStatus'
,
type
:
'switch'
},
{
label
:
'图标'
,
prop
:
'icon'
,
type
:
'input'
}
],
userRules
:
{
account
:
[{
required
:
true
,
message
:
'请输入登录名称'
,
trigger
:
blur
}]
menuRules
:
{
type
:
[{
required
:
true
,
message
:
'请输入菜单类型'
,
trigger
:
'change'
}],
menuName
:
[{
required
:
true
,
message
:
'请输入菜单名称'
,
trigger
:
'blur'
}],
orderNum
:
[{
required
:
true
,
message
:
'请输入显示排序'
,
trigger
:
'blur'
}],
enableStatus
:
[{
required
:
true
}],
},
// 部门弹窗
filterDialogTitle
:
'选择
组织
'
,
filterDialogTitle
:
'选择
上级
'
,
filterVisible
:
false
,
filterText
:
''
,
filterTextData
:
[
...
...
@@ -276,8 +290,6 @@ export default {
children
:
'children'
,
label
:
'label'
},
listData
:
[
],
loading
:
false
}
...
...
@@ -291,12 +303,25 @@ export default {
this
.
getList
()
},
methods
:
{
// 确定,新增用户、编辑用户
search
()
{
},
// 重置搜索条件
refresh
()
{
this
.
searchForm
=
{}
},
// 确定,新增、编辑
handleConfirm
()
{
console
.
log
(
this
.
$refs
.
user
Form
)
this
.
$refs
.
user
Form
.
$children
[
0
].
validate
((
valid
)
=>
{
console
.
log
(
this
.
menu
Form
)
this
.
$refs
.
menu
Form
.
$children
[
0
].
validate
((
valid
)
=>
{
if
(
valid
)
{
this
.
handleClose
()
let
params
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
menuForm
))
params
.
enableStatus
=
this
.
menuForm
.
enableStatus
?
1
:
2
let
api
=
addMenu
if
(
params
.
id
)
api
=
editMenu
api
(
params
).
then
(
res
=>
{
this
.
handleClose
()
})
}
else
{
console
.
log
(
'error'
)
}
...
...
@@ -304,10 +329,10 @@ export default {
},
// 取消
handleClose
()
{
if
(
!
this
.
userVisible
&&
this
.
$refs
.
user
Form
)
{
this
.
$refs
.
user
Form
.
$children
[
0
].
resetFields
()
if
(
!
this
.
menuVisible
&&
this
.
$refs
.
menu
Form
)
{
this
.
$refs
.
menu
Form
.
$children
[
0
].
resetFields
()
}
this
.
userVisible
=
!
this
.
user
Visible
this
.
menuVisible
=
!
this
.
menu
Visible
},
// 按钮事件
btnClick
(
pType
,
scope
)
{
...
...
@@ -323,7 +348,13 @@ export default {
},
// 编辑触发事件
editEvent
(
row
)
{
this
.
handleClose
()
console
.
log
(
row
)
menuInfo
({
id
:
row
.
id
}).
then
(
res
=>
{
this
.
menuDialogTitle
=
'编辑菜单'
this
.
menuForm
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
this
.
menuForm
.
enableStatus
=
res
.
data
.
enableStatus
==
1
?
true
:
false
this
.
handleClose
(
res
.
data
)
})
},
// 删除触发事件
deleteEvent
(
id
)
{
...
...
@@ -334,52 +365,64 @@ export default {
tipTitle
:
'提示'
,
type
:
'error'
,
callBack
:
()
=>
{
this
.
$message
({
type
:
'success'
,
message
:
'删除成功!'
deleteMenu
({
id
:
id
}).
then
(
res
=>
{
this
.
$message
({
type
:
'success'
,
message
:
'删除成功!'
})
})
}
}
this
.
$Common
.
confirmDialog
(
tipData
)
},
// 部门弹窗
selectDepart
()
{
this
.
filterDialogTitle
=
'选择组织'
this
.
closeFilter
()
load
(
tree
,
treeNode
,
resolve
)
{
setTimeout
(()
=>
{
resolve
([
{
id
:
31
,
date
:
'2016-05-01'
,
name
:
'王小虎'
,
address
:
'上海市普陀区金沙江路 1519 弄'
},
{
id
:
32
,
date
:
'2016-05-01'
,
name
:
'王小虎'
,
address
:
'上海市普陀区金沙江路 1519 弄'
}
])
},
1000
)
},
// 上级弹窗
selectSuperior
()
{
this
.
filterDialogTitle
=
'选择直接上级'
this
.
closeFilter
()
},
closeFilter
()
{
this
.
filterVisible
=
!
this
.
filterVisible
},
filterConfirm
()
{
console
.
log
(
this
.
$refs
.
tree
.
getCheckedKeys
(
false
,
true
))
// this.closeFilter()
console
.
log
(
this
.
$refs
.
tree
.
getCurrentNode
())
this
.
menuForm
.
parentId
=
this
.
$refs
.
tree
.
getCurrentNode
().
id
this
.
menuForm
.
parentName
=
this
.
$refs
.
tree
.
getCurrentNode
().
label
this
.
closeFilter
()
},
filterNode
(
value
,
data
)
{
console
.
log
(
value
,
data
)
if
(
!
value
)
return
true
return
data
.
label
.
indexOf
(
value
)
!==
-
1
},
// 表格方法
rowClick
(
row
,
e
,
col
)
{
console
.
log
(
row
,
e
,
col
,
'row cliock data'
)
orginizaService
.
getChildren
(
row
.
id
).
then
(
res
=>
{
console
.
log
(
res
)
row
.
children
=
res
.
data
.
list
})
},
// 业务
tableClick
(
that
,
index
,
row
,
data
)
{
console
.
log
(
that
,
index
,
row
,
data
,
'tableClick'
)
},
getList
()
{
orginizaService
.
getTable
List
().
then
((
res
)
=>
{
getMenu
List
().
then
((
res
)
=>
{
console
.
log
(
res
);
this
.
listData
=
res
.
data
.
list
let
arr
=
res
.
data
.
list
// for (let i in arr) {
// console.log(i)
// if (arr[i].haschildren) {
// console.log('Jinlaile ')
// arr[i].children = []
// }
// }
this
.
menuTableData
=
arr
console
.
log
(
this
.
menuTableData
)
},
(
err
)
=>
{
});
...
...
src/views/role/index.vue
View file @
b71d9b4
...
...
@@ -31,7 +31,7 @@
</div>
<basic-table
:tableParams=
"tableParams"
:
apiParame=
"apiParame
"
:
getListApi=
"getListApi
"
:searchForm=
"searchForm"
:hasNum=
"false"
>
...
...
@@ -63,10 +63,32 @@
:labelWidth=
"'120px'"
ref=
'roleForm'
>
<slot
name=
"form-slot"
slot-scope=
"scope"
>
<div
slot=
"visible-type"
>
<el-radio-group
@
change=
"radioChange($event)"
v-model=
"roleForm.visibleType"
>
<el-radio
v-for=
"(child,childIndex) in $Constants.ROLE_VISIBLE"
:key=
"childIndex"
:label=
"childIndex"
>
{{
child
}}
</el-radio>
</el-radio-group>
<el-select
v-if=
"roleForm.visibleType == '2'"
v-model=
"roleForm.visibleTenant"
placeholder=
"请选择"
>
<el-option
v-for=
"i in tenantList"
:key=
"i.tenantId"
:label=
"i.departmentName"
:value=
"i.tenantId"
>
</el-option>
</el-select>
</div>
<div
slot=
"menu-list"
>
<el-tree
:data=
"data"
show-checkbox
...
...
@@ -74,9 +96,11 @@
node-key=
"id"
ref=
"tree"
highlight-current
@
getCheckedKeys=
"getCheckedKeys"
@
setCheckedNodes=
"setCheckedNodes"
>
</el-tree>
</
slot
>
</
div
>
</rule-form>
</slot>
</basic-dialog>
...
...
@@ -85,13 +109,17 @@
</
template
>
<
script
>
import
{
ROLE_API
}
from
'@/config/config'
import
RoleService
from
'services/role'
;
import
{
getRoleList
,
roleInfo
,
getTenantList
,
addRole
,
editRole
,
deleteRole
}
from
'services/role'
;
export
default
{
data
()
{
var
checkMenu
=
(
rule
,
value
,
callBack
)
=>
{
if
(
value
&&
value
.
length
==
0
)
{
return
callBack
(
new
Error
(
'请选择菜单列表'
))
}
else
{
return
callBack
()
}
}
return
{
searchForm
:
{},
roleFormList
:
[
...
...
@@ -140,31 +168,30 @@ export default {
]
}
},
apiParame
:
ROLE_API
.
ROLE_SEARCH
,
getListApi
:
getRoleList
,
// 弹窗数据
roleDialogTitle
:
'新增角色'
,
roleVisible
:
false
,
roleForm
:
{
account
:
'胡悦'
,
departmentId
:
''
,
superiorId
:
''
,
enableStatus
:
true
enableStatus
:
true
,
menuIdList
:
[]
},
roleData
:
[
{
label
:
'角色名称:'
,
prop
:
'roleName'
,
type
:
'input'
},
{
label
:
'备注:'
,
prop
:
'remark'
,
type
:
'input'
},
{
label
:
'状态:'
,
prop
:
'enableStatus'
,
type
:
'switch'
},
{
label
:
'租户可见度:'
,
prop
:
'visibleType'
,
type
:
'radio'
,
hasSelect
:
true
,
children
:
this
.
$Constants
.
ROLE_VISIBLE
},
{
label
:
'租户可见度:'
,
prop
:
'visibleType'
,
type
:
'customize'
,
slotName
:
'visible-type'
},
// { label: '租户可见度:', prop: 'visibleType', type: 'radio', hasSelect: true, children: this.$Constants.ROLE_VISIBLE },
{
label
:
'数据权限:'
,
prop
:
'permissionType'
,
type
:
'radio'
,
children
:
this
.
$Constants
.
ROLE_AUTH
},
// [{ id: 1, label: '本人' }, { id: 2, label: '本人及下属' }, { id: 3, label: '本部门' }, { id: 4, label: '本部门&下属' }, { id: 5, label: '全部' }]
{
label
:
'菜单权限:'
,
prop
:
'menuIdList'
,
type
:
'customize'
}
{
label
:
'菜单权限:'
,
prop
:
'menuIdList'
,
type
:
'customize'
,
slotName
:
'menu-list'
}
],
roleRules
:
{
roleName
:
[{
required
:
true
,
message
:
'请输入角色名称'
,
trigger
:
blur
}],
roleName
:
[{
required
:
true
,
message
:
'请输入角色名称'
,
trigger
:
'blur'
}],
enableStatus
:
[{
required
:
true
}],
visibleType
:
[{
required
:
true
,
message
:
'请选择租户可见度'
}],
permissionType
:
[{
required
:
true
,
message
:
'请选择数据权限'
}],
menuIdList
:
[{
required
:
true
,
message
:
'请选择菜单列表
'
}]
menuIdList
:
[{
required
:
true
,
validator
:
checkMenu
,
trigger
:
'blur
'
}]
},
data
:
[{
id
:
1
,
...
...
@@ -200,9 +227,13 @@ export default {
id
:
8
,
label
:
'二级 3-2'
}]
}]
}],
tenantList
:
[]
}
},
mounted
()
{
this
.
getTenantList
()
},
methods
:
{
// 重置搜索条件
refresh
()
{
...
...
@@ -210,10 +241,17 @@ export default {
},
// 确定
handleConfirm
()
{
console
.
log
(
this
.
$refs
.
roleForm
)
this
.
getCheckedKeys
()
console
.
log
(
this
.
roleForm
)
this
.
$refs
.
roleForm
.
$children
[
0
].
validate
((
valid
)
=>
{
if
(
valid
)
{
this
.
handleClose
()
let
params
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
roleForm
))
params
.
enableStatus
=
this
.
roleForm
.
enableStatus
?
1
:
2
let
api
=
addRole
if
(
params
.
id
)
api
=
editRole
api
(
params
).
then
(
res
=>
{
this
.
handleClose
()
})
}
else
{
console
.
log
(
'error'
)
}
...
...
@@ -232,6 +270,11 @@ export default {
switch
(
pType
)
{
case
'create'
:
this
.
roleDialogTitle
=
'新增角色'
this
.
roleForm
=
{
enableStatus
:
true
,
menuIdList
:
[]
}
this
.
setCheckedNodes
()
this
.
handleClose
()
break
case
'edit'
:
...
...
@@ -245,7 +288,12 @@ export default {
},
// 编辑触发事件
editEvent
(
row
)
{
this
.
handleClose
()
roleInfo
({
id
:
row
.
id
}).
then
(
res
=>
{
this
.
roleForm
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
this
.
roleForm
.
enableStatus
=
res
.
data
.
enableStatus
==
1
?
true
:
false
this
.
handleClose
(
res
.
data
)
})
},
// 删除触发事件
deleteEvent
(
id
)
{
...
...
@@ -256,13 +304,32 @@ export default {
tipTitle
:
'提示'
,
type
:
'error'
,
callBack
:
()
=>
{
this
.
$message
({
type
:
'success'
,
message
:
'删除成功!'
deleteRole
({
id
:
id
}).
then
(
res
=>
{
this
.
$message
({
type
:
'success'
,
message
:
'删除成功!'
})
})
}
}
this
.
$Common
.
confirmDialog
(
tipData
)
},
// 获取选中菜单数组
getCheckedKeys
()
{
this
.
roleForm
.
menuIdList
=
this
.
$refs
.
tree
.
getCheckedKeys
()
console
.
log
(
this
.
$refs
.
tree
.
getCheckedKeys
())
},
setCheckedNodes
()
{
this
.
$refs
.
tree
.
setCheckedNodes
([])
},
// 获取租户列表
getTenantList
()
{
getTenantList
().
then
(
res
=>
{
this
.
tenantList
=
res
.
data
})
},
radioChange
(
e
)
{
console
.
log
(
e
)
}
}
}
...
...
src/views/user/index.vue
View file @
b71d9b4
...
...
@@ -56,7 +56,8 @@
<span
class=
"dot"
:class=
"scope.scope.enableStatus ? USERSTATUS[scope.scope.enableStatus].split(',')[1] : ''"
></span><span
class=
"statusText"
>
{{
scope
.
scope
.
enableStatus
?
USERSTATUS
[
scope
.
scope
.
enableStatus
].
split
(
','
)[
0
]
:
'--'
}}
</span>
></span>
<span
class=
"statusText"
>
{{
scope
.
scope
.
enableStatus
?
USERSTATUS
[
scope
.
scope
.
enableStatus
].
split
(
','
)[
0
]
:
'--'
}}
</span>
</span>
<span
slot=
"table-button"
...
...
@@ -119,7 +120,7 @@
<
script
>
// import UserService from 'services/user';
import
{
getUserList
,
getSuperUser
,
addUser
}
from
'services/user'
;
import
{
getUserList
,
getSuperUser
,
addUser
,
editUser
,
detailUser
,
deleteUser
,
roleList
}
from
'services/user'
;
import
OrginizaService
from
'services/orginizaManage'
;
const
orginizaService
=
new
OrginizaService
();
export
default
{
...
...
@@ -207,18 +208,19 @@ export default {
superiorName
:
''
,
enableStatus
:
true
},
roleList
:
[],
userData
:
[
{
label
:
'登录名称:'
,
prop
:
'account'
,
type
:
'input'
},
{
label
:
'部门名称:'
,
prop
:
'departmentName'
,
type
:
'input'
,
readonly
:
true
,
clickFunc
:
this
.
selectDepart
},
{
label
:
'直接上级:'
,
prop
:
'superiorName'
,
type
:
'input'
,
readonly
:
true
,
clickFunc
:
this
.
selectSuperior
},
{
label
:
'用户名称:'
,
prop
:
'username'
,
type
:
'input'
},
{
label
:
'密码:'
,
prop
:
'password'
,
type
:
'input'
,
inputText
:
'password'
},
{
label
:
'角色:'
,
prop
:
'roleId'
,
type
:
'select'
,
options
:
[]
},
{
label
:
'角色:'
,
prop
:
'roleId'
,
type
:
'select'
,
options
:
[]
,
key
:
'roleName'
,
value
:
'roleId'
,
filterable
:
true
},
{
label
:
'邮箱:'
,
prop
:
'email'
,
type
:
'input'
},
{
label
:
'手机:'
,
prop
:
'phoneNumber'
,
type
:
'input'
},
{
label
:
'性别:'
,
prop
:
'gender'
,
type
:
'select'
,
options
:
[]
},
{
label
:
'性别:'
,
prop
:
'gender'
,
type
:
'select'
,
options
:
[
{
label
:
'男'
,
value
:
0
},
{
label
:
'女'
,
value
:
1
}
]
},
{
label
:
'状态:'
,
prop
:
'enableStatus'
,
type
:
'switch'
},
{
label
:
'岗位:'
,
prop
:
'position'
,
type
:
'select'
,
options
:
[]
}
{
label
:
'岗位:'
,
prop
:
'position'
,
type
:
'select'
,
options
:
[
{
label
:
'12121'
,
value
:
0
},
{
label
:
'fasdfas'
,
value
:
1
}
]
}
],
userRules
:
{
account
:
[{
required
:
true
,
message
:
'请输入登录名称'
,
trigger
:
blur
}],
...
...
@@ -305,6 +307,7 @@ export default {
},
mounted
()
{
this
.
getTreeOrg
()
this
.
getRoleList
()
},
methods
:
{
// 重置搜索条件
...
...
@@ -313,10 +316,16 @@ export default {
},
// 确定,新增用户、编辑用户
handleConfirm
()
{
console
.
log
(
this
.
$refs
.
userForm
)
console
.
log
(
this
.
userForm
)
this
.
$refs
.
userForm
.
$children
[
0
].
validate
((
valid
)
=>
{
if
(
valid
)
{
this
.
handleClose
()
let
params
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
userForm
))
params
.
enableStatus
=
this
.
userForm
.
enableStatus
?
1
:
2
let
api
=
addUser
if
(
params
.
id
)
api
=
editUser
api
(
params
).
then
(
res
=>
{
this
.
handleClose
()
})
}
else
{
console
.
log
(
'error'
)
}
...
...
@@ -328,6 +337,7 @@ export default {
this
.
$refs
.
userForm
.
$children
[
0
].
resetFields
()
}
this
.
userVisible
=
!
this
.
userVisible
console
.
log
(
this
.
userForm
)
},
// 组织架构节点
handleNodeClick
(
data
)
{
...
...
@@ -347,6 +357,11 @@ export default {
switch
(
pType
)
{
case
'create'
:
this
.
userDialogTitle
=
'新增用户'
this
.
userForm
=
{
departmentName
:
''
,
superiorName
:
''
,
enableStatus
:
true
}
this
.
handleClose
()
break
case
'edit'
:
...
...
@@ -361,9 +376,13 @@ export default {
// 编辑触发事件
editEvent
(
row
)
{
console
.
log
(
row
)
this
.
userDialogTitle
=
'编辑用户'
this
.
userForm
=
row
this
.
handleClose
(
row
)
detailUser
({
id
:
row
.
id
}).
then
(
res
=>
{
this
.
userDialogTitle
=
'编辑用户'
this
.
userForm
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
))
this
.
userForm
.
enableStatus
=
res
.
data
.
enableStatus
==
1
?
true
:
false
this
.
handleClose
(
res
.
data
)
})
},
// 删除触发事件
deleteEvent
(
id
)
{
...
...
@@ -374,9 +393,11 @@ export default {
tipTitle
:
'提示'
,
type
:
'error'
,
callBack
:
()
=>
{
this
.
$message
({
type
:
'success'
,
message
:
'删除成功!'
deleteUser
({
id
:
id
}).
then
(
res
=>
{
this
.
$message
({
type
:
'success'
,
message
:
'删除成功!'
})
})
}
}
...
...
@@ -435,6 +456,14 @@ export default {
console
.
log
(
res
)
this
.
data
=
res
.
data
.
list
})
},
// 角色下拉列表
getRoleList
()
{
roleList
().
then
(
res
=>
{
this
.
roleList
=
res
.
data
this
.
userData
[
5
].
options
=
res
.
data
console
.
log
(
this
.
roleList
)
})
}
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment