@wjya/ngx-webapp-icpc.group.pms
Version:
angular webapp : icpc.group.pms
164 lines • 8.09 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 data_source_helper_1 = require("../../service/data-source.helper");
var region_dialog_component_1 = require("./region-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 }
},
code: {
label: '区域编码',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
name: {
label: '区域名称',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
remarks: {
label: '区域描述',
sort: { enabled: false },
query: {},
filter: { enabled: false }
}
}
};
var RegionComponent = /** @class */ (function () {
function RegionComponent(dataSourceHelper, userStorageService, injector, confirmServ) {
this.dataSourceHelper = dataSourceHelper;
this.userStorageService = userStorageService;
this.injector = injector;
this.confirmServ = confirmServ;
this.parentId = -1;
this.dataSource = dataSourceHelper.regions;
}
RegionComponent.prototype.ngOnInit = function () {
this.listView = new ngx_webapp_fx_1.ListView(def, this.injector);
this.communityGroupId = this.userStorageService.getCurrentOffice().id;
this.treeViewDataUrl = '/uaa/api/branch-regions?&size=9999&parentId=-1&communityGroupId=' + this.communityGroupId;
this.loadAll();
};
RegionComponent.prototype.loadAll = function () {
var _this = this;
this.dataSource.findList({
communityGroupId: this.communityGroupId,
parentId: this.parentId,
page: this.listView.pageIndex - 1,
size: this.listView.pageSize,
query: this.listView.params.queryString,
sort: this.listView.sortValueToQueryStatement
}).subscribe(function (res) {
_this.listView.data = res.body;
_this.listView.setTotal(res.headers);
});
};
RegionComponent.prototype.insert = function () {
this.regionDialog.setFormValue({ parentId: this.parentId === -1 ? this.regionDialog.options[0].id : this.parentId });
this.regionDialog.loadAll();
};
RegionComponent.prototype.dialog = function (dataRow) {
dataRow.parentId = this.parentId === -1 ? this.regionDialog.options[0].id : this.parentId;
this.regionDialog.loadAll();
this.regionDialog.setFormValue(dataRow);
};
RegionComponent.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();
_self.reloadTreeNode();
});
}
});
};
RegionComponent.prototype.onSave = function (entity) {
var _this = this;
if (entity.id === null) {
this.dataSource.create(entity, { communityGroupId: this.communityGroupId }).subscribe(function (success) {
_this.regionDialog.modalIsVisible = false;
_this.treeView.reloadLoadChildren();
_this.loadAll();
});
}
else {
this.dataSource.update(entity, { communityGroupId: this.communityGroupId }).subscribe(function (success) {
_this.regionDialog.modalIsVisible = false;
_this.treeView.reloadLoadChildren();
_this.loadAll();
});
}
};
RegionComponent.prototype.reloadTreeNode = function () {
var selectedTreeNode = this.treeView.treeView.getSelectedNode();
if (selectedTreeNode) {
this.treeView.treeView.loadChildren(selectedTreeNode);
}
};
RegionComponent.prototype.treeViewDataLoaded = function (data) {
this.setTreeNodeAttributes(Array.isArray(data) ? { children: data } : data);
};
RegionComponent.prototype.setTreeNodeAttributes = function (data) {
var _this = this;
if (data.children == null) {
return;
}
data.children.forEach(function (child) {
child.icon = null;
child.visible = true;
child.childrenUrl = '/uaa/api/branch-regions?parentId=${data.id}&size=9999&communityGroupId=' + _this.communityGroupId;
_this.setTreeNodeAttributes(child);
});
};
RegionComponent.prototype.treeViewHeaderClick = function (treeView) {
this.parentId = -1;
this.loadAll();
};
RegionComponent.prototype.treeViewSelectChange = function (node) {
if (node.selected) {
this.parentId = node.data.id;
this.loadAll();
}
};
RegionComponent.prototype.search = function (e) {
this.listView.params.queryString = e;
this.loadAll();
};
RegionComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'zx-region',
template: "<zx-header-block [title]=\"'\u533A\u57DF\u8BBE\u7F6E'\" [showBottomLine]=\"false\" [showBreadcrumb]=\"true\"><p>\u672C\u96C6\u56E2\u533A\u57DF\u8BBE\u7F6E</p></zx-header-block><zx-content-block><ng-template #sider><zx-tree-view #treeView [dataUrl]=\"treeViewDataUrl\" (dataLoaded)=\"treeViewDataLoaded($event)\" (headerClicked)=\"treeViewHeaderClick($event)\" [accordion]=\"true\" [enableCheckbox]=\"false\" [enableHeader]=\"true\" [headerText]=\"'\u533A\u57DF'\" [headerIcon]=\"'anticon anticon-layout ng-star-inserted'\" (selectChange)=\"treeViewSelectChange($event)\"></zx-tree-view></ng-template><ng-template #operations><button nz-button [nzType]=\"'primary'\" (click)=\"insert()\"><i class=\"anticon anticon-plus\"></i> <span>\u6DFB\u52A0\u533A\u57DF</span></button></ng-template><ng-template #extra><nz-input [nzType]=\"'search'\" [(ngModel)]=\"listView.params.queryString\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u533A\u57DF\u7F16\u7801\u6216\u540D\u79F0\u641C\u7D22'\" style=\"width: 250px;\" (nzOnSearch)=\"search($event)\" [nzSize]=\"'large'\"></nz-input></ng-template><ng-template #content><zx-list-view [listView]=\"listView\" (loadData)=\"loadAll()\"><ng-template #dataOperations let-dataRow=\"dataRow\"><div class=\"operation\"><a (click)=\"dialog(dataRow)\">\u4FEE\u6539</a> <a (click)=\"delete(dataRow)\">\u5220\u9664</a></div></ng-template></zx-list-view></ng-template></zx-content-block><zx-region-dialog #regionDialog (clickSave)=\"onSave($event)\"></zx-region-dialog>",
styles: [
"\n :host ::ng-deep .ant-select-dropdown-menu-item{\n font-size:0 !important;\n }\n "
]
},] },
];
/** @nocollapse */
RegionComponent.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, },
]; };
RegionComponent.propDecorators = {
"regionDialog": [{ type: core_1.ViewChild, args: ['regionDialog',] },],
"treeView": [{ type: core_1.ViewChild, args: ['treeView',] },],
};
return RegionComponent;
}());
exports.RegionComponent = RegionComponent;
//# sourceMappingURL=region.component.js.map