portalview-base.tsx 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
import { IPSAppPortalView, IPSDEDashboard } from '@ibiz/dynamic-model-api';
import { ModelTool, PortalViewInterface } from 'ibiz-core';
import { ViewBase } from './view-base';

/**
 * 应用视图基类
 *
 * @export
 * @class PortalViewBase
 * @extends {ViewBase}
 * @implements {PortalViewInterface}
 */
export class PortalViewBase extends ViewBase implements PortalViewInterface {

    /**
     * 数据视图视图实例
     * 
     * @memberof GanttViewBase
     */
    public declare viewInstance: IPSAppPortalView;

    /**
     * 数据看板实例
     *
     * @public
     * @type {IPSDEDashboard}
     * @memberof PortalViewBase
     */
    public dashboardInstance !:IPSDEDashboard;

    /**
     * 初始化列表视图实例
     *
     * @memberof PortalViewBase
     */
    public async viewModelInit() {
        await super.viewModelInit();
        this.dashboardInstance = ModelTool.findPSControlByName('dashboard',this.viewInstance.getPSControls()) as IPSDEDashboard;      
    }

    /**
     *  视图挂载
     *
     * @memberof ViewBase
     */
     public containerMounted() {
        this.viewState.next({ tag: 'dashboard', action: 'load', data: {} });
    }

    /**
     * 渲染视图主体内容区
     *
     * @memberof PortalViewBase
     */
    public renderMainContent() {
        let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(this.dashboardInstance);
        Object.assign(targetCtrlParam.staticProps, { noPadding: true });
        return this.$createElement(targetCtrlName, {
            props: targetCtrlParam,
            ref: this.dashboardInstance.name,
            on: targetCtrlEvent,
        });
    }

    /**
     * 部件事件
     * @param ctrl 部件 
     * @param action  行为
     * @param data 数据
     * 
     * @memberof ViewBase
     */
    public onCtrlEvent(controlname: string, action: string, data: any) {
        super.onCtrlEvent(controlname, action, data);
    }

}