import { __decorate } from "tslib";
import { Component, Prop } from 'vue-property-decorator';
import { AppDefaultSearchFormDetail } from '../app-default-searchform-detail/app-default-searchform-detail';
import { VueLifeCycleProcessing } from '../../../../decorators';
/**
 * 表单UI组件
 *
 * @export
 * @class AppDefaultSearchFormItem
 * @extends {Vue}
 */
let AppDefaultSearchFormItem = class AppDefaultSearchFormItem extends AppDefaultSearchFormDetail {
    /**
     * 表单项值变化事件
     *
     * @memberof AppDefaultSearchFormItem
     */
    onFormItemValueChange(...args) {
        this.$emit('formItemValueChange', ...args);
    }
    /**
     * 绘制复合表单项
     *
     * @returns
     * @memberof AppDefaultSearchFormItem
     */
    renderCompositeItem() {
        var _a, _b, _c;
        const { name, contentHeight, contentWidth, editor, formItems } = this.detailsInstance;
        let editorType = editor === null || editor === void 0 ? void 0 : editor.editorType;
        // 设置高宽
        let contentStyle = '';
        contentStyle += contentWidth && contentWidth != 0 ? `width:${contentWidth}px;` : '';
        contentStyle += contentHeight && contentHeight != 0 ? `height:${contentHeight}px;` : '';
        contentStyle += ((_a = this.runtimeModel) === null || _a === void 0 ? void 0 : _a.visible) ? '' : 'display: none;';
        const refFormItem = [];
        if (formItems) {
            formItems === null || formItems === void 0 ? void 0 : formItems.forEach((formItem) => {
                refFormItem.push(formItem === null || formItem === void 0 ? void 0 : formItem.name);
            });
        }
        if ((editor === null || editor === void 0 ? void 0 : editor.editorType) !== 'USERCONTROL') {
            return (<app-range-editor value={this.data[name]} activeData={this.data} name={name} editorType={editorType} refFormItem={refFormItem} disabled={(_b = this.runtimeModel) === null || _b === void 0 ? void 0 : _b.disabled} format={editor.getEditorParam('TIMEFMT')} on-formitemvaluechange={(value) => {
                    this.onFormItemValueChange(value);
                }} style={contentStyle}></app-range-editor>);
        }
        else {
            return (<app-default-editor editorInstance={editor} containerCtrl={this.controlInstance} value={this.data[editor.name]} contextData={this.data} context={this.context} viewparams={this.viewparams} service={this.service} disabled={(_c = this.runtimeModel) === null || _c === void 0 ? void 0 : _c.disabled} ignorefieldvaluechange={this.ignorefieldvaluechange} on-change={(value) => {
                    this.onFormItemValueChange(value);
                }}/>);
        }
    }
    /**
     * 绘制内容
     *
     * @returns {*}
     * @memberof AppDefaultSearchFormItem
     */
    render() {
        var _a, _b, _c, _d;
        const { detailClassNames } = this.renderOptions;
        let { name, caption, labelWidth, labelPos, showCaption, emptyCaption, detailStyle, getLabelPSSysCss, editor, compositeItem, contentWidth, contentHeight, } = this.detailsInstance;
        let editorType = editor === null || editor === void 0 ? void 0 : editor.editorType;
        // 隐藏表单项
        if (editorType == 'HIDDEN') {
            return;
        }
        // 设置高宽
        let contentStyle = '';
        contentStyle += contentWidth && contentWidth != 0 ? `width:${contentWidth}px;` : '';
        contentStyle += contentHeight && contentHeight != 0 ? `height:${contentHeight}px;` : '';
        contentStyle += ((_a = this.runtimeModel) === null || _a === void 0 ? void 0 : _a.visible) ? '' : 'display: none;';
        let labelCaption = this.$tl((_b = this.detailsInstance.getCapPSLanguageRes()) === null || _b === void 0 ? void 0 : _b.lanResTag, caption);
        return (<app-form-item name={name} caption={labelCaption} isEmptyCaption={emptyCaption} isShowCaption={showCaption} labelWidth={labelWidth} labelPos={labelPos} uiStyle={detailStyle} itemRules={this.rules} required={(_c = this.runtimeModel) === null || _c === void 0 ? void 0 : _c.required} error={(_d = this.runtimeModel) === null || _d === void 0 ? void 0 : _d.error} class={detailClassNames} labelStyle={getLabelPSSysCss === null || getLabelPSSysCss === void 0 ? void 0 : getLabelPSSysCss.cssName} style={contentStyle} controlInstance={this.controlInstance}>
                {compositeItem ? (this.renderCompositeItem()) : this.$slots.default}
            </app-form-item>);
    }
};
__decorate([
    Prop()
], AppDefaultSearchFormItem.prototype, "data", void 0);
__decorate([
    Prop()
], AppDefaultSearchFormItem.prototype, "rules", void 0);
__decorate([
    Prop()
], AppDefaultSearchFormItem.prototype, "context", void 0);
__decorate([
    Prop()
], AppDefaultSearchFormItem.prototype, "viewparams", void 0);
__decorate([
    Prop()
], AppDefaultSearchFormItem.prototype, "service", void 0);
__decorate([
    Prop()
], AppDefaultSearchFormItem.prototype, "ignorefieldvaluechange", void 0);
AppDefaultSearchFormItem = __decorate([
    Component({}),
    VueLifeCycleProcessing()
], AppDefaultSearchFormItem);
export { AppDefaultSearchFormItem };
