import { ModelTool, WizardViewEngine } from '@ibizstudio/runtime';
import { MDViewBase } from './mdview-base';
/**
 * 实体向导视图基类
 *
 * @export
 * @class WizardViewBase
 * @extends {MDViewBase}
 * @implements {WizardViewInterface}
 */
export class WizardViewBase extends MDViewBase {
    constructor() {
        super(...arguments);
        /**
     * 视图引擎
     *
     * @public
     * @type {Engine}
     * @memberof TreeViewBase
     */
        this.engine = new WizardViewEngine();
    }
    /**
     * 引擎初始化
     *
     * @param {*} [opts={}] 引擎参数
     * @memberof TreeViewBase
     */
    engineInit(opts = {}) {
        if (this.Environment && this.Environment.isPreviewMode) {
            return;
        }
        if (this.engine && this.wizardPanelInstance) {
            let engineOpts = Object.assign({
                view: this,
                parentContainer: this.$parent,
                p2k: '0',
                isLoadDefault: true,
                //TODO IPSAppDEWizardView缺少loaddefault
                // isLoadDefault: this.viewInstance.loadDefault,
                keyPSDEField: this.appDeCodeName.toLowerCase(),
                majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
                opendata: (args, fullargs, params, $event, xData) => {
                    this.opendata(args, fullargs, params, $event, xData);
                },
                newdata: (args, fullargs, params, $event, xData) => {
                    this.newdata(args, fullargs, params, $event, xData);
                },
                wizardpanel: this.$refs[this.wizardPanelInstance.name].ctrl,
            }, opts);
            this.engine.init(engineOpts);
        }
    }
    /**
    * 初始化列表视图实例
    *
    * @memberof WizardViewBase
    */
    async viewModelInit() {
        var _a;
        this.viewInstance = ((_a = this.staticProps) === null || _a === void 0 ? void 0 : _a.modeldata);
        await super.viewModelInit();
        this.wizardPanelInstance = ModelTool.findPSControlByType('WIZARDPANEL', this.viewInstance.getPSControls() || []);
    }
    /**
     * 渲染视图主体内容区
     *
     * @memberof WizardViewBase
     */
    renderMainContent() {
        var _a;
        let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(this.wizardPanelInstance);
        return this.$createElement(targetCtrlName, { slot: 'default', props: targetCtrlParam, ref: (_a = this.wizardPanelInstance) === null || _a === void 0 ? void 0 : _a.name, on: targetCtrlEvent });
    }
}
