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 38595d6d
authored
Oct 08, 2018
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
https://github.com/glsx-web/authority
2 parents
8324b025
9cf2f9b5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
45 deletions
package.json
src/components/RoleCreate/src/main.vue
src/components/Tree/src/main.vue
src/views/customer/role/index.vue
package.json
View file @
38595d6
...
...
@@ -9,7 +9,7 @@
},
"dependencies"
:
{
"glsx-vue-common"
:
"^1.1.12"
,
"glsx-vue-components"
:
"^1.0.1
3
"
,
"glsx-vue-components"
:
"^1.0.1
2
"
,
"lodash"
:
"^4.17.10"
,
"node-sass"
:
"^4.9.3"
,
"sass-loader"
:
"^7.1.0"
,
...
...
src/components/RoleCreate/src/main.vue
View file @
38595d6
...
...
@@ -21,7 +21,7 @@
</gl-select>
</gl-form-item>
<gl-form-item
label=
"菜单选项:"
prop=
"rights"
>
<tree
ref=
'tree'
v-model=
"createRuleForm.rights"
:show-checkbox=
"show_checkbox"
:defaultExpandAll=
"defaultExpandAll"
:defaultCheckedKeys=
"
createRuleForm.right
s"
@
input=
"getMenuOption"
style=
"height:160px"
:keyFresh=
"keyFresh"
></tree>
<tree
ref=
'tree'
v-model=
"createRuleForm.rights"
:show-checkbox=
"show_checkbox"
:defaultExpandAll=
"defaultExpandAll"
:defaultCheckedKeys=
"
defaultCheckedKey
s"
@
input=
"getMenuOption"
style=
"height:160px"
:keyFresh=
"keyFresh"
></tree>
</gl-form-item>
</gl-form>
<div
slot=
"footer"
class=
"dialog-footer"
>
...
...
@@ -37,12 +37,26 @@ export default {
props
:
{
createVisible
:
Boolean
,
createRuleForm
:
Object
,
flagCOrE
:
[
Boolean
,
Array
,
Function
]
flagCOrE
:
[
Boolean
,
Array
,
Function
],
defaultCheckedKeys
:
Array
},
watch
:
{
createVisible
(
val
)
{
!
val
&&
this
.
$refs
[
'createRuleForm'
].
resetFields
()
this
.
keyFresh
=
val
// this.checkStrictlyOrNot = true
// val && (this.defaultCheckedKeys = this.$deep_clone(this.createRuleForm.rights))
// clearTimeout(timer)
// if (val) {
// this.defaultCheckedKeys = this.$deep_clone(this.createRuleForm.rights)
// this.checkStrictlyOrNot = true
// var timer = setTimeout(() => {
// this.checkStrictlyOrNot = false
// console.log('-----------------')
// }, 1000)
// }
// console.log(this.createRuleForm)
// console.log(this.defaultCheckedKeys)
// console.log(this.keyFresh)
},
flagCOrE
(
val
)
{
...
...
@@ -56,11 +70,12 @@ export default {
return
{
isDepart
:
true
,
show_checkbox
:
true
,
defaultExpandAll
:
tru
e
,
defaultExpandAll
:
fals
e
,
departName
:
[],
numberErr
:
false
,
title
:
''
,
keyFresh
:
Boolean
,
// checkStrictlyOrNot: true,
createRules
:
{
roleName
:
[
{
required
:
true
,
message
:
'请输入角色名称!'
,
trigger
:
'blur'
}
...
...
@@ -81,8 +96,9 @@ export default {
methods
:
{
// tree-strat
getMenuOption
(
params
)
{
this
.
createRuleForm
.
rights
=
params
.
treeData
.
checkedKeys
// this.createRuleForm.rights = params.treeData.checkedKeys.concat(params.treeData.halfCheckedKeys)
// this.checkStrictlyOrNot = false
// this.createRuleForm.rights = params.treeData.checkedKeys
this
.
createRuleForm
.
rights
=
params
.
treeData
.
checkedKeys
.
concat
(
params
.
treeData
.
halfCheckedKeys
)
},
clickDepart
(
data
,
treeData
,
vue
,
props
)
{
if
(
data
.
parent
!==
'#'
||
!
data
.
children
)
{
...
...
src/components/Tree/src/main.vue
View file @
38595d6
...
...
@@ -9,10 +9,10 @@
:props=
'props'
:default-expand-all=
'defaultExpandAll'
:default-checked-keys=
"defaultCheckedKeys"
:check-strictly=
"checkStrictly"
:check-strictly=
"checkStrictly
OrNot
"
@
check=
'check'
@
node-click=
'nodeClick'
v-loading=
"loading"
v-loading=
"loading"
gl-loading-text=
"拼命加载中"
gl-loading-icon=
"el-icon-loading"
></gl-tree>
...
...
@@ -27,7 +27,7 @@ export default {
return
{
data
:
null
,
loading
:
true
,
checkStrictly
:
true
,
checkStrictly
OrNot
:
true
,
props
:
{
label
:
'text'
}
...
...
@@ -44,14 +44,16 @@ export default {
default
:
()
=>
[]
},
isDepart
:
Boolean
,
// checkStrictlyOrNot: true,
propsData
:
null
},
watch
:
{
keyFresh
(
val
)
{
// console.log(val)
// console.log(`keyFresh----------------------${this.keyFresh}`)
// console.log(this.defaultCheckedKeys)
val
&&
(
this
.
checkStrictly
=
val
)
&&
this
.
loadingTree
()
this
.
loading
=
true
this
.
checkStrictlyOrNot
=
true
val
&&
this
.
loadingTree
()
},
propsData
(
val
)
{
this
.
loadingTree
()
...
...
@@ -63,12 +65,22 @@ export default {
},
check
(
data
,
treeData
)
{
this
.
$emit
(
'input'
,
{
data
,
treeData
})
this
.
checkStrictly
=
false
},
loadingTree
()
{
// console.log(this.checkStrictly)
!
this
.
propsData
&&
this
.
getData
()
this
.
propsData
&&
(
this
.
data
=
fn
(
this
.
propsData
,
'#'
))
// !this.propsData && this.getData()
// this.propsData && (this.data = fn(this.propsData, '#'))
if
(
this
.
propsData
)
{
this
.
data
=
fn
(
this
.
propsData
,
'#'
)
this
.
loading
=
false
}
else
{
clearTimeout
(
timer
)
this
.
getData
()
var
timer
=
setTimeout
(()
=>
{
this
.
checkStrictlyOrNot
=
false
this
.
loading
=
false
},
400
)
}
// console.log(this.checkStrictly)
// console.log(this.propsData)
// console.log(this.data)
...
...
@@ -79,13 +91,13 @@ export default {
?
findMenuTree
.
req
().
then
(
res
=>
{
// console.log(res)
this
.
data
=
fn
(
res
,
'#'
)
this
.
loading
=
false
//
this.loading = false
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
:
findDepartTree
.
req
().
then
(
res
=>
{
this
.
data
=
fn
(
res
,
'#'
)
this
.
loading
=
false
//
this.loading = false
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
...
...
@@ -102,10 +114,6 @@ function fn(data, pid) {
if
(
data
[
i
].
parent
==
pid
)
{
result
.
push
(
data
[
i
])
temp
=
fn
(
data
,
data
[
i
].
id
)
// if (data[i].id === 1013 || data[i].id === 1014) {
// console.log(`i = ${i}`)
// console.log(`pid = ${pid}`)
// }
if
(
temp
.
length
>
0
)
{
data
[
i
].
children
=
temp
}
...
...
src/views/customer/role/index.vue
View file @
38595d6
...
...
@@ -7,7 +7,7 @@
</div>
<div
class=
"default p-t15"
>
<gl-button
class=
"control-tabledata-button"
size=
"small"
@
click=
"handleCreateOrEdit(flagCOrE = true)"
>
创建
</gl-button>
<role-create
:createVisible=
"createVisible"
:createRuleForm=
"roleParam"
:flagCOrE=
"flagCOrE"
@
createClose=
"handleCreateClose"
></role-create>
<role-create
:createVisible=
"createVisible"
:createRuleForm=
"roleParam"
:
defaultCheckedKeys=
"roleMenu"
:
flagCOrE=
"flagCOrE"
@
createClose=
"handleCreateClose"
></role-create>
<div
class=
"m-b8"
>
<transition>
<gl-table
:table=
"roleData"
></gl-table>
...
...
@@ -43,11 +43,13 @@ export default {
detailVisible
:
false
,
userDetailVisible
:
false
,
roleParam
:
this
.
$deep_clone
(
roleCreateStructure
),
roleMenu
:
[],
columnParam
:
[],
consoleParam
:
[],
apiParam
:
Number
,
flagRoleOrUser
:
true
,
flagCOrE
:
Boolean
,
editOrDetail
:
Boolean
,
roleMenuTree
:
[],
createOrEditTitle
:
'新增角色'
,
userDetailTitle
:
'用户列表'
,
...
...
@@ -154,35 +156,32 @@ export default {
this
.
message
(
message
,
'error'
)
})
},
roleMenuOption
(
data
,
pid
)
{
data
.
forEach
(
item
=>
{
if
(
item
.
parent
==
pid
)
{
this
.
roleMenu
.
push
(
item
.
id
)
this
.
roleMenuOption
(
data
,
item
.
id
)
}
})
},
// 获得角色的相关权限详细信息,并返回树形数据
getMenuTree
(
params
)
{
selectMenuTreeRoleId
.
req
({
id
:
params
}).
then
(
res
=>
{
this
.
roleMenuTree
=
res
this
.
deleteDialogVisible
()
// console.log(res)
if
(
this
.
editOrDetail
)
{
this
.
roleMenuOption
(
res
,
'#'
)
this
.
createDialogVisible
()
// console.log(this.roleMenu)
}
else
{
this
.
roleMenuTree
=
res
this
.
deleteDialogVisible
()
}
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
},
// 添加角色
addRole
(
params
)
{
console
.
log
(
params
)
// this.createOrEditSuccess()
// editData = { roleName: editData.roleName }
// const aa = { role: editData }
// const aa = JSON.stringify(editData)
// console.log(aa)
// console.log(editData)
// const cc = { roleName: 'ggg' }
// ----------------------
// delete params.roleName
// delete params.description
// delete params.departId
// delete params.departName
// delete params.departPath
// delete params.rights
// delete params.state
// const paramsJS = JSON.stringify(params)
// console.log(paramsJS)
saveRoleList
.
req
(
params
).
then
((
data
)
=>
{
console
.
log
(
data
)
this
.
createOrEditSuccess
()
...
...
@@ -195,7 +194,6 @@ export default {
console
.
log
(
params
)
delete
params
.
createTime
delete
params
.
updateTime
// this.createOrEditSuccess()
updateRole
.
req
(
params
).
then
((
data
)
=>
{
console
.
log
(
data
)
this
.
createOrEditSuccess
()
...
...
@@ -216,6 +214,7 @@ export default {
createOrEditSuccess
()
{
this
.
createDialogVisible
()
this
.
message
(
this
.
flagCOrE
?
'创建角色成功!'
:
'已经成功修改数据!'
,
'success'
)
this
.
roleMenu
=
[]
this
.
getList
()
},
// 调取接口相关函数
...
...
@@ -231,7 +230,7 @@ export default {
this
.
getList
()
},
handleGetRoleDetail
()
{
this
.
getMenuTree
(
this
.
roleParam
.
id
)
this
.
getMenuTree
(
this
.
roleParam
.
id
,
this
.
editOrDetail
=
false
)
},
handleDetailClose
()
{
this
.
deleteDialogVisible
()
...
...
@@ -252,8 +251,9 @@ export default {
},
handleCreateOrEdit
()
{
this
.
roleParam
=
this
.
flagCOrE
?
this
.
$deep_clone
(
roleCreateStructure
)
:
this
.
roleParam
this
.
createDialogVisible
()
// this.flagCOrE && this.createDialogVisible()
// this.createDialogVisible()
this
.
flagCOrE
&&
this
.
createDialogVisible
()
!
this
.
flagCOrE
&&
this
.
getMenuTree
(
this
.
roleParam
.
id
,
this
.
editOrDetail
=
true
)
// !this.flagCOrE && this.getMenuTree(this.roleParam.id, this.editOrDetail = true)
},
// 关闭新增用户组件
...
...
@@ -261,6 +261,7 @@ export default {
// this.roleParam = this.$deep_clone(roleCreateStructure)
if
(
!
data
)
{
this
.
createDialogVisible
()
this
.
roleMenu
=
[]
this
.
message
(
this
.
flagCOrE
?
'取消创建角色'
:
'取消编辑角色'
,
'info'
)
return
false
}
...
...
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