import { HtmlViewBase } from '../../../view/htmlview-base';
import { AppLayoutService } from '../../../app-service/common-service/app-layout-service';

/**
 * 实体html视图基类
 *
 * @export
 * @class AppHtmlViewBase
 * @extends {HtmlViewBase}
 */
export class AppHtmlViewBase extends HtmlViewBase {
  /**
   * 实体html视图渲染
   *
   * @memberof AppHtmlViewBase
   */
  render(h: any) {
    if (!this.viewIsLoaded) {
      return null;
    }
    const targetViewLayoutComponent: any = AppLayoutService.getLayoutComponent(`${this.viewInstance?.viewType}-${this.viewInstance?.viewStyle}`);
    return h(
      targetViewLayoutComponent,
      {
        props: { viewInstance: this.viewInstance, model: this.model, modelService: this.modelService, viewparams: this.viewparams, context: this.context },
      },
      [this.renderTopMessage(), this.renderBodyMessage(), this.renderMainContent(), this.renderBottomMessage()],
    );
  }
}
