import { MDViewBase } from './mdview-base';
import { ModelTool } from '@ibizstudio/runtime';
/**
 * 甘特视图基类
 *
 * @export
 * @class GanttViewBase
 * @extends {MDViewBase}
 * @implements {GanttViewInterface}
 */
export class GanttViewBase extends MDViewBase {
    constructor() {
        super(...arguments);
        /**
        * 视图默认加载
        *
        * @memberof GanttViewBase
        */
        this.isLoadDefault = true;
    }
    /**
     * 初始化甘特视图实例
     *
     * @param opts
     * @memberof GanttViewBase
     */
    async viewModelInit() {
        var _a;
        this.viewInstance = (this.staticProps.modeldata);
        await super.viewModelInit();
        this.isLoadDefault = (_a = this.viewInstance) === null || _a === void 0 ? void 0 : _a.loadDefault;
        this.ganttInstance = ModelTool.findPSControlByName('gantt', this.viewInstance.getPSControls());
    }
    /**
     *  多数据视图挂载
     *
     * @memberof GanttViewBase
     */
    viewMounted() {
        super.viewMounted();
        if (this.viewIsLoaded && this.isLoadDefault) {
            this.viewState.next({ tag: 'gantt', action: 'load', data: this.viewparams });
        }
    }
    /**
     *  绘制甘特部件
     *
     * @memberof GanttViewBase
     */
    renderMainContent() {
        var _a;
        let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(this.ganttInstance);
        return this.$createElement(targetCtrlName, { props: targetCtrlParam, ref: (_a = this.ganttInstance) === null || _a === void 0 ? void 0 : _a.name, on: targetCtrlEvent });
    }
}
