Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Starter Web Vue
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
product
kim3-web-vue
Starter Web Vue
Commits
42e2fa95
Commit
42e2fa95
authored
Jun 25, 2021
by
水落(YangLei)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 菜单管理优化
parent
3133e0a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
26 deletions
+98
-26
src/components/table/index.vue
src/components/table/index.vue
+64
-20
src/pages/system/view/menu/MenuManagement.vue
src/pages/system/view/menu/MenuManagement.vue
+34
-5
src/utils/requestUtil.js
src/utils/requestUtil.js
+0
-1
No files found.
src/components/table/index.vue
View file @
42e2fa95
...
@@ -47,25 +47,66 @@ import { request, METHOD } from '@/utils/requestUtil';
...
@@ -47,25 +47,66 @@ import { request, METHOD } from '@/utils/requestUtil';
const
data
=
[
const
data
=
[
{
{
key
:
'
1
'
,
key
:
1
,
name
:
'
John Brown
'
,
name
:
'
John Brown
sr.
'
,
age
:
32
,
age
:
60
,
address
:
'
New York No. 1 Lake Park
'
,
address
:
'
New York No. 1 Lake Park
'
,
tags
:
[
'
nice
'
,
'
developer
'
],
children
:
[
},
{
{
key
:
11
,
key
:
'
2
'
,
name
:
'
John Brown
'
,
name
:
'
Jim Green
'
,
age
:
42
,
age
:
42
,
address
:
'
New York No. 2 Lake Park
'
,
address
:
'
London No. 1 Lake Park
'
,
},
tags
:
[
'
loser
'
],
{
key
:
12
,
name
:
'
John Brown jr.
'
,
age
:
30
,
address
:
'
New York No. 3 Lake Park
'
,
children
:
[
{
key
:
121
,
name
:
'
Jimmy Brown
'
,
age
:
16
,
address
:
'
New York No. 3 Lake Park
'
,
},
],
},
{
key
:
13
,
name
:
'
Jim Green sr.
'
,
age
:
72
,
address
:
'
London No. 1 Lake Park
'
,
children
:
[
{
key
:
131
,
name
:
'
Jim Green
'
,
age
:
42
,
address
:
'
London No. 2 Lake Park
'
,
children
:
[
{
key
:
1311
,
name
:
'
Jim Green jr.
'
,
age
:
25
,
address
:
'
London No. 3 Lake Park
'
,
},
{
key
:
1312
,
name
:
'
Jimmy Green sr.
'
,
age
:
18
,
address
:
'
London No. 4 Lake Park
'
,
},
],
},
],
},
],
},
},
{
{
key
:
'
3
'
,
key
:
2
,
name
:
'
Joe Black
'
,
name
:
'
Joe Black
'
,
age
:
32
,
age
:
32
,
address
:
'
Sidney No. 1 Lake Park
'
,
address
:
'
Sidney No. 1 Lake Park
'
,
tags
:
[
'
cool
'
,
'
teacher
'
],
},
},
];
];
...
@@ -79,6 +120,7 @@ export default {
...
@@ -79,6 +120,7 @@ export default {
addBtn
:
{
addBtn
:
{
type
:
Object
,
type
:
Object
,
},
},
formatData
:
Function
,
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -89,19 +131,21 @@ export default {
...
@@ -89,19 +131,21 @@ export default {
};
};
},
},
mounted
()
{
mounted
()
{
console
.
log
(
this
.
addBtn
);
this
.
getData
();
this
.
getData
();
},
},
methods
:
{
methods
:
{
async
getData
()
{
async
getData
()
{
console
.
log
(
'
查询
'
);
this
.
loading
=
true
;
this
.
loading
=
true
;
setTimeout
(()
=>
{
try
{
this
.
data
=
data
;
const
res
=
await
request
(
this
.
url
,
METHOD
.
GET
);
this
.
loading
=
false
;
if
(
this
.
formatData
)
this
.
data
=
this
.
formatData
(
res
);
},
1000
);
else
this
.
data
=
res
;
const
res
=
await
request
(
this
.
url
,
METHOD
.
GET
);
}
catch
(
error
)
{
console
.
log
(
res
);
// todo
}
this
.
loading
=
false
;
},
},
add
()
{
add
()
{
this
.
addVisible
=
true
;
this
.
addVisible
=
true
;
...
...
src/pages/system/view/menu/MenuManagement.vue
View file @
42e2fa95
<
template
>
<
template
>
<my-table
url=
"/api/v1/menus"
addBtn=
"addBtn
"
>
<my-table
url=
"/api/v1/menus"
:addBtn=
"addBtn"
:formatData=
"formatData"
rowKey=
"menuId
"
>
<template
#search
="
{query}">
<template
#search
="
{query}">
<a-form-model-item
label=
"菜单、目录名称"
>
<a-form-model-item
label=
"菜单、目录名称"
>
<a-input
v-model=
"query.name"
/>
<a-input
v-model=
"query.name"
/>
...
@@ -8,13 +8,17 @@
...
@@ -8,13 +8,17 @@
<
template
#add
>
<
template
#add
>
<a-input
v-model=
"add.name"
/>
<a-input
v-model=
"add.name"
/>
</
template
>
</
template
>
<a-table-column
title=
"姓名"
data-index=
"name"
/>
<a-table-column
title=
"名称"
data-index=
"menuName"
/>
<a-table-column
title=
"类型"
data-index=
"menuTypeName"
/>
<a-table-column
title=
"显示排序"
data-index=
"viewIndex"
:sorter=
"sorter"
sortOrder=
"ascend"
/>
<a-table-column
title=
"显示图标"
data-index=
"menuIcon"
/>
<a-table-column
title=
"模块URL"
data-index=
"menuUrl"
/>
<a-table-column
title=
"操作"
>
<a-table-column
title=
"操作"
>
<
template
#default
=
"row"
>
<
template
#default
>
<span>
<span>
<a>
{{
row
}}
</a>
<a>
编辑
</a>
<a-divider
type=
"vertical"
/>
<a-divider
type=
"vertical"
/>
<a>
Delete
</a>
<a>
删除
</a>
</span>
</span>
</
template
>
</
template
>
</a-table-column>
</a-table-column>
...
@@ -26,6 +30,31 @@ export default {
...
@@ -26,6 +30,31 @@ export default {
data
:
()
=>
({
data
:
()
=>
({
add
:
{},
add
:
{},
addBtn
:
{
text
:
'
新建
'
,
title
:
'
菜单配置
'
},
addBtn
:
{
text
:
'
新建
'
,
title
:
'
菜单配置
'
},
sortOrder
:
'
ascend
'
,
}),
}),
methods
:
{
formatData
(
data
=
[])
{
let
menu
,
res
=
[],
tmp
=
data
.
slice
();
while
((
menu
=
tmp
.
pop
()))
{
if
(
menu
.
parentMenuId
===
0
)
res
.
push
(
menu
);
else
{
for
(
const
resetMenu
of
data
)
{
if
(
menu
.
parentMenuId
===
resetMenu
.
menuId
)
{
resetMenu
.
children
?
resetMenu
.
children
.
push
(
menu
)
:
(
resetMenu
.
children
=
[
menu
]);
}
}
}
}
console
.
log
(
res
);
return
res
;
},
sorter
(
pre
,
next
)
{
return
pre
.
viewIndex
-
next
.
viewIndex
;
},
},
};
};
</
script
>
</
script
>
src/utils/requestUtil.js
View file @
42e2fa95
...
@@ -17,7 +17,6 @@ axios.defaults.xsrfCookieName = xsrfHeaderName;
...
@@ -17,7 +17,6 @@ axios.defaults.xsrfCookieName = xsrfHeaderName;
function
loadResponseInterceptor
({
router
})
{
function
loadResponseInterceptor
({
router
})
{
axios
.
interceptors
.
request
.
use
(
axios
.
interceptors
.
request
.
use
(
function
(
config
)
{
function
(
config
)
{
console
.
log
(
getToken
(),
config
);
// 在发送请求之前做些什么
// 在发送请求之前做些什么
config
.
headers
=
{
config
.
headers
=
{
...
config
.
headers
,
...
config
.
headers
,
...
...
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