From 008baf1470f2aaf6fe388a20b9a61069270a1471 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Tue, 15 May 2018 17:19:11 +0800 Subject: [PATCH] 监控坐标编辑功能完善 --- src/app/routes/reports/query/query.component.ts | 163 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 123 insertions(+), 40 deletions(-) diff --git a/src/app/routes/reports/query/query.component.ts b/src/app/routes/reports/query/query.component.ts index 6e81d40..a01c9bd 100644 --- a/src/app/routes/reports/query/query.component.ts +++ b/src/app/routes/reports/query/query.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { _HttpClient } from '@delon/theme'; import { Sensor, Device, DataCondition, MonitorPoint, Organization, LineChartCriteria } from '@business/entity/data'; -import { TimeUnits, AreaRange, ResultCode } from '@business/enum/types.enum'; +import { TimeUnits, AreaRange, ResultCode, DeviceDimension } from '@business/enum/types.enum'; import { SensorsService } from '@business/services/http/sensors.service'; import { PageBean, ResultBean, Grid } from '@business/entity/grid'; import { NzTreeComponent } from 'ng-tree-antd'; @@ -24,6 +24,7 @@ styleUrls: ['./query.component.less'] }) export class QueryComponent implements OnInit { + // aqi������������ private aqiSort = { e1: 1, @@ -33,6 +34,7 @@ e15: 5, e16: 6 }; + public tableWidth = 2800; // private tableWidthOption = { // 'MONTH': 1400, @@ -88,9 +90,9 @@ this.isChartCollapse = !this.isChartCollapse; } public deviceOptions: Device[] = []; - public dataCondition: DataCondition = {areaRangeId: 320583, areaRange: AreaRange.AREA }; + public dataCondition: DataCondition = {areaRangeId: 320583, areaRange: AreaRange.AREA, deviceDimension:DeviceDimension.NONE}; - public monitorPointOptions: MonitorPoint[] = []; + public dimensionOptions: MonitorPoint[] = []; get actualYear(): number { return this.actualTime.getFullYear(); @@ -98,6 +100,23 @@ set actualYear(year) { this.actualTime.setFullYear(Number(year)); } + dimensionsChange(text?: string){ + switch(this.dimensionItem.value){ + case DeviceDimension.MONITORPOINT: + this.monitorPointsChange(text);break; + case DeviceDimension.PROFESSION: + this.professionsChange(text);break; + } + } + professionsChange(text?: string){ + this.http.get<ResultBean<any[]>>(environment.SERVER_BASH_URL+"profession/getall").subscribe( + result => { + if(!!result.code){ + this.dimensionOptions = result.data; + } + } + ); + } monitorPointsChange(text?: string) { const pageBean: PageBean = { pageIndex: 0, pageSize: 20 }; const example = new ExampleService(); @@ -120,19 +139,21 @@ this.monitorPointService.getPageByExample(pageBean, example).subscribe( (res: PageBean) => { if (!!res && !!res.data) { - this.monitorPointOptions = res.data; + this.dimensionOptions = res.data; } } ); } devicesChange(text?: string) { - if (!!this.monitorPoint) { + if (!!this.deviceDimension) { const example = new ExampleService(); + const deviceDimensionProperty = + this.dimensionItem.value === DeviceDimension.MONITORPOINT ?'monitorPointId':'professionId'; if (!!text) { - example.or().andEqualTo({ name: 'monitorPointId', value: this.monitorPoint.id }) + example.or().andEqualTo({ name: deviceDimensionProperty, value: this.deviceDimension.id }) .andLike({name: 'text', value: text}); - }else { - example.or().andEqualTo({ name: 'monitorPointId', value: this.monitorPoint.id }); + } else { + example.or().andEqualTo({ name: deviceDimensionProperty, value: this.deviceDimension.id }); } this.deviceService.getPageByExample(null, example).subscribe( (res: PageBean) => { @@ -164,7 +185,7 @@ private msg: NzMessageService, private dateService: DateService, ) { } - ngOnInit() { + ngOnInit() { this.initPage(); // ������������ tree click ������ this.treeClickStream.debounceTime(1).subscribe( event => { @@ -182,7 +203,7 @@ }); this._sensors = {}; // ������ ������ ������������ - }else { + } else { // ������������ children.forEach(element => { element['checked'] = true; @@ -191,7 +212,7 @@ data['checked'] = true; data['halfChecked'] = false; } - }else { + } else { const parentData = event.node.parent.data; data['checked'] = !data['checked']; if (data['checked']) { @@ -207,6 +228,7 @@ this.reloadSensorNames(); }); } + private initPage() { this.sensorsService.getPagingList(null, null).subscribe( (res: PageBean) => { @@ -253,6 +275,14 @@ } } ); + this.dimensionItem = this.dimensions[0]; + // this.dimensionsChange(); + } + public get sensorsLength():number { + return this.sensorOptions.length>0?this.sensorOptions[0].children.length:0; + } + public get sensorsSelect():number{ + return Object.keys(this._sensors).length; } public areaLazyLoad(event: { option: CascaderOption, index: number, resolve: (children: CascaderOption[]) => void, reject: () => void }) { const index = event['index']; @@ -278,44 +308,66 @@ ); break; } } - // ��������������������� ��������� ��� ��������������������� + // ��������������������� ��������� ��� ������������������������ public setAreasData(areas: {label: string, value: string}[] ) { let isChanged = false; isChanged = areas.some( (item , index: number) => { - // this._areas[index] ���null ������ ��������������� + // this._areas[index] ���null ������ ������������������ return this._areas.length < areas.length || !this._areas[index] || this._areas[index].value !== item.value; }); if ( isChanged ) { this._areas = areas; - this.monitorPoint = null; - this.monitorPointsChange(); + this.deviceDimension = null; + if(this.dimensionItem.value === DeviceDimension.MONITORPOINT){ + this.dimensionsChange(); + } } } - // ��������� ������ ���������, ������ ���������������������������null ������������������������������ - public _monitorPoint: MonitorPoint; - get monitorPoint(): MonitorPoint { - return this._monitorPoint; + // ��������� ������ ������������, ������ ���������������������������null ������������������������������ + public dimensionItem:{label: string,value: DeviceDimension}; + public dimensions:{label: string,value: DeviceDimension}[] = [ + {label:"������������",value:DeviceDimension.MONITORPOINT}, + {label:"������������",value:DeviceDimension.PROFESSION} + ]; + public get otherDimensions():{label: string,value: DeviceDimension}[] { + return this.dimensions.filter( + item => { + return item.value != this.dimensionItem.value; + } + ); } - set monitorPoint(value) { + public selectDimension(option:{label: string,value: DeviceDimension}){ + this.dimensionItem = option; + this.dimensionsChange(); + this._deviceDimension = null; + // ������������������ + this.device = null; + this.deviceOptions = null; + } + public _deviceDimension: {id: number,name: string}; + get deviceDimension(): {id: number,name: string} { + return this._deviceDimension; + } + set deviceDimension(value) { if (!!value) { // ������ ������������������ - if (this._monitorPoint !== value) { - this._monitorPoint = value; // ��������������������������������������������������������� + if (this._deviceDimension !== value) { + this._deviceDimension = value; // ��������������������������������������������������������� this._device = null; // ��������������� this.devicesChange(); } // ������null ������������������������������ } else { - this._monitorPoint = null; + this._deviceDimension = null; this.device = null; this.deviceOptions = null; } } - // ��������� ������ ��������� + // ��������� ������ ������������ public _device: Device; set device(val: Device) { this._device = val; @@ -349,10 +401,10 @@ } else { this._sensors = {}; } - }else { + } else { if (!!data.checked) { this._sensors [data.id] = data.sensorKey; - }else { + } else { delete this._sensors[data.id]; } } @@ -440,22 +492,32 @@ this.dataCondition['actualTime'] = null; this.dataCondition['timeUnits'] = this.timeUnit.value; // ��������������� - const mptValue: number = !!this._monitorPoint ? this._monitorPoint.id : null; + const dimValue: number = !!this._deviceDimension ? this._deviceDimension.id : null; const devValue: number = !!this._device ? this._device.id : null; - const areasData = [ devValue, mptValue, Number(this._areas.slice(-1).pop().value)]; + const areasData = [ devValue, dimValue, Number(this._areas.slice(-1).pop().value)]; + if(!!this.deviceDimension){ + this.dataCondition.dimensionValue = this._deviceDimension.id; + this.dataCondition.deviceDimension = this.dimensionItem.value; + } for (let index = 0 ; index < areasData.length ; index++) { const item = areasData[index]; if ( item !== null ) { this.dataCondition.areaRangeId = item; switch (index) { case 0: this.dataCondition.areaRange = AreaRange.DEVICE; break; - case 1: this.dataCondition.areaRange = AreaRange.MONITORPOINT; break; + case 1: + // ������������������ + if(this.dimensionItem.value === DeviceDimension.MONITORPOINT){ + this.dataCondition.areaRange = AreaRange.MONITORPOINT; + // ��������������� + }else{ + // ������������������������ + this.switchAreas(); + // ��������������������� + this.dataCondition.areaRangeId = areasData.slice(-1).pop(); + } break; case 2: - switch (this._areas.length ) { - case 1: this.dataCondition.areaRange = AreaRange.PROVINCE; break; - case 2: this.dataCondition.areaRange = AreaRange.CITY; break; - case 3: this.dataCondition.areaRange = AreaRange.AREA; break; - } + this.switchAreas(); break; } break; @@ -547,6 +609,13 @@ } ); } + private switchAreas(): void{ + switch (this._areas.length ) { + case 1: this.dataCondition.areaRange = AreaRange.PROVINCE; break; + case 2: this.dataCondition.areaRange = AreaRange.CITY; break; + case 3: this.dataCondition.areaRange = AreaRange.AREA; break; + } + } private reloadChart(): void { const timeList = this.grid.columns.map(item => item.text); if (!!this.echartsIntance) { @@ -613,22 +682,36 @@ public _chartTitleTemp = ''; public _tableTitleTemp = ''; public reloadChartTitle(): void { - const names = ['������', '������', '������', '������']; + const names = ['������', '������', '������','������','������']; switch ( this.dataCondition.areaRange ) { case AreaRange.MONITORPOINT : - names[0] = '���������'; - names[1] = this._monitorPoint.name; break; + names[0] = '������������'; + names[1] = this._deviceDimension.name; break; case AreaRange.DEVICE : - names[0] = '������'; + names[0] = '������'; names[1] = this._device.name; break; default : names[0] = ''; names[1] = this._areas.map( item => item.label).join('/'); break; } - names[2] = moment(this.actualTime).format(this._timeType.dateFormat); + // ������������ + if(!!this._deviceDimension){ + switch(this.dataCondition.deviceDimension){ + case DeviceDimension.PROFESSION : + names[2] ='['+this._deviceDimension.name+']'; + break; + default : + names[2] =''; + break; + } + }else{ + names[2] =''; + } + + names[3] = moment(this.actualTime).format(this._timeType.dateFormat); if ( this.grid.data.length > this.chartSelectedIndex) { - names[3] = this.grid.data[this.chartSelectedIndex].sensor.name; + names[4] = this.grid.data[this.chartSelectedIndex].sensor.name; } const title = names.join(' ') + ' ������'; if (title.trim() !== this._chartTitleTemp.trim()) { -- Gitblit v1.8.0