import { throttle, Util } from '@ibizstudio/runtime'; import { DrbarControlBase } from '../../../widgets/drbar-control-base'; /** * 数据关系栏部件基类 * * @export * @class AppDrbarBase * @extends {TabExpPanelBase} */ export class AppDrbarBase extends DrbarControlBase { /** * 绘制关系界面 * * @return {*} * @memberof AppDrbarBase */ renderDrView() { if (this.selection && this.selection.view && !this.selection.disabled) { let viewData: any = Util.deepCopy(this.context); let viewParam: any = Util.deepCopy(this.viewparams); if (this.selection.localContext) { Object.assign(viewData, this.selection.localContext); } if (this.selection.localViewParam) { Object.assign(viewParam, this.selection.localViewParam); } if (this.selection.view.getPSAppView?.()) { Object.assign(viewData, { viewpath: this.selection.view.getPSAppView()?.modelPath }); } // 填充主视图标识参数 if (this.appDeCodeName && viewData.hasOwnProperty(this.appDeCodeName.toLowerCase())) { Object.assign(viewData, { srfparentdename: this.appDeCodeName, srfparentkey: viewData[this.appDeCodeName.toLowerCase()] }); Object.assign(viewParam, { srfparentdename: this.appDeCodeName, srfparentkey: viewData[this.appDeCodeName.toLowerCase()] }); } return this.$createElement('app-view-shell', { props: { staticProps: { viewDefaultUsage: false, appDeCodeName: this.appDeCodeName, }, dynamicProps: { viewdata: JSON.stringify(viewData), viewparam: JSON.stringify(viewParam), }, }, key: Util.createUUID(), class: 'viewcontainer2', on: {}, }); } } /** * @description 渲染菜单项 * @param {any[]} items * @return {*} * @memberof AppDrbarBase */ renderMenuItems(items: any[]) { const getGroupTitle = (item: any): string => { if (this.showMode == 'DEFAULT') { return item.text; } if (this.selection && this.selection.groupCodeName == item.id) { return item.text + '-' + this.selection.text; } else { return item.text; } }; return items.map((item: any, index: number) => { if (this.showMode == 'INDEXMODE' && item.id == this.formName) { return null; } if (item.items && item.items.length > 0) { return ( {item.icon ? : item.iconcls ? : null} {getGroupTitle(item)} {this.renderMenuItems(item.items)} ); } else { return ( {item.icon ? : item.iconcls ? : null} {item.text} {item.counter && (item.counter.count || item.counter.count == 0) ? : null} ); } }); } /** * @description 渲染侧边栏 * @return {*} * @memberof AppDrbarBase */ renderSider() { return ( throttle(this.onSelect, [event], this)}> {this.renderMenuItems(this.menuItems)} ); } /** * @description 渲染头部 * @return {*} * @memberof AppDrbarBase */ renderHeader() { return ( throttle(this.onSelect, [event], this)}> {this.renderMenuItems(this.menuItems)} ); } /** * 绘制关系栏部件 * * @returns {*} * @memberof AppDrbarBase */ render() { if (!this.controlIsLoaded) { return null; } const { controlClassNames } = this.renderOptions; return ( {this.menuDir == 'horizontal' ? this.renderHeader() : this.renderSider()} {this.showMode == 'DEFAULT' ? ( {this.$parent.$slots.mainform} ) : null} {this.renderDrView()} ); } }