|
@@ -1,39 +1,77 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="side-menu-wrapper">
|
|
<div class="side-menu-wrapper">
|
|
|
<slot></slot>
|
|
<slot></slot>
|
|
|
- <Menu
|
|
|
|
|
- ref="menu"
|
|
|
|
|
- v-show="!collapsed"
|
|
|
|
|
- :active-name="activeName"
|
|
|
|
|
- :open-names="openMenus"
|
|
|
|
|
- :accordion="accordion"
|
|
|
|
|
- :theme="theme"
|
|
|
|
|
- width="auto"
|
|
|
|
|
- @on-open-change="openNameData"
|
|
|
|
|
- @on-select="handleSelect"
|
|
|
|
|
- >
|
|
|
|
|
- <template v-for="item in menuList">
|
|
|
|
|
- <template v-if="item.children && item.children.length === 1">
|
|
|
|
|
- <side-menu-item v-if="showChildren(item)" :key="`menu-${item.path}`" :parent-item="item"></side-menu-item>
|
|
|
|
|
- <menu-item v-else :name="item.path" :key="`menu-${item.children[0].path}`"
|
|
|
|
|
- ><common-icon :type="item.children[0].icon || ''" /><span>{{ item.children[0].title }}</span></menu-item
|
|
|
|
|
- >
|
|
|
|
|
- </template>
|
|
|
|
|
- <template v-else>
|
|
|
|
|
- <side-menu-item v-if="showChildren(item)" :key="`menu${item.path}`" :parent-item="item"></side-menu-item>
|
|
|
|
|
- <menu-item v-else :name="item.path" :key="`menu${item.path}`"
|
|
|
|
|
- ><common-icon :type="item.icon || ''" /><span>{{ item.title }}</span></menu-item
|
|
|
|
|
- >
|
|
|
|
|
- </template>
|
|
|
|
|
- </template>
|
|
|
|
|
- </Menu>
|
|
|
|
|
|
|
+ <div class="side-menu-box" v-show="!collapsed">
|
|
|
|
|
+ <div class="parent-menu">
|
|
|
|
|
+ <Menu
|
|
|
|
|
+ ref="menu"
|
|
|
|
|
+ :active-name="activeMenuPath"
|
|
|
|
|
+ :open-names="openedNames"
|
|
|
|
|
+ :accordion="accordion"
|
|
|
|
|
+ :theme="theme"
|
|
|
|
|
+ width="75px"
|
|
|
|
|
+ @on-open-change="openNameData"
|
|
|
|
|
+ @on-select="handleSelect"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template v-for="item in menuList">
|
|
|
|
|
+ <template>
|
|
|
|
|
+ <menu-item :name="item.path" :key="`menu${item.path}`"
|
|
|
|
|
+ ><common-icon :type="item.icon || ''" /><span class="title">{{ item.title }}</span></menu-item
|
|
|
|
|
+ >
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </Menu>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="child-menu" v-if="childList.length">
|
|
|
|
|
+ <div class="cat-name">{{ catName }}</div>
|
|
|
|
|
+ <Menu
|
|
|
|
|
+ ref="childMenu"
|
|
|
|
|
+ :active-name="activePath"
|
|
|
|
|
+ :open-names="openMenus"
|
|
|
|
|
+ :accordion="accordion"
|
|
|
|
|
+ :theme="theme"
|
|
|
|
|
+ width="140px"
|
|
|
|
|
+ @on-open-change="openChildNameData"
|
|
|
|
|
+ @on-select="handleChildSelect"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template v-for="item in childList">
|
|
|
|
|
+ <template v-if="item.auth === undefined">
|
|
|
|
|
+ <template v-if="item.children && item.children.length >= 1">
|
|
|
|
|
+ <side-menu-item
|
|
|
|
|
+ v-if="showChildren(item)"
|
|
|
|
|
+ :key="`menu${item.path}`"
|
|
|
|
|
+ :parent-item="item"
|
|
|
|
|
+ ></side-menu-item>
|
|
|
|
|
+ <menu-item v-else :name="item.path" :key="`menu${item.path}`"
|
|
|
|
|
+ ><common-icon :type="item.children[0].icon || ''" /><span class="title">{{
|
|
|
|
|
+ item.children[0].title
|
|
|
|
|
+ }}</span></menu-item
|
|
|
|
|
+ >
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-else>
|
|
|
|
|
+ <side-menu-item
|
|
|
|
|
+ v-if="showChildren(item)"
|
|
|
|
|
+ :key="`menu${item.path}`"
|
|
|
|
|
+ :parent-item="item"
|
|
|
|
|
+ ></side-menu-item>
|
|
|
|
|
+ <menu-item v-else :name="item.path" :key="`menu${item.path}`"
|
|
|
|
|
+ ><common-icon :type="item.icon || ''" /><span class="title">{{ item.title }}</span></menu-item
|
|
|
|
|
+ >
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </Menu>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
<div class="menu-collapsed" v-show="collapsed" :list="menuList">
|
|
<div class="menu-collapsed" v-show="collapsed" :list="menuList">
|
|
|
<template v-for="item in menuList">
|
|
<template v-for="item in menuList">
|
|
|
<collapsed-menu
|
|
<collapsed-menu
|
|
|
v-if="item.children && item.children.length > 0"
|
|
v-if="item.children && item.children.length > 0"
|
|
|
@on-click="handleSelect"
|
|
@on-click="handleSelect"
|
|
|
- hide-title
|
|
|
|
|
|
|
+ :hide-title="true"
|
|
|
|
|
+ :activeMenuPath="activeMenuPath"
|
|
|
:root-icon-size="rootIconSize"
|
|
:root-icon-size="rootIconSize"
|
|
|
:icon-size="iconSize"
|
|
:icon-size="iconSize"
|
|
|
:theme="theme"
|
|
:theme="theme"
|
|
@@ -41,12 +79,14 @@
|
|
|
:key="`drop-menu-${item.path}`"
|
|
:key="`drop-menu-${item.path}`"
|
|
|
></collapsed-menu>
|
|
></collapsed-menu>
|
|
|
<Tooltip transfer v-else :content="item.title" placement="right" :key="`drop-menu-${item.path}`">
|
|
<Tooltip transfer v-else :content="item.title" placement="right" :key="`drop-menu-${item.path}`">
|
|
|
- <a @click="handleSelect(getNameOrHref(item, true))" class="drop-menu-a" :style="{ textAlign: 'center' }"
|
|
|
|
|
- ><common-icon
|
|
|
|
|
- :size="rootIconSize"
|
|
|
|
|
- :color="textColor"
|
|
|
|
|
- :type="item.icon || (item.children && item.children[0].icon)"
|
|
|
|
|
- /></a>
|
|
|
|
|
|
|
+ <a
|
|
|
|
|
+ @click="handleSelect(item)"
|
|
|
|
|
+ class="drop-menu-a"
|
|
|
|
|
+ :class="{ on: item.path == activeMenuPath }"
|
|
|
|
|
+ :style="{ textAlign: 'center' }"
|
|
|
|
|
+ ><common-icon :color="textColor" :type="item.icon || (item.children && item.children[0].icon)" />
|
|
|
|
|
+ <span class="title">{{ item.title }}</span>
|
|
|
|
|
+ </a>
|
|
|
</Tooltip>
|
|
</Tooltip>
|
|
|
</template>
|
|
</template>
|
|
|
</div>
|
|
</div>
|
|
@@ -58,10 +98,11 @@ import CollapsedMenu from './collapsed-menu.vue';
|
|
|
import { getUnion } from '@/libs/tools';
|
|
import { getUnion } from '@/libs/tools';
|
|
|
import { mapState } from 'vuex';
|
|
import { mapState } from 'vuex';
|
|
|
import mixin from './mixin';
|
|
import mixin from './mixin';
|
|
|
|
|
+import itemMixin from './item-mixin';
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'SideMenu',
|
|
name: 'SideMenu',
|
|
|
- mixins: [mixin],
|
|
|
|
|
|
|
+ mixins: [mixin, itemMixin],
|
|
|
components: {
|
|
components: {
|
|
|
SideMenuItem,
|
|
SideMenuItem,
|
|
|
CollapsedMenu,
|
|
CollapsedMenu,
|
|
@@ -78,7 +119,7 @@ export default {
|
|
|
},
|
|
},
|
|
|
theme: {
|
|
theme: {
|
|
|
type: String,
|
|
type: String,
|
|
|
- default: 'dark',
|
|
|
|
|
|
|
+ default: 'light',
|
|
|
},
|
|
},
|
|
|
rootIconSize: {
|
|
rootIconSize: {
|
|
|
type: Number,
|
|
type: Number,
|
|
@@ -89,10 +130,6 @@ export default {
|
|
|
default: 16,
|
|
default: 16,
|
|
|
},
|
|
},
|
|
|
accordion: Boolean,
|
|
accordion: Boolean,
|
|
|
- activeName: {
|
|
|
|
|
- type: String,
|
|
|
|
|
- default: '',
|
|
|
|
|
- },
|
|
|
|
|
openNames: {
|
|
openNames: {
|
|
|
type: Array,
|
|
type: Array,
|
|
|
default: () => [],
|
|
default: () => [],
|
|
@@ -101,12 +138,56 @@ export default {
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
openedNames: [],
|
|
openedNames: [],
|
|
|
|
|
+ childList: [],
|
|
|
|
|
+ activeChildName: '',
|
|
|
|
|
+ childOptions: [],
|
|
|
|
|
+ activePath: '',
|
|
|
|
|
+ activeMenuPath: '',
|
|
|
|
|
+ catName: '',
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- handleSelect(name) {
|
|
|
|
|
- this.$emit('on-select', name);
|
|
|
|
|
- // this.$store.commit('menus/getopenMenus', this.openedNames)
|
|
|
|
|
|
|
+ handleSelect(name, type) {
|
|
|
|
|
+ if (!type) {
|
|
|
|
|
+ this.$emit('on-select', name);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.childOptions = [];
|
|
|
|
|
+ this.menuList.map((e) => {
|
|
|
|
|
+ if (e.path === name) {
|
|
|
|
|
+ console.log(e, 'eeee');
|
|
|
|
|
+ if (e.children) {
|
|
|
|
|
+ this.catName = e.title;
|
|
|
|
|
+ this.activeMenuPath = e.path;
|
|
|
|
|
+ this.childList = e.children || [];
|
|
|
|
|
+ this.activeChildName = e.children[0].path;
|
|
|
|
|
+ this.childOptions = [e.children[0].path];
|
|
|
|
|
+ this.$store.commit('menus/childMenuList', this.childList);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.childList = [];
|
|
|
|
|
+ this.$store.commit('menus/childMenuList', []);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ handleChildSelect(name) {
|
|
|
|
|
+ this.turnToPage(name);
|
|
|
|
|
+ },
|
|
|
|
|
+ turnToPage(route, all) {
|
|
|
|
|
+ let { path, name, params, query } = {};
|
|
|
|
|
+ if (typeof route === 'string' && !all) path = route;
|
|
|
|
|
+ else if (typeof route === 'string' && all) name = route;
|
|
|
|
|
+ else {
|
|
|
|
|
+ path = route.path;
|
|
|
|
|
+ name = route.name;
|
|
|
|
|
+ params = route.params;
|
|
|
|
|
+ query = route.query;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.$router.push({
|
|
|
|
|
+ path,
|
|
|
|
|
+ name,
|
|
|
|
|
+ params,
|
|
|
|
|
+ query,
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
getOpenedNamesByActiveName() {
|
|
getOpenedNamesByActiveName() {
|
|
|
return this.$route.matched.map((item) => item.path).filter((item) => item !== name);
|
|
return this.$route.matched.map((item) => item.path).filter((item) => item !== name);
|
|
@@ -119,6 +200,17 @@ export default {
|
|
|
// this.openedNames = n
|
|
// this.openedNames = n
|
|
|
// this.$store.commit('menus/getopenMenus', n)
|
|
// this.$store.commit('menus/getopenMenus', n)
|
|
|
},
|
|
},
|
|
|
|
|
+ openChildNameData(e) {
|
|
|
|
|
+ console.log(e);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleUpdateMenuState() {
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ if (this.$refs.childMenu) {
|
|
|
|
|
+ this.$refs.childMenu.updateActiveName();
|
|
|
|
|
+ if (this.accordion) this.$refs.childMenu.updateOpened();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
|
...mapState('menus', ['openMenus']),
|
|
...mapState('menus', ['openMenus']),
|
|
@@ -130,18 +222,32 @@ export default {
|
|
|
activeName(name) {
|
|
activeName(name) {
|
|
|
if (this.accordion) this.openedNames = this.getOpenedNamesByActiveName();
|
|
if (this.accordion) this.openedNames = this.getOpenedNamesByActiveName();
|
|
|
else this.openedNames = getUnion(this.openedNames, this.getOpenedNamesByActiveName());
|
|
else this.openedNames = getUnion(this.openedNames, this.getOpenedNamesByActiveName());
|
|
|
|
|
+ // this.handleSelect(this.activeName);
|
|
|
},
|
|
},
|
|
|
openNames(newNames) {
|
|
openNames(newNames) {
|
|
|
this.openedNames = newNames;
|
|
this.openedNames = newNames;
|
|
|
},
|
|
},
|
|
|
openedNames() {
|
|
openedNames() {
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
- // this.$refs.menu.updateOpened()
|
|
|
|
|
|
|
+ this.$refs.menu.updateOpened();
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
+ $route(newRoute) {},
|
|
|
|
|
+ $route: {
|
|
|
|
|
+ handler(newRoute) {
|
|
|
|
|
+ console.log(newRoute, 'newRoutenewRoute');
|
|
|
|
|
+ this.activePath = newRoute.path;
|
|
|
|
|
+ this.activeMenuPath = newRoute.matched[0].path;
|
|
|
|
|
+ this.handleUpdateMenuState();
|
|
|
|
|
+ console.log(activeMenuPath, 'activeMenuPath');
|
|
|
|
|
+ },
|
|
|
|
|
+ immediate: true,
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
this.openedNames = getUnion(this.openedNames, this.getOpenedNamesByActiveName());
|
|
this.openedNames = getUnion(this.openedNames, this.getOpenedNamesByActiveName());
|
|
|
|
|
+ this.handleSelect(this.openedNames[0], 'one');
|
|
|
|
|
+ this.activeMenuPath = this.openedNames[0];
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|
|
@@ -149,8 +255,9 @@ export default {
|
|
|
@import './side-menu.less';
|
|
@import './side-menu.less';
|
|
|
.ivu-menu {
|
|
.ivu-menu {
|
|
|
.side-menu-wrapper a.drop-menu-a {
|
|
.side-menu-wrapper a.drop-menu-a {
|
|
|
- padding: 15px !important;
|
|
|
|
|
|
|
+ padding: 1px !important;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
.ivu-select-dropdown.ivu-dropdown-transfer {
|
|
.ivu-select-dropdown.ivu-dropdown-transfer {
|
|
|
background: rgb(0, 21, 41) !important;
|
|
background: rgb(0, 21, 41) !important;
|
|
|
width: 170px !important;
|
|
width: 170px !important;
|
|
@@ -191,6 +298,8 @@ export default {
|
|
|
> .drop-menu-a
|
|
> .drop-menu-a
|
|
|
> .menu-title {
|
|
> .menu-title {
|
|
|
color: #fff !important;
|
|
color: #fff !important;
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ line-height: 14px;
|
|
|
}
|
|
}
|
|
|
.ivu-select-dropdown.ivu-dropdown-transfer
|
|
.ivu-select-dropdown.ivu-dropdown-transfer
|
|
|
.collased-menu-dropdown:hover
|
|
.collased-menu-dropdown:hover
|
|
@@ -200,4 +309,124 @@ export default {
|
|
|
color: #fff !important;
|
|
color: #fff !important;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+.side-menu-wrapper a.drop-menu-a {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.side-menu-box {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ .drop-menu-a {
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ line-height: 14px;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ padding: 10px 10px;
|
|
|
|
|
+ margin-bottom: 4px;
|
|
|
|
|
+ .ivu-icon {
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ margin-right: 8px;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .parent-menu {
|
|
|
|
|
+ z-index: 99;
|
|
|
|
|
+ padding: 0 8px;
|
|
|
|
|
+ box-shadow: 2px 0px 4px 0px rgba(0, 0, 0, 0.06);
|
|
|
|
|
+ height: calc(~'100vh - 50px');
|
|
|
|
|
+ .ivu-menu-item-selected {
|
|
|
|
|
+ background-color: #1890ff !important;
|
|
|
|
|
+ color: #fff !important;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ }
|
|
|
|
|
+ .ivu-menu-vertical .ivu-menu-item {
|
|
|
|
|
+ padding: 10px 10px;
|
|
|
|
|
+ margin-bottom: 8px;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ .title {
|
|
|
|
|
+ line-height: 14px;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .ivu-menu-vertical .ivu-menu-item:first-child {
|
|
|
|
|
+ margin-top: 8px;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .child-menu {
|
|
|
|
|
+ z-index: 88;
|
|
|
|
|
+ .ivu-menu-vertical .ivu-menu-item {
|
|
|
|
|
+ padding: 12px 10px;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ .title {
|
|
|
|
|
+ line-height: 14px;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .ivu-menu-submenu {
|
|
|
|
|
+ .ivu-menu-item {
|
|
|
|
|
+ padding-left: 16px !important;
|
|
|
|
|
+ }
|
|
|
|
|
+ .ivu-menu-submenu {
|
|
|
|
|
+ .ivu-menu-submenu-title {
|
|
|
|
|
+ padding-left: 16px !important;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .ivu-menu-vertical .ivu-menu-submenu-title {
|
|
|
|
|
+ padding: 12px 10px;
|
|
|
|
|
+ line-height: 16px;
|
|
|
|
|
+ }
|
|
|
|
|
+ .cat-name {
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ line-height: 16px;
|
|
|
|
|
+ font-weight: 600;
|
|
|
|
|
+ color: #303133;
|
|
|
|
|
+ padding: 18px;
|
|
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ > .ivu-menu {
|
|
|
|
|
+ padding: 8px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .ivu-menu-vertical.ivu-menu-light:after {
|
|
|
|
|
+ width: 0px !important;
|
|
|
|
|
+ }
|
|
|
|
|
+ .ivu-menu-light.ivu-menu-vertical .ivu-menu-item-active:not(.ivu-menu-submenu):after {
|
|
|
|
|
+ width: 0px;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+.menu-collapsed {
|
|
|
|
|
+ padding: 0 8px;
|
|
|
|
|
+ .drop-menu-a.on {
|
|
|
|
|
+ background-color: #1890ff !important;
|
|
|
|
|
+ color: #fff !important;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ .ivu-icon {
|
|
|
|
|
+ color: #fff !important;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .drop-menu-a {
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ line-height: 14px;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ padding: 10px 11px;
|
|
|
|
|
+ margin-bottom: 4px;
|
|
|
|
|
+ flex-wrap: nowrap;
|
|
|
|
|
+ .ivu-icon {
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ margin-right: 8px;
|
|
|
|
|
+ }
|
|
|
|
|
+ .title {
|
|
|
|
|
+ white-space: nowrap;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .drop-menu-a {
|
|
|
|
|
+ padding: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ .collased-menu-dropdown * {
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|