import { DeIndexViewEngine, ModelTool } from '@ibizstudio/runtime';
import { MainViewBase } from './mainview-base';
/**
 * @description 实体首页视图基类
 * @export
 * @class DeIndexViewBase
 * @extends {MainViewBase}
 */
export class DeIndexViewBase extends MainViewBase {
    constructor() {
        super(...arguments);
        /**
         * @description 实体首页视图引擎实例对象
         * @type {DeIndexViewEngine}
         * @memberof DeIndexViewBase
         */
        this.engine = new DeIndexViewEngine();
    }
    /**
     * @description 视图模型初始化
     * @memberof DeIndexViewBase
     */
    async viewModelInit() {
        await super.viewModelInit();
        const controls = this.viewInstance.getPSControls() || [];
        this.formInstance = ModelTool.findPSControlByType('FORM', controls);
        this.drBarInstance = ModelTool.findPSControlByType('DRBAR', controls);
    }
    /**
     * @description 引擎初始化
     * @return {*}  {void}
     * @memberof DeIndexViewBase
     */
    engineInit() {
        if (this.Environment && this.Environment.isPreviewMode) {
            return;
        }
        this.engine.init({
            view: this,
            parentContainer: this.$parent,
            form: this.$refs[this.formInstance.name].ctrl,
            drbar: this.$refs[this.drBarInstance.name].ctrl,
            p2k: '0',
            isLoadDefault: true,
            keyPSDEField: this.appDeCodeName.toLowerCase(),
            majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
        });
    }
}
