UNPKG

@wjya/ngx-webapp-icpc.group.pms

Version:

angular webapp : icpc.group.pms

86 lines 6.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx"); var data_source_helper_1 = require("../../service/data-source.helper"); var ngx_utils_1 = require("@wjya/ngx-utils"); var PostDialogComponent = /** @class */ (function () { function PostDialogComponent(fb, dataSourceHelper, userStorageService) { this.fb = fb; this.dataSourceHelper = dataSourceHelper; this.userStorageService = userStorageService; this.clickSave = new core_1.EventEmitter(); this.modalIsVisible = false; this.options = []; this.isDialog = false; this.dataSource = dataSourceHelper.postTemplates; this.validateForm = this.fb.group({ id: [null], code: [null], name: [null, [forms_1.Validators.required]], remarks: [null], }); } PostDialogComponent.prototype.ngOnInit = function () { this.communityGroupId = this.userStorageService.getCurrentOffice().id; this.loadAll(); }; PostDialogComponent.prototype.loadAll = function () { var _this = this; this.dataSource.findList({ communityGroupId: this.communityGroupId, scope: 'COMMUNITY_GROUP', size: 9999 }, true).subscribe(function (res) { _this.options = res.body; _this.optionLength = _this.options.length; }); }; PostDialogComponent.prototype.setFormValue = function (dataRow) { this.data = ngx_utils_1.ObjectUtils.cloneObject(dataRow, true); this.modalIsVisible = true; this.validateForm.patchValue(this.data); }; PostDialogComponent.prototype.onSearchChange = function (e) { this.options[this.optionLength] = { name: e, label: e }; }; PostDialogComponent.prototype.getFormControl = function (name) { return this.validateForm.controls[name]; }; PostDialogComponent.prototype.resetForm = function () { this.validateForm.reset(); for (var _i = 0, _a = Object.keys(this.validateForm.controls); _i < _a.length; _i++) { var key = _a[_i]; this.validateForm.controls[key].markAsPristine(); } }; PostDialogComponent.prototype.handleCancel = function () { this.modalIsVisible = false; this.resetForm(); }; PostDialogComponent.prototype.onSave = function (value) { this.clickSave.emit(ngx_utils_1.ObjectUtils.patchFieldValue(value, this.data)); }; PostDialogComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'zx-post-dialog', template: "<nz-modal [nzVisible]=\"modalIsVisible\" [nzWidth]=\"600\" [nzTitle]=\"modalTitle\" [nzContent]=\"modalContent\" [nzFooter]=\"modalFooter\" (nzOnCancel)=\"handleCancel()\"><ng-template #modalTitle><span>\u5C97\u4F4D</span> <span>\u9009\u62E9\u9884\u5B9A\u4E49\u7684\u5C97\u4F4D\u6216\u8F93\u5165\u540D\u79F0\u548C\u63CF\u8FF0\u6DFB\u52A0\u5C97\u4F4D</span></ng-template><ng-template #modalContent><form nz-form [formGroup]=\"validateForm\"><div nz-form-item nz-row class=\"hidden\"><div nz-form-label nz-col [nzSpan]=\"4\"><label>ID</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-input formControlName=\"id\" [nzPlaceHolder]=\"'ID'\" [nzSize]=\"'large'\" name=\"id\"></nz-input></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label nz-form-item-required>\u5C97\u4F4D\u540D\u79F0</label></div><div nz-col [nzSpan]=\"20\" nz-form-control *ngIf=\"!isDialog\"><nz-select formControlName=\"name\" (nzSearchChange)=\"onSearchChange($event)\" [nzPlaceHolder]=\"'\u8BF7\u9009\u62E9\u6216\u8F93\u5165\u5C97\u4F4D\u540D\u79F0'\" [nzSize]=\"'large'\" nzAllowClear nzShowSearch><nz-option *ngFor=\"let option of options\" [nzLabel]=\"option.name\" [nzValue]=\"option.name\"></nz-option></nz-select><div nz-form-explain *ngIf=\"getFormControl('name').dirty&&getFormControl('name').hasError('required')\">\u5C97\u4F4D\u540D\u79F0\u662F\u5FC5\u586B\u7684!</div></div><div nz-col [nzSpan]=\"20\" nz-form-control *ngIf=\"isDialog\"><nz-input formControlName=\"name\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u5C97\u4F4D\u540D\u79F0'\" [nzSize]=\"'large'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('name').dirty&&getFormControl('name').hasError('required')\">\u5C97\u4F4D\u540D\u79F0\u662F\u5FC5\u586B\u7684!</div></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label>\u5C97\u4F4D\u63CF\u8FF0</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-input formControlName=\"remarks\" [nzRows]=\"6\" [nzType]=\"'textarea'\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u5C97\u4F4D\u63CF\u8FF0'\" [nzSize]=\"'large'\"></nz-input></div></div></form></ng-template><ng-template #modalFooter><button nz-button [nzType]=\"'default'\" [nzSize]=\"'large'\" (click)=\"handleCancel()\"><span>\u5173 \u95ED</span></button> <button nz-button [nzType]=\"'primary'\" [nzSize]=\"'large'\" (click)=\"onSave(validateForm.value)\" [disabled]=\"!validateForm.valid\"><span>\u4FDD \u5B58</span></button></ng-template></nz-modal>", styles: [ "\n :host .hidden {\n display: none;\n }\n :host ::ng-deep .ant-select-dropdown-menu-item{\n font-size:0 !important;\n }\n " ] },] }, ]; /** @nocollapse */ PostDialogComponent.ctorParameters = function () { return [ { type: forms_1.FormBuilder, }, { type: data_source_helper_1.DataSourceHelper, }, { type: ngx_webapp_fx_1.UserStorageService, }, ]; }; PostDialogComponent.propDecorators = { "clickSave": [{ type: core_1.Output },], }; return PostDialogComponent; }()); exports.PostDialogComponent = PostDialogComponent; //# sourceMappingURL=post-dialog.component.js.map