From 926097f9307e13aa224538dc263d78d84613e98e Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Fri, 03 Aug 2018 17:11:48 +0800 Subject: [PATCH] 企业数据 页面 响应 --- src/app/routes/reports/query2/query2.component.ts | 51 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/app/routes/reports/query2/query2.component.ts b/src/app/routes/reports/query2/query2.component.ts index 3134b45..6b01c89 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: 'day'}; + 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({ @@ -250,7 +262,6 @@ // ������������ tree click ������ this.treeClickStream.debounceTime(1).subscribe( event => { const data = event.node.data; - // console.log(data); if (data.id === -1) { const children = data.children; // ������������ -- Gitblit v1.8.0