Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HeliosJ
gin-vue-admin
提交
c70be85a
G
gin-vue-admin
项目概览
HeliosJ
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c70be85a
编写于
9月 19, 2019
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
动态menu和角色关联
上级
8a8fa3b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
117 addition
and
35 deletion
+117
-35
QMPlusVuePage/src/store/module/router.js
QMPlusVuePage/src/store/module/router.js
+13
-3
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
+104
-32
未找到文件。
QMPlusVuePage/src/store/module/router.js
浏览文件 @
c70be85a
...
...
@@ -16,15 +16,25 @@ export const router = {
actions
:
{
// 从后台获取动态路由
async
SetAsyncRouter
({
commit
})
{
const
baseRouter
=
[{
path
:
'
/layout
'
,
name
:
'
layout
'
,
component
:
"
view/layout/index.vue
"
,
meta
:
{
title
:
"
底层layout
"
},
children
:
[]
}]
const
asyncRouterRes
=
await
asyncMenu
()
const
asyncRouter
=
asyncRouterRes
.
data
.
menus
asyncRouter
.
push
({
baseRouter
[
0
].
children
=
asyncRouter
baseRouter
.
push
({
path
:
'
*
'
,
redirect
:
'
/404
'
})
asyncRouterHandle
(
async
Router
)
commit
(
'
setAsyncRouter
'
,
async
Router
)
asyncRouterHandle
(
base
Router
)
commit
(
'
setAsyncRouter
'
,
base
Router
)
}
},
getters
:
{
...
...
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
浏览文件 @
c70be85a
...
...
@@ -6,8 +6,9 @@
<el-table
:data=
"tableData"
border
stripe
>
<el-table-column
label=
"角色id"
min-width=
"180"
prop=
"authorityId"
></el-table-column>
<el-table-column
label=
"角色名称"
min-width=
"180"
prop=
"authorityName"
></el-table-column>
<el-table-column
fixed=
"right"
label=
"操作"
width=
"
1
00"
>
<el-table-column
fixed=
"right"
label=
"操作"
width=
"
5
00"
>
<template
slot-scope=
"scope"
>
<el-button
@
click=
"addAuthMenu(scope.row)"
size=
"small"
type=
"text"
>
增加角色菜单
</el-button>
<el-button
@
click=
"deleteAuth(scope.row)"
size=
"small"
type=
"text"
>
删除角色
</el-button>
</
template
>
</el-table-column>
...
...
@@ -23,7 +24,7 @@
hide-on-single-page
layout=
"total, sizes, prev, pager, next, jumper"
></el-pagination>
<!-- 新增角色弹窗 -->
<el-dialog
:visible.sync=
"dialogFormVisible"
title=
"新增角色"
>
<el-form
:model=
"form"
>
<el-form-item
label=
"角色ID"
>
...
...
@@ -38,35 +39,69 @@
<el-button
@
click=
"enterDialog"
type=
"primary"
>
确 定
</el-button>
</div>
</el-dialog>
<!-- 关联menu弹窗 -->
<el-dialog
:visible.sync=
"menuDialogFlag"
title=
"关联菜单"
>
<el-tree
:data=
"treeData"
:props=
"defaultProps"
default-expand-all
highlight-current
node-key=
"ID"
:default-checked-keys=
"treeIds"
ref=
"tree"
show-checkbox
></el-tree>
<div
class=
"dialog-footer"
slot=
"footer"
>
<el-button
@
click=
"closeDialog"
>
取 消
</el-button>
<el-button
@
click=
"relation"
type=
"primary"
>
确 定
</el-button>
</div>
</el-dialog>
</div>
</template>
<
script
>
import
{
getAuthorityList
,
deleteAuthority
,
createAuthority
}
from
'
@/api/authority
'
import
{
getAuthorityList
,
deleteAuthority
,
createAuthority
}
from
'
@/api/authority
'
import
{
getBaseMenuTree
,
addMenuAuthority
,
getMenuAuthority
}
from
'
@/api/menu
'
export
default
{
name
:
'
Authority
'
,
data
()
{
return
{
activeUserId
:
0
,
page
:
1
,
total
:
10
,
pageSize
:
10
,
tableData
:
[],
treeData
:
[],
treeIds
:[],
defaultProps
:
{
children
:
'
children
'
,
label
:
'
nickName
'
},
dialogFormVisible
:
false
,
form
:{
authorityId
:
""
,
authorityName
:
""
menuDialogFlag
:
false
,
form
:
{
authorityId
:
''
,
authorityName
:
''
}
}
},
methods
:
{
// 条数
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
this
.
getAuthList
()
},
// 页码
handleCurrentChange
(
val
)
{
this
.
page
=
val
this
.
getAuthList
()
},
// 删除角色
deleteAuth
(
row
)
{
this
.
$confirm
(
'
此操作将永久删除该角色, 是否继续?
'
,
'
提示
'
,
{
confirmButtonText
:
'
确定
'
,
...
...
@@ -95,37 +130,43 @@ export default {
})
})
},
initForm
(){
for
(
const
key
in
this
.
form
){
this
.
form
[
key
]
=
''
}
// 初始化表单
initForm
()
{
for
(
const
key
in
this
.
form
)
{
this
.
form
[
key
]
=
''
}
},
closeDialog
(){
this
.
initForm
()
this
.
dialogFormVisible
=
false
// 关闭窗口
closeDialog
()
{
this
.
initForm
()
this
.
dialogFormVisible
=
false
this
.
menuDialogFlag
=
false
},
async
enterDialog
(){
const
res
=
await
createAuthority
(
this
.
form
)
if
(
res
.
success
){
this
.
$message
({
type
:
'
success
'
,
message
:
'
添加成功!
'
})
this
.
getAuthList
()
this
.
closeDialog
()
}
else
{
this
.
$message
({
type
:
'
error
'
,
message
:
'
添加失败!
'
})
this
.
closeDialog
()
}
this
.
initForm
()
this
.
dialogFormVisible
=
false
// 确定弹窗
async
enterDialog
()
{
const
res
=
await
createAuthority
(
this
.
form
)
if
(
res
.
success
)
{
this
.
$message
({
type
:
'
success
'
,
message
:
'
添加成功!
'
})
this
.
getAuthList
()
this
.
closeDialog
()
}
else
{
this
.
$message
({
type
:
'
error
'
,
message
:
'
添加失败!
'
})
this
.
closeDialog
()
}
this
.
initForm
()
this
.
dialogFormVisible
=
false
},
// 增加角色
addAuthority
()
{
this
.
dialogFormVisible
=
true
this
.
dialogFormVisible
=
true
},
// 获取用户列表
async
getAuthList
(
page
=
this
.
page
,
pageSize
=
this
.
pageSize
)
{
try
{
const
table
=
await
getAuthorityList
({
page
,
pageSize
})
...
...
@@ -133,10 +174,41 @@ export default {
}
catch
(
err
)
{
console
.
log
(
err
)
}
},
async
addAuthMenu
(
row
)
{
const
res1
=
await
getMenuAuthority
({
authorityId
:
row
.
authorityId
})
const
menus
=
res1
.
data
.
menus
const
arr
=
[]
menus
.
map
(
item
=>
{
arr
.
push
(
Number
(
item
.
menuId
))})
this
.
treeIds
=
arr
const
res2
=
await
getBaseMenuTree
()
this
.
treeData
=
res2
.
data
.
menus
console
.
log
(
this
.
treeData
)
this
.
activeUserId
=
row
.
authorityId
this
.
menuDialogFlag
=
true
},
// 关联树
async
relation
()
{
const
checkArr
=
this
.
$refs
.
tree
.
getCheckedNodes
()
.
concat
(
this
.
$refs
.
tree
.
getHalfCheckedNodes
())
const
res
=
await
addMenuAuthority
({
menus
:
checkArr
,
authorityId
:
this
.
activeUserId
})
if
(
res
.
success
)
{
this
.
$message
({
type
:
'
success
'
,
message
:
'
添加成功!
'
})
}
this
.
closeDialog
()
}
// 获取基础menu树
},
created
()
{
this
.
getAuthList
()
}
}
</
script
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录