UNPKG

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

Version:

angular webapp : icpc.group.pms

216 lines 10.9 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 data_source_helper_1 = require("../../../service/data-source.helper"); var ng_zorro_antd_1 = require("ng-zorro-antd"); var common_1 = require("@angular/common"); var def = { data: null, showOperations: false, fields: { id: { label: 'id', hidden: true, sort: { enabled: false }, query: {}, filter: { enabled: false } }, parkName: { label: '车场名称', sort: { enabled: true }, query: {}, filter: { enabled: false } }, reportYearMonth: { label: '日期', sort: { enabled: true, value: 'descend' }, query: {}, filter: { enabled: false } }, orderQuantity: { label: '总订单数', sort: { enabled: true }, query: {}, filter: { enabled: false } }, epayAmount: { label: '电子收费', sort: { enabled: true }, query: {}, filter: { enabled: false } }, cashAmount: { label: '现金支付', sort: { enabled: true }, query: {}, filter: { enabled: false }, } } }; var ParkingMonthlyFeeComponent = /** @class */ (function () { function ParkingMonthlyFeeComponent(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.parkOptions = []; this.isDisabled = true; this._startValueChange = function () { if (_this.listView.params.reportYearMonthFrom > _this.listView.params.reportYearMonthTo) { _this.listView.params.reportYearMonthTo = null; } }; this._endValueChange = function () { if (_this.listView.params.reportYearMonthFrom > _this.listView.params.reportYearMonthTo) { _this.listView.params.reportYearMonthFrom = null; } }; this._disabledStartDate = function (startValue) { if (!startValue || !_this.listView.params.reportYearMonthTo) { return false; } return startValue.getTime() > _this.listView.params.reportYearMonthTo.getTime(); }; this._disabledEndDate = function (endValue) { if (!endValue || !_this.listView.params.reportYearMonthFrom) { return false; } return endValue.getTime() < _this.listView.params.reportYearMonthFrom.getTime(); }; this.dataSource = this.dataSourceHelper.reportParkFeeMonthlies; this.generateFileStoragesDataSource = this.dataSourceHelper.generateFileStorages; this.parkDataSource = this.dataSourceHelper.parks; this.parkFeeMonthliesExportExcelDataSource = this.dataSourceHelper.parkFeeMonthliesExportExcel; } ParkingMonthlyFeeComponent.prototype.ngOnInit = function () { this.communityGroupId = this.userStorageService.getCurrentOffice().id; this.listView = new ngx_webapp_fx_1.ListView(def, this.injector); this.listView.params.parkId = this.listView.params.parkId || -1; this.listView.params.reportYearMonthFrom = this.listView.params.reportYearMonthFrom || null; this.listView.params.reportYearMonthTo = this.listView.params.reportYearMonthTo || null; this.loadAll(); this.loadPark(); }; ParkingMonthlyFeeComponent.prototype.loadAll = function () { var _this = this; this.dataSource.findList({ communityGroupId: this.communityGroupId, page: this.listView.pageIndex - 1, size: this.listView.pageSize, reportByCommunityGroup: true, parkId: this.listView.params.parkId === -1 ? null : this.listView.params.parkId, 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); }); }; ParkingMonthlyFeeComponent.prototype.loadPark = function () { var _this = this; this.parkDataSource.findList({ communityGroupId: this.communityGroupId, size: 9999, }, true).subscribe(function (res) { _this.parkOptions = res.body; if (_this.parkOptions.findIndex(function (obj) { return obj.id === -1; }) === -1) { _this.parkOptions.unshift({ name: '所有车场', id: -1 }); } }); }; ParkingMonthlyFeeComponent.prototype.filter = function () { var result = []; if (this.listView.params.reportYearMonthFrom) { result[result.length] = 'reportYearMonth>=' + this.datePipe.transform(this.listView.params.reportYearMonthFrom, 'yyyy-MM'); } if (this.listView.params.reportYearMonthTo) { result[result.length] = 'reportYearMonth<=' + this.datePipe.transform(this.listView.params.reportYearMonthTo, '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(); }; ParkingMonthlyFeeComponent.prototype.exportExcel = function () { var _self = this; _self.confirmServ.confirm({ title: '您确定要导出报表?', showConfirmLoading: true, onOk: function () { return new Promise(function (resolve) { _self.parkFeeMonthliesExportExcelDataSource.findList({ communityGroupId: _self.communityGroupId, page: _self.listView.pageIndex - 1, size: _self.listView.pageSize, parkId: _self.listView.params.parkId === -1 ? null : _self.listView.params.parkId, query: _self.listView.params.queryString, sort: _self.listView.sortValueToQueryStatement }).subscribe(function (success) { _self.getDownLoadUrl(success.body.fileKey, resolve); }, function (error) { _self._message.error('导出报表失败'); resolve(); }); }); }, }); }; ParkingMonthlyFeeComponent.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); }; ParkingMonthlyFeeComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'zx-parking-monthly-fee', template: "<zx-header-block [title]=\"'\u8F66\u573A\u6708\u62A5'\" [showBottomLine]=\"false\" [showBreadcrumb]=\"true\"><p>\u8F66\u573A\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.parkId\" [nzPlaceHolder]=\"'\u9009\u62E9\u8F66\u573A'\" [nzSize]=\"'large'\" (ngModelChange)=\"filter()\"><nz-option *ngFor=\"let option of parkOptions\" [nzLabel]=\"option.name\" [nzValue]=\"option.id\"></nz-option></nz-select>&nbsp;<nz-datepicker [(ngModel)]=\"listView.params.reportYearMonthFrom\" [nzMode]=\"'month'\" (ngModelChange)=\"listView.params.reportYearMonthFrom=$event;_startValueChange()\" [nzDisabledDate]=\"_disabledStartDate\" [nzFormat]=\"'YYYY-MM'\" [nzPlaceHolder]=\"'\u5F00\u59CB\u65F6\u95F4'\" [nzSize]=\"'large'\" (ngModelChange)=\"filter()\"></nz-datepicker>&nbsp;<nz-datepicker [(ngModel)]=\"listView.params.reportYearMonthTo\" [nzMode]=\"'month'\" (ngModelChange)=\"listView.params.reportYearMonthTo=$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]=\"['../parking-monthly-fee', dataRow.id]\">\u8BE6\u60C5</a></ng-template></zx-list-view></ng-template></zx-content-block>" },] }, ]; /** @nocollapse */ ParkingMonthlyFeeComponent.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 ParkingMonthlyFeeComponent; }()); exports.ParkingMonthlyFeeComponent = ParkingMonthlyFeeComponent; //# sourceMappingURL=parking-monthly-fee.component.js.map