import { __decorate } from "tslib";
import { ModelTool } from '@ibizstudio/runtime';
import { Component } from 'vue-property-decorator';
import { VueLifeCycleProcessing } from '../../../decorators';
import { EditorBase } from '../editor-base/editor-base';
/**
 * 选项框编辑器
 *
 * @export
 * @class CheckboxEditor
 * @extends {EditorBase}
 */
let CheckboxEditor = class CheckboxEditor extends EditorBase {
    /**
     * 编辑器初始化
     *
     * @memberof CheckboxEditor
     */
    async initEditor() {
        var _a, _b, _c, _d, _e, _f;
        await super.initEditor();
        let appDEField = (_b = (_a = this.parentItem) === null || _a === void 0 ? void 0 : _a.getPSAppDEField) === null || _b === void 0 ? void 0 : _b.call(_a);
        this.customProps.valueType = ModelTool.isNumberField(appDEField) ? 'number' : 'string';
        switch ((_c = this.editorInstance) === null || _c === void 0 ? void 0 : _c.editorType) {
            // 单选框列表
            case 'RADIOBUTTONLIST':
                break;
            // 选项框
            case 'CHECKBOX':
                break;
            // 选项框列表
            case 'CHECKBOXLIST':
                break;
            // 列表框
            case 'LISTBOX':
                this.initParams();
                break;
            // 列表框选择
            case 'LISTBOXPICKUP':
                this.initParams();
                break;
        }
        let codeList = (_e = (_d = this.editorInstance) === null || _d === void 0 ? void 0 : _d.getPSAppCodeList) === null || _e === void 0 ? void 0 : _e.call(_d);
        if (codeList) {
            Object.assign(this.customProps, {
                tag: codeList.codeName,
                codelistType: codeList.codeListType,
                codeList: codeList,
                valueSeparator: codeList.valueSeparator,
                mode: ((_f = codeList === null || codeList === void 0 ? void 0 : codeList.orMode) === null || _f === void 0 ? void 0 : _f.toLowerCase()) || 'str'
            });
        }
    }
    /**
     * 编辑器change事件
     *
     * @param {*} value
     * @memberof CheckboxEditor
     */
    handleChange($event) {
        this.editorChange({ name: this.editorInstance.name, value: $event });
    }
    /**
     * 初始化参数
     *
     * @memberof CheckboxEditor
     */
    initParams() {
        var _a;
        let params = {
            service: this.service,
            editorType: this.editorInstance.editorType,
            acParams: ModelTool.getAcParams(this.editorInstance),
            deMajorField: ModelTool.getEditorMajorName(this.editorInstance),
            deKeyField: ModelTool.getEditorKeyName(this.editorInstance),
            multiple: ((_a = this.editorInstance.editorParams) === null || _a === void 0 ? void 0 : _a['multiple']) ? JSON.parse(this.editorInstance.editorParams['multiple']) : false,
        };
        Object.assign(this.customProps, params);
        if (!this.customStyle.height) {
            this.customStyle.maxHeight = '200px';
            this.customStyle.overflow = 'auto';
        }
    }
    /**
     * 绘制内容
     *
     * @returns {*}
     * @memberof CheckboxEditor
     */
    render() {
        if (!this.editorIsLoaded) {
            return null;
        }
        return this.$createElement(this.editorComponentName, {
            props: Object.assign({ name: this.editorInstance.name, value: this.value, item: this.value, disabled: this.disabled, context: this.context, data: this.contextData, viewparams: this.viewparams }, this.customProps),
            on: {
                change: this.handleChange,
                formitemvaluechange: this.editorChange,
            },
            style: this.customStyle,
        });
    }
};
CheckboxEditor = __decorate([
    Component({}),
    VueLifeCycleProcessing()
], CheckboxEditor);
export default CheckboxEditor;
