import { getToken } from 'pz-unit'; export class MenuModel { public key?: number; public title: string; public routerLink?: string; public icon?: string; public privilege?: number; public children?: MenuModel[]; public open?: boolean; public selected?: boolean; public authCode?: number; } const menuList: MenuModel[] = [ { title: '商品管理', icon: 'appstore', privilege: 1, open: false, selected: false, children: [ { title: '分类管理', authCode: 101000, icon: 'appstore', routerLink: '/home/commodity-class', }, { title: '商品列表', authCode: 101100, icon: 'shop', routerLink: '/home/commodity-manage', }, { title: '标签管理', authCode: 101200, icon: 'shop', routerLink: '/home/tags-manage', } ], }, { title: '订单管理', icon: 'laptop', privilege: 1, open: false, children: [ { title: '订单列表', authCode: 111000, icon: 'customer-service', routerLink: '/home/order-manage', }, { title: '退款管理', authCode: 111200, icon: 'customer-service', routerLink: '/home/return-list', }, { title: '星星冷柜', authCode: 111100, icon: 'hdd', routerLink: '/home/order-s', }, { title: '采购订单', authCode: 111300, icon: 'hdd', routerLink: '/home/purchase-order', } ], }, { title: '营销管理', icon: 'gift', open: false, children: [ { title: '主题馆', authCode: 121200, icon: 'bank', routerLink: '/home/theme-pavilion', }, { title: '优惠劵列表', icon: 'shake', authCode: null, routerLink: '/home/coupon', }, { title: '优惠劵领取记录', icon: 'file-sync', authCode: null, routerLink: '/home/coupon-receive-log', }, { title: '优惠劵使用记录', icon: 'file-done', authCode: null, routerLink: '/home/coupon-use-log', }, { title: '拼团管理', icon: 'pie-chart', authCode: 121000, routerLink: '/home/group-manage', }, { title: '新人活动', icon: 'gift', authCode: 121600, routerLink: '/home/newcomer', }, { title: '广告管理', icon: 'picture', authCode: 121300, routerLink: '/home/advertising' }, { title: '分享记录', authCode: 121500, icon: 'read', routerLink: '/home/share-log', }, ] }, { title: '自提点管理', routerLink: '/home/place', authCode: 131000, icon: 'environment', privilege: 1, open: true, }, { title: '用户管理', routerLink: '/home/principal', authCode: 141000, icon: 'user', privilege: 1, open: true, }, { title: '分红奖金', icon: 'user', privilege: 1, open: false, children: [ { title: '比例设置', icon: 'team', authCode: 171000, privilege: 1, routerLink: '/home/proportion-set', children: [] }, ] }, { title: '财务管理', icon: 'user', privilege: 1, open: false, children: [ { title: '营长收益', icon: 'key', authCode: 181000, privilege: 1, routerLink: '/home/earnings', children: [] }, { title: '分红管理', icon: 'team', authCode: 181100, privilege: 1, routerLink: '/home/dividend', children: [] }, ] }, { title: '权限管理', icon: 'safety', privilege: 1, open: false, children: [ { title: '账号管理', icon: 'key', authCode: 151000, privilege: 1, routerLink: '/home/account', children: [] }, { title: '职位管理', icon: 'team', authCode: 151100, privilege: 1, routerLink: '/home/position', children: [] }, { title: '权限设置', icon: 'solution', privilege: 1, authCode: 151200, routerLink: '/home/permission', children: [] }, { title: '权限列表', icon: 'solution', privilege: 1, authCode: 151300, routerLink: '/home/permission-list', children: [] }, ] }, { title: '业务审核', icon: 'profile', open: false, children: [ { title: '优惠券审核', routerLink: '/home/business', authCode: null, icon: 'profile', privilege: 1, open: true, children: [] }, ] }, { title: '供应商管理', routerLink: '/home/supplier', authCode: null, icon: 'cluster', privilege: 1, open: true, } ]; export const menuCheck = (type: string): any => { const res: MenuModel[] = []; const linkLink: string[] = ['/home', '/']; menuList.map(y => { if (y.children) { y.children = y.children.filter(z => { if (z.authCode) { return !!getToken().menu.some(x => x === z.authCode.toString()); } else { return false; } }); if (y.children) { if (y.children.length) { y.children.map(x => linkLink.push(x.routerLink)); res.push(y); } } } else { if (y.authCode) { if (getToken().menu.some(x => x === y.authCode.toString())) { res.push(y); linkLink.push(y.routerLink); } } } }); return type === 'menu' ? res : linkLink; };