From 5913516ca6ac3a15a629803a2bf78ab9a2afcc68 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Tue, 14 Aug 2018 09:10:54 +0800
Subject: [PATCH] 控制加载网格 层级
---
src/app/routes/reports/query2/query2.component.ts | 79 +++++++++++++++++++++++++--------------
1 files changed, 51 insertions(+), 28 deletions(-)
diff --git a/src/app/routes/reports/query2/query2.component.ts b/src/app/routes/reports/query2/query2.component.ts
index df0a741..6b01c89 100644
--- a/src/app/routes/reports/query2/query2.component.ts
+++ b/src/app/routes/reports/query2/query2.component.ts
@@ -1,3 +1,5 @@
+import { environment } from '../../../../environments/environment';
+import { HttpClient } from '@angular/common/http';
import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { Sensor, Device, DataCondition, MonitorPoint, Organization, LineChartCriteria } from '@business/entity/data';
@@ -204,26 +206,62 @@
private monitorPointService: MonitorPointService,
private msg: NzMessageService,
private dateService: DateService,
+ private http2: HttpClient
) { }
- ngOnInit() {
- const searchData = [];
- for (let i = 0; i < 50; i += 1) {
- searchData.push({
- index: i + 1,
- point: `������������-${i}`,
- value: Math.floor(Math.random() * 100)
- });
- }
+
+ _dataSet = [];
+ sensorKey = 'e1';
+ loading = false;
+ sensorData = {};
+
+ changeSensorKey(sensorKey) {
+ 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;
+ });
- this.data = {
- searchData: searchData
- };
+ }
+ }
+
+ 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(this.sensorKey);
+// const searchData = [];
+// for (let i = 0; i < 50; i += 1) {
+// searchData.push({
+// index: i + 1,
+// point: `������������-${i}`,
+// value: Math.floor(Math.random() * 100)
+// });
+// }
+//
+// this.data = {
+// searchData: searchData
+// };
this.initPage();
// ������������ tree click ������
this.treeClickStream.debounceTime(1).subscribe( event => {
const data = event.node.data;
- // console.log(data);
if (data.id === -1) {
const children = data.children;
// ������������
@@ -424,7 +462,6 @@
this.treeClickStream.next(event);
}
public onSensorSelect(event): void {
- debugger;
const data = event.node.data;
if (data.id === -1 && data.halfChecked === false) {
if (!!data.checked) {
@@ -515,7 +552,6 @@
public loadGrid(): void {
// ������������
const sensors = Object.values(this._sensors);
- debugger;
if ( sensors.length === 0 ) {
this.msg.error(' ������������ ������������');
return ;
@@ -831,19 +867,6 @@
}
- 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