import { TabViewPanelBase } from '../../../widgets';
import { IPSAppDEView } from '@ibizstudio/runtime';

/**
 * 分页视图面板部件基类
 *
 * @export
 * @class AppTabViewPanelBase
 * @extends {TabViewPanelBase}
 */
export class AppTabViewPanelBase extends TabViewPanelBase {
  /**
   * 绘制分页视图面板
   *
   * @returns {*}
   * @memberof AppTabViewPanelBase
   */
  render() {
    if (!this.controlIsLoaded) {
      return null;
    }
    const { controlClassNames } = this.renderOptions;
    const embedView: IPSAppDEView = this.controlInstance.getEmbeddedPSAppDEView() as IPSAppDEView;
    let tempViewParam: any = this.viewparam;
    let targetCtrlParam: any = {
      staticProps: {
        viewDefaultUsage: false,
        viewModelData: embedView,
        viewUseByExpBar: true,
      },
      dynamicProps: {
        viewparam: tempViewParam,
        viewdata: JSON.stringify(this.context),
      },
    };
    return (
      <div class={{ ...controlClassNames, tabviewpanel: true }}>
        {this.isActivied && embedView
          ? this.$createElement('app-view-shell', {
              props: targetCtrlParam,
              class: 'viewcontainer2',
              on: {
                viewload: this.viewDatasChange.bind(this),
              },
            })
          : null}
      </div>
    );
  }
}
