Browse Source

显示路由及所有路由处理

noToken
安虹睿 1 year ago
parent
commit
fd626126d5
  1. 17
      PC/UI.WinIn.FasterZ.Store/src/store/modules/permission.js
  2. 60
      PC/UI.WinIn.FasterZ.Store/src/views/menuAll/index.vue

17
PC/UI.WinIn.FasterZ.Store/src/store/modules/permission.js

@ -88,11 +88,13 @@ const mutations = {
* @param data 后端返回的菜单数据 * @param data 后端返回的菜单数据
*/ */
export function generaMenu(routes, data, first) { export function generaMenu(routes, data, first) {
// 不显示的菜单配置隐藏
let _noShowMenus = localStorage.getItem('menuHiddenConfig').split(',')
data.forEach(item => { data.forEach(item => {
let _item = { let _item = {
path: '/'+item.name, path: '/'+item.name,
component: loadView(item.name), component: loadView(item.name),
// hidden: item.status === 0, // 状态为0的隐藏 hidden: _noShowMenus.indexOf(item.name) >= 0, // 状态为0的隐藏
name: item.name, name: item.name,
// meta: item.meta // meta: item.meta
meta: { meta: {
@ -180,11 +182,6 @@ const actions = {
} }
// 存储所有的表名 // 存储所有的表名
commit('SET_TABLESNAME', _menuList) commit('SET_TABLESNAME', _menuList)
// todo-new:接口获取 接口没有走配置文件
let _noShowMenus = null//不显示的菜单
_noShowMenus = localStorage.getItem('menuHiddenConfig').split(',')
// 去掉不显示的菜单后全部显示的菜单
let _showMenus = _noShowMenus && _noShowMenus.length > 0 ? _menuList.filter(item1 => !_noShowMenus.some(item2 => item2 === item1)) : _menuList
// 数据模拟,todo-new:接口获取 // 数据模拟,todo-new:接口获取
let _treeMenusAll = null//树形菜单 let _treeMenusAll = null//树形菜单
// _treeMenusAll = [ // _treeMenusAll = [
@ -237,13 +234,13 @@ const actions = {
let _initTreeMenus = [] let _initTreeMenus = []
if(_treeMenusAll && _treeMenusAll.length > 0){ if(_treeMenusAll && _treeMenusAll.length > 0){
_initTreeMenus = initTreeMenusHandle(_treeMenusAll,_showMenus,true) _initTreeMenus = initTreeMenusHandle(_treeMenusAll,_menuList,true)
}else{ }else{
let _data = [] let _data = []
for(let i in _showMenus){ for(let i in _menuList){
_data.push({name:_showMenus[i]}) _data.push({name:_menuList[i]})
} }
_initTreeMenus = initTreeMenusHandle(_data,_showMenus,true) _initTreeMenus = initTreeMenusHandle(_data,_menuList,true)
} }
// 最后查重+层级查重后的菜单 // 最后查重+层级查重后的菜单
let _initEndMenus = generaMenu(asyncRoutes, _initTreeMenus,true) let _initEndMenus = generaMenu(asyncRoutes, _initTreeMenus,true)

60
PC/UI.WinIn.FasterZ.Store/src/views/menuAll/index.vue

@ -0,0 +1,60 @@
<template>
<div class="dashboardPage">
<el-tree
:data="navList"
:props="defaultProps"
@node-click="goPage"
></el-tree>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'Dashboard',
data() {
return {
navList:[],
defaultProps: {
children: 'children',
label: 'title'
}
}
},
computed: {
...mapGetters([
'permission_routes'
])
},
mounted(){
this.initData(this.permission_routes)
},
methods:{
initData(data){
data.forEach(item => {
if(item.path !== '/' && item.meta) {
let _item = {
title:item.meta.title,
name:item.name,
path:item.path,
children:item.children
}
this.navList.push(_item)
}
if(item.children){
this.initData(item.children)
}
})
},
goPage(item){
this.$router.push({name: item.name})
},
}
}
</script>
<style lang="scss" scoped>
.dashboardPage{
padding:30px 10px;
background: #fff;
}
</style>
Loading…
Cancel
Save