fix:菜单“出库管理”默认展开

dev_1.0.2
jiangpeng 2026-06-30 17:00:40 +08:00
parent f3f7a99b10
commit c10a81f271
1 changed files with 53 additions and 0 deletions

View File

@ -3,6 +3,7 @@
<logo v-if="showLogo" :collapse="isCollapse" />
<el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
<el-menu
ref="sideMenu"
:default-active="activeMenu"
:collapse="isCollapse"
:background-color="settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
@ -11,6 +12,8 @@
:active-text-color="settings.theme"
:collapse-transition="false"
mode="vertical"
@open="handleMenuOpen"
@close="handleMenuClose"
>
<sidebar-item
v-for="(route, index) in sidebarRouters"
@ -24,6 +27,7 @@
</template>
<script>
import pathLib from 'path'
import { mapGetters, mapState } from "vuex"
import Logo from "./Logo"
import SidebarItem from "./SidebarItem"
@ -52,6 +56,55 @@ export default {
isCollapse() {
return !this.sidebar.opened
}
},
methods: {
// """"
handleMenuClose(index) {
//
const closedRoute = this.sidebarRouters.find(route => route.path === index)
if (!closedRoute || !closedRoute.children || !closedRoute.children.length) return
// ""
const outerRoute = closedRoute.children.find(
child => !child.hidden && child.meta && child.meta.title === '出库管理'
)
if (!outerRoute) return
// "" el-menu index
const outerBasePath = pathLib.resolve(index, outerRoute.path)
const outerIndex = pathLib.resolve(outerBasePath, outerRoute.path)
if (this.$refs.sideMenu) {
this.$refs.sideMenu.close(outerIndex)
}
},
// ""
handleMenuOpen(index) {
//
const openedRoute = this.sidebarRouters.find(route => route.path === index)
if (!openedRoute || !openedRoute.children || !openedRoute.children.length) return
// ""
const outerRoute = openedRoute.children.find(
child => !child.hidden && child.meta && child.meta.title === '出库管理'
)
if (!outerRoute) return
// "" el-menu index
// SidebarItem
// basePath path.resolve(parentPath, child.path)
// basePath el-submenu :index = path.resolve(basePath, child.path)
// child.path resolve index
const outerBasePath = pathLib.resolve(index, outerRoute.path)
const outerIndex = pathLib.resolve(outerBasePath, outerRoute.path)
// 300ms el-submenu el-menu
setTimeout(() => {
if (this.$refs.sideMenu) {
this.$refs.sideMenu.open(outerIndex)
}
}, 300)
}
}
}
</script>