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/reports/query2/query2.component.ts | 50 +++++++++++++++++++++++++++++++------------------- 1 files changed, 31 insertions(+), 19 deletions(-) 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