import { __decorate } from "tslib";
import { MPickUpViewBase } from '../../../view/mpickupview-base';
import { AppLayoutService } from '../../../app-service/common-service/app-layout-service';
import { Watch } from '../../../decorators';
/**
 * 应用数据多项选择视图基类
 *
 * @export
 * @class AppMPickUpViewBase
 * @extends {MPickUpViewBase}
 */
export class AppMPickUpViewBase extends MPickUpViewBase {
    /**
     * 视图参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof AppMPickUpViewBase
     */
    on_viewparams_change(newVal, oldVal) {
        if (newVal) {
            if (this.viewparams.selectedData) {
                this.selectedData = JSON.stringify(this.viewparams.selectedData);
                this.viewSelections = this.viewparams.selectedData;
            }
        }
    }
    /**
     * 初始化containerModel
     *
     * @memberof AppMPickUpViewBase
     */
    initContainerModel(opts) {
        super.initContainerModel(opts);
        const { modeldata } = opts;
        modeldata === null || modeldata === void 0 ? void 0 : modeldata.getPSControls().forEach((ctrl) => {
            this.containerModel[`view_${ctrl.name}`] = { name: `${ctrl.name}`, type: `${ctrl.controlType}` };
        });
    }
    /**
     * 视图渲染
     *
     * @memberof AppMPickUpViewBase
     */
    render(h) {
        var _a, _b;
        if (!this.viewIsLoaded) {
            return null;
        }
        const targetViewLayoutComponent = AppLayoutService.getLayoutComponent(`${(_a = this.viewInstance) === null || _a === void 0 ? void 0 : _a.viewType}-${(_b = this.viewInstance) === null || _b === void 0 ? void 0 : _b.viewStyle}`);
        return h(targetViewLayoutComponent, {
            props: { viewInstance: this.viewInstance, model: this.model, modelService: this.modelService, viewparams: this.viewparams, context: this.context },
        }, [this.renderTopMessage(), this.renderBodyMessage(), this.renderToolBar(), this.renderMainContent(), this.renderBottomMessage()]);
    }
}
__decorate([
    Watch('viewparam', { immediate: true, deep: true })
], AppMPickUpViewBase.prototype, "on_viewparams_change", null);
