@wjya/ngx-webapp-icpc.group.pms
Version:
angular webapp : icpc.group.pms
189 lines • 9.28 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx");
var core_1 = require("@angular/core");
var data_source_helper_1 = require("../service/data-source.helper");
var carpark_dialog_component_1 = require("./carpark-dialog.component");
var ng_zorro_antd_1 = require("ng-zorro-antd");
var def = {
data: null,
showOperations: true,
fields: {
id: {
label: '车场编号',
sort: { enabled: true, value: 'descend' },
query: {},
filter: { enabled: false }
},
name: {
label: '车场名称',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
secretKey: {
label: '车场密钥',
sort: { enabled: false },
query: {},
filter: { enabled: false },
},
communityName: {
label: '隶属小区',
sort: { enabled: false },
query: {},
filter: { enabled: false }
},
berthTotal: {
label: '车位总数',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
createTime: {
label: '创建时间',
sort: { enabled: true },
query: {},
filter: { enabled: false },
dataTemplateEnabled: true
},
updateTime: {
label: '修改时间',
sort: { enabled: true },
query: {},
filter: { enabled: false },
dataTemplateEnabled: true
},
address: {
label: '车场地址',
sort: { enabled: true },
query: {},
filter: { enabled: false }
}
}
};
var CarparkComponent = /** @class */ (function () {
function CarparkComponent(dataSourceHelper, userStorageService, injector, confirmServ) {
this.dataSourceHelper = dataSourceHelper;
this.userStorageService = userStorageService;
this.injector = injector;
this.confirmServ = confirmServ;
this.dataSource = this.dataSourceHelper.parks;
this.communityDataSource = this.dataSourceHelper.communities;
this.parkConfigDataSource = this.dataSourceHelper.parkConfigs;
}
CarparkComponent.prototype.ngOnInit = function () {
this.listView = new ngx_webapp_fx_1.ListView(def, this.injector);
this.communityGroupId = this.userStorageService.getCurrentOffice().id;
this.loadAll();
};
CarparkComponent.prototype.loadAll = function () {
var _this = this;
this.dataSource.findList({
communityGroupId: this.communityGroupId,
page: this.listView.pageIndex - 1,
size: this.listView.pageSize,
keywords: this.listView.params.searchQuery,
sort: this.listView.sortValueToQueryStatement
}).subscribe(function (res) {
_this.listView.data = res.body;
_this.listView.setTotal(res.headers);
if (_this.listView.data != null && _this.listView.data.length > 0) {
var communityIds = [];
var parkIds = [];
for (var i = 0; i < _this.listView.data.length; i++) {
communityIds[communityIds.length] = _this.listView.data[i].communityId;
parkIds[parkIds.length] = _this.listView.data[i].id;
}
_this.communityDataSource.findList({
query: encodeURI('{"simpleStatement":"id IN ' + communityIds + '"}'),
size: 9999
}, true).subscribe(function (dicts) {
var dictItems = dicts.body;
if (dictItems.length > 0) {
for (var i = 0; i < _this.listView.data.length; i++) {
for (var k = 0; k < dictItems.length; k++) {
if (_this.listView.data[i].communityId === dictItems[k].id) {
_this.listView.data[i].communityName = dictItems[k].name;
}
}
}
}
});
if (parkIds.length > 0) {
for (var i = 0; i < parkIds.length; i++) {
_this.parkConfigDataSource.findList({
parkId: parkIds[i]
}, true).subscribe(function (config) {
var configs = config.body;
if (configs.length > 0) {
for (var o = 0; o < _this.listView.data.length; o++) {
for (var b = 0; b < configs.length; b++) {
if (_this.listView.data[o].id === configs[b].parkId) {
_this.listView.data[o].secretKey = configs[b].secretKey;
}
}
}
}
});
}
}
}
});
};
CarparkComponent.prototype.search = function (searchQuery) {
this.listView.params.searchQuery = searchQuery;
this.loadAll();
};
CarparkComponent.prototype.insert = function () {
this.carparkDialog.resetForm();
this.carparkDialog.setFormValue({});
};
CarparkComponent.prototype.onSave = function (entity) {
var _this = this;
if (entity.id === null) {
this.dataSource.create(entity).subscribe(function (success) {
_this.carparkDialog.modalIsVisible = false;
_this.loadAll();
});
}
else {
this.dataSource.update(entity).subscribe(function (success) {
_this.carparkDialog.modalIsVisible = false;
_this.loadAll();
});
}
};
CarparkComponent.prototype.delete = function (val) {
var _self = this;
this.confirmServ.confirm({
title: '您确定要删除此车场?',
onOk: function () {
_self.dataSource.delete(val.id).subscribe(function (success) {
_self.loadAll();
});
},
});
};
CarparkComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'zx-carpark',
template: "<zx-header-block [title]=\"'\u8F66\u573A\u4FE1\u606F'\" [showBottomLine]=\"false\" [showBreadcrumb]=\"true\"><p>\u505C\u8F66\u573A\u8D44\u6599\u4FE1\u606F\u7BA1\u7406</p></zx-header-block><zx-content-block><ng-template #operations><button nz-button [nzType]=\"'primary'\" (click)=\"insert()\"><span>\u65B0\u5EFA\u8F66\u573A</span></button></ng-template><ng-template #extra><nz-input [nzType]=\"'search'\" [(ngModel)]=\"listView.params.searchQuery\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u8F66\u573A\u540D\u79F0\u3001\u8F66\u573A\u7F16\u53F7\u6216\u8005\u8F66\u573A\u5730\u5740\u68C0\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 == 'createTime'\">{{dataRow.createTime | date:'yyyy-MM-dd HH:mm:ss'}}</div><div *ngIf=\"field.name == 'updateTime'\">{{dataRow.updateTime | date:'yyyy-MM-dd HH:mm:ss'}}</div></ng-template><ng-template #dataOperations let-dataRow=\"dataRow\"><div class=\"operation\"><a [routerLink]=\"['../carpark-info', dataRow.id]\">\u8BBE\u7F6E</a> <a (click)=\"delete(dataRow)\" style=\"color:#ff0000\">\u5220\u9664</a></div></ng-template></zx-list-view></ng-template></zx-content-block><zx-carpark-dialog #carparkDialog (clickSave)=\"onSave($event)\"></zx-carpark-dialog>",
styles: [
"\n :host .operation > a{\n padding: 0 5px;\n }\n\n :host .operation > a::after{\n content:\"|\";\n padding-left: 10px;\n color: #999;\n }\n\n :host .operation > a:last-child::after{\n content:\"\";\n }\n "
]
},] },
];
/** @nocollapse */
CarparkComponent.ctorParameters = function () { return [
{ type: data_source_helper_1.DataSourceHelper, },
{ type: ngx_webapp_fx_1.UserStorageService, },
{ type: core_1.Injector, },
{ type: ng_zorro_antd_1.NzModalService, },
]; };
CarparkComponent.propDecorators = {
"carparkDialog": [{ type: core_1.ViewChild, args: ['carparkDialog',] },],
};
return CarparkComponent;
}());
exports.CarparkComponent = CarparkComponent;
//# sourceMappingURL=carpark.component.js.map