UNPKG

@kre-form/ant

Version:

1,010 lines (997 loc) 687 kB
import { ActivatedRoute } from '@angular/router'; import { tap, catchError } from 'rxjs/operators'; import { CommonModule, registerLocaleData } from '@angular/common'; import { HttpModule } from '@angular/http'; import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop'; import { HttpClient, HttpParams, HttpClientModule } from '@angular/common/http'; import { TranslateModule } from '@ngx-translate/core'; import { NzModalService, NgZorroAntdModule, NZ_I18N, zh_CN, NZ_ICONS } from 'ng-zorro-antd'; import { ColorPickerModule } from 'ngx-color-picker'; import { MenuFoldOutline, MenuUnfoldOutline, FormOutline, DashboardOutline, MinusSquareFill, MinusSquareOutline, MinusSquareTwoTone, MinusOutline, InboxOutline } from '@ant-design/icons-angular/icons'; import zh from '@angular/common/locales/zh'; import { Observable, throwError, BehaviorSubject } from 'rxjs'; import { NzModalService as NzModalService$1 } from 'ng-zorro-antd/modal'; import { DomSanitizer } from '@angular/platform-browser'; import { FieldType, Guid, KreFormCommonService, FormGlobalService, FieldWrapper, clone, FieldArrayType, KreFormBuilder, KreFormModule } from '@kre-form/core'; import { NzMessageService } from 'ng-zorro-antd/message'; import { CdkOverlayOrigin, OverlayModule } from '@angular/cdk/overlay'; import { get, isEmpty, cloneDeep, assignIn, round } from 'lodash'; import { __extends, __spread, __assign } from 'tslib'; import { FormGroup, FormBuilder, NG_VALUE_ACCESSOR, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms'; import * as differenceInCalendarDays_ from 'date-fns/difference_in_calendar_days'; import * as moment_ from 'moment'; import { DeonCodemirrorModule } from '@kre-form/abc'; import { Component, ViewChild, HostListener, Injectable, EventEmitter, Pipe, Input, Output, ChangeDetectorRef, forwardRef, ElementRef, Inject, NgModule, ɵɵdefineInjectable, ɵɵinject } from '@angular/core'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldAnchor = /** @class */ (function (_super) { __extends(KreFormFieldAnchor, _super); function KreFormFieldAnchor() { return _super !== null && _super.apply(this, arguments) || this; } KreFormFieldAnchor.decorators = [ { type: Component, args: [{ selector: "krefield-anchor", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <nz-divider\n class=\"control-design\"\n [id]=\"field.key\"\n [nzText]=\"to.description\"\n ></nz-divider>\n <!-- <div id=\"components-anchor-demo-basic\" style=\"height: 400px;\">1</div> -->\n </ng-container>\n\n <ng-template #other>\n <nz-divider\n class=\"control-design\"\n [id]=\"field.key\"\n [nzText]=\"to.description\"\n ></nz-divider>\n <!-- <div id=\"components-anchor-demo-basic\" style=\"height: 400px;\">1</div> -->\n </ng-template>\n " }] } ]; return KreFormFieldAnchor; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /* <ng-container *ngIf="formStatus !== 0"> <krefield-private_text [field]="field" [status]="formStatus"></krefield-private_text> </ng-container> */ var KreFormFieldText = /** @class */ (function (_super) { __extends(KreFormFieldText, _super); function KreFormFieldText() { return _super !== null && _super.apply(this, arguments) || this; } KreFormFieldText.decorators = [ { type: Component, args: [{ selector: "krefield-text", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <input nz-input disabled />\n </div>\n </ng-container>\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <input\n nz-input\n autocomplete=\"off\"\n [formControl]=\"formControl\"\n [kreFormAttributes]=\"field\"\n [placeholder]=\"placeHolder\"\n [class.is-invalid]=\"showError\"\n [maxLength]=\"to.maxLength || 200\"\n [minLength]=\"to.minLength || 0\"\n />\n <!-- <div class=\"tips\">\n <i\n class=\"icon-bangzhu\"\n [nzTooltipTitle]=\"tips\"\n nzTooltipPlacement=\"top\"\n nz-tooltip\n *ngIf=\"tips != ''\"\n ></i>\n </div> -->\n </ng-container>\n\n <div class=\"fieldtext\" *ngIf=\"editor === false\">{{ text }}</div>\n </ng-template>\n " }] } ]; return KreFormFieldText; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldTextI18n = /** @class */ (function (_super) { __extends(KreFormFieldTextI18n, _super); function KreFormFieldTextI18n(route) { var _this = _super.call(this) || this; _this.route = route; _this.triggerWidth = "260px"; _this.languageList = [ { languageType: "zh-cn", label: "中", resValue: null }, { languageType: "en", label: "英", resValue: null }, ]; return _this; } /** * @param {?} event * @return {?} */ KreFormFieldTextI18n.prototype.resize = /** * @param {?} event * @return {?} */ function (event) { this.visibleChange(event); }; /** * @return {?} */ KreFormFieldTextI18n.prototype.ngOnInit = /** * @return {?} */ function () { if (!!this.route.snapshot.queryParams["lang"] && ((/** @type {?} */ (this.route.snapshot.queryParams["lang"]))).toLocaleLowerCase() === "en") { this.languageList = [ { languageType: "zh-cn", label: "中", resValue: null }, { languageType: "en", label: "EN", resValue: null }, ]; } }; Object.defineProperty(KreFormFieldTextI18n.prototype, "language", { get: /** * @return {?} */ function () { if (this.model != undefined && this.model != null && this.key != undefined && this.key != null && this.model.hasOwnProperty(this.key)) { if (this.formControl.value != undefined && this.formControl.value != null && this.formControl.value != [] && this.formControl.value.length > 0) { if (this.formControl.value != this.languageList) { this.languageList = this.formControl.value; } } } return this.languageList; }, enumerable: true, configurable: true }); /** * @param {?} value * @return {?} */ KreFormFieldTextI18n.prototype.onChange = /** * @param {?} value * @return {?} */ function (value) { if (this.to.required) { /** @type {?} */ var empty = this.languageList.some((/** * @param {?} item * @return {?} */ function (item) { return ((item.resValue === null || item.resValue === "" || item.resValue === " ") && item.languageType === "zh-cn"); })); if (empty) { this.formControl.setValue([]); } else { this.formControl.setValue(this.languageList); } } else { this.formControl.setValue(this.languageList); } this.formControl.markAsTouched(); }; /** * @param {?} event * @return {?} */ KreFormFieldTextI18n.prototype.visibleChange = /** * @param {?} event * @return {?} */ function (event) { if (event) { if (this.cdkOverlayOrigin !== undefined) { this.triggerWidth = this.cdkOverlayOrigin.elementRef.nativeElement.getBoundingClientRect() .width - 0 + "px"; } } }; Object.defineProperty(KreFormFieldTextI18n.prototype, "langText", { get: /** * @return {?} */ function () { if (this.model != undefined && this.model != null && this.key != undefined && this.key != null && this.model[this.key] != undefined) { /** @type {?} */ var lang = this.model[this.key]; if (lang != undefined && lang != null && lang != "" && lang instanceof Array && lang.length > 0) { return lang[0]["resValue"]; } return ""; } return ""; }, enumerable: true, configurable: true }); KreFormFieldTextI18n.decorators = [ { type: Component, args: [{ selector: "kreform-field-inputi18n", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <input nz-input disabled />\n </div>\n </ng-container>\n\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <div class=\"inputi18n\">\n <div class=\"inputi18n-text\" cdkOverlayOrigin>\n <input\n nz-input\n autocomplete=\"off\"\n [(ngModel)]=\"language[0].resValue\"\n [kreFormAttributes]=\"field\"\n (ngModelChange)=\"onChange(language[0].resValue)\"\n nz-popover\n nzPopoverTrigger=\"click\"\n [nzPopoverContent]=\"contentTemplate\"\n nzOverlayClassName=\"inputi18n-template\"\n nzPopoverPlacement=\"bottom\"\n [nzOverlayStyle]=\"{ width: triggerWidth }\"\n (nzVisibleChange)=\"visibleChange($event)\"\n [maxLength]=\"to.maxLength || 200\"\n [minLength]=\"to.minLength || 0\"\n />\n <i nz-icon class=\"inputi18n-i\" nzType=\"global\"></i>\n </div>\n <!-- <div class=\"tips\">\n <i\n class=\"icon-bangzhu\"\n [nzTooltipTitle]=\"tips\"\n nzTooltipPlacement=\"top\"\n nz-tooltip\n *ngIf=\"tips != ''\"\n ></i>\n </div> -->\n </div>\n\n <ng-template #contentTemplate>\n <ul>\n <ng-container *ngFor=\"let item of language; let i = index\">\n <li *ngIf=\"i > 0\">\n <label>{{ item.label }}</label>\n <input\n nz-input\n autocomplete=\"off\"\n [(ngModel)]=\"item.resValue\"\n [kreFormAttributes]=\"field\"\n (ngModelChange)=\"onChange(item.resValue)\"\n [maxLength]=\"to.maxLength || 200\"\n [minLength]=\"to.minLength || 0\"\n />\n </li>\n </ng-container>\n </ul>\n </ng-template>\n </ng-container>\n <div class=\"fieldtext\" *ngIf=\"editor === false\">{{ langText }}</div>\n </ng-template>\n " }] } ]; /** @nocollapse */ KreFormFieldTextI18n.ctorParameters = function () { return [ { type: ActivatedRoute } ]; }; KreFormFieldTextI18n.propDecorators = { cdkOverlayOrigin: [{ type: ViewChild, args: [CdkOverlayOrigin, { static: false },] }], resize: [{ type: HostListener, args: ["window:resize", ["$event"],] }] }; return KreFormFieldTextI18n; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldTextArea = /** @class */ (function (_super) { __extends(KreFormFieldTextArea, _super); function KreFormFieldTextArea() { return _super !== null && _super.apply(this, arguments) || this; } /** * @return {?} */ KreFormFieldTextArea.prototype.ngOnInit = /** * @return {?} */ function () { // console.log(this.formControl.value); }; KreFormFieldTextArea.decorators = [ { type: Component, args: [{ selector: "krefield-textarea", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <textarea\n nz-input\n disabled\n [rows]=\"to.rows ? to.rows : 4\"\n style=\"resize:none\"\n >\n </textarea>\n </div>\n </ng-container>\n\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <textarea\n wrap=\"hard\"\n nz-input\n autocomplete=\"off\"\n [formControl]=\"formControl\"\n class=\"form-control\"\n [class.is-invalid]=\"showError\"\n [kreFormAttributes]=\"field\"\n [rows]=\"to.rows ? to.rows : 4\"\n style=\"resize:none\"\n [maxLength]=\"to.maxLength || 500\"\n [minLength]=\"to.minLength || 0\"\n >\n </textarea>\n <!-- <div class=\"tips\">\n <i\n class=\"icon-bangzhu\"\n [nzTooltipTitle]=\"tips\"\n nzTooltipPlacement=\"top\"\n nz-tooltip\n *ngIf=\"tips != ''\"\n ></i>\n </div> -->\n </ng-container>\n <div\n class=\"fieldtext krefield-textarea-{{ to.rows || 4 }} \"\n *ngIf=\"editor === false\"\n [innerHTML]=\"text | replaceLine\"\n ></div>\n </ng-template>\n " }] } ]; return KreFormFieldTextArea; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldNumber = /** @class */ (function (_super) { __extends(KreFormFieldNumber, _super); function KreFormFieldNumber() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(KreFormFieldNumber.prototype, "precision", { get: /** * @return {?} */ function () { /** @type {?} */ var result = 0; if (this.to != undefined && this.to != null && this.to["precision"] != undefined && this.to["precision"] != null) { result = this.to["precision"]; } return result; }, enumerable: true, configurable: true }); Object.defineProperty(KreFormFieldNumber.prototype, "number", { get: /** * @return {?} */ function () { /** @type {?} */ var result = this.text; if (this.to != undefined && this.to != null && this.to["precision"] != undefined && this.to["precision"] != null) { if (!!result || result === 0) { result = round(result, this.to["precision"]); if (!isEmpty(this.model) && ((/** @type {?} */ (this.model))).hasOwnProperty(this.key)) { this.model[this.key] = result; } } } return result; }, enumerable: true, configurable: true }); KreFormFieldNumber.decorators = [ { type: Component, args: [{ selector: "krefield-number", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <input nz-input disabled />\n </div>\n </ng-container>\n\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <nz-input-number\n autocomplete=\"off\"\n [formControl]=\"formControl\"\n [nzPlaceHolder]=\"placeHolder\"\n [kreFormAttributes]=\"field\"\n [class.is-invalid]=\"showError\"\n [nzPrecision]=\"\n to.precision == undefined || to.precision == null\n ? null\n : to.precision\n \"\n [nzMax]=\"to.max || 999999\"\n [nzMin]=\"to.min || -999999\"\n ></nz-input-number>\n </ng-container>\n <div class=\"fieldtext\" *ngIf=\"editor === false\">{{ number }}</div>\n </ng-template>\n " }] } ]; return KreFormFieldNumber; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldPassWord = /** @class */ (function (_super) { __extends(KreFormFieldPassWord, _super); function KreFormFieldPassWord() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.passwordVisible = false; return _this; // clickRead() { // this.read = !this.read; // if (this.read) { // this.password = new Array(this.text.length).fill("*").join(""); // } else { // this.password = this.text; // } // } // <div class="text"> // {{ password }} // </div> // <div class="read"> // <i // nz-icon // [nzType]="read ? 'eye-invisible' : 'eye'" // (click)="clickRead()" // ></i> // </div> } // password = ""; // read = true; // password = ""; // read = true; /** * @return {?} */ KreFormFieldPassWord.prototype.ngOnInit = // password = ""; // read = true; /** * @return {?} */ function () { // this.password = new Array(this.text.length).fill("*").join(""); }; KreFormFieldPassWord.decorators = [ { type: Component, args: [{ selector: "krefield-password", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <input nz-input disabled />\n </div>\n </ng-container>\n\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <!-- <input\n nz-input\n autocomplete=\"off\"\n [formControl]=\"formControl\"\n [kreFormAttributes]=\"field\"\n [class.is-invalid]=\"showError\"\n [type]=\"'password'\"\n />-->\n\n <nz-input-group [nzSuffix]=\"suffixTemplate\">\n <input\n [type]=\"passwordVisible ? 'text' : 'password'\"\n nz-input\n autocomplete=\"off\"\n [formControl]=\"formControl\"\n [kreFormAttributes]=\"field\"\n [class.is-invalid]=\"showError\"\n />\n </nz-input-group>\n <ng-template #suffixTemplate>\n <i\n nz-icon\n [nzType]=\"passwordVisible ? 'eye-invisible' : 'eye'\"\n (click)=\"passwordVisible = !passwordVisible\"\n ></i>\n </ng-template>\n </ng-container>\n\n <div class=\"fieldtext\" *ngIf=\"editor === false\">\n {{ text }}\n </div>\n </ng-template>\n " }] } ]; return KreFormFieldPassWord; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldRadio = /** @class */ (function (_super) { __extends(KreFormFieldRadio, _super); function KreFormFieldRadio() { return _super !== null && _super.apply(this, arguments) || this; } KreFormFieldRadio.decorators = [ { type: Component, args: [{ selector: "krefield-radio", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <label nz-radio nzDisabled=\"true\"></label>\n </div>\n </ng-container>\n\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <label\n nz-radio\n [formControl]=\"formControl\"\n [kreFormAttributes]=\"field\"\n [class.is-invalid]=\"showError\"\n ></label>\n <!-- <div class=\"tips\">\n <i\n class=\"icon-bangzhu\"\n [nzTooltipTitle]=\"tips\"\n nzTooltipPlacement=\"top\"\n nz-tooltip\n *ngIf=\"tips != ''\"\n ></i>\n </div> -->\n </ng-container>\n\n <div class=\"fieldtext\" *ngIf=\"editor === false\">{{ text }}</div>\n </ng-template>\n " }] } ]; return KreFormFieldRadio; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldRadioGroup = /** @class */ (function (_super) { __extends(KreFormFieldRadioGroup, _super); function KreFormFieldRadioGroup() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.guid = Guid.create()["value"]; return _this; } KreFormFieldRadioGroup.decorators = [ { type: Component, args: [{ selector: "krefield-radiogroup", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <nz-radio-group\n [nzName]=\"'radiogroup-' + guid\"\n [formControl]=\"formControl\"\n [kreFormAttributes]=\"field\"\n [class.is-invalid]=\"showError\"\n >\n <ng-container *ngFor=\"let item of to.options\">\n <label nz-radio [nzValue]=\"item.value\" nzDisabled=\"true\">{{\n item.label\n }}</label>\n </ng-container>\n </nz-radio-group>\n </div>\n </ng-container>\n\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <nz-radio-group\n [nzName]=\"'radiogroup-' + guid\"\n [formControl]=\"formControl\"\n [kreFormAttributes]=\"field\"\n [class.is-invalid]=\"showError\"\n >\n <ng-container *ngFor=\"let item of to.options\">\n <ng-container *ngIf=\"to.type == 'button'\">\n <label nz-radio-button [nzValue]=\"item.value\">{{\n item.label\n }}</label>\n </ng-container>\n <ng-container\n *ngIf=\"\n to.type == null || to.type == undefined || to.type == 'default'\n \"\n >\n <label nz-radio [nzValue]=\"item.value\">{{ item.label }}</label>\n </ng-container>\n </ng-container>\n </nz-radio-group>\n <!-- <div class=\"tips\">\n <i\n class=\"icon-bangzhu\"\n [nzTooltipTitle]=\"tips\"\n nzTooltipPlacement=\"top\"\n nz-tooltip\n *ngIf=\"tips != ''\"\n ></i>\n </div> -->\n </ng-container>\n\n <div class=\"fieldtext\" *ngIf=\"editor === false\">{{ textRadio }}</div>\n </ng-template>\n " }] } ]; return KreFormFieldRadioGroup; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldCheckbox = /** @class */ (function (_super) { __extends(KreFormFieldCheckbox, _super); function KreFormFieldCheckbox() { return _super !== null && _super.apply(this, arguments) || this; } KreFormFieldCheckbox.decorators = [ { type: Component, args: [{ selector: "krefield-checkbox", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <label nz-checkbox nzDisabled=\"true\"></label>\n </div>\n </ng-container>\n\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <label\n nz-checkbox\n [formControl]=\"formControl\"\n [kreFormAttributes]=\"field\"\n [class.is-invalid]=\"showError\"\n ></label>\n <!-- <div class=\"tips\">\n <i\n class=\"icon-bangzhu\"\n [nzTooltipTitle]=\"tips\"\n nzTooltipPlacement=\"top\"\n nz-tooltip\n *ngIf=\"tips != ''\"\n ></i>\n </div> -->\n </ng-container>\n\n <div class=\"fieldtext\" *ngIf=\"editor === false\">{{ text }}</div>\n </ng-template>\n " }] } ]; return KreFormFieldCheckbox; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldCheckboxGroup = /** @class */ (function (_super) { __extends(KreFormFieldCheckboxGroup, _super); function KreFormFieldCheckboxGroup() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.guid = Guid.create()["value"]; return _this; } /** * @param {?} values * @return {?} */ KreFormFieldCheckboxGroup.prototype.onChange = /** * @param {?} values * @return {?} */ function (values) { var _this = this; if (values != undefined && values != null && values.length > 0) { values.forEach((/** * @param {?} value * @return {?} */ function (value) { if (_this.to.options !== undefined && _this.to.options !== null) { _this.to.options.forEach((/** * @param {?} option * @return {?} */ function (option) { if (option["value"] === value) ; })); } })); } this.formControl.patchValue(values); this.formControl.markAsTouched(); }; /** * @param {?} option * @return {?} */ KreFormFieldCheckboxGroup.prototype.getCheckStatus = /** * @param {?} option * @return {?} */ function (option) { this.formControl.value; }; /** * @param {?} values * @param {?} option * @return {?} */ KreFormFieldCheckboxGroup.prototype.getControlChecked = /** * @param {?} values * @param {?} option * @return {?} */ function (values, option) { /** @type {?} */ var result = false; if (option && values) { result = values.some((/** * @param {?} value * @return {?} */ function (value) { return value == option.value; })); } return result; }; KreFormFieldCheckboxGroup.decorators = [ { type: Component, args: [{ selector: "krefield-checkboxgroup", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <nz-checkbox-wrapper\n style=\"width: 100%;\"\n (nzOnChange)=\"onChange($event)\"\n [class.is-invalid]=\"showError\"\n >\n <ng-container *ngFor=\"let option of to.options; let i = index\">\n <label\n nz-checkbox\n [nzValue]=\"option.value\"\n [ngModel]=\"getControlChecked(formControl.value, option)\"\n [kreFormAttributes]=\"field\"\n disabled\n >{{ option.label }}</label\n >\n </ng-container>\n </nz-checkbox-wrapper>\n </div>\n </ng-container>\n\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <nz-checkbox-wrapper\n style=\"width: 100%;\"\n (nzOnChange)=\"onChange($event)\"\n [class.is-invalid]=\"showError\"\n >\n <ng-container *ngFor=\"let option of to.options; let i = index\">\n <label\n nz-checkbox\n [nzValue]=\"option.value\"\n [ngModel]=\"getControlChecked(formControl.value, option)\"\n [kreFormAttributes]=\"field\"\n >{{ option.label }}</label\n >\n </ng-container>\n </nz-checkbox-wrapper>\n <!-- <div class=\"tips\">\n <i\n class=\"icon-bangzhu\"\n [nzTooltipTitle]=\"tips\"\n nzTooltipPlacement=\"top\"\n nz-tooltip\n *ngIf=\"tips != ''\"\n ></i>\n </div> -->\n </ng-container>\n <div class=\"fieldtext\" *ngIf=\"editor === false\">{{ textMultiple }}</div>\n </ng-template>\n " }] } ]; return KreFormFieldCheckboxGroup; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var KreFormFieldSelect = /** @class */ (function (_super) { __extends(KreFormFieldSelect, _super); function KreFormFieldSelect() { var _this = _super !== null && _super.apply(this, arguments) || this; _this._defaultValue = ""; _this._defaultValues = []; _this.selectType = "default"; return _this; } Object.defineProperty(KreFormFieldSelect.prototype, "getModelValue", { get: /** * @return {?} */ function () { if (this.to.selectType === "multiple") { return this.defaultValues; } else { return this.defaultValue; } }, set: /** * @param {?} value * @return {?} */ function (value) { }, enumerable: true, configurable: true }); Object.defineProperty(KreFormFieldSelect.prototype, "defaultValue", { get: /** * @return {?} */ function () { if (this.model && this.model[this.key] && Array.isArray(this.model[this.key]) && this.model[this.key].length > 0) { this._defaultValue = this.model[this.key][0].value; } else { return null; } return this._defaultValue; }, enumerable: true, configurable: true }); Object.defineProperty(KreFormFieldSelect.prototype, "defaultValues", { get: /** * @return {?} */ function () { var _this = this; if (this.model && this.model[this.key] && Array.isArray(this.model[this.key])) { this._defaultValues.length = 0; this.model[this.key].forEach((/** * @param {?} item * @return {?} */ function (item) { _this._defaultValues.push(item.value); })); } else { return null; } return this._defaultValues; }, enumerable: true, configurable: true }); // get defaultValues() { // if (!this._defaultValues) { // this._defaultValues = []; // } else { // this._defaultValues.length = 0; // } // if ( // this.model && // this.model[this.key] && // Array.isArray(this.model[this.key]) && // !_.isEmpty(this.model[this.key]) // ) { // if (!!this.model[this.key]) { // this.model[this.key].forEach((item: any) => { // this._defaultValues.push(item.value); // }); // } // } else { // this._defaultValues = null; // } // return this._defaultValues; // } // get defaultValues() { // if (!this._defaultValues) { // this._defaultValues = []; // } else { // this._defaultValues.length = 0; // } // if ( // this.model && // this.model[this.key] && // Array.isArray(this.model[this.key]) && // !_.isEmpty(this.model[this.key]) // ) { // if (!!this.model[this.key]) { // this.model[this.key].forEach((item: any) => { // this._defaultValues.push(item.value); // }); // } // } else { // this._defaultValues = null; // } // return this._defaultValues; // } /** * @return {?} */ KreFormFieldSelect.prototype.getSelectText = // get defaultValues() { // if (!this._defaultValues) { // this._defaultValues = []; // } else { // this._defaultValues.length = 0; // } // if ( // this.model && // this.model[this.key] && // Array.isArray(this.model[this.key]) && // !_.isEmpty(this.model[this.key]) // ) { // if (!!this.model[this.key]) { // this.model[this.key].forEach((item: any) => { // this._defaultValues.push(item.value); // }); // } // } else { // this._defaultValues = null; // } // return this._defaultValues; // } /** * @return {?} */ function () { /** @type {?} */ var result = ""; if (this.to && this.to.selectType) { if (this.to.selectType === "multiple") { result = this.textMultiple; } else { result = this.textSingle; } } else { result = this.textSingle; } return result; }; /** * @param {?} e * @return {?} */ KreFormFieldSelect.prototype.selectedChange = /** * @param {?} e * @return {?} */ function (e) { var _this = this; /** @type {?} */ var values = []; if (this.to.selectType && this.to.selectType == "multiple") { if (e && Array.isArray(e)) { e.forEach((/** * @param {?} item * @return {?} */ function (item) { if (_this.to.options && Array.isArray(_this.to.options)) { _this.to.options.forEach((/** * @param {?} options * @return {?} */ function (options) { if (options.value == item) { values.push(options); } })); } })); } } else { if (this.to.options && Array.isArray(this.to.options)) { this.to.options.forEach((/** * @param {?} options * @return {?} */ function (options) { if (options.value == e) { values = [options]; } })); } } this.formControl.patchValue(values); this.formControl.markAsTouched(); }; Object.defineProperty(KreFormFieldSelect.prototype, "clear", { get: /** * @return {?} */ function () { if (typeof this.to.clear === "undefined") { return true; } return !!this.to.clear; }, enumerable: true, configurable: true }); KreFormFieldSelect.decorators = [ { type: Component, args: [{ selector: "krefield-select", template: "\n <ng-container *ngIf=\"formStatus !== 0; else other\">\n <div class=\"control-design\">\n <input nz-input disabled />\n </div>\n </ng-container>\n\n <ng-template #other>\n <ng-container *ngIf=\"editor === true\">\n <nz-select\n [nzAllowClear]=\"!to.required && clear\"\n [nzMode]=\"to.selectType === 'multiple' ? 'multiple' : 'default'\"\n [kreFormAttributes]=\"field\"\n [class.is-invalid]=\"showError\"\n [nzPlaceHolder]=\"placeHolder\"\n [(ngModel)]=\"getModelValue\"\n nzShowSearch=\"true\"\n (ngModelChange)=\"selectedChange($event)\"\n >\n <ng-container *ngFor=\"let item of to.options\">\n <nz-option\n [nzLabel]=\"item.label\"\n [nzValue]=\"item.value\"\n ></nz-option>\n </ng-container>\n </nz-select>\n <!-- <div class=\"tips\">\n <i\n class=\"icon-bangzhu\"\n [nzTooltipTitle]=\"tips\"\n nzTooltipPlacement=\"top\"\n nz-tooltip\n *ngIf=\"tips != ''\"\n ></i>\n </div> -->\n </ng-container>\n <div class=\"fieldtext\" *ngIf=\"editor === false\">\n {{ getSelectText() }}\n </div>\n </ng-template>\n " }] } ]; return KreFormFieldSelect; }(FieldType)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var moment = moment_; /** @type {?} */ var differenceInCalendarDays = differenceInCalendarDays_; var KreFormFieldDateTime = /** @class */ (function (_super) { __extends(KreFormFieldDateTime, _super); function KreFormFieldDateTime(globalService, commonService) { var _this = _super.call(this) || this; _this.globalService = globalService; _this.commonService = commonService; _this.disabledDate = (/** * @param {?} current * @return {?} */ function (current) { if (!!(/** @type {?} */ (_this.to)).maxDate && !!(/** @type {?} */ (_this.to)).minDate) { return (differenceInCalendarDays(current, new Date((/** @type {?} */ (_this.to)).maxDate)) > 0 || differenceInCalendarDays(current, new Date((/** @type {?} */ ((/** @type {?} */ (_this.to)).minDate)))) < 0); } else if (!!(/** @type {?} */ (_this.to)).maxDate && !(/** @type {?} */ (_this.to)).minDate) { return differenceInCalendarDays(current, new Date((/** @type {?} */ (_this.to)).maxDate)) > 0; } else if (!(/** @type {?} */ (_this.to)).maxDate && !!(/** @type {?} */ (_this.to)).minDate) { return differenceInCalendarDays(current, new Date((/** @type {?} */ (_this.to)).minDate)) < 0; } else { return false; } }); _this.disabledDateTime = (/** * @param {?} e * @return {?} */ function (e) { /** @type {?} */ var nzDisabledHours = []; /** @type {?} */ var nzDisabledMinutes = []; if (!!(/** @type {?} */ (_this.to)).maxDate && !!(/** @type {?} */ (_this.to)).minDate) { if (differenceInCalendarDays(e, new Date((/** @type {?} */ (_this.to)).minDate)) === 0) { nzDisabledHours = _this.range(-1, new Date((/** @type {?} */ (_this.to)).minDate).getHours()); if (!!e && new Date((/** @type {?} */ (_this.to)).minDate).getHours() - e.getHours() === 0) { nzDisabledMinutes = _this.range(-1, new Date((/** @type {?} */ (_this.to)).minDate).getMinutes()); } } if (differenceInCalendarDays(e, new Date((/** @type {?} */ (_this.to)).maxDate)) === 0) { nzDisabledHours = __spread(nzDisabledHours, _this.range(new Date((/** @type {?} */ (_this.to)).maxDate).getHours() + 1, 24)); if (!!e && new Date((/** @type {?} */ (_this.to)).maxDate).getHours() - e.getHours() === 0) { nzDisabledMinutes = __spread(nzDisabledMinutes, _this.range(new Date((/** @type {?} */ (_this.to)).maxDate).getMinutes(), 60)); } } } else if (!!(/** @type {?} */ (_this.to)).maxDate && !(/** @type {?} */ (_this.to)).minDate) { if (!!e && differenceInCalendarDays(e, new Date((/** @type {?} */ (_this.to)).maxDate)) === 0) { nzDisabledHours = _this.range(new Date((/** @type {?} */ (_this.to)).maxDate).getHours() + 1, 24); if (!!e && new Date((/** @type {?} */ (_this.to)).maxDate).getHours() - e.getHours() === 0) { nzDisabledMinutes = _this.range(new Date((/** @type {?} */ (_this.to)).maxDate).getMinutes(), 60); } } } else if (!(/** @type {?} */ (_this.to)).maxDate && !!(/** @type {?} */ (_this.to)).minDate) { if (!!e && differenceInCalendarDays(e, new Date((/** @type {?} */ (_this.to)).minDate)) === 0) { nzDisabledHours = _this.range(0, new Date((/** @type {?} */ (_this.to)).minDate).getHours()); if (!!e && new Date((/** @type {?} */ (_this.to)).minDate).getHours() - e.getHours() === 0) { nzDisabledMinutes = _this.range(-1, new Date((/** @type {?} */ (_this.to)).minDate).getMinutes()); } } } return { nzDisabledHours: (/** * @return {?} */ function () { return nzDisabledHours; }), nzDisabledMinutes: (/** * @return {?} */ function () { return nzDisabledMinutes; }), nzDisabledSeconds: (/** * @return {?} */ function () { return []; }), }; }); _this.disabledHours = (/** * @return {?} */ function () { /** @type {?} */ var nzDisabledHours = []; if (!!(/** @type {?} */ (_this.to)).maxDate && !!(/** @type {?} */ (_this.to)).minDate) { nzDisabledHours = _this.range(-1, new Date((/** @type {?} */ (_this.to)).minDate).getHours()); nzDisabledHours = nzDisabledHours.concat(_this.range(new Date((/** @type {?} */ (_this.to)).maxDate).getHours() + 1, 24)); } else if (!!(/** @type {?} */ (_this.to)).maxDate && !(/** @type {?} */ (_this.to)).minDate) { nzDisabledHours = _this.range(new Date((/** @type {?} */ (_this.to)).maxDate).getHours() + 1, 24); } else if (!(/** @type {?} */ (_this.to)).maxDate && !!(/** @type {?} */ (_this.to)).minDate) { nzDisabledHours = _this.range(0, new Date((/** @type {?} */ (_this.to)).minDate).getHours()); } return nzDisabledHours; }); _this.disabledMinutes = (/** * @param {?} e * @return {?} */ function (e) { /** @type {?} */ var nzDisabledMinutes = []; if (!!(/** @type {?} */ (_this.to)).maxDate && !!(/** @type {?} */ (_this.to)).minDate) { if (differenceInCalendarDays(e, new Date((/** @type {?} */ (_this.to)).minDate)) === 0) { if (!!e && new Date((/** @type {?} */ (_this.to)).minDate).getHours() - e.getHours() === 0) { nzDisabledMinutes = _this.range(-1, new Date((/** @type {?} */ (_this.to)).minDate).getMinutes()); } } if (differenceInCalendarDays(e, new Date((/** @type {?} */ (_this.to)).maxDate)) === 0) { if (!!e && new Date((/** @type {?} */ (_this.to)).maxDate).getHours() - e.getHours() === 0) { nzDisabledMinutes = _this.range(new Date((/** @type {?} */ (_this.to)).maxDate).getMinutes(), 60); } } } else if (!!(/** @type {?} */ (_this.to)).maxDate && !(/** @type {?} */ (_this.to)).minDate) { if (!!e && differenceInCalendarDays(e, new Date((/** @type {?} */ (_this.to)).maxDate)) === 0) { if (!!e && new Date((/** @type {?} */ (_this.to)).maxDate).getHours() - e.getHours() === 0) { nzDisabledMinutes = _this.range(new Date((/** @type {?} */ (_this.to)).maxDate).getMinutes(), 60); } } } else if (!(/** @type {?} */ (_this.to)).maxDate && !!(/** @type {?} */ (_this.to)).minDate) { if (!!e && differenceInCalendarDays(e, new Date((/** @type {?} */ (_this.to)).minDate)) === 0) { if (!!e && new Date((/** @type {?} */ (_this.to)).minDate).getHours() - e.getHours() === 0) { nzDisabledMinutes = _this.range(-1, new Date((/** @type {?} */ (_this.to)).minDate).getMinutes()); } } } return nzDisabledMinutes; }); return _this; } /** * * @param e * @param global 该变量是用来做之前的兼容,具体用来干什么 需要看外部的调用 */ /** * * @param {?} e * @param {?} global 该变量是用来做之前的兼容,具体用来干什么 需要看外部的调用 * @return {?} */ KreFormFieldDateTime.prototype.nzOnOpenChange = /** * * @param {?} e * @param {?} global 该变量是用来做之前的兼容,具体用来干什么 需要看外部的调用 * @return {?} */ function (e, global) { if (global == true) { if (!!this.field && !!this.field.templateOptions && this.field.templateOptions.enableInterface) { this.globalService.notifyDataChanged("DateTimeClick", { rdm: Math.random(), config: this.field, state: e, }); } } if (e == false && this.to != undefined && this.to != null && this.to.blur != undefined && this.to.blur != null) { this.to.blur(this.field, null); } }; Object.defineProperty(KreFormFieldDateTime.prototype, "format", { //datetime date month year time get: //datetime date month year time /** * @return {?} */ function () { /** @type {?} */ var result = "yyyy/MM/dd HH:mm"; if ((/** @type {?} */ (this.to))["format"] != undefined && (/** @type {?} */ (this.to))["format"] != null && (/** @type {?} */ (this.to))["format"] != "") { result = (/** @type {?} */ (this.to))["format"]; } return result; }, enumerable: true, configurable: true }); Object.defineProperty(KreFormFieldDateTime.prototype, "showType", { get: /** * @return {?} */ function () { /** @type {?} */ var result = "datetime"; if ((/** @type {?} */ (this.to))["type"] != undefined && (/** @type {?} */ (this.to))["type"] != null && (/** @type {?} */ (this.to))["type"] != "") { result = (/** @type {?} */ (this.to))["type"].toLowerCase(); } return result; }, enumerable: true, configurable: true }); /** * @return {?} */ KreFormFieldDateTime.prototype.getText = /** * @return {?} */ function () { /** @type {?} */ var result = ""; if ((/** @type {?} */ (this.to)).type === undefined || (/** @type {?} */ (this.to)).type === null || (/** @type {?} */ (this.to)).type === "") { (/** @type {?} */ (this.to)).type = "datetime"; } if (this.model != undefined && this.model != null && this.field != undefined && this.field != null && this.field.key != undefined && this.field.key != null && this.model[this.field.key] != undefined && this.model[this.field.key] != null && this.model[this.field.key] != "") { if (moment(this.model[this.field.key]).isValid()) { /** @type {?} */ var date = this.model[this.field.key]; switch ((/** @type {?} */ (this.to)).type) { case "datetime": result = moment(date).format("YYYY/MM/DD HH:mm"); break; case "date": result = moment(date).format("YYYY/MM/DD"); break; case "year": result = moment(date).format("YYYY"); break; case "month": result = moment(date).format("YYYY/MM"); break; case "time": result = moment(date).format("HH:mm"); break;