|
|
<template>
|
|
|
<Menu class="sidebar-menu" theme="light" width="auto">
|
|
|
<template v-for="(menu, index) in menus">
|
|
|
import React from 'react'
|
|
|
import { Link } from 'react-router-dom'
|
|
|
import { Layout, Menu, Icon } from 'antd'
|
|
|
|
|
|
import {
|
|
|
normalMenus,
|
|
|
masterMenus,
|
|
|
businessMenus
|
|
|
} from '../../../../config/menus' // 考虑与原有业务复用
|
|
|
|
|
|
const { Header, Sider } = Layout
|
|
|
|
|
|
function Title(props) {
|
|
|
return <div>
|
|
|
<Icon type={props.icon}></Icon>
|
|
|
{props.title}
|
|
|
</div>
|
|
|
}
|
|
|
|
|
|
function Menus(props) {
|
|
|
const user = props.user
|
|
|
|
|
|
function isMaster() {
|
|
|
return user.role === '1000'
|
|
|
}
|
|
|
|
|
|
function isBusiness() {
|
|
|
return user.role === '3000'
|
|
|
}
|
|
|
|
|
|
const menus = (function() {
|
|
|
if (isBusiness()) {
|
|
|
return businessMenus
|
|
|
}
|
|
|
if (isMaster()) {
|
|
|
return [...normalMenus, ...masterMenus]
|
|
|
}
|
|
|
return normalMenus
|
|
|
}())
|
|
|
|
|
|
const ListItems = menus.map((menu, index) => {
|
|
|
if (menu.subMenus && menu.subMenus.length) {
|
|
|
return <Menu.SubMenu title={Title(menu)} key={index + ''}>
|
|
|
{menu.subMenus.map((subMenu, subIndex) => {
|
|
|
return <Menu.Item key={`${index}-${subIndex}`}>
|
|
|
{subMenu.isClassic ? <a href={subMenu.link}>
|
|
|
<Icon type={subMenu.icon}></Icon>
|
|
|
{subMenu.title}
|
|
|
</a> : <Link to={subMenu.link}>
|
|
|
<Icon type={subMenu.icon}></Icon>
|
|
|
{subMenu.title}
|
|
|
</Link>}
|
|
|
</Menu.Item>
|
|
|
})}
|
|
|
</Menu.SubMenu>
|
|
|
}
|
|
|
|
|
|
return <Menu.Item key={index + ''}>
|
|
|
{menu.isClassic ? <a href={menu.link}>
|
|
|
<Icon type={menu.icon}></Icon>
|
|
|
{menu.title}
|
|
|
</a> : <Link to={menu.link}>
|
|
|
<Icon type={menu.icon}></Icon>
|
|
|
{menu.title}
|
|
|
</Link>}
|
|
|
</Menu.Item>
|
|
|
// return <Item menu={menu} key={index + ''} />
|
|
|
})
|
|
|
|
|
|
return <div className="menus">
|
|
|
<Menu className="sidebar-menu" theme="light" mode="inline" width="auto">
|
|
|
{ListItems}
|
|
|
{/* <template v-for="(menu, index) in menus">
|
|
|
<Submenu v-if="menu.subMenus" :name="index">
|
|
|
<template slot="title">
|
|
|
<Icon :type="menu.icon"></Icon>
|
...
|
...
|
@@ -28,50 +98,9 @@ |
|
|
{{menu.title}}
|
|
|
</router-link>
|
|
|
</MenuItem>
|
|
|
</template>
|
|
|
</template> */}
|
|
|
</Menu>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
normalMenus,
|
|
|
masterMenus,
|
|
|
businessMenus
|
|
|
} from '../../../../config/menus' // 考虑与原有业务复用
|
|
|
|
|
|
export default {
|
|
|
props: ['user'],
|
|
|
computed: {
|
|
|
isMaster: function() {
|
|
|
return this.user.role === '1000'
|
|
|
},
|
|
|
isBusiness: function() {
|
|
|
return this.user.role === '3000'
|
|
|
},
|
|
|
menus: function() {
|
|
|
if (this.isBusiness) {
|
|
|
return businessMenus
|
|
|
}
|
|
|
if (this.isMaster) {
|
|
|
return [...normalMenus, ...masterMenus]
|
|
|
}
|
|
|
return normalMenus
|
|
|
}
|
|
|
}
|
|
|
</div>
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
a {
|
|
|
display: block;
|
|
|
color: #495060;
|
|
|
|
|
|
> i {
|
|
|
margin-right: 6px;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.ivu-menu-light.ivu-menu-vertical .ivu-menu-item-active {
|
|
|
color: #495060;
|
|
|
}
|
|
|
</style> |
|
|
\ No newline at end of file |
|
|
export default Menus |
...
|
...
|
|