123456789101112131415161718 |
- // 树状结构构建插件
- const setParentsetSession = {
- install (Vue) {
- Vue.prototype.$setParentsetSession = function(options) {
- // 点击制造当前菜单父级项
- const tree = item => {
- const parent = options.menus.filter(j => item.parentCode === j.code).map(e => tree({ ...e, children: item }));
- if (parent.length > 0) {
- return { ...parent[0] };
- }
- return { ...item };
- };
- const childrens = tree(options.iscode);
- sessionStorage.setItem('childrens', JSON.stringify(childrens));
- };
- }
- };
- export default setParentsetSession;
|