From c69ddde7828d777f04c6468c269aaa0aa03d72c9 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Thu, 02 Aug 2018 09:50:58 +0800 Subject: [PATCH] 文件修改 --- src/app/routes/pollution/management/management.component.ts | 91 ++++++++++++++++++++++----------------------- 1 files changed, 45 insertions(+), 46 deletions(-) diff --git a/src/app/routes/pollution/management/management.component.ts b/src/app/routes/pollution/management/management.component.ts index 3f97f26..ae25788 100644 --- a/src/app/routes/pollution/management/management.component.ts +++ b/src/app/routes/pollution/management/management.component.ts @@ -1,56 +1,55 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; -import { NzMessageService } from 'ng-zorro-antd'; -import { _HttpClient } from '@delon/theme'; -import { HttpClient } from '@angular/common/http'; +import {environment} from '@env/environment'; +import {Component, OnInit, OnDestroy} from '@angular/core'; +import {NzMessageService} from 'ng-zorro-antd'; +import {_HttpClient} from '@delon/theme'; +import {HttpClient} from '@angular/common/http'; import * as moment from 'moment'; -import { DeviceService } from '@business/services/http/device.service'; +import {DeviceService} from '@business/services/http/device.service'; @Component({ - selector: 'pollution-management', - templateUrl: './management.component.html', - styleUrls: ['./management.component.less'], - providers: [DeviceService] + selector: 'pollution-management', + templateUrl: './management.component.html', + styleUrls: ['./management.component.less'], + providers: [DeviceService] }) export class PollutionManagementComponent implements OnInit, OnDestroy { - data: any = {}; + constructor( + private deviceService: DeviceService, + private http: _HttpClient, + public msg: NzMessageService, + private http2: HttpClient) { + } - constructor( - private deviceService: DeviceService, - private http: _HttpClient, - public msg: NzMessageService, - 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) - }); + sensorKey = 'e1'; + + ngOnInit() { + this.changeSensorKey(this.sensorKey); + } + + 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._dataSet = [ + ...(<any[]>this._dataSet).sort((a, b) => { + if (a[sortName] > b[sortName]) { + return (sortValue === 'ascend') ? 1 : -1; + } else if (a[sortName] < b[sortName]) { + return (sortValue === 'ascend') ? -1 : 1; + } else { + return 0; } - - this.data = { - searchData: searchData - }; - } - - ngOnDestroy(): void { - } - - sort(sortName, sortValue) { - this.data.searchData = [ - ...(<any[]>this.data.searchData).sort((a, b) => { - if (a[sortName] > b[sortName]) { - return (sortValue === 'ascend') ? 1 : -1; - } else if (a[sortName] < b[sortName]) { - return (sortValue === 'ascend') ? -1 : 1; - } else { - return 0; - } - }) - ]; - } + }) + ]; + } } -- Gitblit v1.8.0