From f4839b6e3fac1f877190a78c36d7affdde091efe Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Fri, 03 Aug 2018 08:46:30 +0800
Subject: [PATCH] 设备数据

---
 src/app/routes/environment/management/management.component.ts |  105 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 64 insertions(+), 41 deletions(-)

diff --git a/src/app/routes/environment/management/management.component.ts b/src/app/routes/environment/management/management.component.ts
index dae826d..eb73346 100644
--- a/src/app/routes/environment/management/management.component.ts
+++ b/src/app/routes/environment/management/management.component.ts
@@ -1,9 +1,12 @@
-import { Component, OnInit, OnDestroy } from '@angular/core';
+import { environment } from '@env/environment';
+import { Component, OnInit, OnDestroy, AfterViewInit } 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 * as echarts from 'echarts';
+import * as $ from 'jquery';
 
 @Component({
     selector: 'environment-management',
@@ -13,55 +16,75 @@
 })
 export class EnvironmentManagementComponent implements OnInit, OnDestroy {
 
-    data: any = {};
-    offlineChartData: any[] = [];
-
     constructor(
         private deviceService: DeviceService,
         private http: _HttpClient,
         public msg: NzMessageService,
         private http2: HttpClient) {
     }
-
+  
+    public option = {
+      tooltip: {
+        trigger: 'item',
+        axisPointer: {
+          type: 'cross'
+        }
+      },
+      legend: {
+        right: '10%',
+        top: '10%',
+        data: ['������������', '������������']
+      },
+      xAxis: {
+        type: 'category'
+      },
+      yAxis: {
+        type: 'value',
+        name: '���������ug/m��'
+      },
+      series: [
+        {
+          type: 'line',
+          smooth: true,
+          name: '������������'
+        }, {
+          type: 'line',
+          smooth: true,
+          name: '������������'
+        }
+      ]
+    };
+  
+    ngAfterViewInit() {
+      const PM25 = echarts.init(document.getElementById('PM25'));
+      PM25.showLoading();
+      const params = {
+        type: 'month',
+        sensors: JSON.stringify(['e1']),
+        items: JSON.stringify([
+          {areaCode: 320583, formatTime: moment().format('YYYY-MM')},
+          {areaCode: 320583, formatTime: moment().subtract(1, 'M').format('YYYY-MM')}
+        ])
+      };
+      this.http2.get(environment.SERVER_BASH_URL + 'report/compare', {params: params}).subscribe((res: any) => {
+        const PM25Option = $.extend(true,
+          {
+            xAxis: {data: res.data.times},
+            series: [
+              {data: res.data.datas[0]['e1']},
+              {data: res.data.datas[1]['e1']}
+            ]
+          },
+          this.option);
+        PM25.setOption(PM25Option, false);
+        window.onresize = PM25.resize;
+        PM25.hideLoading();
+      });
+    }
+    
     ngOnInit() {
-        const searchData = [];
-        for (let i = 0; i < 50; i += 1) {
-            searchData.push({
-                index: i + 1,
-                point: `������������-${i}`,
-                value: Math.floor(Math.random() * 100)
-            });
-        }
-
-        const offlineChartData = [];
-        for (let i = 0; i < 20; i += 1) {
-            offlineChartData.push({
-                x: new Date().getTime() + 1000 * 60 * 30 * i,
-                y1: Math.floor(Math.random() * 100) + 10,
-                y2: Math.floor(Math.random() * 100) + 10
-            });
-        }
-        this.offlineChartData = offlineChartData;
-
-        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