更多按钮
作者:
更多按钮
- 过滤掉子按钮:在
getMenuOptions
方法中可以控制不显示哪些按钮。 - 动态控制按钮显示:
MenuController.setVisible
方法
class ProjectScheduleFormPresenter extends EasyBizFormPresenter<IProjectSchedule> {
constructor(options: IEasyBizFormPresenterOptions) {
super(EN_ProjectSchedule, options);
}
isRestartVisible() {
const currentUserId = store.currentUser.id;
const formCreateUserId = oc(this.formValue).createdUser.id('');
this.formPresenter
.getBean(BeanNames.MenuController)
.setVisible(BizFormMenuButtons.Restart, currentUserId === formCreateUserId);
}
protected onFormCreated(form: EntityForm, disposers: Array<IDisposer>) {
this.isRestartVisible();
}
protected getMenuOptions(): MenuOptions {
const defaultMenuOptions = super.getMenuOptions();
const excludeButtons: BizFormMenuCreator[] = [buildInMenus.Aborted, buildInMenus.Copy];
const filterCopyMenu = defaultMenuOptions.menus.filter(menu => !excludeButtons.includes(menu));
return {
...defaultMenuOptions,
menus: filterCopyMenu,
};
}