@wjya/ngx-webapp-icpc.group.pms
Version:
angular webapp : icpc.group.pms
210 lines • 9.59 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var data_source_helper_1 = require("../../service/data-source.helper");
var core_1 = require("@angular/core");
var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx");
var user_dialog_component_1 = require("./user-dialog.component");
var ng_zorro_antd_1 = require("ng-zorro-antd");
var def = {
data: null,
showOperations: true,
fields: {
id: {
label: 'id',
hidden: true,
sort: { enabled: false, value: 'descend' },
query: {},
filter: { enabled: false }
},
login: {
label: '登录名',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
name: {
label: '姓名',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
sex: {
label: '性别',
sort: { enabled: true },
query: {},
filter: { enabled: true },
dictionaryRef: 'SYS_SEX',
},
mobilePhone: {
label: '绑定手机号',
sort: { enabled: true },
query: {},
filter: { enabled: false },
dataTemplateEnabled: true
},
posts: {
label: '岗位',
sort: { enabled: false },
query: {},
filter: { enabled: false },
dataTemplateEnabled: true
},
departments: {
label: '部门',
hidden: true,
sort: { enabled: false },
query: {},
filter: { enabled: false },
dataTemplateEnabled: true
}
}
};
var UserComponent = /** @class */ (function () {
function UserComponent(dataSourceHelper, injector, confirmServ, userStorageService) {
this.dataSourceHelper = dataSourceHelper;
this.injector = injector;
this.confirmServ = confirmServ;
this.userStorageService = userStorageService;
this.dataSource = dataSourceHelper.employees;
}
UserComponent.prototype.ngOnInit = function () {
this.listView = new ngx_webapp_fx_1.ListView(def, this.injector);
this.communityGroupId = this.userStorageService.getCurrentOffice().id;
this.loadAll();
};
UserComponent.prototype.loadAll = function () {
var _this = this;
this.dataSource.findList({
communityGroupId: this.communityGroupId,
page: this.listView.pageIndex - 1,
size: this.listView.pageSize,
query: this.listView.params.queryString,
sort: this.listView.sortValueToQueryStatement
}).subscribe(function (res) {
if (res.body) {
res.body.map(function (val) {
if (val.sex === 0 || val.sex) {
val.sex = val.sex.toString();
}
});
}
_this.listView.data = res.body;
_this.listView.setTotal(res.headers);
});
};
UserComponent.prototype.search = function (e) {
this.listView.params.queryString = e;
this.loadAll();
};
UserComponent.prototype.insert = function () {
this.userDialog.isDialog = false;
this.userDialog.resetForm();
this.userDialog.setFormValue({});
};
UserComponent.prototype.dialog = function (dataRow) {
this.userDialog.isDialog = true;
this.userDialog.resetForm();
this.userDialog.setFormValue(dataRow);
};
UserComponent.prototype.delete = function (dataRow) {
var _self = this;
this.confirmServ.confirm({
title: '您确定要删除这条记录?',
onOk: function () {
_self.dataSource.delete(dataRow.id, { communityGroupId: _self.communityGroupId }).subscribe(function (success) {
_self.loadAll();
});
}
});
};
UserComponent.prototype.filter = function () {
var result = [];
for (var _i = 0, _a = Object.keys(this.listView.fields); _i < _a.length; _i++) {
var key = _a[_i];
if (this.listView.fields[key].filter.value) {
if (this.listView.fields[key].filter.value.length > 0) {
for (var b = 0; b < this.listView.fields[key].filter.value.length; b++) {
result[result.length] = this.listView.fields[key].name + '=' + this.listView.fields[key].filter.value[b];
}
}
}
}
var str = '';
for (var i = 0; i < result.length; i++) {
if (str !== '') {
str += ',';
}
str += '"' + result[i] + '"';
}
if (str !== '') {
str = '{"op":"AND","simpleStatements":[' + str + ']}';
}
this.listView.params.queryString = encodeURI(str);
this.loadAll();
};
UserComponent.prototype.onSave = function (entity) {
var _this = this;
if (entity.id === null) {
this.dataSource.create(entity, { communityGroupId: this.communityGroupId }).subscribe(function (success) {
_this.userDialog.modalIsVisible = false;
_this.loadAll();
});
}
else {
if (entity.posts.length > 0) {
var posts = [];
for (var i = 0; i < this.userDialog.postOptions.length; i++) {
for (var b = 0; b < entity.posts.length; b++) {
if (this.userDialog.postOptions[i].id === entity.posts[b]) {
posts[posts.length] = this.userDialog.postOptions[i];
}
}
}
entity.posts = posts;
}
if (entity.departments.length > 0) {
var departments = [];
for (var i = 0; i < this.userDialog.departmentOptions.length; i++) {
for (var b = 0; b < entity.departments.length; b++) {
if (this.userDialog.departmentOptions[i].id === entity.departments[b]) {
departments[departments.length] = this.userDialog.departmentOptions[i];
}
}
}
entity.departments = departments;
}
this.dataSource.update(entity, { communityGroupId: this.communityGroupId }).subscribe(function (success) {
_this.userDialog.modalIsVisible = false;
_this.loadAll();
});
}
};
UserComponent.prototype.formateValue = function (val) {
var arr = [];
if (val) {
val.map(function (node) {
arr[arr.length] = node.name;
});
}
return arr.join(',');
};
UserComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'zx-user',
template: "<zx-header-block [title]=\"'\u804C\u5458\u7BA1\u7406'\" [showBottomLine]=\"false\" [showBreadcrumb]=\"true\"><p>\u672C\u673A\u6784\u804C\u5458\u7BA1\u7406</p></zx-header-block><zx-content-block><ng-template #operations><button nz-button [nzType]=\"'primary'\" (click)=\"insert()\"><span>\u6DFB\u52A0\u804C\u5458</span></button></ng-template><ng-template #extra><nz-input [nzType]=\"'search'\" [(ngModel)]=\"listView.params.queryString\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u767B\u5F55\u540D\u3001\u59D3\u540D\u6216\u624B\u673A\u53F7\u641C\u7D22'\" style=\"width: 300px;\" (nzOnSearch)=\"search($event)\" [nzSize]=\"'large'\"></nz-input></ng-template><ng-template #content><zx-list-view [listView]=\"listView\" (loadData)=\"loadAll()\"><ng-template #dataColumn let-dataRow=\"dataRow\" let-field=\"field\" let-value=\"value\"><div *ngIf=\"field.name == 'mobilePhone'\"><span>{{dataRow.mobilePhone}}</span> <i class=\"anticon anticon-check-circle\" *ngIf=\"dataRow.mobilePhoneVerified && dataRow.mobilePhone\" style=\"color: #52c41a; font-size: 18px;vertical-align: text-bottom;\"></i> <i class=\"anticon anticon-question-circle\" *ngIf=\"!dataRow.mobilePhoneVerified && dataRow.mobilePhone\" style=\"color: #bfbfbf; font-size: 18px;vertical-align: text-bottom;\"></i></div><div *ngIf=\"field.name == 'posts'\" style=\"max-width: 300px\">{{formateValue(dataRow.posts)}}</div></ng-template><ng-template #dataOperations let-dataRow=\"dataRow\"><a (click)=\"dialog(dataRow)\">\u4FEE\u6539</a> <a (click)=\"delete(dataRow)\">\u5220\u9664</a></ng-template></zx-list-view></ng-template></zx-content-block><zx-user-dialog #userDialog (clickSave)=\"onSave($event)\"></zx-user-dialog>"
},] },
];
/** @nocollapse */
UserComponent.ctorParameters = function () { return [
{ type: data_source_helper_1.DataSourceHelper, },
{ type: core_1.Injector, },
{ type: ng_zorro_antd_1.NzModalService, },
{ type: ngx_webapp_fx_1.UserStorageService, },
]; };
UserComponent.propDecorators = {
"userDialog": [{ type: core_1.ViewChild, args: ['userDialog',] },],
};
return UserComponent;
}());
exports.UserComponent = UserComponent;
//# sourceMappingURL=user.component.js.map