From fd35962de838e033a8964e0959c99572f02b15f0 Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Tue, 24 Jul 2018 13:12:49 +0800
Subject: [PATCH] 站点排行 首次加载 选中效果及加载load效果

---
 src/app/routes/pollution/management/management.component.ts   |    4 +++-
 src/app/routes/reports/query2/query2.component.ts             |   50 +++++++++++++++++++++++++++++++-------------------
 src/app/routes/reports/query2/query2.component.html           |    4 ++--
 src/app/routes/pollution/management/management.component.html |    2 +-
 4 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/src/app/routes/pollution/management/management.component.html b/src/app/routes/pollution/management/management.component.html
index 1045a41..6467a90 100644
--- a/src/app/routes/pollution/management/management.component.html
+++ b/src/app/routes/pollution/management/management.component.html
@@ -25,7 +25,7 @@
                         <th nz-th><span>������</span></th>
                         <th nz-th><span>������������</span></th>
                         <th nz-th class="text-right">
-                            <span>������������ mg/m3</span>
+                            <span>������������</span>
                             <nz-table-sort (nzValueChange)="sort('sum',$event)"></nz-table-sort>
                         </th>
                     </tr>
diff --git a/src/app/routes/pollution/management/management.component.ts b/src/app/routes/pollution/management/management.component.ts
index 3566fb0..7b6a412 100644
--- a/src/app/routes/pollution/management/management.component.ts
+++ b/src/app/routes/pollution/management/management.component.ts
@@ -23,8 +23,10 @@
 
   _dataSet = [];
 
+  sensorKey = 'e1';
+  
   ngOnInit() {
-    this.changeSensorKey('e1');
+    this.changeSensorKey(this.sensorKey);
   }
 
   changeSensorKey(sensorKey) {
diff --git a/src/app/routes/reports/query2/query2.component.html b/src/app/routes/reports/query2/query2.component.html
index 27e994a..79f0ddd 100644
--- a/src/app/routes/reports/query2/query2.component.html
+++ b/src/app/routes/reports/query2/query2.component.html
@@ -5,7 +5,7 @@
             <ng-template #extra>
                 <div class="sales-card-extra">
                     <div class="sales-type-radio">
-                        <nz-radio-group [(ngModel)]="sensorKey1" (ngModelChange)="changeSensorKey($event)" [nzSize]="'large'">
+                        <nz-radio-group [(ngModel)]="sensorKey" (ngModelChange)="changeSensorKey($event)" [nzSize]="'large'">
                             <label nz-radio-button [nzValue]="'e1'"><span>PM2.5</span></label>
                             <label nz-radio-button [nzValue]="'e2'"><span>PM10</span></label>
                             <label nz-radio-button [nzValue]="'e11'"><span>SO2</span></label>
@@ -19,7 +19,7 @@
             <ng-template #body>
                 <h4 class="margin:8px 0 32px 0;">������������������</h4>
 
-                <nz-table #keyTable [nzDataSource]="_dataSet" [nzPageSize]="5" nzSize="small">
+                <nz-table #keyTable [nzDataSource]="_dataSet" [nzPageSize]="5" nzSize="small" [nzLoading]="loading">
                     <thead nz-thead>
                     <tr>
                         <th nz-th><span>������</span></th>
diff --git a/src/app/routes/reports/query2/query2.component.ts b/src/app/routes/reports/query2/query2.component.ts
index 3134b45..738bf9e 100644
--- a/src/app/routes/reports/query2/query2.component.ts
+++ b/src/app/routes/reports/query2/query2.component.ts
@@ -209,30 +209,42 @@
     private http2: HttpClient
     ) { }
   
-  _dataSet = [];
-    
+    _dataSet = [];
+    sensorKey = 'e1';
+    loading = false;
+    sensorData = {};
+  
     changeSensorKey(sensorKey) {
-      const params = {sensorKey: sensorKey, dimension: 'monitorPoint', regionCode: '320583', accountId: '1', timeType: 'month'};
-      this.http2.get(environment.SERVER_BASH_URL + 'screen/region_ranking_data', {params: params}).subscribe((res: any) => {
-        this._dataSet = res.data;
-      });
+      this._dataSet = [];
+      if (!!this.sensorData[sensorKey]) {
+        this._dataSet = this.sensorData[sensorKey];
+      } else {
+        this.loading = true;
+        const params = {sensorKey: sensorKey, dimension: 'monitorPoint', regionCode: '320583', accountId: '1', timeType: 'month'};
+        this.http2.get(environment.SERVER_BASH_URL + 'screen/region_ranking_data', {params: params}).subscribe((res: any) => {
+          this._dataSet = this.sensorData[sensorKey] = res.data;
+          this.loading = false;
+        });
+
+      }
     }
-      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;
-                }
-            })
-        ];
+  
+    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;
+          }
+        })
+      ];
     }
 
     ngOnInit() {
-      this.changeSensorKey('e1');
+      this.changeSensorKey(this.sensorKey);
 //        const searchData = [];
 //        for (let i = 0; i < 50; i += 1) {
 //            searchData.push({

--
Gitblit v1.8.0