| | |
| | | import {HttpClient} from '@angular/common/http'; |
| | | import {ActivatedRoute} from '@angular/router'; |
| | | import * as echarts from 'echarts'; |
| | | |
| | | import * as $ from 'jquery'; |
| | | @Component({ |
| | | selector: 'app-report', |
| | | templateUrl: './report.component.html', |
| | | styles: [] |
| | | }) |
| | | export class ReportComponent implements OnInit { |
| | | |
| | | public data: any; |
| | | |
| | | public isShow = true; |
| | | [x: string]: any; |
| | | |
| | | constructor( |
| | | injector: Injector, |
| | | public injector: Injector, |
| | | public http: HttpClient, |
| | | public activeRoute: ActivatedRoute, |
| | | public msgSrv: NzMessageService |
| | | ) { } |
| | | ) { |
| | | for (let index = 0; index < 19; index++) { |
| | | this.sensorArr.push(index); |
| | | } |
| | | } |
| | | |
| | | public echartOption = { |
| | | title: { |
| | | text: '', |
| | | subtext: '12月份', |
| | | // subtext: '12月份', |
| | | left: 'center' |
| | | }, |
| | | tooltip: { |
| | |
| | | }, |
| | | series: [ |
| | | { |
| | | smooth: false, |
| | | smooth: true, |
| | | type: 'line', |
| | | data: [], |
| | | name: '' |
| | |
| | | ] |
| | | }; |
| | | |
| | | sensorArr: any = []; |
| | | arr = new Array(); |
| | | |
| | | ngOnInit() { |
| | | this.activeRoute.queryParams.subscribe(params => { |
| | | const query = params; |
| | | this.http.get(environment.SERVER_BASH_URL + 'report/compare', {params: query}).subscribe((res: any) => { |
| | | console.info(query.label); |
| | | query.items = JSON.parse(query.items); |
| | | this.http.post(environment.SERVER_BASH_URL + 'report/compare', query).subscribe((res: any) => { |
| | | if (res.code === 0) { |
| | | this.msgSrv.error(res.message); |
| | | } else { |
| | |
| | | const data = res.data; |
| | | if (data['time']) { |
| | | option.xAxis.data = data['time']; |
| | | option.title.text = query.sensorName + query.label + '历走势图'; |
| | | option.series[0].data = []; |
| | | option.legend.data[0] = ''; |
| | | option.series[0].name = ''; |
| | | option.series[1].data = []; |
| | | option.legend.data[1] = ''; |
| | | option.series[1].name = ''; |
| | | option.xAxis.name = query.xAxisName; |
| | | if (data.dataA) { |
| | | const legendNamea = (query.deviceaName ? query.deviceaName : query.monitorPointaName) + query.time + query.label; |
| | | option.series[0].data = data.dataA; |
| | | option.legend.data[0] = legendNamea; |
| | | option.series[0].name = legendNamea; |
| | | let index = 0; |
| | | for (const key in data.dataA[0]) { |
| | | this.arr.push(index); |
| | | let split = key.split('-'); |
| | | option.title.text = split[1] + query.label + '历走势图'; |
| | | option.series[0].data = data.dataA[0][key]; |
| | | option.yAxis.name = split[2]; |
| | | const myChart = echarts.init(document.getElementById('mydiv' + index)); |
| | | myChart.setOption(option, true); |
| | | window.onresize = myChart.resize; |
| | | index++; |
| | | } |
| | | this.sensorArr.forEach(i => { |
| | | if (this.arr.indexOf(i) == -1) { |
| | | $('#mydiv' + i).remove(); |
| | | } |
| | | }); |
| | | } |
| | | if (data.dataB) { |
| | | const legendNameb = (query.devicebName ? query.devicebName : params.monitorPointbName) + query.timeb + query.label; |
| | |
| | | option.legend.data[1] = legendNameb; |
| | | option.series[1].name = legendNameb; |
| | | } |
| | | option.yAxis.name = query.sensorUnit; |
| | | option.xAxis.name = query.xAxisName; |
| | | const myChart = echarts.init(document.getElementById('mydiv')); |
| | | myChart.setOption(option, true); |
| | | window.onresize = myChart.resize; |
| | | } |
| | | this.isShow = true; |
| | | } |
| | | |
| | | }); |
| | | }); |
| | | |
| | | } |
| | | |
| | | doPrint() { |
| | | this.isShow = false; |
| | | window.print(); |
| | | } |
| | | printBtnBoolean = true; |
| | | printComplete() { |
| | | this.printBtnBoolean = true; |
| | | } |
| | | beforePrint() { |
| | | this.printBtnBoolean = false; |
| | | } |
| | | } |