@wjya/ngx-webapp-icpc.group.pms
Version:
angular webapp : icpc.group.pms
108 lines • 6.78 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 ngx_utils_1 = require("@wjya/ngx-utils");
var ng_zorro_antd_1 = require("ng-zorro-antd");
var CommunityListComponent = /** @class */ (function () {
function CommunityListComponent(dataSourceHelper, userStorageService, confirmServ) {
this.dataSourceHelper = dataSourceHelper;
this.userStorageService = userStorageService;
this.confirmServ = confirmServ;
this.reload = new core_1.EventEmitter();
this.modalIsVisible = false;
this.data = [];
this.communityOptions = [];
this.isInsert = false;
this.dataSource = this.dataSourceHelper.communities;
this.officalCommunitiesDataSource = this.dataSourceHelper.officalCommunities;
this.communityGroupId = this.userStorageService.getCurrentOffice().id;
}
CommunityListComponent.prototype.ngOnInit = function () {
};
CommunityListComponent.prototype.getCommunityList = function (bindCommunities, dataRow) {
this.isInsert = false;
this.officalId = dataRow.id;
this.modalIsVisible = true;
this.data = bindCommunities;
this.loadAll(this.data);
};
CommunityListComponent.prototype.loadAll = function (communities) {
var _this = this;
this.dataSource.findList({
communityGroupId: this.communityGroupId
}, true).subscribe(function (res) {
_this.communityOptions = ngx_utils_1.ObjectUtils.cloneObject(res.body, true);
_this.doesJudgmentExist(communities);
});
};
CommunityListComponent.prototype.doesJudgmentExist = function (communities) {
for (var i = 0; i < communities.length; i++) {
for (var b = 0; b < this.communityOptions.length; b++) {
if (this.communityOptions[b].id === communities[i].id) {
this.communityOptions[b].disabled = true;
}
}
}
};
CommunityListComponent.prototype.handleCancel = function () {
this.modalIsVisible = false;
this.reload.emit();
};
CommunityListComponent.prototype.onSave = function () {
var _this = this;
if (!this.selectedOption) {
return;
}
this.officalCommunitiesDataSource.createOne(this.officalId, null, {
communityGroupId: this.communityGroupId,
communityId: this.selectedOption.id
}).subscribe(function (success) {
_this.data[_this.data.length] = _this.selectedOption;
_this.selectedOption = null;
_this.doesJudgmentExist(_this.data);
});
};
CommunityListComponent.prototype.removeCommunity = function (communityId) {
var _self = this;
this.confirmServ.confirm({
title: '您确定移除该小区?',
onOk: function () {
_self.officalCommunitiesDataSource.deleteOne(_self.officalId, {
communityGroupId: _self.communityGroupId,
communityId: communityId
}).subscribe(function (res) {
for (var i = 0; i < _self.data.length; i++) {
if (_self.data[i].id === communityId) {
_self.data.splice(i, 1);
_self.loadAll(_self.data);
break;
}
}
});
}
});
};
CommunityListComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'zx-community-list',
template: "<nz-modal [nzVisible]=\"modalIsVisible\" [nzZIndex]=\"999\" [nzWidth]=\"800\" [nzTitle]=\"modalTitle\" [nzContent]=\"modalContent\" [nzFooter]=\"modalFooter\" (nzOnCancel)=\"handleCancel()\"><ng-template #modalTitle><span>\u516C\u4F17\u53F7{{name}}\u4E0B\u7ED1\u5B9A\u5C0F\u533A</span></ng-template><ng-template #modalContent><div nz-row class=\"row\" [nzGutter]=\"8\"><div nz-col [nzSpan]=\"6\" *ngFor=\"let item of data\"><div><i class=\"anticon anticon-home\"></i> <span>{{item.name}}</span></div><i class=\"anticon anticon-close\" style=\"position: absolute;top: 5px;right: 10px;padding: 5px;cursor: pointer;\" (click)=\"removeCommunity(item.id)\"></i></div><div nz-col [nzSpan]=\"6\"><div style=\"height: 100%;cursor: pointer;\" (click)=\"isInsert = !isInsert\" *ngIf=\"!isInsert\"><i class=\"anticon anticon-plus\" style=\"position: initial; font-size: 40px; line-height: 80px;\"></i></div><div *ngIf=\"isInsert\" style=\"line-height: normal;height: 100%;\"><nz-select style=\"width: 100%;padding: 0 10px;margin-top: 15px;\" [(ngModel)]=\"selectedOption\" [nzPlaceHolder]=\"'\u8BF7\u9009\u62E9\u5C0F\u533A'\" nzAllowClear><nz-option *ngFor=\"let option of communityOptions\" [nzLabel]=\"option.name\" [nzValue]=\"option\" [nzDisabled]=\"option.disabled\"></nz-option></nz-select><div style=\"margin-top: 8px;font-size: 16px;text-align: right;padding-right: 6px;\"><i class=\"anticon anticon-check\" style=\"padding: 0 5px;cursor: pointer;\" (click)=\"onSave()\"></i> <i class=\"anticon anticon-close\" style=\"padding: 0 5px;cursor: pointer;\" (click)=\"isInsert = false\"></i></div></div></div></div></ng-template><ng-template #modalFooter></ng-template></nz-modal>",
styles: [
"\n :host .row > div{\n margin-bottom:16px;\n height:80px\n }\n :host .row > div > div{\n line-height:80px;\n text-align: center;\n border: 1px solid #ccc;\n }\n :host .row > div > div > i{\n position: absolute;\n left: 16px;\n top: 31px;\n font-size: 18px;\n }\n :host ::ng-deep .ant-modal-footer{\n display:none;\n }\n "
]
},] },
];
/** @nocollapse */
CommunityListComponent.ctorParameters = function () { return [
{ type: data_source_helper_1.DataSourceHelper, },
{ type: ngx_webapp_fx_1.UserStorageService, },
{ type: ng_zorro_antd_1.NzModalService, },
]; };
CommunityListComponent.propDecorators = {
"reload": [{ type: core_1.Output },],
};
return CommunityListComponent;
}());
exports.CommunityListComponent = CommunityListComponent;
//# sourceMappingURL=community-list.component.js.map