UNPKG

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

Version:

angular webapp : icpc.group.pms

108 lines 7.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var data_source_helper_1 = require("../../service/data-source.helper"); var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx"); var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var ngx_utils_1 = require("@wjya/ngx-utils"); var CommunityDialogComponent = /** @class */ (function () { function CommunityDialogComponent(fb, dataSourceHelper, userStorageService) { this.fb = fb; this.dataSourceHelper = dataSourceHelper; this.userStorageService = userStorageService; this.clickSave = new core_1.EventEmitter(); this.modalIsVisible = false; this.options = []; this.dataSource = dataSourceHelper.regionsTree; this.validateForm = this.fb.group({ id: [null], branchRegion: [null, [forms_1.Validators.required]], name: [null, [forms_1.Validators.required]], contacts: [null], phone: [null], remarks: [null], area: [null], province: [null], city: [null], county: [null], fullName: [null], address: [null], zipCode: [null] }); } CommunityDialogComponent.prototype.getFormControl = function (name) { return this.validateForm.controls[name]; }; CommunityDialogComponent.prototype.ngOnInit = function () { this.communityGroupId = this.userStorageService.getCurrentOffice().id; this.loadAll(); }; CommunityDialogComponent.prototype.setFormValue = function (dataRow) { this.data = ngx_utils_1.ObjectUtils.cloneObject(dataRow, true); this.modalIsVisible = true; this.validateForm.patchValue(this.data); }; CommunityDialogComponent.prototype.handleCancel = function () { this.modalIsVisible = false; }; CommunityDialogComponent.prototype.onSave = function (value) { this.clickSave.emit(ngx_utils_1.ObjectUtils.patchFieldValue(value, this.data)); }; CommunityDialogComponent.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(); } }; // 获取区域 // 获取区域 CommunityDialogComponent.prototype.loadAll = // 获取区域 function () { var _this = this; this.dataSource.findList({ communityGroupId: this.communityGroupId }).subscribe(function (res) { var result = []; res.body.children.forEach(function (item) { _this.tree2Paint(item, result); }); _this.options = result; }); }; CommunityDialogComponent.prototype.tree2Paint = function (option, result) { var _this = this; if (option.level == null) { option.level = 0; } result.push(option); if (option.children) { option.children.forEach(function (item) { item.level = option.level + 1; _this.tree2Paint(item, result); }); } }; CommunityDialogComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'zx-community-dialog', template: "<nz-modal [nzVisible]=\"modalIsVisible\" [nzWidth]=\"600\" [nzTitle]=\"modalTitle\" [nzContent]=\"modalContent\" [nzFooter]=\"modalFooter\" (nzOnCancel)=\"handleCancel()\"><ng-template #modalTitle><span>\u5C0F\u533A</span> <span>\u6307\u5B9A\u5C0F\u533A\u6240\u5C5E\u533A\u57DF\u3001\u540D\u79F0\u3001\u8054\u7CFB\u4EBA\u4FE1\u606F\u7B49</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]=\"24\"><label>ID</label></div><div nz-col [nzSpan]=\"24\" nz-form-control><nz-input formControlName=\"id\" [nzPlaceHolder]=\"'ID'\" [nzSize]=\"'large'\"></nz-input></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label nz-form-item-required>\u6240\u5C5E\u533A\u57DF</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-select formControlName=\"branchRegion\" (nzSearchChange)=\"onSearchChange($event)\" [nzPlaceHolder]=\"'\u8BF7\u9009\u62E9\u533A\u57DF'\" [nzSize]=\"'large'\" nzAllowClear><nz-option *ngFor=\"let option of options\" [nzLabel]=\"option.name\" [nzValue]=\"option\"><ng-template #nzOptionTemplate><span [ngStyle]=\"{'padding-left': 30 * option.level + 'px'}\">{{option.name}}</span></ng-template></nz-option></nz-select></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label nz-form-item-required>\u5C0F\u533A\u540D\u79F0</label></div><div nz-col [nzSpan]=\"20\" nz-form-control nzHasFeedback><nz-input formControlName=\"name\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u5C0F\u533A\u540D\u79F0'\" [nzSize]=\"'large'\"></nz-input></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label>\u8054\u7CFB\u4EBA</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-input formControlName=\"contacts\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u8054\u7CFB\u4EBA\u59D3\u540D'\" [nzSize]=\"'large'\"></nz-input></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label>\u8054\u7CFB\u7535\u8BDD</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-input formControlName=\"phone\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u8054\u7CFB\u4EBA\u624B\u673A\u53F7\u7801'\" [nzSize]=\"'large'\"></nz-input></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label>\u5907\u6CE8</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-input formControlName=\"remarks\" [nzRows]=\"6\" [nzType]=\"'textarea'\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u5907\u6CE8'\" [nzSize]=\"'large'\"></nz-input></div></div></form></ng-template><ng-template #modalFooter><button nz-button [nzType]=\"'primary'\" [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 " ] },] }, ]; /** @nocollapse */ CommunityDialogComponent.ctorParameters = function () { return [ { type: forms_1.FormBuilder, }, { type: data_source_helper_1.DataSourceHelper, }, { type: ngx_webapp_fx_1.UserStorageService, }, ]; }; CommunityDialogComponent.propDecorators = { "clickSave": [{ type: core_1.Output },], }; return CommunityDialogComponent; }()); exports.CommunityDialogComponent = CommunityDialogComponent; //# sourceMappingURL=community-dialog.component.js.map