import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { BaseControl } from '../basecontrol';
import * as i0 from "@angular/core";
import * as i1 from "../../service/common.service";
import * as i2 from "../form-box/form-box.component";
import * as i3 from "ng-devui";
import * as i4 from "@angular/common";
import * as i5 from "@angular/forms";
export class FormSelectComponent extends BaseControl {
    constructor(commonService) {
        super(commonService);
        this.commonService = commonService;
        this.control = new FormControl();
    }
    ngOnInit() {
        this.getData();
        this.commonService.testEvent.subscribe(o => {
            if (o == this.data.name) {
                this.getData();
            }
        });
    }
    getData() {
        this.commonService.getTheData(this.data)?.subscribe(o => {
            var res = null;
            eval("res =" + this.data.postdata.function);
            this.data.options = res(o);
        });
    }
    maxOptions(num) {
        return (val) => {
            return !val || val.length <= num;
        };
    }
    minOptions(num) {
        return (val) => {
            return !val || val.length >= num;
        };
    }
}
FormSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: FormSelectComponent, deps: [{ token: i1.CommonService }], target: i0.ɵɵFactoryTarget.Component });
FormSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.6", type: FormSelectComponent, selector: "form-select", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"data.mode=='op'; else detail\">\r\n    <form-box #box [mainCarry]=\"detail\" [name]=\"data.name\" [controltype]=\"data.controltype\" (controlclick)=\"onClick($event)\"></form-box>\r\n  </ng-container>\r\n  <ng-template #detail>\r\n      <d-form-item>\r\n          <d-form-label [required]=\"data.required\" [hasHelp]=\"data.help\" [helpTips]=\"data.helptip||''\">{{data.label}}</d-form-label>\r\n          <d-form-control>\r\n            <div>\r\n                <d-select \r\n                [formControl]=\"control\"\r\n                [attr.name]=\"data.controlname\" \r\n                [multiple]=\"data.multiple\" \r\n                [options]=\"data.options\" \r\n                [filterKey]=\"data.filter\" \r\n                [placeholder]=\"data.placeholder\" \r\n                [(ngModel)]=\"data.defaultvalue\"\r\n                [extraConfig]=\"{\r\n                  labelization: { enable: true, overflow: 'multiple-line' }\r\n                }\"\r\n                [dValidateRules]=\"data.rules\"\r\n                [disabled]=\"data.disabled\"></d-select>\r\n            </div>\r\n          </d-form-control>\r\n        </d-form-item>\r\n  </ng-template>", styles: [""], components: [{ type: i2.FormBoxComponent, selector: "form-box", inputs: ["mainCarry", "name", "controltype", "additionalcss"], outputs: ["controlclick"] }, { type: i3.FormItemComponent, selector: "d-form-item", inputs: ["dFeedbackType", "dHasFeedback"] }, { type: i3.FormLabelComponent, selector: "d-form-label", inputs: ["required", "hasHelp", "helpTips"] }, { type: i3.FormControlComponent, selector: "d-form-control", inputs: ["extraInfo", "feedbackStatus", "suffixTemplate"] }, { type: i3.SelectComponent, selector: "d-select", inputs: ["options", "isSearch", "toggleOnFocus", "scrollHight", "highlightItemClass", "filterKey", "multiple", "isSelectAll", "readonly", "size", "appendToBody", "appendToBodyDirections", "width", "templateItemSize", "disabled", "placeholder", "searchPlaceholder", "searchFn", "valueParser", "formatter", "direction", "overview", "allowClear", "color", "enableLazyLoad", "virtualScroll", "inputItemTemplate", "extraConfig", "optionDisabledKey", "optionImmutableKey", "noResultItemTemplate", "keepMultipleOrder", "customViewTemplate", "customViewDirection", "autoFocus", "notAutoScroll", "loadingTemplateRef", "showAnimation"], outputs: ["valueChange", "toggleChange", "loadMore"], exportAs: ["select"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i3.DFormControlRuleDirective, selector: "[dValidateRules][formControlName],[dValidateRules][ngModel],[dValidateRules][formControl]", inputs: ["dValidateRules", "dValidatePopConfig"], outputs: ["dRulesStatusChange"], exportAs: ["dValidateRules"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: FormSelectComponent, decorators: [{
            type: Component,
            args: [{ selector: 'form-select', template: "<ng-container *ngIf=\"data.mode=='op'; else detail\">\r\n    <form-box #box [mainCarry]=\"detail\" [name]=\"data.name\" [controltype]=\"data.controltype\" (controlclick)=\"onClick($event)\"></form-box>\r\n  </ng-container>\r\n  <ng-template #detail>\r\n      <d-form-item>\r\n          <d-form-label [required]=\"data.required\" [hasHelp]=\"data.help\" [helpTips]=\"data.helptip||''\">{{data.label}}</d-form-label>\r\n          <d-form-control>\r\n            <div>\r\n                <d-select \r\n                [formControl]=\"control\"\r\n                [attr.name]=\"data.controlname\" \r\n                [multiple]=\"data.multiple\" \r\n                [options]=\"data.options\" \r\n                [filterKey]=\"data.filter\" \r\n                [placeholder]=\"data.placeholder\" \r\n                [(ngModel)]=\"data.defaultvalue\"\r\n                [extraConfig]=\"{\r\n                  labelization: { enable: true, overflow: 'multiple-line' }\r\n                }\"\r\n                [dValidateRules]=\"data.rules\"\r\n                [disabled]=\"data.disabled\"></d-select>\r\n            </div>\r\n          </d-form-control>\r\n        </d-form-item>\r\n  </ng-template>", styles: [""] }]
        }], ctorParameters: function () { return [{ type: i1.CommonService }]; } });
//# sourceMappingURL=data:application/json;base64, 