From 87393cfec0e482f1d0c1d36196a4788b104df859 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Thu, 29 Mar 2018 10:45:03 +0800 Subject: [PATCH] Merge branch 'develop' of http://blit.7drlb.com:8888/r/screen-frontend into develop --- src/app/routes/reports/excel/excel.component.ts | 71 +++++++++-------------------------- 1 files changed, 18 insertions(+), 53 deletions(-) diff --git a/src/app/routes/reports/excel/excel.component.ts b/src/app/routes/reports/excel/excel.component.ts index 519b820..a6fce42 100644 --- a/src/app/routes/reports/excel/excel.component.ts +++ b/src/app/routes/reports/excel/excel.component.ts @@ -3,7 +3,7 @@ import {NzMessageService, NzModalService} from 'ng-zorro-antd'; import {Component, OnInit, Inject} from '@angular/core'; import {HttpClient} from '@angular/common/http'; -import { ITokenService, DA_SERVICE_TOKEN } from '@delon/auth'; +import {ITokenService, DA_SERVICE_TOKEN} from '@delon/auth'; @Component({ selector: 'app-excel', @@ -12,25 +12,25 @@ }) export class ExcelComponent implements OnInit { [x: string]: any; - - query: any = { - }; - - time: any = { - format: 'YYYY', - mode: 'month' - }; - + public query: any = {}; public sensorOptions = []; public monitorPointOptions = []; public deviceOptions = []; + public typeOptions = [ + {value: 'year', label: '���', format: 'YYYY'}, + {value: 'month', label: '���', format: 'YYYY-MM'}, + {value: 'day', label: '���', format: 'YYYY-MM-DD'}, + {value: 'hour', label: '���', format: 'YYYY-MM-DD HH'} + ]; constructor( public http: HttpClient, public dateSrv: DateService, public msgSrv: NzMessageService, - @Inject(DA_SERVICE_TOKEN)public tokenService: ITokenService - ) {} + @Inject(DA_SERVICE_TOKEN) public tokenService: ITokenService + ) { + this.timeType = this.typeOptions[1]; + } ngOnInit() { this.query.time = null; @@ -40,14 +40,6 @@ this.msgSrv.error(res.message); } else { this.sensorOptions = res.data; - } - }); - } - - sensorChange(value) { - this.sensorOptions.forEach(sensor => { - if (sensor.sensorKey === value) { - this.sensor = sensor; } }); } @@ -78,56 +70,29 @@ this.deviceOptions = res.data; } }); - } else { - this.monitorPointa = null; } - } - - - public typeOptions = [ - {value: 'year', label: '���', mode: 'month', xAxisName: '���', format: 'yyyy', typeFormat: '%Y-%m'}, - {value: 'month', label: '���', mode: 'month', xAxisName: '���', format: 'yyyy-MM', typeFormat: '%Y-%m-%d'}, - {value: 'day', label: '���', mode: 'day', xAxisName: '���', format: 'yyyy-MM-dd', typeFormat: '%Y-%m-%d %H'}, - {value: 'hour', label: '���', mode: 'day', xAxisName: '���', format: 'yyyy-MM-dd HH', typeFormat: '%Y-%m-%d %H:%i'} - ]; - - - typeChange(searchText) { - this.typeOptions.forEach(types => { - if (types.value === searchText) { - this.timeType = types; - this.time.format = types.format.toUpperCase(); - this.time.mode = types.mode; - } - }); } reportQuery() { const query = this.query; - if (query.type && query.monitorPointId && query.time) { - if (query.time) { - query.time = this.dateSrv.date_format(query.time, this.time.format); - } + if (this.timeType && query.monitorPointId && query.time) { + query.time = this.dateSrv.date_format(query.time, this.timeType.format); if (query.timeb) { - query.timeb = this.dateSrv.date_format(query.timeb, this.time.format); + query.timeb = this.dateSrv.date_format(query.timeb, this.timeType.format); } - if (query.sensorKey) { - query.sensorName = this.sensor.name; + if (query.sensorKey && query.sensorKey.length > 0) { + query.sensors = JSON.stringify(query.sensorKey); } - query.format = this.timeType.format; - query.typeFormat = this.timeType.typeFormat; + query.type = this.timeType.value; let url = environment.SERVER_BASH_URL + 'report/excel?'; for (const a in query) { if (query[a]) { url += encodeURI(a) + '=' + encodeURI(query[a]) + '&'; } } - window.location.href = url + '_token=' + this.tokenService.get().token; } else { this.msgSrv.error('������������������'); } - } - } -- Gitblit v1.8.0