menus.js 911 Bytes
Newer Older
潘际乾 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
let n = 0;
const generateMenuTree = (menus) => {
	const arr = [];
	for (let i = 0; i < menus.length; i++) {
		const menu = menus[i];
		if (menu.subMenu.length) {
			const children = generateMenuTree(menu.subMenu)
			arr.push({
				index: menu.value + '_' + n++,
				name: menu.label,
				path: menu.value,
				children
			})
		} else {
			arr.push({
				name: menu.label,
17
				value: 'dzsys-' + menu.value,
潘际乾 committed
18
				path: '/business/dzsys/' + menu.value,
19 20 21
				isDz: true,
				icon: "el-icon-document",
				children: []
潘际乾 committed
22 23 24 25 26 27
			})
		}
	}
	return arr;
}

潘际乾 committed
28
export const getDzSysMenu = () => {
29 30 31 32 33 34 35 36 37 38 39 40
	const menuStr = window.sessionStorage.getItem('menu')
	if (!menuStr) {
		return null;
	}
	const menusConfig = JSON.parse(menuStr);
	// menusConfig.unshift( { id: null, label: "登陆", value: "login", subMenu: [] } )
	return {
		name: '电证系统',
		index: 'dzsys',
		path: 'dzsys',
		children: generateMenuTree(menusConfig)
	}
潘际乾 committed
41
}