Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jeecg-boot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
jeecg-boot
Commits
107e9018
Commit
107e9018
authored
Oct 20, 2019
by
zhangdaihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JeecgBoot 2.1.1 代码生成器AI版本发布
parent
c69884c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
35 deletions
+19
-35
ant-design-vue-jeecg/src/views/system/modules/UserRoleModal.vue
+19
-35
No files found.
ant-design-vue-jeecg/src/views/system/modules/UserRoleModal.vue
View file @
107e9018
...
@@ -31,10 +31,8 @@
...
@@ -31,10 +31,8 @@
<div
class=
"drawer-bootom-button"
>
<div
class=
"drawer-bootom-button"
>
<a-dropdown
style=
"float: left"
:trigger=
"['click']"
placement=
"topCenter"
>
<a-dropdown
style=
"float: left"
:trigger=
"['click']"
placement=
"topCenter"
>
<a-menu
slot=
"overlay"
>
<a-menu
slot=
"overlay"
>
<!-- 简化Tree逻辑,使用默认checkStrictly为false的行为,即默认父子关联
<a-menu-item
key=
"1"
@
click=
"switchCheckStrictly(1)"
>
父子关联
</a-menu-item>
<a-menu-item
key=
"1"
@
click=
"switchCheckStrictly(1)"
>
父子关联
</a-menu-item>
<a-menu-item
key=
"2"
@
click=
"switchCheckStrictly(2)"
>
取消关联
</a-menu-item>
<a-menu-item
key=
"2"
@
click=
"switchCheckStrictly(2)"
>
取消关联
</a-menu-item>
-->
<a-menu-item
key=
"3"
@
click=
"checkALL"
>
全部勾选
</a-menu-item>
<a-menu-item
key=
"3"
@
click=
"checkALL"
>
全部勾选
</a-menu-item>
<a-menu-item
key=
"4"
@
click=
"cancelCheckALL"
>
取消全选
</a-menu-item>
<a-menu-item
key=
"4"
@
click=
"cancelCheckALL"
>
取消全选
</a-menu-item>
<a-menu-item
key=
"5"
@
click=
"expandAll"
>
展开所有
</a-menu-item>
<a-menu-item
key=
"5"
@
click=
"expandAll"
>
展开所有
</a-menu-item>
...
@@ -70,11 +68,10 @@
...
@@ -70,11 +68,10 @@
treeData
:
[],
treeData
:
[],
defaultCheckedKeys
:[],
defaultCheckedKeys
:[],
checkedKeys
:[],
checkedKeys
:[],
halfCheckedKeys
:[],
expandedKeysss
:[],
expandedKeysss
:[],
allTreeKeys
:[],
allTreeKeys
:[],
autoExpandParent
:
true
,
autoExpandParent
:
true
,
checkStrictly
:
fals
e
,
checkStrictly
:
tru
e
,
title
:
"角色权限配置"
,
title
:
"角色权限配置"
,
visible
:
false
,
visible
:
false
,
loading
:
false
,
loading
:
false
,
...
@@ -88,10 +85,12 @@
...
@@ -88,10 +85,12 @@
}
}
this
.
$refs
.
datarule
.
show
(
this
.
selectedKeys
[
0
],
this
.
roleId
)
this
.
$refs
.
datarule
.
show
(
this
.
selectedKeys
[
0
],
this
.
roleId
)
},
},
onCheck
(
checkedKeys
,
{
halfCheckedKeys
})
{
onCheck
(
o
)
{
// 保存选中的和半选中的,后面保存的时候合并提交
if
(
this
.
checkStrictly
){
this
.
checkedKeys
=
checkedKeys
this
.
checkedKeys
=
o
.
checked
;
this
.
halfCheckedKeys
=
halfCheckedKeys
}
else
{
this
.
checkedKeys
=
o
}
},
},
show
(
roleId
){
show
(
roleId
){
this
.
roleId
=
roleId
this
.
roleId
=
roleId
...
@@ -122,18 +121,24 @@
...
@@ -122,18 +121,24 @@
this
.
checkedKeys
=
this
.
allTreeKeys
this
.
checkedKeys
=
this
.
allTreeKeys
},
},
cancelCheckALL
()
{
cancelCheckALL
()
{
//this.checkedKeys = this.defaultCheckedKeys
this
.
checkedKeys
=
[]
this
.
checkedKeys
=
[]
},
},
switchCheckStrictly
(
v
)
{
if
(
v
==
1
){
this
.
checkStrictly
=
false
}
else
if
(
v
==
2
){
this
.
checkStrictly
=
true
}
},
handleCancel
()
{
handleCancel
()
{
this
.
close
()
this
.
close
()
},
},
handleSubmit
(){
handleSubmit
(){
let
that
=
this
;
let
that
=
this
;
let
checkedKeys
=
[...
that
.
checkedKeys
,
...
that
.
halfCheckedKeys
]
const
permissionIds
=
checkedKeys
.
join
(
","
)
let
params
=
{
let
params
=
{
roleId
:
that
.
roleId
,
roleId
:
that
.
roleId
,
permissionIds
,
permissionIds
:
that
.
checkedKeys
.
join
(
","
)
,
lastpermissionIds
:
that
.
defaultCheckedKeys
.
join
(
","
),
lastpermissionIds
:
that
.
defaultCheckedKeys
.
join
(
","
),
};
};
that
.
loading
=
true
;
that
.
loading
=
true
;
...
@@ -150,15 +155,6 @@
...
@@ -150,15 +155,6 @@
}
}
})
})
},
},
convertTreeListToKeyLeafPairs
(
treeList
,
keyLeafPair
=
[])
{
for
(
const
{
key
,
isLeaf
,
children
}
of
treeList
)
{
keyLeafPair
.
push
({
key
,
isLeaf
})
if
(
children
&&
children
.
length
>
0
)
{
this
.
convertTreeListToKeyLeafPairs
(
children
,
keyLeafPair
)
}
}
return
keyLeafPair
;
},
},
},
watch
:
{
watch
:
{
visible
()
{
visible
()
{
...
@@ -166,23 +162,11 @@
...
@@ -166,23 +162,11 @@
queryTreeListForRole
().
then
((
res
)
=>
{
queryTreeListForRole
().
then
((
res
)
=>
{
this
.
treeData
=
res
.
result
.
treeList
this
.
treeData
=
res
.
result
.
treeList
this
.
allTreeKeys
=
res
.
result
.
ids
this
.
allTreeKeys
=
res
.
result
.
ids
const
keyLeafPairs
=
this
.
convertTreeListToKeyLeafPairs
(
this
.
treeData
)
queryRolePermission
({
roleId
:
this
.
roleId
}).
then
((
res
)
=>
{
queryRolePermission
({
roleId
:
this
.
roleId
}).
then
((
res
)
=>
{
// 过滤出 leaf node 即可,即选中的
this
.
checkedKeys
=
[...
res
.
result
];
// Tree组件中checkStrictly默认为false的时候,选中子节点,父节点会自动设置选中或半选中
this
.
defaultCheckedKeys
=
[...
res
.
result
];
// 保存 checkedKeys 以及 halfCheckedKeys 以便于未做任何操作时提交表单数据
const
checkedKeys
=
[...
res
.
result
].
filter
(
key
=>
{
const
keyLeafPair
=
keyLeafPairs
.
filter
(
item
=>
item
.
key
===
key
)[
0
]
return
keyLeafPair
&&
keyLeafPair
.
isLeaf
})
const
halfCheckedKeys
=
[...
res
.
result
].
filter
(
key
=>
{
const
keyLeafPair
=
keyLeafPairs
.
filter
(
item
=>
item
.
key
===
key
)[
0
]
return
keyLeafPair
&&
!
keyLeafPair
.
isLeaf
})
this
.
checkedKeys
=
[...
checkedKeys
];
this
.
halfCheckedKeys
=
[...
halfCheckedKeys
]
this
.
defaultCheckedKeys
=
[...
halfCheckedKeys
,
...
checkedKeys
];
this
.
expandedKeysss
=
this
.
allTreeKeys
;
this
.
expandedKeysss
=
this
.
allTreeKeys
;
//console.log(this.defaultCheckedKeys)
})
})
})
})
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment