Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx-web
/
authority
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 89ca2a8a
authored
Nov 01, 2018
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
验证提交
2 parents
b3fb7b9d
90966f7c
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
365 additions
and
132 deletions
src/api/api.js
src/api/roleApi.js
src/api/userApi.js
src/base.js
src/common/commonConst.js
src/common/notice.js
src/common/roleConst.js
src/common/userConst.js
src/components/LeftManager/src/main.vue
src/components/RightForm/src/main.vue
src/components/RoleCreate/src/main.vue
src/components/UserCreate/src/main.vue
src/components/UserDetail/src/main.vue
src/config/common.conf.js
src/views/customer/role/index.vue
src/views/customer/user/index.vue
src/api/api.js
View file @
89ca2a8
...
...
@@ -3,7 +3,7 @@ import {
deleteUserRoleById
,
getRoleDetail
,
getRoleList
,
//
isRoleNameExit,
isRoleNameExit
,
saveRoleList
,
selectMenuTreeRoleId
,
selectUserRoleByRoleId
,
...
...
@@ -16,7 +16,8 @@ import {
getUser
,
getWithRoles
,
operatUser
,
updateUser
updateUser
,
existsByName
}
from
'./userApi'
import
{
...
...
@@ -43,7 +44,7 @@ export {
deleteUserRoleById
,
getRoleDetail
,
getRoleList
,
//
isRoleNameExit,
isRoleNameExit
,
saveRoleList
,
selectMenuTreeRoleId
,
selectUserRoleByRoleId
,
...
...
@@ -55,6 +56,7 @@ export {
getWithRoles
,
operatUser
,
updateUser
,
existsByName
,
// depart接口
delDepartment
,
findDepartTree
,
...
...
src/api/roleApi.js
View file @
89ca2a8
...
...
@@ -6,7 +6,7 @@ const __sDeleteRole = `${path}/deleteRoleById`
const
__sDeleteUserRole
=
`
${
path
}
/deleteUserRoleById`
const
__sGetRoleDetail
=
`
${
path
}
/getRoleDetail`
const
__sGetRoleList
=
`
${
path
}
/getRoleList`
//
const __sIsRoleNameExit = `${path}/isRoleNameExit`
const
__sIsRoleNameExit
=
`
${
path
}
/isRoleNameExit`
const
__sSaveRoleList
=
`
${
path
}
/saveRoleList`
const
__sSelectMenuTreeRoleId
=
`
${
path
}
/selectMenuTreeRoleId`
const
__sSelectUserRole
=
`
${
path
}
/selectUserRoleByRoleId`
...
...
@@ -32,10 +32,10 @@ const getRoleList = {
req
:
params
=>
GlAxios
.
get
(
__sGetRoleList
,
{
params
})
}
//
const isRoleNameExit = {
//
p: [__sIsRoleNameExit],
//
req: params => GlAxios.get(__sIsRoleNameExit, { params })
//
}
const
isRoleNameExit
=
{
p
:
[
__sIsRoleNameExit
],
req
:
params
=>
GlAxios
.
get
(
__sIsRoleNameExit
,
{
params
})
}
const
saveRoleList
=
{
p
:
[
__sSaveRoleList
],
...
...
@@ -62,7 +62,7 @@ export {
deleteUserRoleById
,
getRoleDetail
,
getRoleList
,
//
isRoleNameExit,
isRoleNameExit
,
saveRoleList
,
selectMenuTreeRoleId
,
selectUserRoleByRoleId
,
...
...
src/api/userApi.js
View file @
89ca2a8
...
...
@@ -8,6 +8,7 @@ const __sGet = `${path}/get`
const
__sGetWithRoles
=
`
${
path
}
/getWithRoles`
const
__sOperatUser
=
`
${
path
}
/operatUser`
const
__sUpdateUser
=
`
${
path
}
/updateUser`
const
__sExistsByName
=
`
${
path
}
/existsByName`
const
batcheDelUser
=
{
p
:
[
__sBatcheDel
],
...
...
@@ -38,6 +39,10 @@ const updateUser = {
p
:
[
__sUpdateUser
],
req
:
params
=>
GlAxios
.
post
(
__sUpdateUser
,
params
)
}
const
existsByName
=
{
p
:
[
__sExistsByName
],
req
:
params
=>
GlAxios
.
get
(
__sExistsByName
,
{
params
})
}
export
{
batcheDelUser
,
...
...
@@ -45,5 +50,6 @@ export {
getUser
,
getWithRoles
,
operatUser
,
updateUser
updateUser
,
existsByName
}
src/base.js
View file @
89ca2a8
...
...
@@ -22,7 +22,7 @@ const config = {
}
Vue
.
use
(
VeeValidate
,
config
)
Validator
.
localize
(
'zh_CN'
,
zh_CN
)
Vue
.
prototype
.
$valid
=
Validator
var
mixin
=
{
mounted
()
{
const
_this
=
this
...
...
src/common/commonConst.js
View file @
89ca2a8
import
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
userRoleDetailConsole
}
from
'./roleConst'
import
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
}
from
'./roleConst'
import
{
userForm
,
userDetailColumn
}
from
'./userConst'
function
fn
(
data
,
pid
)
{
...
...
@@ -20,7 +20,6 @@ export {
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
userRoleDetailConsole
,
userDetailColumn
,
userForm
,
fn
...
...
src/common/notice.js
View file @
89ca2a8
import
Vue
from
'vue'
import
{
deleteUserRoleById
}
from
'@/api/api'
export
default
new
Vue
({
methods
:
{
confirmTips
(
conMessage
,
source
,
index
,
rows
,
roleLoadingParams
)
{
this
.
$confirm
(
conMessage
,
''
,
{
conirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
if
(
source
===
'userRoleDetail'
)
{
roleLoadingParams
.
loading
=
true
this
.
deleteUserRole
(
index
,
rows
,
roleLoadingParams
)
}
}).
catch
(()
=>
{})
},
deleteUserRole
(
index
,
rows
,
roleLoadingParams
)
{
const
data
=
rows
[
index
]
const
params
=
{
roleId
:
data
.
roleId
,
userId
:
data
.
userId
}
deleteUserRoleById
.
req
(
params
).
then
(()
=>
{
this
.
okTips
(
`删除成功`
)
roleLoadingParams
.
freshList
=
true
}).
catch
(
err
=>
{
roleLoadingParams
.
loading
=
false
this
.
errorTips
(
err
)
})
},
warningTips
(
message
)
{
this
.
$notify
({
type
:
'warning'
,
title
:
message
})
},
okTips
(
message
)
{
this
.
$notify
({
type
:
'success'
,
...
...
src/common/roleConst.js
View file @
89ca2a8
import
{
deleteUserRoleById
}
from
'@/api/api'
import
notice
from
'./notice'
const
roleCreateStructure
=
{
id
:
Number
,
roleName
:
''
,
...
...
@@ -54,32 +51,8 @@ const userRoleDetailColumn = [{
}
}]
const
userRoleDetailConsole
=
{
show
:
true
,
label
:
'操作'
,
prop
:
'option'
,
button
:
[{
label
:
'删除'
,
type
:
'text'
,
callback
:
(
index
,
rows
)
=>
{
const
data
=
rows
[
index
]
const
params
=
{
roleId
:
data
.
roleId
,
userId
:
data
.
userId
}
deleteUserRoleById
.
req
(
params
).
then
(
res
=>
{
notice
.
okTips
(
'删除成功'
)
rows
.
splice
(
index
,
1
)
}).
catch
(
err
=>
{
notice
.
errorTips
(
err
)
})
}
}]
}
export
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
userRoleDetailConsole
userRoleDetailColumn
}
src/common/userConst.js
View file @
89ca2a8
...
...
@@ -38,7 +38,6 @@ const userDetailColumn = [{
label
:
'状态'
,
prop
:
'state'
,
formatter
:
(
cellValue
)
=>
{
console
.
log
(
cellValue
)
return
cellValue
.
state
<
1
?
'禁用'
:
'启动'
}
}]
...
...
src/components/LeftManager/src/main.vue
View file @
89ca2a8
...
...
@@ -64,6 +64,7 @@ export default {
this
.
clearFrom
()
},
clearFrom
()
{
// console.log(this.value.form)
this
.
value
.
showDetails
=
true
this
.
value
.
btnTxt
=
'保存'
this
.
value
.
del
=
false
...
...
src/components/RightForm/src/main.vue
View file @
89ca2a8
...
...
@@ -29,11 +29,13 @@
v-model=
"value.form[i.value]"
:disabled=
"i.disabled"
>
</gl-input>
<div
v-show=
"err && index === 0"
class=
"err"
>
{{
textName
}}
</div>
<span
v-show=
"err && index === 0"
class=
"err"
>
{{
textName
}}
</span>
<span
v-show=
"errExist && index === 0"
class=
"err"
>
{{
textExist
}}
</span>
<span
v-show=
"errOpenstyle && !isDepart && index === 2"
class=
"err"
>
请选择打开模式
</span>
</gl-form-item>
<gl-form-item>
<gl-button
type=
"primary"
@
click=
"submit"
>
{{
value
.
btnTxt
}}
</gl-button>
<gl-button
type=
"danger"
v-show=
'value.del'
@
click=
"dialog = true "
>
删除
</gl-button>
<gl-button
type=
"primary"
@
click=
"submit"
:loading=
"subLoading"
>
{{
value
.
btnTxt
}}
</gl-button>
<gl-button
type=
"danger"
v-show=
'value.del'
@
click=
"dialog = true "
:loading=
"delLoading"
>
删除
</gl-button>
<gl-button
@
click=
'value.showDetails = false'
style=
"float:right"
>
取消
</gl-button>
</gl-form-item>
</gl-form>
...
...
@@ -52,6 +54,7 @@
</
template
>
<
script
type=
'text/ecmascript-6'
>
import
{
delDepartment
,
delMenu
,
editMenu
,
addMenu
,
updateDepartment
}
from
'@/api/api'
import
notice
from
'@/common/notice'
const
reg
=
new
RegExp
(
/^
[
0-9
]
*$/
)
export
default
{
name
:
'rightForm'
,
...
...
@@ -62,9 +65,12 @@ export default {
textName
:
this
.
isDepart
?
'请填写部门名称'
:
'请填写列表名称'
,
errExist
:
false
,
textExist
:
''
,
errOpenstyle
:
false
,
errIorder
:
false
,
textType
:
'请填写数字'
,
menu
:
''
menu
:
''
,
subLoading
:
false
,
delLoading
:
false
}
},
mounted
()
{
...
...
@@ -82,9 +88,16 @@ export default {
eventBus
:
Object
},
watch
:
{
'value.showDetails'
(
val
)
{
this
.
err
=
false
this
.
errOpenstyle
=
false
},
'value.form.urlName'
(
val
)
{
if
(
val
!==
''
)
this
.
nameTip
()
},
'value.form.openStyle'
(
val
)
{
if
(
val
!==
null
)
this
.
openStyleTip
()
},
'value.form.name'
(
val
)
{
if
(
val
!==
''
)
this
.
nameTip
()
}
...
...
@@ -100,6 +113,10 @@ export default {
this
.
errExist
=
false
this
.
textExist
=
''
},
openStyleTip
()
{
this
.
errOpenstyle
=
false
this
.
openText
=
''
},
nameExitTip
(
err
)
{
this
.
errExist
=
true
this
.
textExist
=
err
...
...
@@ -116,26 +133,34 @@ export default {
// 接口调用-start
addOrEditDepart
(
params
)
{
updateDepartment
.
req
(
params
).
then
(
res
=>
{
this
.
subLoading
=
false
this
.
Tip
(
true
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
subLoading
=
false
notice
.
errorTips
(
err
)
})
},
// 接口调用-end
// 删除
delData
()
{
this
.
delLoading
=
true
const
obj
=
this
.
getMenuObj
()
obj
.
isHidden
=
this
.
value
.
form
.
isHidden
===
true
?
0
:
1
this
.
dialog
=
false
this
.
isDepart
?
delDepartment
.
req
(
obj
).
then
(
res
=>
{
this
.
delLoading
=
false
this
.
delTip
(
true
)
}).
catch
(
err
=>
{
this
.
delLoading
=
false
console
.
log
(
err
)
this
.
delErrTip
()
})
:
delMenu
.
req
({
menuId
:
obj
.
id
}).
then
(
res
=>
{
this
.
delLoading
=
false
this
.
delTip
(
true
)
}).
catch
(
err
=>
{
this
.
delLoading
=
false
console
.
log
(
err
)
this
.
delErrTip
()
})
...
...
@@ -152,13 +177,7 @@ export default {
})
this
.
value
.
showDetails
=
false
this
.
value
.
updateTree
=
!
this
.
value
.
updateTree
}
else
{
this
.
$notify
({
title
:
'已取消'
,
type
:
'info'
})
}
this
.
dialog
=
false
},
delErrTip
()
{
this
.
$notify
({
...
...
@@ -170,8 +189,9 @@ export default {
// 保存修改
submit
()
{
const
treeData
=
this
.
value
.
allNode
if
(
this
.
value
.
form
[
this
.
form
[
0
].
value
]
!==
''
&&
this
.
value
.
form
[
this
.
form
[
0
].
value
]
!==
null
)
{
if
(
this
.
value
.
form
[
this
.
form
[
0
].
value
]
!==
''
&&
this
.
value
.
form
[
this
.
form
[
0
].
value
]
!==
null
&&
(
this
.
value
.
form
[
this
.
form
[
2
].
value
]
!==
null
||
this
.
isDepart
)
)
{
const
obj
=
this
.
getMenuObj
()
this
.
subLoading
=
true
obj
.
isHidden
=
this
.
value
.
form
.
isHidden
===
true
?
0
:
1
// 添加同级
if
(
this
.
value
.
sublings
)
{
...
...
@@ -190,18 +210,25 @@ export default {
}
else
{
if
(
!
this
.
isDepart
)
{
editMenu
.
req
(
obj
).
then
(
res
=>
{
this
.
subLoading
=
false
this
.
Tip
(
true
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
subLoading
=
false
this
.
Tip
(
false
)
})
}
else
{
this
.
subLoading
=
true
this
.
addOrEditDepart
(
obj
)
}
}
}
else
{
}
if
(
this
.
value
.
form
[
this
.
form
[
0
].
value
]
===
''
||
this
.
value
.
form
[
this
.
form
[
0
].
value
]
===
null
)
{
this
.
err
=
true
}
if
(
this
.
value
.
form
[
this
.
form
[
2
].
value
]
===
null
&&
!
this
.
isDepart
)
{
this
.
errOpenstyle
=
true
}
},
unix
(
time
)
{
time
=
time
.
substring
(
0
,
19
)
...
...
@@ -211,11 +238,19 @@ export default {
addData
(
obj
)
{
if
(
!
this
.
isDepart
)
{
addMenu
.
req
(
obj
).
then
(
res
=>
{
this
.
subLoading
=
false
this
.
Tip
(
true
)
}).
catch
(
err
=>
{
this
.
nameExitTip
(
err
)
this
.
subLoading
=
false
console
.
log
(
err
)
if
(
err
===
'菜单名已存在'
)
{
this
.
nameExitTip
(
err
)
}
else
{
notice
.
errorTips
(
err
)
}
})
}
else
{
this
.
errIorder
=
true
this
.
addOrEditDepart
(
obj
)
}
},
...
...
src/components/RoleCreate/src/main.vue
View file @
89ca2a8
<!-- createRoleComponent -->
<
template
>
<gl-dialog
:title=
"title"
:visible
.
sync=
"createVisible"
:before-close=
"handleCreateCancel"
>
<gl-form
:model=
"createRuleForm"
:rules=
"createRules"
ref=
"createRuleForm"
label-width=
"10
5
px"
>
<gl-form
:model=
"createRuleForm"
:rules=
"createRules"
ref=
"createRuleForm"
label-width=
"10
0
px"
>
<gl-form-item
label=
"角色名称:"
prop=
"roleName"
>
<gl-input
name=
"roleName"
data-vv-as=
"角色名称"
v-validate=
"'required'"
v-model=
"createRuleForm.roleName"
clearable
></gl-input>
<gl-input
name=
"roleName"
data-vv-as=
"角色名称"
v-validate=
"'required|uniqueName'"
v-model=
"createRuleForm.roleName"
clearable
></gl-input>
<span
v-show=
"errorBags.has('roleName')"
class=
"error"
>
{{
errorBags
.
first
(
'roleName'
)
}}
</span>
</gl-form-item>
<gl-form-item
label=
"角色描述:"
prop=
"description"
>
<gl-input
name=
"description"
data-vv-as=
"角色描述"
v-validate=
"'required|max:200'"
v-model=
"createRuleForm.description"
type=
"textarea"
:rows=
"3"
clearable
></gl-input>
<gl-input
name=
"description"
data-vv-as=
"角色描述"
v-validate=
"'required|max:200'"
v-model=
"createRuleForm.description"
type=
"textarea"
:rows=
"3"
clearable
></gl-input>
<span
v-show=
"errorBags.has('description')"
class=
"error"
>
{{
errorBags
.
first
(
'description'
)
}}
</span>
</gl-form-item>
<gl-form-item>
...
...
@@ -53,6 +61,7 @@
</
template
>
<
script
>
import
{
isRoleNameExit
}
from
'@/api/api'
export
default
{
name
:
'RoleCreate'
,
props
:
{
...
...
@@ -77,6 +86,7 @@ export default {
},
data
()
{
return
{
roleName
:
''
,
isDepart
:
true
,
show_checkbox
:
true
,
defaultExpandAll
:
false
,
...
...
@@ -104,6 +114,31 @@ export default {
}
}
},
mounted
()
{
this
.
$valid
.
extend
(
'uniqueName'
,
{
validate
:
value
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
value
===
this
.
createRuleForm
.
oldRoleName
)
{
resolve
(
true
)
}
isRoleNameExit
.
req
({
roleName
:
this
.
createRuleForm
.
roleName
}).
then
(
data
=>
{
// 此处data返回一个布尔值,true为已存在,false为不存在
resolve
(
data
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
resolve
(
false
)
})
})
}
})
this
.
$validator
.
localize
(
'zh_CN'
,
{
custom
:
{
roleName
:
{
uniqueName
:
'该角色已存在'
}
}
})
},
methods
:
{
// tree-strat
getMenuOption
(
params
)
{
...
...
@@ -148,6 +183,9 @@ export default {
}
</
script
>
<
style
scoped
>
.dialog-footer
{
margin-top
:
-40px
;
}
.err
{
color
:
red
;
}
...
...
src/components/UserCreate/src/main.vue
View file @
89ca2a8
...
...
@@ -3,38 +3,73 @@
<gl-form
:model=
"userManageForm"
:rules=
"rules"
ref=
"userManageForm"
label-width=
"100px"
>
<el-col
:span=
"12"
>
<gl-form-item
label=
"用户名"
prop=
"username"
>
<gl-input
type=
"text"
name=
"username"
data-vv-as=
"用户名"
v-validate=
"'required|min:5'"
v-model=
"userManageForm.username"
placeholder=
"请输入用户名"
clearable
></gl-input>
<gl-input
type=
"text"
name=
"username"
data-vv-as=
"用户名"
v-validate=
"'required|min:5|uniqueName'"
v-model=
"userManageForm.username"
placeholder=
"请输入用户名"
clearable
></gl-input>
<span
v-show=
"errorBags.has('username')"
class=
"error"
>
{{
errorBags
.
first
(
'username'
)
}}
</span>
</gl-form-item>
</el-col>
<gl-col
:span=
"12"
>
<gl-form-item
label=
"真实姓名"
prop=
"realname"
>
<gl-input
type=
"text"
name=
"realname"
data-vv-as=
"真实姓名"
v-validate=
"'required'"
v-model=
"userManageForm.realname"
placeholder=
"请输入用户真实名字"
clearable
></gl-input>
<gl-input
type=
"text"
name=
"realname"
data-vv-as=
"真实姓名"
v-validate=
"'required'"
v-model=
"userManageForm.realname"
placeholder=
"请输入用户真实名字"
clearable
></gl-input>
<span
v-show=
"errorBags.has('realname')"
class=
"error"
>
{{
errorBags
.
first
(
'realname'
)
}}
</span>
</gl-form-item>
</gl-col>
<gl-col
:span=
"12"
>
<gl-form-item
label=
"密码"
prop=
"password"
:rules=
"[
{ required: !userManageForm.id }]" >
<gl-input
type=
'password'
name=
"password"
data-vv-as=
"密码"
v-validate=
"!userManageForm.id? 'required|min:5': ''"
v-model=
"userManageForm.password"
:placeholder=
'placeholder'
clearable
></gl-input>
<gl-input
type=
'password'
name=
"password"
data-vv-as=
"密码"
v-validate=
"!userManageForm.id? 'required|min:5': ''"
v-model=
"userManageForm.password"
:placeholder=
'placeholder'
clearable
></gl-input>
<span
v-show=
"errorBags.has('password')"
class=
"error"
>
{{
errorBags
.
first
(
'password'
)
}}
</span>
</gl-form-item>
</gl-col>
<gl-col
:span=
"12"
>
<gl-form-item
label=
"手机号码"
prop=
"mobile"
>
<gl-masked
type=
"text"
name=
"mobile"
data-vv-as=
"手机号码"
v-validate=
"'required|length:11'"
placeholder=
"请输入手机号码"
v-model=
"userManageForm.mobile"
:mask=
"[ 1, /[34578]/, /\d/, /\d/, /\d/,/\d/, /\d/, /\d/,/\d/, /\d/, /\d/]"
clearable
></gl-masked>
<gl-masked
type=
"text"
name=
"mobile"
data-vv-as=
"手机号码"
v-validate=
"'required|length:11'"
placeholder=
"请输入手机号码"
v-model=
"userManageForm.mobile"
:mask=
"[ 1, /[34578]/, /\d/, /\d/, /\d/,/\d/, /\d/, /\d/,/\d/, /\d/, /\d/]"
clearable
></gl-masked>
<span
v-show=
"errorBags.has('mobile')"
class=
"error"
>
{{
errorBags
.
first
(
'mobile'
)
}}
</span>
</gl-form-item>
</gl-col>
<gl-col
:span=
"12"
>
<gl-form-item
label=
"注册IP"
prop=
"joinip"
>
<gl-masked
name=
"joinip"
v-validate=
"'required'"
data-vv-as=
"注册IP"
v-model=
"userManageForm.joinip"
ip
clearable
></gl-masked>
<gl-masked
name=
"joinip"
v-validate=
"'required'"
data-vv-as=
"注册IP"
v-model=
"userManageForm.joinip"
ip
clearable
></gl-masked>
<span
v-show=
"errorBags.has('joinip')"
class=
"error"
>
{{
errorBags
.
first
(
'joinip'
)
}}
</span>
</gl-form-item>
</gl-col>
<gl-col
:span=
"12"
>
<gl-form-item
prop=
"email"
label=
"邮箱"
>
<gl-input
type=
"text"
name=
"email"
data-vv-as=
"邮箱"
v-model=
'userManageForm.email'
placeholder=
"请输入邮箱地址"
v-validate=
"'required|email'"
clearable
></gl-input>
<gl-input
type=
"text"
name=
"email"
data-vv-as=
"邮箱"
v-model=
'userManageForm.email'
placeholder=
"请输入邮箱地址"
v-validate=
"'required|email'"
clearable
></gl-input>
<span
v-show=
"errorBags.has('email')"
class=
"error"
>
{{
errorBags
.
first
(
'email'
)
}}
</span>
</gl-form-item>
</gl-col>
...
...
@@ -57,15 +92,32 @@
<gl-col
:span=
"24"
>
<gl-form-item
label=
"所属部门"
prop=
"departName"
>
<gl-input-tree
name=
"departName"
data-vv-as=
"所属部门"
v-validate=
"'required'"
:data=
'userManageForm.departList'
:props=
"props"
:treeStyle=
'
{ maxHeight: "160px" }' @node-click='clickDepart' v-model="userManageForm.departName" />
<gl-input-tree
name=
"departName"
data-vv-as=
"所属部门"
v-validate=
"'required'"
:data=
'userManageForm.departList'
:props=
"props"
:treeStyle=
'
{ maxHeight: "160px" }'
@node-click='clickDepart'
v-model="userManageForm.departName" />
<span
v-show=
"errorBags.has('departName')"
class=
"error"
>
{{
errorBags
.
first
(
'departName'
)
}}
</span>
</gl-form-item>
</gl-col>
<gl-col
:span=
"24"
>
<gl-form-item
label=
"角色选项"
prop=
"roles"
:key=
"key"
>
<gl-checkbox-group
name=
"roles"
data-vv-as=
"角色选项"
v-validate=
"'required'"
class=
"height"
v-model=
"userManageForm.roles"
@
change=
"handleCheckedChange"
>
<gl-checkbox
v-for=
"item in userManageForm.roleList"
:key=
"item.id"
:label=
'item.id'
>
{{
item
.
roleName
}}
</gl-checkbox>
<gl-checkbox-group
name=
"roles"
data-vv-as=
"角色选项"
v-validate=
"'required'"
class=
"height"
v-model=
"userManageForm.roles"
@
change=
"handleCheckedChange"
>
<gl-checkbox
v-for=
"item in userManageForm.roleList"
:key=
"item.id"
:label=
'item.id'
>
{{
item
.
roleName
}}
</gl-checkbox>
</gl-checkbox-group>
<span
v-show=
"errorBags.has('roles')"
class=
"error"
>
{{
errorBags
.
first
(
'roles'
)
}}
</span>
</gl-form-item>
...
...
@@ -79,6 +131,7 @@
</
template
>
<
script
>
import
{
existsByName
}
from
'@/api/api'
import
{
userForm
}
from
'@/common/userConst'
export
default
{
name
:
'UserCreate'
,
...
...
@@ -138,6 +191,31 @@ export default {
}
}
},
mounted
()
{
this
.
$valid
.
extend
(
'uniqueName'
,
{
validate
:
value
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
value
===
this
.
userManageForm
.
oldUserName
)
{
resolve
(
true
)
}
existsByName
.
req
({
username
:
this
.
userManageForm
.
username
}).
then
(
data
=>
{
// 此处data返回一个布尔值,false为已存在,true为不存在
resolve
(
data
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
resolve
(
false
)
})
})
}
})
this
.
$validator
.
localize
(
'zh_CN'
,
{
custom
:
{
username
:
{
uniqueName
:
'该用户已存在'
}
}
})
},
methods
:
{
// 部门树
clickDepart
(
data
,
treeData
,
vue
,
props
)
{
...
...
@@ -181,7 +259,6 @@ export default {
},
cancelForm
()
{
this
.
$emit
(
'userFormData'
)
// this.$validator.errors.clear()
},
handleCheckedChange
(
value
)
{
if
(
!
value
)
return
...
...
src/components/UserDetail/src/main.vue
View file @
89ca2a8
...
...
@@ -2,7 +2,7 @@
<
template
>
<div>
<gl-dialog
:title=
"userDetailTitle"
:visible
.
sync=
"userDetailVisible"
:before-close=
"handleClose"
>
<gl-table
:table=
"tableParam"
></gl-table>
<gl-table
:table=
"tableParam"
v-loading=
"roleLoadingParams.loading"
gl-loading-text=
"拼命加载中"
></gl-table>
<gl-pagination
background
v-show=
"flagRoleOrUser"
...
...
@@ -18,6 +18,8 @@
<
script
>
import
{
selectUserRoleByRoleId
}
from
'@/api/api'
import
notice
from
'@/common/notice'
export
default
{
name
:
'UserDetail'
,
props
:
{
...
...
@@ -25,33 +27,46 @@ export default {
userDetailVisible
:
Boolean
,
apiParam
:
[
Object
,
Function
],
flagRoleOrUser
:
[
Boolean
,
Function
],
columnParam
:
Array
,
consoleParam
:
[
Array
,
Object
]
columnParam
:
Array
},
watch
:
{
columnParam
(
val
)
{
this
.
tableParam
.
column
=
val
},
consoleParam
(
val
)
{
this
.
tableParam
.
console
=
val
this
.
flagRoleOrUser
&&
(
this
.
tableParam
.
console
=
this
.
userRoleDetailConsole
)
},
apiParam
(
val
)
{
this
.
id
=
val
.
id
this
.
id
&&
this
.
callApi
()
},
'roleLoadingParams.freshList'
(
val
)
{
val
&&
this
.
callApi
()
}
},
data
()
{
return
{
pageNum
:
1
,
pageSize
:
5
,
total
:
10
,
total
:
5
,
id
:
Number
,
roleLoadingParams
:
{
loading
:
false
,
freshList
:
false
},
userRoleDetailConsole
:
{
show
:
true
,
label
:
'操作'
,
prop
:
'option'
,
button
:
[{
label
:
'删除'
,
type
:
'text'
,
callback
:
(
index
,
rows
)
=>
{
notice
.
confirmTips
(
'确定要删除该用户吗?'
,
'userRoleDetail'
,
index
,
rows
,
this
.
roleLoadingParams
)
}
}]
},
tableParam
:
{
border
:
true
,
align
:
'center'
,
data
:
[],
column
:
[],
console
:
[]
console
:
{}
}
}
},
...
...
@@ -69,16 +84,23 @@ export default {
selectUserRoleByRoleId
.
req
(
params
).
then
(
res
=>
{
this
.
total
=
res
.
total
this
.
tableParam
.
data
=
res
.
list
this
.
roleLoadingParams
.
loading
=
false
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
roleLoadingParams
.
loading
=
false
notice
.
errorTips
(
err
)
})
},
callApi
()
{
this
.
flagRoleOrUser
&&
this
.
selectUser
()
!
this
.
flagRoleOrUser
&&
(
this
.
tableParam
.
data
=
[
this
.
apiParam
])
this
.
flagRoleOrUser
&&
(
this
.
roleLoadingParams
.
loading
=
true
)
this
.
flagRoleOrUser
?
this
.
selectUser
()
:
(
this
.
tableParam
.
data
=
[
this
.
apiParam
])
this
.
roleLoadingParams
.
freshList
=
false
},
handleClose
()
{
this
.
$emit
(
'userDetailClose'
)
clearTimeout
(
timer
)
var
timer
=
setTimeout
(()
=>
{
this
.
pageNum
=
1
},
200
)
},
handleCurrentChange
(
val
)
{
this
.
pageNum
=
val
...
...
src/config/common.conf.js
View file @
89ca2a8
...
...
@@ -2,7 +2,7 @@ export default {
axios
:
{
baseURL
:
'http://cas.dev.glsx.net/admin-operating-auth/'
,
// baseURL: 'http://192.168.3.171:7300/mock/5b91805391b67469b43e2921/subsystem/',
whiteList
:
[
'role/deleteRoleById'
,
'role/deleteUserRoleById'
,
'role/getRoleDetail'
,
'role/getRoleDetail'
,
'role/getRoleList'
,
'role/isRoleNameExit'
,
'role/saveRoleList'
,
'role/selectMenuTreeRoleId'
,
'role/selectUserRoleByRoleId'
,
'role/updateRole'
,
'user/batcheDel'
,
'user/findAll'
,
'user/get'
,
'user/getWithRoles'
,
'user/operatUser'
,
'user/updateUser'
,
'department/del'
,
'department/findTree'
,
'department/getPName'
,
'department/getTreeNode'
,
'department/updateDepartment'
,
'menu/add'
,
'menu/del'
,
'menu/edit'
,
'menu/findById'
,
'menu/findTree'
,
'menu/getByUserId'
,
'menu/getPName'
],
whiteList
:
[
'role/deleteRoleById'
,
'role/deleteUserRoleById'
,
'role/getRoleDetail'
,
'role/getRoleDetail'
,
'role/getRoleList'
,
'role/isRoleNameExit'
,
'role/saveRoleList'
,
'role/selectMenuTreeRoleId'
,
'role/selectUserRoleByRoleId'
,
'role/updateRole'
,
'user/batcheDel'
,
'user/findAll'
,
'user/get'
,
'user/getWithRoles'
,
'user/
existsByName'
,
'user/
operatUser'
,
'user/updateUser'
,
'department/del'
,
'department/findTree'
,
'department/getPName'
,
'department/getTreeNode'
,
'department/updateDepartment'
,
'menu/add'
,
'menu/del'
,
'menu/edit'
,
'menu/findById'
,
'menu/findTree'
,
'menu/getByUserId'
,
'menu/getPName'
],
timeout
:
15000
,
result
:
{
data_key
:
'data'
,
// 返回值数据实体存放对象
...
...
src/views/customer/role/index.vue
View file @
89ca2a8
...
...
@@ -18,7 +18,7 @@
</role-create>
<div
class=
"m-b8"
>
<transition>
<gl-table
:table=
"roleData"
></gl-table>
<gl-table
:table=
"roleData"
v-loading=
"loadingTable"
gl-loading-text=
"拼命加载中"
></gl-table>
</transition>
<gl-pagination
background
@
size-change=
"handleSizeChange"
...
...
@@ -41,7 +41,6 @@
@
userDetailClose=
"handleUserDetailClose"
:apiParam=
"apiParam"
:columnParam=
"columnParam"
:consoleParam=
"consoleParam"
:flagRoleOrUser=
"flagRoleOrUser"
></user-detail>
</div>
</div>
...
...
@@ -52,19 +51,18 @@
import
{
RoleCreate
,
RoleDetail
,
UserDetail
}
from
'@/components/index'
// 接口
import
{
getRoleList
,
deleteRoleById
,
selectMenuTreeRoleId
,
saveRoleList
,
updateRole
,
findDepartTree
}
from
'@/api/api'
import
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
userRoleDetailConsole
,
fn
}
from
'@/common/commonConst'
import
{
roleCreateStructure
,
roleDataColumn
,
userRoleDetailColumn
,
fn
}
from
'@/common/commonConst'
import
notice
from
'@/common/notice'
export
default
{
name
:
'role'
,
components
:
{
RoleCreate
,
RoleDetail
,
UserDetail
,
saveRoleList
,
updateRole
UserDetail
},
data
()
{
return
{
loadingTable
:
false
,
loading
:
false
,
roleName
:
''
,
createVisible
:
false
,
...
...
@@ -73,7 +71,6 @@ export default {
roleParam
:
this
.
$deep_clone
(
roleCreateStructure
),
roleMenu
:
[],
columnParam
:
[],
consoleParam
:
[],
apiParam
:
Object
,
flagRoleOrUser
:
true
,
flagCOrE
:
Boolean
,
...
...
@@ -82,6 +79,7 @@ export default {
createOrEditTitle
:
'新增角色'
,
userDetailTitle
:
'用户列表'
,
departList
:
[],
tipParams
:
''
,
// 分页所需参数-start
total
:
10
,
pageNum
:
1
,
...
...
@@ -133,7 +131,11 @@ export default {
},
watch
:
{
roleName
(
val
)
{
!
val
&&
this
.
getList
()
// !val && this.getList()
if
(
!
val
)
{
this
.
loadingTable
=
true
this
.
getList
()
}
}
},
methods
:
{
...
...
@@ -144,6 +146,7 @@ export default {
type
:
'warning'
}).
then
(()
=>
{
// 删除角色,根据返回的code值来判断是否删除成功(已有拦截器)
this
.
loadingTable
=
true
this
.
deleteRole
(
rows
[
index
].
id
)
}).
catch
(()
=>
{
})
...
...
@@ -163,8 +166,12 @@ export default {
getRoleList
.
req
(
params
).
then
(
res
=>
{
this
.
total
=
res
.
total
this
.
roleData
.
data
=
res
.
list
this
.
loadingTable
=
false
this
.
tipParams
=
''
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
tipParams
=
''
this
.
loadingTable
=
false
notice
.
errorTips
(
err
)
})
},
// 删除角色
...
...
@@ -173,6 +180,7 @@ export default {
notice
.
okTips
(
'删除成功'
)
this
.
getList
()
}).
catch
(
message
=>
{
this
.
loadingTable
=
false
notice
.
errorTips
(
message
)
})
},
...
...
@@ -203,10 +211,9 @@ export default {
saveRoleList
.
req
(
params
).
then
((
data
)
=>
{
this
.
createOrEditSuccess
()
}).
catch
(
err
=>
{
this
.
loading
=
false
notice
.
errorTips
(
err
)
console
.
log
(
err
)
})
this
.
loading
=
false
},
// 编辑角色
updateRoleInfo
(
params
)
{
...
...
@@ -215,15 +222,16 @@ export default {
updateRole
.
req
(
params
).
then
((
data
)
=>
{
this
.
createOrEditSuccess
()
}).
catch
(
err
=>
{
this
.
loading
=
false
notice
.
errorTips
(
err
)
console
.
log
(
err
)
})
this
.
loading
=
false
},
// 获取部门树
getdepartData
()
{
findDepartTree
.
req
().
then
(
res
=>
{
this
.
departList
=
fn
(
res
,
'#'
)
}).
catch
(
err
=>
{
notice
.
errorTips
(
err
)
})
},
// 接口请求-end---------------------------------------
...
...
@@ -238,29 +246,32 @@ export default {
},
emptyParam
()
{
this
.
createDialogVisible
()
this
.
roleMenu
=
[]
clearTimeout
(
timer
)
var
timer
=
setTimeout
(()
=>
{
this
.
roleParam
=
this
.
$deep_clone
(
roleCreateStructure
)
},
200
)
},
createOrEditSuccess
()
{
// this.createDialogVisible()
this
.
emptyParam
()
this
.
loading
=
false
notice
.
okTips
(
this
.
flagCOrE
?
'创建角色成功!'
:
'已经成功修改数据!'
)
this
.
roleMenu
=
[]
this
.
loadingTable
=
true
this
.
getList
()
},
// 调取接口相关函数
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
this
.
loadingTable
=
true
this
.
getList
()
},
handleCurrentChange
(
val
)
{
this
.
pageNum
=
val
this
.
loadingTable
=
true
this
.
getList
()
},
handleSearchRoleName
()
{
this
.
loadingTable
=
true
this
.
getList
()
},
handleGetRoleDetail
()
{
...
...
@@ -273,18 +284,19 @@ export default {
},
handleGetUserDetail
(
index
,
rows
)
{
this
.
columnParam
=
userRoleDetailColumn
this
.
consoleParam
=
userRoleDetailConsole
this
.
flagRoleOrUser
=
true
this
.
apiParam
=
rows
[
index
]
this
.
userDetailDialogVisible
()
},
handleUserDetailClose
()
{
this
.
userDetailDialogVisible
()
this
.
loadingTable
=
true
this
.
getList
()
this
.
apiParam
=
Object
},
handleCreateOrEdit
()
{
this
.
roleParam
=
this
.
flagCOrE
?
this
.
$deep_clone
(
roleCreateStructure
)
:
this
.
roleParam
this
.
roleParam
.
oldRoleName
=
this
.
roleParam
.
roleName
this
.
flagCOrE
?
this
.
createDialogVisible
()
:
this
.
getMenuTree
(
this
.
roleParam
.
id
,
this
.
editOrDetail
=
true
)
},
// 关闭新增用户组件
...
...
src/views/customer/user/index.vue
View file @
89ca2a8
...
...
@@ -18,7 +18,7 @@
</user-create>
</div>
<div
class=
"m-b8"
>
<gl-table
:table=
"userData"
ref=
"multipleTable"
></gl-table>
<gl-table
:table=
"userData"
v-loading=
"laodingTable"
gl-loading-text=
"拼命加载中"
ref=
"multipleTable"
></gl-table>
<gl-pagination
background
@
size-change=
"handleSizeChange"
@
current-change=
"handleCurrentChange"
...
...
@@ -53,7 +53,6 @@ export default {
components
:
{
UserCreate
,
UserDetail
,
updateUser
,
userForm
},
data
()
{
...
...
@@ -66,6 +65,8 @@ export default {
userManageForm
:
this
.
$deep_clone
(
userForm
),
userDetailVisible
:
false
,
loading
:
false
,
laodingTable
:
false
,
tipParams
:
''
,
userDetailTitle
:
'用户详情'
,
// 分页所需参数-start
total
:
10
,
...
...
@@ -151,17 +152,13 @@ export default {
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
laodingTable
=
true
if
(
rows
[
index
].
state
<
1
)
{
this
.
$set
(
rows
[
index
],
'state'
,
'1'
)
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
1
})
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
1
},
rows
,
index
)
}
else
{
this
.
$set
(
rows
[
index
],
'state'
,
'0'
)
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
0
})
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
0
},
rows
,
index
)
}
notice
.
okTips
(
'修改成功'
)
}).
catch
(()
=>
{
notice
.
errorTips
(
'修改失败'
)
})
}).
catch
(()
=>
{})
}
},
{
label
:
'删除'
,
...
...
@@ -183,7 +180,10 @@ export default {
},
watch
:
{
userName
(
val
)
{
!
val
&&
this
.
findUserList
()
if
(
!
val
)
{
this
.
laodingTable
=
true
this
.
findUserList
()
}
}
},
methods
:
{
...
...
@@ -201,8 +201,12 @@ export default {
findAll
.
req
(
params
).
then
(
res
=>
{
this
.
total
=
res
.
total
this
.
userData
.
data
=
res
.
list
this
.
laodingTable
=
false
this
.
tipParams
=
''
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
tipParams
=
''
this
.
laodingTable
=
false
notice
.
errorTips
(
err
)
})
},
// 获取所有角色选项
...
...
@@ -220,30 +224,55 @@ export default {
},
// 新增更新用户接口请求
updateUser_Post
(
params
)
{
this
.
loading
=
true
updateUser
.
req
(
params
).
then
(
res
=>
{
notice
.
okTips
(
'操作成功'
)
this
.
emptyForm
()
this
.
loading
=
false
this
.
laodingTable
=
true
notice
.
okTips
(
'操作成功'
)
this
.
findUserList
()
}).
catch
(
message
=>
{
notice
.
errorTips
(
message
)
//
notice.errorTips(message)
this
.
loading
=
false
})
},
// 删除用户接口
batcheDel
(
params
)
{
this
.
laodingTable
=
true
batcheDelUser
.
req
({
ids
:
params
}).
then
(
res
=>
{
notice
.
okTips
(
'删除成功'
)
this
.
findUserList
()
}).
catch
(
err
=>
{
this
.
laodingTable
=
false
notice
.
errorTips
(
err
)
})
},
// 删除、禁用、启用接口f
operatUser
(
params
)
{
operatUser
(
params
,
rows
,
index
)
{
operatUser
.
req
(
params
).
then
(
res
=>
{
(
params
.
state
===
2
)
&&
this
.
findUserList
()
switch
(
params
.
state
)
{
case
0
:
this
.
$set
(
rows
[
index
],
'state'
,
'0'
)
this
.
laodingTable
=
false
notice
.
okTips
(
rows
[
index
].
username
+
'用户状态已禁用'
)
break
case
1
:
this
.
$set
(
rows
[
index
],
'state'
,
'1'
)
this
.
laodingTable
=
false
notice
.
okTips
(
rows
[
index
].
username
+
'用户状态已启动'
)
break
case
2
:
notice
.
okTips
(
'删除成功'
)
this
.
findUserList
()
break
}
}).
catch
(
err
=>
{
this
.
laodingTable
=
false
notice
.
errorTips
(
err
)
})
},
emptyForm
()
{
this
.
dialogFormVisible
=
!
this
.
dialogFormVisible
this
.
loading
=
false
this
.
handleUserFormVisible
()
clearTimeout
(
timer
)
var
timer
=
setTimeout
(()
=>
{
this
.
userManageForm
=
this
.
$deep_clone
(
userForm
)
...
...
@@ -251,21 +280,20 @@ export default {
},
// 接受子组件传递的值
handleUserFormData
(
isEdit
,
params
)
{
this
.
loading
=
true
params
&&
this
.
updateUser_Post
(
params
)
!
params
&&
this
.
emptyForm
()
},
// 新增按钮
createUser
()
{
this
.
loading
=
false
this
.
userManageForm
=
this
.
$deep_clone
(
userForm
)
this
.
dialogFormVisible
=
!
this
.
dialogFormVisible
this
.
handleUserFormVisible
()
this
.
isEdit
=
false
},
// 编辑按钮
editUser
(
row
)
{
this
.
loading
=
false
row
.
password
=
''
// console.log(row)
row
.
oldUserName
=
row
.
username
row
.
roleList
=
this
.
$deep_clone
(
userForm
.
roleList
)
row
.
departList
=
this
.
$deep_clone
(
userForm
.
departList
)
row
.
state
=
row
.
state
+
''
...
...
@@ -285,7 +313,7 @@ export default {
}
this
.
userManageForm
=
this
.
$deep_clone
(
row
)
})
this
.
dialogFormVisible
=
!
this
.
dialogFormVisible
this
.
handleUserFormVisible
()
this
.
isEdit
=
true
},
// 获取选中的行
...
...
@@ -299,30 +327,33 @@ export default {
this
.
toggle
.
forEach
(
row
=>
{
ids
.
push
(
row
.
id
+
''
)
})
this
.
$confirm
(
'确定要删除这条数据?'
,
''
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消
'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
batcheDel
(
ids
.
join
(
','
))
notice
.
okTips
(
'删除成功'
)
}).
catch
(
err
=>
{
notice
.
errorTips
(
err
)
// console.log('error'
)
}
)
ids
.
length
?
this
.
$confirm
(
'确定要删除这条数据?'
,
''
,
{
confirmButtonText
:
'确定
'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
batcheDel
(
ids
.
join
(
','
)
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
}
)
:
notice
.
warningTips
(
'请选中你需要删除的用户'
)
}
},
// 搜索
finduserName
()
{
this
.
laodingTable
=
true
this
.
findUserList
()
},
// 调取接口相关函数 分页
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
this
.
laodingTable
=
true
this
.
findUserList
()
},
handleCurrentChange
(
val
)
{
this
.
pageNum
=
val
this
.
laodingTable
=
true
this
.
findUserList
()
},
// 单行删除
...
...
@@ -332,8 +363,8 @@ export default {
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
laodingTable
=
true
this
.
operatUser
({
id
:
rows
[
index
].
id
,
state
:
2
})
notice
.
okTips
(
'成功删除该用户'
)
}).
catch
(()
=>
{
})
},
...
...
@@ -361,6 +392,9 @@ export default {
handleUserDetailClose
()
{
this
.
userDetailVisible
=
!
this
.
userDetailVisible
this
.
apiParam
=
Object
},
handleUserFormVisible
()
{
this
.
dialogFormVisible
=
!
this
.
dialogFormVisible
}
}
}
...
...
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