UNPKG

@wjya/ngx-webapp-icpc.group.pms

Version:

angular webapp : icpc.group.pms

206 lines 10.5 kB
"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 common_1 = require("@angular/common"); var ng_zorro_antd_1 = require("ng-zorro-antd"); var data_source_helper_1 = require("../../../service/data-source.helper"); var def = { data: null, showOperations: false, fields: { id: { label: 'id', hidden: true, sort: { enabled: false }, query: {}, filter: { enabled: false } }, communityName: { label: '小区名字', sort: { enabled: true }, query: {}, filter: { enabled: false } }, yearMonth: { label: '月份', sort: { enabled: true, value: 'descend' }, query: {}, filter: { enabled: false } }, orderCount: { label: '总订单数', sort: { enabled: true }, query: {}, filter: { enabled: false } }, orderAmount: { label: '电子收费', sort: { enabled: true }, query: {}, filter: { enabled: false } } } }; var PropertyMonthlyFeeComponent = /** @class */ (function () { function PropertyMonthlyFeeComponent(injector, datePipe, confirmServ, _message, dataSourceHelper, userStorageService) { var _this = this; this.injector = injector; this.datePipe = datePipe; this.confirmServ = confirmServ; this._message = _message; this.dataSourceHelper = dataSourceHelper; this.userStorageService = userStorageService; this.communityOptions = []; this.isDisabled = true; this._startValueChange = function () { if (_this.listView.params.yearMonthFrom > _this.listView.params.yearMonthTo) { _this.listView.params.yearMonthTo = null; } }; this._endValueChange = function () { if (_this.listView.params.yearMonthFrom > _this.listView.params.yearMonthTo) { _this.listView.params.yearMonthFrom = null; } }; this._disabledStartDate = function (startValue) { if (!startValue || !_this.listView.params.yearMonthTo) { return false; } return startValue.getTime() > _this.listView.params.yearMonthTo.getTime(); }; this._disabledEndDate = function (endValue) { if (!endValue || !_this.listView.params.yearMonthFrom) { return false; } return endValue.getTime() < _this.listView.params.yearMonthFrom.getTime(); }; this.dataSource = this.dataSourceHelper.reportPropertyFeeMonthlies; this.propertyFeeMonthliesExportExcelDataSource = this.dataSourceHelper.propertyFeeMonthliesExportExcel; this.generateFileStoragesDataSource = this.dataSourceHelper.generateFileStorages; this.communityDataSource = this.dataSourceHelper.communities; } PropertyMonthlyFeeComponent.prototype.ngOnInit = function () { this.communityGroupId = this.userStorageService.getCurrentOffice().id; this.listView = new ngx_webapp_fx_1.ListView(def, this.injector); this.listView.params.communityId = this.listView.params.communityId || -1; this.listView.params.yearMonthFrom = this.listView.params.yearMonthFrom || null; this.listView.params.yearMonthTo = this.listView.params.yearMonthTo || null; this.loadAll(); this.loadGroupCommunity(); }; PropertyMonthlyFeeComponent.prototype.loadAll = function () { var _this = this; this.dataSource.findList({ communityGroupId: this.communityGroupId, communityId: this.listView.params.communityId === -1 ? null : this.listView.params.communityId, 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; if (_this.listView.data.length > 0) { _this.isDisabled = false; } else { _this.isDisabled = true; } _this.listView.setTotal(res.headers); }); }; PropertyMonthlyFeeComponent.prototype.loadGroupCommunity = function () { var _this = this; this.communityDataSource.findList({ communityGroupId: this.communityGroupId }, true).subscribe(function (res) { _this.communityOptions = res.body; if (_this.communityOptions.findIndex(function (obj) { return obj.id === -1; }) === -1) { _this.communityOptions.unshift({ name: '所有小区', id: -1 }); } }); }; PropertyMonthlyFeeComponent.prototype.filter = function () { var result = []; if (this.listView.params.yearMonthFrom) { result[result.length] = 'yearMonth>=' + this.datePipe.transform(this.listView.params.yearMonthFrom, 'yyyy-MM'); } if (this.listView.params.yearMonthTo) { result[result.length] = 'yearMonth<=' + this.datePipe.transform(this.listView.params.yearMonthTo, 'yyyy-MM'); } 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(); }; PropertyMonthlyFeeComponent.prototype.exportExcel = function () { var _self = this; _self.confirmServ.confirm({ title: '您确定要导出报表?', showConfirmLoading: true, onOk: function () { return new Promise(function (resolve) { _self.propertyFeeMonthliesExportExcelDataSource.findList({ communityGroupId: _self.communityGroupId, communityId: _self.listView.params.communityId === -1 ? null : _self.listView.params.communityId, query: _self.listView.params.queryString, sort: _self.listView.sortValueToQueryStatement }).subscribe(function (success) { _self.getDownLoadUrl(success.body.fileKey, resolve); }, function (error) { _self._message.error('导出报表失败'); resolve(); }); }); }, }); }; PropertyMonthlyFeeComponent.prototype.getDownLoadUrl = function (fileKey, resolve) { var _this = this; var t = setInterval(function () { _this.generateFileStoragesDataSource.findOne(fileKey).subscribe(function (success) { if (success.body.status === 'DONE') { _this._message.success('导出报表成功'); clearInterval(t); resolve(); window.location.href = success.body.downLoadUrl; } else if (success.body.status === 'ERROR') { _this._message.error('导出报表失败'); clearInterval(t); resolve(); } }, function (error) { _this._message.error('导出报表失败'); clearInterval(t); resolve(); }); }, 1000); }; PropertyMonthlyFeeComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'zx-property-monthly-fee', template: "<zx-header-block [title]=\"'\u7269\u7F34\u6708\u62A5'\" [showBottomLine]=\"false\" [showBreadcrumb]=\"true\"><p>\u7269\u4E1A\u6BCF\u6708\u6536\u8D39\u7EDF\u8BA1</p></zx-header-block><zx-content-block><ng-template #operations><button nz-button [nzType]=\"'primary'\" (click)=\"exportExcel()\" [disabled]=\"isDisabled\"><span>\u6708\u62A5\u5BFC\u51FA</span></button></ng-template><ng-template #extra><nz-select style=\"width: 150px;\" [(ngModel)]=\"listView.params.communityId\" [nzPlaceHolder]=\"'\u9009\u62E9\u5C0F\u533A'\" [nzSize]=\"'large'\" (ngModelChange)=\"filter()\"><nz-option *ngFor=\"let option of communityOptions\" [nzLabel]=\"option.name\" [nzValue]=\"option.id\"></nz-option></nz-select>&nbsp;<nz-datepicker [(ngModel)]=\"listView.params.yearMonthFrom\" [nzMode]=\"'month'\" (ngModelChange)=\"listView.params.yearMonthFrom=$event;_startValueChange()\" [nzDisabledDate]=\"_disabledStartDate\" [nzFormat]=\"'YYYY-MM'\" [nzPlaceHolder]=\"'\u5F00\u59CB\u65F6\u95F4'\" [nzSize]=\"'large'\" (ngModelChange)=\"filter()\"></nz-datepicker>&nbsp;<nz-datepicker [(ngModel)]=\"listView.params.yearMonthTo\" [nzMode]=\"'month'\" (ngModelChange)=\"listView.params.yearMonthTo=$event;_endValueChange()\" [nzDisabledDate]=\"_disabledEndDate\" [nzFormat]=\"'YYYY-MM'\" [nzPlaceHolder]=\"'\u7ED3\u675F\u65F6\u95F4'\" [nzSize]=\"'large'\" (ngModelChange)=\"filter()\"></nz-datepicker></ng-template><ng-template #content><zx-list-view [listView]=\"listView\" (loadData)=\"loadAll()\"><ng-template #dataOperations let-dataRow=\"dataRow\"><a [routerLink]=\"['../property-monthly-fee', dataRow.id]\">\u8BE6\u60C5</a></ng-template></zx-list-view></ng-template></zx-content-block>" },] }, ]; /** @nocollapse */ PropertyMonthlyFeeComponent.ctorParameters = function () { return [ { type: core_1.Injector, }, { type: common_1.DatePipe, }, { type: ng_zorro_antd_1.NzModalService, }, { type: ng_zorro_antd_1.NzMessageService, }, { type: data_source_helper_1.DataSourceHelper, }, { type: ngx_webapp_fx_1.UserStorageService, }, ]; }; return PropertyMonthlyFeeComponent; }()); exports.PropertyMonthlyFeeComponent = PropertyMonthlyFeeComponent; //# sourceMappingURL=property-monthly-fee.component.js.map