From 820cc14842e73c9980b87002eae127af626622fd Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Mon, 14 May 2018 15:59:45 +0800
Subject: [PATCH] 报表展示 增加行业筛选

---
 src/app/routes/reports/demo/demo.component.ts |   67 +++++++++++++++++++++++++++++++--
 1 files changed, 63 insertions(+), 4 deletions(-)

diff --git a/src/app/routes/reports/demo/demo.component.ts b/src/app/routes/reports/demo/demo.component.ts
index 506b60c..ee873aa 100644
--- a/src/app/routes/reports/demo/demo.component.ts
+++ b/src/app/routes/reports/demo/demo.component.ts
@@ -28,12 +28,19 @@
     {value: 'bar', label: '���������'},
     {value: 'line', label: '���������'}
   ];
-
+  public professionOptions = [];
+  public dimensionOptions = [
+    {value: 'monitorPoint', label: '������������'},
+    {value: 'profession', label: '������'}
+  ];
+  monitorPointShow = true;
+  professionShow = false;
   public items: any[] = [{
     id: 0,
+    profession: null,
     monitorPoint: null,
     device: null,
-    time: null,
+    time: new Date(),
     monitorPointOptions: [],
     deviceOptions: []
   }];
@@ -53,6 +60,7 @@
   ) {
     this.timeType = this.typeOptions[1];
     this.query.reportType = this.reportOptions[1].value;
+    this.query.dimension = this.dimensionOptions[0].value;
   }
 
   ngOnInit() {
@@ -64,6 +72,28 @@
       }
     });
 
+    this.http.get(environment.SERVER_BASH_URL + 'mobile/profession').subscribe((res: any) => {
+      if (res.errno !== 0) {
+        this.msgSrv.error(res.message);
+      } else {
+        this.professionOptions = res.data;
+      }
+    });
+  }
+  
+  dimensionChange(value) {
+    this.items.forEach((item,index) => {
+      item.profession = null;
+      item.monitorPoint = null;
+      item.device = null;
+    });
+    if (value === 'monitorPoint') {
+      this.professionShow = false;
+      this.monitorPointShow = true;
+    } else {
+      this.professionShow = true;
+      this.monitorPointShow = false;
+    }
   }
 
   public onTreeClickSelect(event): void {
@@ -112,9 +142,10 @@
     const id = (this.items.length > 0) ? this.items[this.items.length - 1].id + 1 : 0;
     const index = this.items.push({
       id: id,
+      profession: null,
       monitorPoint: null,
       device: null,
-      time: null,
+      time: new Date(),
       monitorPointOptions: [],
       deviceOptions: []
     });
@@ -150,6 +181,7 @@
     let areaName = '';
     const option = event.option;
     this.items[i].monitorPoint = null;
+    this.items[i].profession = null;
     this.items[i].areaCode = null;
     this.items[i].device = null;
     
@@ -195,6 +227,26 @@
     }
   }
 
+  professionChange(value, i) {
+    this.items[i].deviceOptions = [];
+    this.items[i].device = null;
+    if (value) {
+      if (!!this.items[i].areaName) {
+        this.items[i].professionId = value.id;
+        this.http.get(environment.SERVER_BASH_URL + 'device/professionId', {params: this.items[i]}).subscribe((res: any) => {
+          if (res.code === 0) {
+            this.msgSrv.error(res.message);
+          } else {
+            this.items[i].deviceOptions = res.data;
+          }
+        });
+      } else {
+        this.msgSrv.error('������������ ������������');
+      }
+    }
+
+  }
+
   _disabledDate(current: Date): boolean {
     return current && current.getTime() > Date.now();
   }
@@ -207,17 +259,24 @@
       const areaName = '';
       const item = this.items[i];
       const queryItem: any = {};
-      if ((!!item.time) && (item.monitorPointOptions.length > 0)) {
+      if (item.monitorPointOptions.length > 0) {
         for (const key in item) {
           if (item[key]) {
             queryItem[key] = item[key];
           }
+        }
+        if (queryItem.profession) {
+          queryItem.professionId = queryItem.profession.id;
+          queryItem.professionName = queryItem.profession.name;
+          delete queryItem.profession;
         }
         if (queryItem.monitorPoint) {
           queryItem.monitorPointId = queryItem.monitorPoint.id;
           queryItem.monitorPointName = queryItem.monitorPoint.name;
           queryItem.monitorPointAddress = queryItem.monitorPoint.address;
           delete queryItem.monitorPoint;
+        } else {
+          queryItem.monitorPointName = queryItem.areaName;
         }
         delete queryItem.monitorPointOptions;
         if (queryItem.device) {

--
Gitblit v1.8.0