top-menu

3.x
smallchill 3 years ago
parent 3ebb87362f
commit 6fb0ca49ed
  1. 22
      src/page/index/index.vue
  2. 34
      src/page/index/top/top-menu.vue
  3. 2
      src/store/modules/user.js

@ -61,36 +61,38 @@ export default {
computed: { computed: {
...mapGetters(["isHorizontal", "isRefresh", "isLock", "isCollapse", "isSearch", "menu", "setting",]), ...mapGetters(["isHorizontal", "isRefresh", "isLock", "isCollapse", "isSearch", "menu", "setting",]),
validSidebar () { validSidebar () {
return !((this.$route.meta || {}).menu == false || (this.$route.query || {}).menu == 'false') return !((this.$route.meta || {}).menu === false || (this.$route.query || {}).menu === 'false')
} }
}, },
props: [], props: [],
methods: { methods: {
// //
openMenu (item = {}) { openMenu(item = {}) {
this.$store.dispatch("GetMenu", item.parentId).then(data => { this.$store.dispatch("GetMenu", item.id).then(data => {
if (data.length !== 0) { if (data.length !== 0) {
this.$router.$avueRouter.formatRoutes(data, true); this.$router.$avueRouter.formatRoutes(data, true);
} }
// //
if (!validatenull(item)) { /*if (!this.validatenull(item)) {
let itemActive = {}, let itemActive = {},
childItemActive = 0; childItemActive = 0;
//vue-router
if (item.path) { if (item.path) {
itemActive = item; itemActive = item;
} else { } else {
if (this.menu[childItemActive].length == 0) { if (this.menu[childItemActive].length === 0) {
itemActive = this.menu[childItemActive]; itemActive = this.menu[childItemActive];
} else { } else {
itemActive = this.menu[childItemActive].children[childItemActive]; itemActive = this.menu[childItemActive].children[childItemActive];
} }
} }
this.$store.commit('SET_MENUID', item); this.$store.commit('SET_MENU_ID', item);
this.$router.push({ this.$router.push({
path: itemActive.path path: this.$router.$avueRouter.getPath({
name: (itemActive.label || itemActive.name),
src: itemActive.path
}, itemActive.meta)
}); });
} }*/
}); });
}, },

@ -3,13 +3,20 @@
:default-active="activeIndex" :default-active="activeIndex"
mode="horizontal" mode="horizontal"
text-color="#333"> text-color="#333">
<template v-for="(item,index) in items"
:key="index"> <el-menu-item index="0" @click.native="openHome(itemHome)">
<el-menu-item :index="item.parentId+''"
@click="openMenu(item)">
<template #title> <template #title>
<i class="icon-caidan"></i> <i :class="itemHome.source" style="padding-right: 5px;"></i>
<span>{{generateTitle(item)}}</span> <span>{{itemHome.name}}</span>
</template>
</el-menu-item>
<template v-for="(item,index) in items" :key="index">
<el-menu-item :index="item.id+''"
@click="openMenu(item)">
<template #title >
<i :class="item.source" style="padding-right: 5px;"></i>
<span>{{item.name}}</span>
</template> </template>
</el-menu-item> </el-menu-item>
</template> </template>
@ -22,6 +29,10 @@ export default {
name: "top-menu", name: "top-menu",
data () { data () {
return { return {
itemHome: {
name: '首页',
source: 'iconfont iconicon_work',
},
activeIndex: "0", activeIndex: "0",
items: [] items: []
}; };
@ -37,14 +48,17 @@ export default {
openMenu (item) { openMenu (item) {
this.index.openMenu(item) this.index.openMenu(item)
}, },
getMenu () { openHome(itemHome) {
this.index.openMenu(itemHome);
this.$router.push({
path: this.website.fistPage
});
},
getMenu() {
this.$store.dispatch("GetTopMenu").then(res => { this.$store.dispatch("GetTopMenu").then(res => {
this.items = res; this.items = res;
}); });
}, },
generateTitle (item) {
return this.$router.$avueRouter.generateTitle(item);
}
} }
}; };
</script> </script>

@ -188,7 +188,7 @@ const user = {
state.refreshToken = token; state.refreshToken = token;
setStore({ name: 'refreshToken', content: state.token }) setStore({ name: 'refreshToken', content: state.token })
}, },
SET_MENUID (state, menuId) { SET_MENU_ID (state, menuId) {
state.menuId = menuId; state.menuId = menuId;
}, },
SET_TENANT_ID: (state, tenantId) => { SET_TENANT_ID: (state, tenantId) => {

Loading…
Cancel
Save