fengxiang
2018-03-26 0e25153037b06851846e80cc745e518ba07bf7af
src/app/routes/reports/query/query.component.ts
File was renamed from src/app/routes/analysis/query/query.component.ts
@@ -1,6 +1,6 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { Sensor, Device, DataCondition, MonitorPoint, Organization, LineChartCriteria, PairData } from '@business/entity/data';
import { Sensor, Device, DataCondition, MonitorPoint, Organization, LineChartCriteria } from '@business/entity/data';
import { TimeUnits, AreaRange, ResultCode } from '@business/enum/types.enum';
import { SensorsService } from '@business/services/http/sensors.service';
import { PageBean, ResultBean, Grid } from '@business/entity/grid';
@@ -454,7 +454,7 @@
      // 清空数据
      this.grid.data = [];
      this.http.post(environment.SERVER_BASH_URL + '/report/line-chart', lineChartCriteria).subscribe(
        (res: ResultBean<{[key: string]: Array<Array<PairData>>}>) => {
        (res: ResultBean<{[key: string]: Array<Array<number>>}>) => {
           if (res.code === 1) {
              const data =  res.data;
              if (!!data) {
@@ -470,13 +470,13 @@
                       weight = !!weight ? weight : 101;
                    //    this.gridSensors.push(sensor);
                       const sensorData = data[key][0].map(
                           pair => {
                           value => {
                                if (weight > 100) {
                                    // pair.value 为null,权重后移
                                    weight = !!pair.value ? weight : weight + 1;
                                    weight = !!value ? weight : weight + 1;
                                }
                                // 四舍五入,保留2位
                                return !!pair.value ? String(Math.round(pair.value * 100) / 100) : '-';
                                return !!value ? String(Math.round(value * 100) / 100) : '-';
                           }
                       );
                       this.grid.data.push({sensor: sensor, data: sensorData, weight: weight});
@@ -560,6 +560,7 @@
    }
    // 报表标题暂存 防止联动
    public _chartTitleTemp = '';
    public _tableTitleTemp = '';
    public reloadChartTitle(): void {
        const names = ['辖区', '地区', '时间', '项目'];
        switch ( this.dataCondition.areaRange ) {
@@ -582,6 +583,10 @@
        if (title.trim() !== this._chartTitleTemp.trim()) {
             this._chartTitleTemp = title;
        }
        const tableTile = names.slice(0, -1).join('  ') + ' 各项数据';
        if (tableTile.trim() !== this._tableTitleTemp.trim()) {
            this._tableTitleTemp = tableTile;
       }
    }
    public switchSensor(index: number): void {
        this.chartSelectedIndex = index;