UNPKG

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

Version:

angular webapp : icpc.group.pms

98 lines 6.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var data_source_helper_1 = require("../../service/data-source.helper"); var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx"); var ngx_utils_1 = require("@wjya/ngx-utils"); var DepartmentDialogComponent = /** @class */ (function () { function DepartmentDialogComponent(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.departmentsTree; this.validateForm = this.fb.group({ id: [null], code: [null], name: [null, [forms_1.Validators.required]], remarks: [null], parentId: [null], }); } DepartmentDialogComponent.prototype.ngOnInit = function () { this.communityGroupId = this.userStorageService.getCurrentOffice().id; this.loadAll(); }; DepartmentDialogComponent.prototype.loadAll = function () { var _this = this; this.dataSource.findList({ communityGroupId: this.communityGroupId }).subscribe(function (res) { var result = []; [res.body].forEach(function (item) { _this.tree2Paint(item, result); }); _this.options = result; _this.options[0].name = '(无)'; }); }; DepartmentDialogComponent.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); }); } }; DepartmentDialogComponent.prototype.setFormValue = function (dataRow) { this.data = ngx_utils_1.ObjectUtils.cloneObject(dataRow, true); this.modalIsVisible = true; this.validateForm.patchValue(this.data); }; DepartmentDialogComponent.prototype.getFormControl = function (name) { return this.validateForm.controls[name]; }; DepartmentDialogComponent.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(); } }; DepartmentDialogComponent.prototype.handleCancel = function () { this.modalIsVisible = false; this.resetForm(); }; DepartmentDialogComponent.prototype.onSave = function (value) { this.clickSave.emit(ngx_utils_1.ObjectUtils.patchFieldValue(value, this.data)); }; DepartmentDialogComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'zx-department-dialog', template: "<nz-modal [nzVisible]=\"modalIsVisible\" [nzWidth]=\"600\" [nzTitle]=\"modalTitle\" [nzContent]=\"modalContent\" [nzFooter]=\"modalFooter\" (nzOnCancel)=\"handleCancel()\"><ng-template #modalTitle><span>\u90E8\u95E8</span> <span>\u8F93\u5165\u540D\u79F0\u548C\u63CF\u8FF0\u6DFB\u52A0\u672C\u673A\u6784\u90E8\u95E8</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>\u4E0A\u7EA7\u90E8\u95E8</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-select formControlName=\"parentId\" [nzPlaceHolder]=\"'\u4E0A\u7EA7\u90E8\u95E8'\" [nzSize]=\"'large'\" nzAllowClear><nz-option *ngFor=\"let option of options\" [nzLabel]=\"option.name\" [nzValue]=\"option.id\"><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>\u90E8\u95E8\u540D\u79F0</label></div><div nz-col [nzSpan]=\"20\" nz-form-control nzHasFeedback><nz-input formControlName=\"name\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u90E8\u95E8\u540D\u79F0'\" [nzSize]=\"'large'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('name').dirty&&getFormControl('name').hasError('required')\">\u90E8\u95E8\u540D\u79F0\u662F\u5FC5\u586B\u7684!</div></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label>\u90E8\u95E8\u63CF\u8FF0</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-input formControlName=\"remarks\" [nzRows]=\"6\" [nzType]=\"'textarea'\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u90E8\u95E8\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 */ DepartmentDialogComponent.ctorParameters = function () { return [ { type: forms_1.FormBuilder, }, { type: data_source_helper_1.DataSourceHelper, }, { type: ngx_webapp_fx_1.UserStorageService, }, ]; }; DepartmentDialogComponent.propDecorators = { "clickSave": [{ type: core_1.Output },], }; return DepartmentDialogComponent; }()); exports.DepartmentDialogComponent = DepartmentDialogComponent; //# sourceMappingURL=department-dialog.component.js.map