fengxiang
2018-07-20 46ca57d5f64bafb642017b50c2fba85e38ca2289
src/app/routes/pollution/management/management.component.ts
@@ -1,3 +1,4 @@
import {environment} from '../../../../environments/environment';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { _HttpClient } from '@delon/theme';
@@ -13,8 +14,6 @@
})
export class PollutionManagementComponent implements OnInit, OnDestroy {
    data: any = {};
    constructor(
        private deviceService: DeviceService,
        private http: _HttpClient,
@@ -22,27 +21,25 @@
        private http2: HttpClient) {
    }
  _dataSet = [];
    ngOnInit() {
        const searchData = [];
        for (let i = 0; i < 50; i += 1) {
            searchData.push({
                index: i + 1,
                point: `监测站点-${i}`,
                value: Math.floor(Math.random() * 100)
            });
    this.changeSensorKey('e1');
        }
        this.data = {
            searchData: searchData
        };
  changeSensorKey(sensorKey) {
    const params = {sensorKey: sensorKey, dimension: 'monitorPoint', areaCode: '320583'};
    this.http2.get(environment.SERVER_BASH_URL + 'demo/pollution', {params: params}).subscribe((res: any) => {
      this._dataSet = res;
    });
    }
    ngOnDestroy(): void {
    }
    sort(sortName, sortValue) {
        this.data.searchData = [
            ...(<any[]>this.data.searchData).sort((a, b) => {
    this._dataSet = [
      ...(<any[]>this._dataSet).sort((a, b) => {
                if (a[sortName] > b[sortName]) {
                    return (sortValue === 'ascend') ? 1 : -1;
                } else if (a[sortName] < b[sortName]) {