@wjya/ngx-webapp-icpc.group.pms
Version:
angular webapp : icpc.group.pms
125 lines • 8.4 kB
JavaScript
"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 UserDialogComponent = /** @class */ (function () {
function UserDialogComponent(fb, dataSourceHelper, userStorageService) {
this.fb = fb;
this.dataSourceHelper = dataSourceHelper;
this.userStorageService = userStorageService;
this.clickSave = new core_1.EventEmitter();
this.modalIsVisible = false;
this.postOptions = [];
this.departmentOptions = [];
this.isDialog = false;
this.data = {};
this.postDataSource = dataSourceHelper.posts;
this.departmentDataSource = dataSourceHelper.departmentsTree;
this.validateForm = this.fb.group({
id: [null],
login: [null],
name: [null, [forms_1.Validators.required]],
sex: [null, [forms_1.Validators.required]],
mobilePhone: [null, [forms_1.Validators.required]],
posts: [null],
departments: [null]
});
}
UserDialogComponent.prototype.ngOnInit = function () {
this.communityGroupId = this.userStorageService.getCurrentOffice().id;
this.loadPost();
this.loadDepartment();
};
UserDialogComponent.prototype.loadPost = function () {
var _this = this;
this.postDataSource.findList({
communityGroupId: this.communityGroupId,
size: 9999
}, true).subscribe(function (res) {
_this.postOptions = res.body;
});
};
UserDialogComponent.prototype.loadDepartment = function () {
var _this = this;
this.departmentDataSource.findList({
communityGroupId: this.communityGroupId,
size: 9999
}, true).subscribe(function (res) {
var result = [];
res.body.children.forEach(function (item) {
_this.tree2Paint(item, result);
});
_this.departmentOptions = result;
});
};
UserDialogComponent.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);
});
}
};
UserDialogComponent.prototype.setFormValue = function (dataRow) {
var _this = this;
this.data = ngx_utils_1.ObjectUtils.cloneObject(dataRow, true);
this.modalIsVisible = true;
if (this.data.posts) {
this.data.posts.map(function (val, idx) {
_this.data.posts[idx] = val.id;
});
}
// if (data.departments) {
// data.departments.map((val: any, idx) => {
// data.departments[idx] = val.id;
// });
// }
this.validateForm.patchValue(this.data);
};
UserDialogComponent.prototype.getFormControl = function (name) {
return this.validateForm.controls[name];
};
UserDialogComponent.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();
}
};
UserDialogComponent.prototype.handleCancel = function () {
this.modalIsVisible = false;
this.resetForm();
};
UserDialogComponent.prototype.onSave = function (value) {
this.clickSave.emit(ngx_utils_1.ObjectUtils.patchFieldValue(value, this.data));
};
UserDialogComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'zx-user-dialog',
template: "<nz-modal [nzVisible]=\"modalIsVisible\" [nzWidth]=\"600\" [nzTitle]=\"modalTitle\" [nzContent]=\"modalContent\" [nzFooter]=\"modalFooter\" (nzOnCancel)=\"handleCancel()\"><ng-template #modalTitle><span>\u804C\u5458</span> <span>\u8F93\u5165\u804C\u5458\u624B\u673A\u53F7\u3001\u59D3\u540D\u7B49\u57FA\u672C\u4FE1\u606F\uFF0C\u5E76\u8BBE\u7F6E\u5176\u90E8\u95E8\u548C\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>\u624B\u673A\u53F7\u7801</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-input formControlName=\"mobilePhone\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u7801'\" [nzSize]=\"'large'\" [nzReadonly]=\"data.mobilePhoneVerified\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('mobilePhone').dirty&&getFormControl('mobilePhone').hasError('required')\">\u624B\u673A\u53F7\u7801\u662F\u5FC5\u586B\u7684!</div></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label nz-form-item-required>\u804C\u5458\u59D3\u540D</label></div><div nz-col [nzSpan]=\"20\" nz-form-control nzHasFeedback><nz-input formControlName=\"name\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u804C\u5458\u59D3\u540D'\" [nzSize]=\"'large'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('name').dirty&&getFormControl('name').hasError('required')\">\u804C\u5458\u59D3\u540D\u662F\u5FC5\u586B\u7684!</div></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label nz-form-item-required>\u6027\u522B</label></div><div nz-col [nzSpan]=\"20\" nz-form-control><nz-radio-group formControlName=\"sex\"><label nz-radio [nzValue]=\"'1'\"><span>\u7537</span></label> <label nz-radio [nzValue]=\"'0'\"><span>\u5973</span></label> <label nz-radio [nzValue]=\"'2'\"><span>\u672A\u77E5</span></label></nz-radio-group><div nz-form-explain *ngIf=\"getFormControl('sex').dirty&&getFormControl('sex').hasError('required')\">\u6027\u522B\u662F\u5FC5\u586B\u7684!</div></div></div><div nz-form-item nz-row><div nz-form-label nz-col [nzSpan]=\"4\"><label>\u5C97\u4F4D</label></div><div nz-col [nzSpan]=\"20\" nz-form-control *ngIf=\"!isDialog\"><nz-select formControlName=\"posts\" [nzSize]=\"'large'\" [nzMode]=\"'multiple'\" [nzPlaceHolder]=\"'\u8BF7\u9009\u62E9\u5C97\u4F4D'\"><nz-option *ngFor=\"let option of postOptions\" [nzLabel]=\"option.name\" [nzValue]=\"option\"></nz-option></nz-select></div><div nz-col [nzSpan]=\"20\" nz-form-control *ngIf=\"isDialog\"><nz-select formControlName=\"posts\" [nzSize]=\"'large'\" [nzMode]=\"'multiple'\" [nzPlaceHolder]=\"'\u8BF7\u9009\u62E9\u5C97\u4F4D'\"><nz-option *ngFor=\"let option of postOptions\" [nzLabel]=\"option.name\" [nzValue]=\"option.id\"></nz-option></nz-select></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 "
]
},] },
];
/** @nocollapse */
UserDialogComponent.ctorParameters = function () { return [
{ type: forms_1.FormBuilder, },
{ type: data_source_helper_1.DataSourceHelper, },
{ type: ngx_webapp_fx_1.UserStorageService, },
]; };
UserDialogComponent.propDecorators = {
"clickSave": [{ type: core_1.Output },],
};
return UserDialogComponent;
}());
exports.UserDialogComponent = UserDialogComponent;
//# sourceMappingURL=user-dialog.component.js.map