@wjya/ngx-webapp-icpc.group.pms
Version:
angular webapp : icpc.group.pms
171 lines • 7.48 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx");
var community_dialog_component_1 = require("./community-dialog.component");
var ng_zorro_antd_1 = require("ng-zorro-antd");
var data_source_helper_1 = require("../../service/data-source.helper");
var def = {
data: null,
showOperations: true,
fields: {
id: {
label: 'id',
hidden: true,
sort: { enabled: false, value: 'descend' },
query: {},
filter: { enabled: false }
},
code: {
label: '小区编码',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
name: {
label: '小区名称',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
branchRegion: {
label: '所属区域',
sort: { enabled: false },
query: {},
filter: { enabled: false },
dataTemplateEnabled: true
},
contacts: {
label: '联系人',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
phone: {
label: '联系电话',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
area: {
label: '小区所在城市',
sort: { enabled: false },
query: {},
filter: { enabled: false },
},
address: {
label: '详细地址',
sort: { enabled: false },
query: {},
filter: { enabled: false }
},
}
};
var CommunityComponent = /** @class */ (function () {
function CommunityComponent(injector, dataSourceHelper, userStorageService, confirmServ, dataDictService) {
this.injector = injector;
this.dataSourceHelper = dataSourceHelper;
this.userStorageService = userStorageService;
this.confirmServ = confirmServ;
this.dataDictService = dataDictService;
this.currentData = {};
this.dataSource = dataSourceHelper.community;
dataDictService.getItems('SYS_REGION').subscribe();
}
CommunityComponent.prototype.ngOnInit = function () {
this.listView = new ngx_webapp_fx_1.ListView(def, this.injector);
this.communityGroupId = this.userStorageService.getCurrentOffice().id;
this.loadAll();
};
CommunityComponent.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) {
for (var i = 0; i < res.body.length; i++) {
if (res.body[i].area) {
res.body[i].area = _this.getAreaByCode(res.body[i].area);
}
}
_this.listView.data = res.body;
_this.listView.setTotal(res.headers);
});
};
CommunityComponent.prototype.insert = function () {
this.communityDialog.resetForm();
this.communityDialog.setFormValue({});
};
CommunityComponent.prototype.onSave = function (entity) {
var _this = this;
if (entity.id === null) {
this.dataSource.create(entity, { communityGroupId: this.communityGroupId }).subscribe(function (success) {
_this.communityDialog.modalIsVisible = false;
_this.loadAll();
});
}
else {
this.dataSource.update(entity, { communityGroupId: this.communityGroupId }).subscribe(function (success) {
_this.communityDialog.modalIsVisible = false;
_this.loadAll();
});
}
};
CommunityComponent.prototype.delete = function (val) {
var _self = this;
this.confirmServ.confirm({
title: '您确定要删除此内容?',
onOk: function () {
_self.dataSource.delete(val.id, { communityGroupId: _self.communityGroupId }).subscribe(function (success) {
_self.loadAll();
});
},
});
};
CommunityComponent.prototype.search = function (e) {
this.listView.params.queryString = e;
this.loadAll();
};
CommunityComponent.prototype.getAreaByCode = function (code) {
if (code) {
var path = this.dataDictService.getDictItemMuiltiLevelPath('SYS_REGION', code);
if (path.length === 3) {
return path[0].text + ' / ' + path[1].text + ' / ' + path[2].text;
}
else if (path.length === 2) {
return path[0].text + ' / ' + path[1].text;
}
else if (path.length === 1) {
return path[0].text;
}
else {
return '';
}
}
return '';
};
CommunityComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'zx-community',
template: "<zx-header-block [title]=\"'\u793E\u533A\u5217\u8868'\" [showBottomLine]=\"false\" [showBreadcrumb]=\"true\"></zx-header-block><zx-content-block><ng-template #operations><button nz-button [nzType]=\"'primary'\" (click)=\"insert()\"><span>\u65B0\u5EFA\u793E\u533A</span></button></ng-template><ng-template #extra><nz-input [nzType]=\"'search'\" [(ngModel)]=\"listView.params.queryString\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u5C0F\u533A\u7F16\u53F7\u6216\u540D\u79F0'\" style=\"width: 250px;\" (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 == 'branchRegion'\">{{dataRow.branchRegion.name}}</div></ng-template><ng-template #dataOperations let-dataRow=\"dataRow\"><div class=\"operation\"><a [routerLink]=\"['../community', dataRow.id]\">\u8BE6\u60C5</a></div></ng-template></zx-list-view></ng-template></zx-content-block><zx-community-dialog #communityDialog (clickSave)=\"onSave($event)\"></zx-community-dialog>"
},] },
];
/** @nocollapse */
CommunityComponent.ctorParameters = function () { return [
{ type: core_1.Injector, },
{ type: data_source_helper_1.DataSourceHelper, },
{ type: ngx_webapp_fx_1.UserStorageService, },
{ type: ng_zorro_antd_1.NzModalService, },
{ type: ngx_webapp_fx_1.DataDictService, },
]; };
CommunityComponent.propDecorators = {
"listControl": [{ type: core_1.ViewChild, args: ['list',] },],
"communityDialog": [{ type: core_1.ViewChild, args: ['communityDialog',] },],
};
return CommunityComponent;
}());
exports.CommunityComponent = CommunityComponent;
//# sourceMappingURL=community.component.js.map