Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
3f0f3f57
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
340
Star
18155
Fork
5506
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
3f0f3f57
编写于
9月 20, 2019
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
动态路由删除修改等操作
上级
c6490afe
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
97 addition
and
66 deletion
+97
-66
QMPlusServer/controller/api/menu.go
QMPlusServer/controller/api/menu.go
+29
-6
QMPlusServer/model/dbModel/baseMenu.go
QMPlusServer/model/dbModel/baseMenu.go
+8
-2
QMPlusServer/router/menu.go
QMPlusServer/router/menu.go
+1
-0
QMPlusVuePage/src/api/menu.js
QMPlusVuePage/src/api/menu.js
+12
-0
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
+20
-32
QMPlusVuePage/src/view/superAdmin/menu/menu.vue
QMPlusVuePage/src/view/superAdmin/menu/menu.vue
+27
-26
未找到文件。
QMPlusServer/controller/api/menu.go
浏览文件 @
3f0f3f57
...
...
@@ -9,7 +9,7 @@ import (
"main/model/modelInterface"
)
// @Tags Menu
// @Tags
authorityAnd
Menu
// @Summary 获取用户动态路由
// @Security ApiKeyAuth
// @Produce application/json
...
...
@@ -27,7 +27,7 @@ func GetMenu(c *gin.Context) {
}
}
// @Tags
authority
// @Tags
menu
// @Summary 分页获取基础menu列表
// @Security ApiKeyAuth
// @accept application/json
...
...
@@ -51,7 +51,7 @@ func GetMenuList(c *gin.Context) {
}
}
// @Tags
authority
// @Tags
menu
// @Summary 分页获取基础menu列表
// @Security ApiKeyAuth
// @accept application/json
...
...
@@ -70,7 +70,7 @@ func AddBaseMenu(c *gin.Context) {
}
}
// @Tags Menu
// @Tags
authorityAnd
Menu
// @Summary 获取用户动态路由
// @Security ApiKeyAuth
// @Produce application/json
...
...
@@ -91,7 +91,7 @@ type AddMenuAuthorityInfo struct {
AuthorityId
string
}
// @Tags authority
// @Tags authority
AndMenu
// @Summary 增加menu和角色关联关系
// @Security ApiKeyAuth
// @accept application/json
...
...
@@ -114,7 +114,7 @@ type AuthorityIdInfo struct {
AuthorityId
string
}
// @Tags authority
// @Tags authority
AndMenu
// @Summary 获取指定角色menu
// @Security ApiKeyAuth
// @accept application/json
...
...
@@ -132,3 +132,26 @@ func GetMenuAuthority(c *gin.Context) {
servers
.
ReportFormat
(
c
,
true
,
"获取成功"
,
gin
.
H
{
"menus"
:
menus
})
}
}
type
IdInfo
struct
{
Id
float64
}
// @Tags menu
// @Summary 获取指定角色menu
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.IdInfo true "删除菜单"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/deleteBaseMenu [post]
func
DeleteBaseMenu
(
c
*
gin
.
Context
)
{
var
idInfo
IdInfo
_
=
c
.
BindJSON
(
&
idInfo
)
err
:=
new
(
dbModel
.
BaseMenu
)
.
DeleteBaseMenu
(
idInfo
.
Id
)
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"删除失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"删除成功"
,
gin
.
H
{})
}
}
\ No newline at end of file
QMPlusServer/model/dbModel/baseMenu.go
浏览文件 @
3f0f3f57
...
...
@@ -32,8 +32,14 @@ func (b *BaseMenu) AddBaseMenu() (err error) {
return
err
}
func
(
b
*
BaseMenu
)
DeleteBaseMenu
(
name
string
)
(
err
error
)
{
err
=
qmsql
.
DEFAULTDB
.
Where
(
"name = ?"
,
name
)
.
Delete
(
&
b
)
.
Delete
(
&
Menu
{})
.
Error
func
(
b
*
BaseMenu
)
DeleteBaseMenu
(
id
float64
)
(
err
error
)
{
err
=
qmsql
.
DEFAULTDB
.
Where
(
"parent_id = ?"
,
id
)
.
First
(
&
BaseMenu
{})
.
Error
if
(
err
!=
nil
){
err
=
qmsql
.
DEFAULTDB
.
Where
(
"id = ?"
,
id
)
.
Delete
(
&
b
)
.
Error
err
=
qmsql
.
DEFAULTDB
.
Where
(
"menu_id = ?"
,
id
)
.
Delete
(
&
Menu
{})
.
Error
}
else
{
return
errors
.
New
(
"此菜单存在子菜单不可删除"
)
}
return
err
}
...
...
QMPlusServer/router/menu.go
浏览文件 @
3f0f3f57
...
...
@@ -15,5 +15,6 @@ func InitMenuRouter(Router *gin.Engine) {
MenuRouter
.
POST
(
"getBaseMenuTree"
,
api
.
GetBaseMenuTree
)
MenuRouter
.
POST
(
"addMenuAuthority"
,
api
.
AddMenuAuthority
)
MenuRouter
.
POST
(
"getMenuAuthority"
,
api
.
GetMenuAuthority
)
MenuRouter
.
POST
(
"deleteBaseMenu"
,
api
.
DeleteBaseMenu
)
}
}
QMPlusVuePage/src/api/menu.js
浏览文件 @
3f0f3f57
...
...
@@ -72,4 +72,16 @@ export const getMenuAuthority = (data) => {
method
:
'
post
'
,
data
})
}
// @Summary 获取用户menu关联关系
// @Produce application/json
// @Param ID float64
// @Router /menu/deleteBaseMenu [post]
export
const
deleteBaseMenu
=
(
data
)
=>
{
return
service
({
url
:
"
/menu/deleteBaseMenu
"
,
method
:
'
post
'
,
data
})
}
\ No newline at end of file
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
浏览文件 @
3f0f3f57
...
...
@@ -44,11 +44,11 @@
<el-dialog
:visible.sync=
"menuDialogFlag"
title=
"关联菜单"
>
<el-tree
:data=
"treeData"
:default-checked-keys=
"treeIds"
:props=
"defaultProps"
default-expand-all
highlight-current
node-key=
"ID"
:default-checked-keys=
"treeIds"
ref=
"tree"
show-checkbox
></el-tree>
...
...
@@ -67,6 +67,7 @@ import {
createAuthority
}
from
'
@/api/authority
'
import
{
getBaseMenuTree
,
addMenuAuthority
,
getMenuAuthority
}
from
'
@/api/menu
'
import
{
mapActions
}
from
'
vuex
'
export
default
{
name
:
'
Authority
'
,
data
()
{
...
...
@@ -77,7 +78,7 @@ export default {
pageSize
:
10
,
tableData
:
[],
treeData
:
[],
treeIds
:[],
treeIds
:
[],
defaultProps
:
{
children
:
'
children
'
,
label
:
'
nickName
'
...
...
@@ -91,6 +92,8 @@ export default {
}
},
methods
:
{
...
mapActions
(
'
router
'
,
[
'
SetAsyncRouter
'
]),
// 条数
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
...
...
@@ -109,19 +112,12 @@ export default {
type
:
'
warning
'
})
.
then
(
async
()
=>
{
try
{
const
res
=
await
deleteAuthority
({
authorityId
:
row
.
authorityId
})
this
.
$message
({
type
:
'
success
'
,
message
:
'
删除成功!
'
})
this
.
getAuthList
()
}
catch
(
err
)
{
this
.
$message
({
type
:
'
error
'
,
message
:
'
删除失败!
'
+
err
})
}
const
res
=
await
deleteAuthority
({
authorityId
:
row
.
authorityId
})
this
.
$message
({
type
:
'
success
'
,
message
:
'
删除成功!
'
})
this
.
getAuthList
()
})
.
catch
(()
=>
{
this
.
$message
({
...
...
@@ -152,12 +148,6 @@ export default {
})
this
.
getAuthList
()
this
.
closeDialog
()
}
else
{
this
.
$message
({
type
:
'
error
'
,
message
:
'
添加失败!
'
})
this
.
closeDialog
()
}
this
.
initForm
()
this
.
dialogFormVisible
=
false
...
...
@@ -168,26 +158,24 @@ export default {
},
// 获取用户列表
async
getAuthList
(
page
=
this
.
page
,
pageSize
=
this
.
pageSize
)
{
try
{
const
table
=
await
getAuthorityList
({
page
,
pageSize
})
this
.
tableData
=
table
.
data
.
authList
}
catch
(
err
)
{
console
.
log
(
err
)
}
const
table
=
await
getAuthorityList
({
page
,
pageSize
})
this
.
tableData
=
table
.
data
.
authList
},
// 关联用户列表关系
async
addAuthMenu
(
row
)
{
const
res1
=
await
getMenuAuthority
({
authorityId
:
row
.
authorityId
})
const
res1
=
await
getMenuAuthority
({
authorityId
:
row
.
authorityId
})
const
menus
=
res1
.
data
.
menus
const
arr
=
[]
menus
.
map
(
item
=>
{
arr
.
push
(
Number
(
item
.
menuId
))})
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
()
...
...
@@ -201,6 +189,7 @@ export default {
type
:
'
success
'
,
message
:
'
添加成功!
'
})
this
.
SetAsyncRouter
()
}
this
.
closeDialog
()
}
...
...
@@ -208,7 +197,6 @@ export default {
},
created
()
{
this
.
getAuthList
()
}
}
</
script
>
...
...
QMPlusVuePage/src/view/superAdmin/menu/menu.vue
浏览文件 @
3f0f3f57
...
...
@@ -4,24 +4,29 @@
<el-button
@
click=
"addMenu('0')"
type=
"primary"
>
新增根菜单
</el-button>
</div>
<el-table
:data=
"tableData"
border
stripe
>
<el-table-column
label=
"ID"
min-width=
"80"
prop=
"ID"
></el-table-column>
<el-table-column
label=
"路径"
min-width=
"180"
prop=
"path"
></el-table-column>
<el-table-column
label=
"名称"
min-width=
"180"
prop=
"name"
></el-table-column>
<el-table-column
label=
"是否隐藏"
min-width=
"180"
prop=
"hidden"
></el-table-column>
<el-table-column
label=
"父节点Id"
min-width=
"180"
prop=
"parentId"
></el-table-column>
<el-table-column
label=
"文件路径"
min-width=
"180"
prop=
"component"
></el-table-column>
<el-table-column
label=
"展示名称"
min-width=
"180"
prop=
"authorityName"
>
<el-table-column
label=
"ID"
min-width=
"40"
prop=
"ID"
></el-table-column>
<el-table-column
label=
"路径"
min-width=
"100"
prop=
"path"
></el-table-column>
<el-table-column
label=
"名称"
min-width=
"100"
prop=
"name"
></el-table-column>
<el-table-column
label=
"是否隐藏"
min-width=
"80"
prop=
"hidden"
>
<template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
hidden
?
"
隐藏
"
:
"
显示
"
}}
</span>
</
template
>
</el-table-column>
<el-table-column
label=
"父节点Id"
min-width=
"70"
prop=
"parentId"
></el-table-column>
<el-table-column
label=
"文件路径"
min-width=
"250"
prop=
"component"
></el-table-column>
<el-table-column
label=
"展示名称"
min-width=
"80"
prop=
"authorityName"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
meta
.
title
}}
</span>
</
template
>
</el-table-column>
<el-table-column
label=
"图标"
min-width=
"180"
prop=
"authorityName"
>
<el-table-column
label=
"图标"
min-width=
"180"
prop=
"authorityName"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
meta
.
icon
}}
</span>
</
template
>
</el-table-column>
<el-table-column
fixed=
"right"
label=
"操作"
width=
"
1
00"
>
<el-table-column
fixed=
"right"
label=
"操作"
width=
"
3
00"
>
<
template
slot-scope=
"scope"
>
<el-button
@
click=
"deleteMenu(scope.row.ID)"
size=
"small"
type=
"text"
>
删除菜单
</el-button>
<el-button
@
click=
"addMenu(scope.row.ID)"
size=
"small"
type=
"text"
>
添加子菜单
</el-button>
</
template
>
</el-table-column>
...
...
@@ -74,7 +79,8 @@
</template>
<
script
>
import
{
getMenuList
,
addBaseMenu
}
from
'
@/api/menu
'
import
{
getMenuList
,
addBaseMenu
,
deleteBaseMenu
}
from
'
@/api/menu
'
import
{
mapActions
}
from
'
vuex
'
export
default
{
name
:
'
Menus
'
,
data
()
{
...
...
@@ -98,6 +104,7 @@ export default {
}
},
methods
:
{
...
mapActions
(
'
router
'
,[
'
SetAsyncRouter
'
]),
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
this
.
getMenuList
()
...
...
@@ -106,26 +113,20 @@ export default {
this
.
page
=
val
this
.
getMenuList
()
},
delete
Auth
(
row
)
{
delete
Menu
(
ID
)
{
this
.
$confirm
(
'
此操作将永久删除所有角色下该菜单, 是否继续?
'
,
'
提示
'
,
{
confirmButtonText
:
'
确定
'
,
cancelButtonText
:
'
取消
'
,
type
:
'
warning
'
})
.
then
(
async
()
=>
{
try
{
const
res
=
await
deleteAuthority
({
authorityId
:
row
.
authorityId
})
this
.
$message
({
type
:
'
success
'
,
message
:
'
删除成功!
'
})
this
.
getAuthList
()
}
catch
(
err
)
{
this
.
$message
({
type
:
'
error
'
,
message
:
'
删除失败!
'
+
err
})
}
const
res
=
await
deleteBaseMenu
({
ID
})
this
.
$message
({
type
:
'
success
'
,
message
:
'
删除成功!
'
})
this
.
getMenuList
()
this
.
SetAsyncRouter
()
})
.
catch
(()
=>
{
this
.
$message
({
...
...
@@ -175,8 +176,8 @@ export default {
this
.
dialogFormVisible
=
true
},
async
getMenuList
(
page
=
this
.
page
,
pageSize
=
this
.
pageSize
)
{
const
table
=
await
getMenuList
({
page
,
pageSize
})
this
.
tableData
=
table
.
data
.
menuList
const
table
=
await
getMenuList
({
page
,
pageSize
})
this
.
tableData
=
table
.
data
.
menuList
}
},
created
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录