spc/src/views/main-sidebar-sub-menu.vue
2023-06-28 15:01:29 +08:00

53 lines
1.5 KiB
Vue

<!--
* @Author: zwq
* @Date: 2022-08-22 14:57:51
* @LastEditors: zwq
* @LastEditTime: 2023-06-28 14:49:58
* @Description:
-->
<template>
<el-submenu v-if="menu.children && menu.children.length >= 1" :index="menu.id" :popper-append-to-body="false">
<template slot="title">
<svg class="icon-svg aui-sidebar__menu-icon" aria-hidden="true"><use :xlink:href="`#${menu.icon}`"></use></svg>
<span>{{ menu.name | i18nFilter }}</span>
</template>
<sub-menu v-for="item in menu.children" :key="item.id" :menu="item"></sub-menu>
</el-submenu>
<el-menu-item v-else :index="menu.id" @click="gotoRouteHandle(menu.id)">
<svg class="icon-svg aui-sidebar__menu-icon-son" aria-hidden="true"><use xlink:href="#椭圆形"></use></svg>
<!-- <svg class="icon-svg aui-sidebar__menu-icon" aria-hidden="true"><use :xlink:href="`#${menu.icon}`"></use></svg> -->
<span>{{ menu.name | i18nFilter }}</span>
</el-menu-item>
</template>
<script>
import SubMenu from './main-sidebar-sub-menu'
import i18n from "@/i18n";
export default {
name: 'sub-menu',
props: {
menu: {
type: Object,
required: true
}
},
filters: {
i18nFilter (val) {
return i18n.t(val)
}
},
components: {
SubMenu
},
methods: {
// 通过menuId与动态(菜单)路由进行匹配跳转至指定路由
gotoRouteHandle (menuId) {
var route = window.SITE_CONFIG['dynamicMenuRoutes'].filter(item => item.meta.menuId === menuId)[0]
if (route) {
this.$router.push({ name: route.name })
}
}
}
}
</script>