import { GridExpViewEngine, ModelTool } from '@ibizstudio/runtime';
import { ExpViewBase } from './expview-base';
/**
 * 表格导航视图基类
 *
 * @export
 * @class GridExpViewBase
 * @extends {ExpViewBase}
 * @implements {GridExpViewInterface}
 */
export class GridExpViewBase extends ExpViewBase {
    constructor() {
        super(...arguments);
        /**
         * 视图引擎
         *
         * @public
         * @type {Engine}
         * @memberof GridExpViewBase
         */
        this.engine = new GridExpViewEngine();
    }
    /**
     * 引擎初始化
     *
     * @public
     * @memberof GridExpViewBase
     */
    engineInit() {
        if (this.Environment && this.Environment.isPreviewMode) {
            return;
        }
        let engineOpts = ({
            view: this,
            parentContainer: this.$parent,
            p2k: '0',
            gridexpbar: this.$refs[this.expBarInstance.name].ctrl,
            keyPSDEField: this.appDeCodeName.toLowerCase(),
            majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
            isLoadDefault: this.viewInstance.loadDefault,
        });
        this.engine.init(engineOpts);
    }
    /**
     * 初始化分页导航视图实例
     *
     * @memberof GridExpViewBase
     */
    async viewModelInit() {
        var _a;
        this.viewInstance = ((_a = this.staticProps) === null || _a === void 0 ? void 0 : _a.modeldata);
        await super.viewModelInit();
        this.expBarInstance = ModelTool.findPSControlByType('GRIDEXPBAR', this.viewInstance.getPSControls() || []);
    }
    /**
     * 计算目标部件所需参数
     *
     * @param {string} [controlType]
     * @returns
     * @memberof GridExpViewBase
     */
    computeTargetCtrlData(controlInstance) {
        const { targetCtrlName, targetCtrlParam, targetCtrlEvent } = super.computeTargetCtrlData(controlInstance);
        Object.assign(targetCtrlParam.staticProps, {
            sideBarLayout: this.viewInstance.sideBarLayout
        });
        return { targetCtrlName: targetCtrlName, targetCtrlParam: targetCtrlParam, targetCtrlEvent: targetCtrlEvent };
    }
}
