提交 7f47a559 编写于 作者: tony001's avatar tony001

修复去掉某个子菜单后,主菜单不显示

上级 37979f4e
...@@ -171,6 +171,9 @@ export class AppMenus extends Vue { ...@@ -171,6 +171,9 @@ export class AppMenus extends Vue {
* @memberof AppMenus * @memberof AppMenus
*/ */
protected renderMenuItem(item: any): any { protected renderMenuItem(item: any): any {
if(item.hidden){
return;
}
return item.type =='SEPERATOR' ? <divider key={item.id} /> : <el-menu-item index={item.id} on-click={() => this.menuActive(item)}> return item.type =='SEPERATOR' ? <divider key={item.id} /> : <el-menu-item index={item.id} on-click={() => this.menuActive(item)}>
{this.renderIcon(item)} {this.renderIcon(item)}
<span slot="title">{item.text}</span> <span slot="title">{item.text}</span>
......
...@@ -140,6 +140,7 @@ export class AppMenusCtrlBase extends CtrlBase { ...@@ -140,6 +140,7 @@ export class AppMenusCtrlBase extends CtrlBase {
this.menus = this.menuModel.getAppMenuItems(); this.menus = this.menuModel.getAppMenuItems();
if(Environment.enablePermissionValid){ if(Environment.enablePermissionValid){
this.computedEffectiveMenus(this.menus); this.computedEffectiveMenus(this.menus);
this.computeParentMenus(this.menus);
} }
this.menusChange(); this.menusChange();
} }
...@@ -161,6 +162,29 @@ export class AppMenusCtrlBase extends CtrlBase { ...@@ -161,6 +162,29 @@ export class AppMenusCtrlBase extends CtrlBase {
}) })
} }
/**
* 计算父项菜单项是否隐藏
*
* @param {*} inputMenus
* @memberof Index
*/
public computeParentMenus(inputMenus:Array<any>){
if(inputMenus && inputMenus.length >0){
inputMenus.forEach((item:any) =>{
if(item.hidden && item.items && item.items.length >0){
item.items.map((singleItem:any) =>{
if(!singleItem.hidden){
item.hidden = false;
}
if(singleItem.items && singleItem.items.length >0){
this.computeParentMenus(singleItem.items);
}
})
}
})
}
}
/** /**
* 菜单变更 * 菜单变更
* *
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册