fengxiang
2018-03-29 87393cfec0e482f1d0c1d36196a4788b104df859
src/app/routes/reports/demo/demo.component.ts
@@ -16,10 +16,10 @@
  public query: any = {};
  public sensorOptions = [];
  public typeOptions = [
    {value: 'year', label: '年', format: 'yyyy', typeFormat: '%Y-%m', timeLength: 12},
    {value: 'month', label: '月', format: 'yyyy-MM', typeFormat: '%Y-%m-%d', timeLength: 28},
    {value: 'day', label: '日', format: 'yyyy-MM-dd', typeFormat: '%Y-%m-%d %H', timeLength: 24},
    {value: 'hour', label: '时', format: 'yyyy-MM-dd HH', typeFormat: '%Y-%m-%d %H:%i', timeLength: 60}
    {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'}
  ];
  public reportOptions = [
    {value: 'bar', label: '柱状图'},
@@ -122,7 +122,7 @@
        }
        queryItem.deviceCount = queryItem.deviceOptions.length;
        delete queryItem.deviceOptions;
        queryItem.formatTime = this.dateSrv.date_format(queryItem.time, this.timeType.format.toUpperCase());
        queryItem.formatTime = this.dateSrv.date_format(queryItem.time, this.timeType.format);
        delete queryItem.time;
        queryItems.push(queryItem);
      } else {
@@ -131,16 +131,11 @@
      }
    }
    if (validate && this.timeType && query.reportType) {
      query.sensors = null;
      if (query.sensorKey && query.sensorKey.length > 0) {
        const sensors = [];
        query.sensorKey.forEach(sensor => {
          sensors.push(sensor.sensorKey + '-' + sensor.name + '-' + sensor.unit);
        });
        query.sensors = JSON.stringify(sensors);
        query.sensors = JSON.stringify(query.sensorKey);
      }
      query.items = JSON.stringify(queryItems);
      query.timeType = JSON.stringify(this.timeType);
      query.type = this.timeType.value;
      this.router.navigate(['report'], {queryParams: query});
    } else {
      this.msgSrv.error('请完善搜索项或删除查询条目');