wizardview-base.tsx 2.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 78 79 80 81 82 83 84 85 86 87 88 89 90
import { IPSAppDEWizardView, IPSDEWizardPanel } from '@ibiz/dynamic-model-api';
import { ModelTool, WizardViewEngine, WizardViewInterface } from 'ibiz-core';
import { MDViewBase } from './mdview-base';

/**
 * 实体向导视图基类
 *
 * @export
 * @class WizardViewBase
 * @extends {MDViewBase}
 * @implements {WizardViewInterface}
 */
export class WizardViewBase extends MDViewBase implements WizardViewInterface {

    /**
     * 向导视图模型实例
     * 
     * @memberof WizardViewBase
     */
    public declare viewInstance: IPSAppDEWizardView;

    /**
     * 向导面板部件模型实例
     * 
     * @memberof WizardViewBase
     */
    public wizardPanelInstance!: IPSDEWizardPanel;

        /**
     * 视图引擎
     *
     * @public
     * @type {Engine}
     * @memberof TreeViewBase
     */
    public declare engine: WizardViewEngine;
    
    /**
     * 引擎初始化
     *
     * @param {*} [opts={}] 引擎参数
     * @memberof TreeViewBase
     */
    public engineInit(opts: any = {}): void {
        if (this.Environment && this.Environment.isPreviewMode) {
            return;
        }
        if(this.engine && this.wizardPanelInstance){
            let engineOpts = Object.assign({
                view: this,
                p2k: '0',
                isLoadDefault: true,
                //TODO IPSAppDEWizardView缺少loaddefault
                // isLoadDefault: this.viewInstance.loadDefault,
                keyPSDEField: this.appDeCodeName.toLowerCase(),
                majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
                opendata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
                    this.opendata(args, fullargs, params, $event, xData);
                },
                newdata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
                    this.newdata(args, fullargs, params, $event, xData);
                },
                wizardpanel: (this.$refs[this.wizardPanelInstance.name] as any).ctrl,
            }, opts)
            this.engine.init(engineOpts);
        }
    }


     /**
     * 初始化列表视图实例
     *
     * @memberof WizardViewBase
     */
    public async viewModelInit() {
        this.viewInstance = (this.staticProps?.modeldata) as IPSAppDEWizardView;
        await super.viewModelInit();
        this.wizardPanelInstance = ModelTool.findPSControlByType('WIZARDPANEL', this.viewInstance.getPSControls() || []);
    }

    /**
     * 渲染视图主体内容区
     * 
     * @memberof WizardViewBase
     */
    public renderMainContent() {
        let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(this.wizardPanelInstance);
        return this.$createElement(targetCtrlName, { slot: 'default', props: targetCtrlParam, ref: this.wizardPanelInstance?.name, on: targetCtrlEvent });
    }
}