Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-customization-system
/
micro-portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2635e3a8
authored
Feb 25, 2022
by
张杰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加对外方法
1 parent
58384bb8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
5 deletions
src/components/DesktopLeftSider/Sub/Menu.vue
src/store/getters.js
src/store/modules/menu.js
src/utils/common/common.js
src/components/DesktopLeftSider/Sub/Menu.vue
View file @
2635e3a
...
...
@@ -72,7 +72,7 @@
</template>
<
script
>
import
{
reactive
,
toRefs
,
onBeforeMount
,
onMounted
,
computed
}
from
"vue"
;
import
{
reactive
,
toRefs
,
onBeforeMount
,
onMounted
,
computed
,
watch
}
from
"vue"
;
import
{
useStore
}
from
"vuex"
;
import
MenuService
from
"services/Menu"
;
...
...
@@ -88,6 +88,17 @@ export default {
defaultActive
:
"0-0"
,
menuIcon
:
require
(
"@/assets/images/icon/setting-icon.png"
),
});
console
.
log
(
store
.
state
)
watch
(()
=>
store
.
state
.
menu
.
updateMenu
,
(
n
,
o
)
=>
{
console
.
log
(
"监听菜单更新"
);
console
.
log
(
n
);
if
(
n
){
//getMenuAuth()
}
},{
immediate
:
true
,
deep
:
true
});
// 点击主菜单标题
const
titleClick
=
(
item
,
idx
)
=>
{
...
...
@@ -236,6 +247,11 @@ export default {
let curBreadcrumb = localStorage.getItem("breadcrumb");
// const getNewTree = getMenuTree(res.data, menuTreeLocalList)
state.menuList = sortMenu(resData);
console.log(state.menuList)
// 数据存入state
store.commit('menu/SET_MENU_LIST',state.menuList)
// 初始化操作
let showEmpty = false;
...
...
src/store/getters.js
View file @
2635e3a
...
...
@@ -12,7 +12,8 @@ const getters = {
curBreadCrumb
:
state
=>
state
.
menu
.
curBreadCrumb
,
updateMenu
:
state
=>
state
.
menu
.
updateMenu
,
curMenuAuth
:
state
=>
state
.
menu
.
curMenuAuth
,
fileUploadURL
:
state
=>
state
.
app
.
fileUploadURL
fileUploadURL
:
state
=>
state
.
app
.
fileUploadURL
,
menuList
:
state
=>
state
.
menu
.
menuList
}
export
default
getters
;
\ No newline at end of file
src/store/modules/menu.js
View file @
2635e3a
...
...
@@ -3,7 +3,8 @@ let state = {
menu
:
[],
// 菜单数据
curBreadCrumb
:
[],
updateMenu
:
false
,
curMenuAuth
:
[]
curMenuAuth
:
[],
menuList
:[],
//菜单数据
};
let
init
=
false
;
try
{
...
...
@@ -62,6 +63,12 @@ export default {
SET_MENU_AUTH
(
state
,
data
)
{
state
.
curMenuAuth
=
data
;
},
// 存入菜单数据
SET_MENU_LIST
(
state
,
data
){
state
.
menuList
=
data
;
}
},
actions
:
{
// 推入用户菜单
...
...
src/utils/common/common.js
View file @
2635e3a
import
store
from
'@/store/index'
import
MenuService
from
"services/Menu"
;
export
const
Common
=
{
setAuthBtn
(
resData
)
{
let
data
=
resData
||
store
.
getters
.
curMenuAuth
.
data
//console.log('setAuthBtn', data)
const
authBtnEl
=
document
.
getElementsByTagName
(
'button'
)
const
authStringArr
=
[
'新增'
,
'编辑'
,
'删除'
,
'导出'
,
'导入'
,
'修改'
,
'解绑'
,
'选择试驾车辆'
,
'新增车辆'
,
'查看'
]
const
authStringArr
=
[
'新增'
,
'编辑'
,
'删除'
,
'导出'
,
'导入'
,
'修改'
,
'解绑'
,
'选择试驾车辆'
,
'新增车辆'
,
'查看'
]
if
(
authBtnEl
&&
authBtnEl
.
length
>
0
)
{
if
(
data
&&
data
.
length
>
0
)
{
authBtnEl
.
forEach
(
elItem
=>
{
...
...
@@ -34,5 +35,20 @@ export const Common = {
},
getAuthData
()
{
return
store
.
getters
.
curMenuAuth
.
data
},
// 获取二级菜单权限
getSecondMenu
(
parentId
,
menuName
)
{
const
menuService
=
new
MenuService
();
menuService
.
getMenuAuth
({
parentId
}).
then
(
(
res
)
=>
{
const
{
code
,
data
}
=
res
;
if
(
code
==
200
)
{
store
.
dispatch
(
"menu/setMenuAuth"
,
{
menuName
,
data
});
}
},
(
err
)
=>
{
}
);
}
}
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