From 780f76a3e8dd68abe6b007006f85a76991ea2c54 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Mon, 16 Apr 2018 13:40:28 +0800
Subject: [PATCH] Merge branch 'develop' of http://blit.7drlb.com:8888/r/screen-frontend into develop

---
 src/app/routes/systems/organization/organization-list/organization-list.component.ts   |    4 
 src/app/routes/report/report.component.html                                            |   11 
 src/app/routes/systems/registration/registration.component.ts                          |   72 ++++++
 src/app/routes/systems/systems.module.ts                                               |    7 
 src/app/routes/report/report.component.ts                                              |  111 +++++++++
 src/app/routes/reports/demo/demo.component.ts                                          |  164 ++++++++++++--
 src/app/routes/reports/excel/excel.component.html                                      |   44 ++-
 src/app/routes/reports/excel/excel.component.ts                                        |  133 ++++++++++-
 src/app/routes/systems/organization/organization-list/organization-list.component.html |    2 
 src/assets/app-data.json                                                               |    7 
 src/app/routes/reports/demo/demo.component.html                                        |   66 ++++-
 src/app/routes/systems/registration/registration.component.html                        |   27 ++
 12 files changed, 563 insertions(+), 85 deletions(-)

diff --git a/src/app/routes/report/report.component.html b/src/app/routes/report/report.component.html
index 42bf6e2..624bb1b 100644
--- a/src/app/routes/report/report.component.html
+++ b/src/app/routes/report/report.component.html
@@ -12,7 +12,7 @@
 			<div class="t_bg">
 				<img src="./assets/img/logo.png">
 				
-				<h1>{{title}}������������������������</h1>
+				<h1>{{title}}������������������</h1>
 				<div class="container">
 					<div class="title">
 						<div class="title_left"></div>
@@ -25,6 +25,10 @@
 					</div>
 				</div>
 				
+				
+				
+				
+				
 				<div class="content">
 					<div *ngFor="let item of items;let i = index">
 						<div class="{{i % 2 == 0 ? 'left' : 'right'}}">
@@ -34,8 +38,8 @@
 								<div class="text_t_right"></div>
 								<div class="clear_fix"></div>
 							</div>
-							<p class="text1">���������������{{item.monitorPointAddress}}</p>
-							<p class="text1">���������������������{{item.deviceCount}}���</p>
+							<p *ngIf="item.monitorPointId" class="text1">���������������{{item.monitorPointAddress}}</p>
+							<p class="text1">������������������{{item.deviceCount}}���</p>
 							<div class="clear_fix"></div>
 						</div> 
 					</div>
@@ -48,6 +52,7 @@
 			<div *ngFor="let i of sensorArr">
 				<div id="mydiv{{i}}" style="height: 485.35px; width: 1000px"></div>
 			</div>
+			<!-- <div id="pieChar" style="height: 485.35px; width: 1000px"></div> -->
 		</div>
 
 		<div class="bg"  *ngIf="!spinning">
diff --git a/src/app/routes/report/report.component.ts b/src/app/routes/report/report.component.ts
index 64d1127..4fcfc16 100644
--- a/src/app/routes/report/report.component.ts
+++ b/src/app/routes/report/report.component.ts
@@ -2,7 +2,6 @@
 import {NzMessageService, NzModalService} from 'ng-zorro-antd';
 import {Component, OnInit, Injector} from '@angular/core';
 import {HttpClient} from '@angular/common/http';
-import {ActivatedRoute} from '@angular/router';
 import * as echarts from 'echarts';
 import * as $ from 'jquery';
 
@@ -69,7 +68,6 @@
   constructor(
     public injector: Injector,
     public http: HttpClient,
-    public activeRoute: ActivatedRoute,
     public msgSrv: NzMessageService
   ) {
     for (let index = 0; index < 30; index++) {
@@ -77,8 +75,93 @@
     }
   }
 
+  private pieCharOption: any = {
+    title: {
+      text: 'AQI������������������������',
+      x: 'center'
+    },
+    tooltip: {
+      trigger: 'item',
+      formatter: "{a} <br/>{b}: {c} ({d}%)"
+    },
+    legend: {
+      //x : 'center',
+      top: '10%',
+      data: ['PM 2.5', 'PM 10', '���������������CO���', '���������������SO������', '���������O������', '���������������NO������']
+    },
+    graphic: [{
+      type: 'text',
+      left: '24%',
+      top: '49%',
+      style: {
+        text: '������������'
+      }
+    }, {
+      type: 'text',
+      left: '74%',
+      top: '49%',
+      style: {
+        text: '{b}'
+      }
+    }
+    ],
+    series: [
+      {
+        name: '������������',
+        type: 'pie',
+        radius: ['30%', '50%'],
+        center: ['25%', '50%'],
+        label: {
+          normal: {
+            formatter: "{b}:{d}%"
+          }
+        },
+        labelLine: {
+          normal: {
+            show: true
+          }
+        },
+        data: [
+          {value: 100, name: 'PM 2.5'},
+          {value: 100, name: 'PM 10'},
+          {value: 200, name: '���������������CO���'},
+          {value: 200, name: '���������������SO������'},
+          {value: 100, name: '���������O������'},
+          {value: 100, name: '���������������NO������'}
+        ]
+      },
+      {
+        name: '������������',
+        type: 'pie',
+        radius: ['30%', '50%'],
+        center: ['75%', '50%'],
+        label: {
+          normal: {
+            formatter: "{b}:{d}%",
+          }
+        },
+        labelLine: {
+          normal: {
+            show: true,
+          }
+        },
+        data: [
+          {value: 0, name: 'PM 2.5'},
+          {value: 0, name: 'PM 10'},
+          {value: 100, name: '���������������CO���'},
+          {value: 100, name: '���������������SO������'},
+          {value: 100, name: '���������O������'},
+          {value: 100, name: '���������������NO������'}
+
+        ]
+      }
+    ]
+  };
+
   ngOnInit() {
-    this.activeRoute.queryParams.subscribe(params => {
+    const params = JSON.parse(sessionStorage.getItem("queryParams"));
+    if (!!params) {
+      localStorage.removeItem("queryParams");
       const items = this.items = JSON.parse(params.items);
       const timeType = params.type;
       this.http.get(environment.SERVER_BASH_URL + 'report/compare', {params: params}).subscribe((res: any) => {
@@ -87,6 +170,7 @@
         } else {
           const option = this.echartOption;
           const sensors = res.data.sensors;
+          const deviceCounts = res.data.deviceCounts;
           const timeArr = this.timeArr;
           const label = timeArr[this.typeArr.indexOf(timeType)];
           option.xAxis.data = res.data.times;
@@ -105,11 +189,15 @@
             }
             for (let i = 0; i < items.length; i++) {
               this.title = items[i].formatTime;
-              const legendName = items[i].formatTime + label + (items[i].mac ? items[i].deviceName : items[i].monitorPointName);
+              items[i].deviceCount = deviceCounts[i];
+              if (!items[i].monitorPointid) {
+                items[i].monitorPointName = items[i].areaName
+              }
+              const legendName = items[i].formatTime + label + (items[i].mac ? '������:' + items[i].deviceName : (items[i].monitorPointid ? '���������:' + items[i].monitorPointName : items[i].areaName));
               option.legend.data[i] = legendName;
               option.series.push({
                 name: legendName,
-                data: res.data.datas[i]['data' + i][0][sensorKey],
+                data: res.data.datas[i][sensorKey],
                 type: params.reportType,
                 smooth: true,
                 itemStyle: {
@@ -134,8 +222,19 @@
           for (let i = 0; i < title.length; i++) {
             this.title += title[i] + timeArr[i];
           }
+          if (sensors.length % 2 == 0) {
+            this.pieCharOption.backgroundColor = 'rgba(0,0,0,0)';
+          } else {
+            this.pieCharOption.backgroundColor = 'rgba(23,133,23,0.06)';
+          }
+//          const myChart = echarts.init(document.getElementById('pieChar'));
+//          myChart.setOption(this.pieCharOption, true);
+//          window.onresize = myChart.resize;
         }
       });
-    });
+    } else {
+      this.msgSrv.error("������������������������������������");
+      setTimeout("window.close();", 1000);
+    }
   }
 }
diff --git a/src/app/routes/reports/demo/demo.component.html b/src/app/routes/reports/demo/demo.component.html
index a88f325..529fe8e 100644
--- a/src/app/routes/reports/demo/demo.component.html
+++ b/src/app/routes/reports/demo/demo.component.html
@@ -2,22 +2,34 @@
 <nz-card [nzBordered]="false">
 	<form nz-form  (ngSubmit)="reportQuery()" [nzLayout]="'inline'">
 		<div nz-row [nzGutter]="24">
-			<div nz-col [nzSpan]="6" class="mb-md">
+			<div nz-col [nzSpan]="5" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
-						<label>&nbsp;&nbsp;&nbsp;���&nbsp;&nbsp;&nbsp;&nbsp;���</label>
+						<label>&nbsp;&nbsp;&nbsp;���&nbsp;&nbsp;&nbsp;���</label>
 					</div>
 					<div nz-form-control class="flex-1">
-						<nz-select [nzMode]="'multiple'" [(ngModel)]="query.sensorKey" name="sensorKey" [nzSize]="'large'" [nzPlaceHolder]="'���������'">
+						<!-- <nz-select [nzMode]="'multiple'" [(ngModel)]="query.sensorKeys" name="sensorKeys" [nzSize]="'large'" [nzPlaceHolder]="'���������'">
 							<nz-option *ngFor="let option of sensorOptions" [nzLabel]="option.name" [nzValue]="option.sensorKey + '-' + option.name + '-' + option.unit"></nz-option>
-            			</nz-select>
+            			</nz-select> -->
+                        <nz-popover [nzPlacement]="'bottomLeft'" [nzTrigger]="'hover'">
+                            <nz-input [nzType]="'input'" nz-popover [ngModel]="sensorNames" name="sensorKeys" [nzReadonly]="true" [nzPlaceHolder]="'��������� ������'">
+                                <ng-template #suffix>
+                                    <i class="anticon anticon-down ant-cascader-picker-arrow "></i>
+                                </ng-template>
+                            </nz-input>
+                            <ng-template #nzTemplate>
+                                <div [ngStyle]="{'width': '240px', 'height': '240px', 'overflow-y' :'auto'}">
+                                    <nz-tree [nzNodes]="sensorOptions" (nzActivate)="onTreeClickSelect($event)" (nzDeactivate)="onTreeClickSelect($event)" [nzCheckable]="true" (nzCheck)="onSensorSelect($event)"></nz-tree>
+                                </div>
+                            </ng-template>
+                        </nz-popover>
 					</div>
 				</div>
 			</div>
-			<div nz-col [nzSpan]="6" class="mb-md">
+			<div nz-col [nzSpan]="5" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
-						<label nz-form-item-required>������</label>
+						<label nz-form-item-required>���&nbsp;���</label>
 					</div>
 					<div nz-form-control class="flex-1">
 						<nz-select [(ngModel)]="timeType" name="timeType" [nzSize]="'large'" [nzPlaceHolder]="'���������'">
@@ -26,7 +38,7 @@
 					</div>
 				</div>
 			</div>
-			<div nz-col [nzSpan]="6" class="mb-md">
+			<div nz-col [nzSpan]="5" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
 						<label nz-form-item-required>������</label>
@@ -38,7 +50,7 @@
 					</div>
 				</div>
 			</div>
-			<div nz-col [nzSpan]="6" class="mb-md" *ngIf="items.length < 2">
+			<div nz-col [nzSpan]="5" class="mb-md" *ngIf="items.length < 2">
 				<button nz-button type="button" [nzType]="'primary'" [nzSize]="'large'" (click)="addItem()">
 					<!-- <i class="anticon anticon-plus"></i> -->
 					<i class="anticon anticon-plus-circle-o"></i>
@@ -49,43 +61,55 @@
 		</div>
 
 		<div nz-row [nzGutter]="24" *ngFor="let item of items;let i = index">
-			<div nz-col [nzSpan]="6" class="mb-md">
+			<div nz-col [nzSpan]="5" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
-						<label nz-form-item-required>���������</label>
+						<label nz-form-item-required>���������</label>
 					</div>
 					<div nz-form-control class="flex-1">
-						<nz-select [(ngModel)]="item.monitorPoint" name="monitorPoint{{item.id}}" nzAllowClear [nzPlaceHolder]="'���������'" [nzFilter]="false" [nzSize]="'large'"  
-							(nzSearchChange)="searchChange($event,i)" [nzNotFoundContent]="'������������'" (ngModelChange)="monitorPointChange($event,i)" nzShowSearch> 
-							<nz-option *ngFor="let option of monitorPointOptions"  [nzLabel]="option['name']" [nzValue]="option"> </nz-option> 
+                        <nz-cascader (nzLoad)="areaLazyLoad($event,i)" [nzPlaceHolder]="'��������� ���/���/���'" [nzAllowClear]="false" [nzChangeOnSelect]="true" (nzSelect)="regionChange($event,i)">
+                        </nz-cascader>
+					</div>
+				</div>
+			</div>
+
+			<div nz-col [nzSpan]="5" class="mb-md">
+				<div nz-form-item class="d-flex">
+					<div nz-form-label>
+						<label>���������</label>
+					</div>
+					<div nz-form-control class="flex-1">
+						<nz-select [(ngModel)]="item.monitorPoint" name="monitorPoint{{item.id}}" [nzPlaceHolder]="'��������� ���������'" [nzSize]="'large'"  
+							[nzNotFoundContent]="'������������'" (ngModelChange)="monitorPointChange($event,i)" nzShowSearch nzAllowClear> 
+							<nz-option *ngFor="let option of item.monitorPointOptions"  [nzLabel]="option['name']" [nzValue]="option"> </nz-option> 
 						</nz-select>
 					</div>
 				</div>
 			</div>
-			<div nz-col [nzSpan]="6" class="mb-md">
+			<div nz-col [nzSpan]="5" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
-						<label>&nbsp;&nbsp;������</label>
+						<label>&nbsp;&nbsp;���&nbsp;���</label>
 					</div>
 					<div nz-form-control class="flex-1">
-						<nz-select [(ngModel)]="item.device" name="mac{{item.id}}" [nzSize]="'large'" nzAllowClear [nzPlaceHolder]="'���������'">
+						<nz-select [(ngModel)]="item.device" name="mac{{item.id}}" [nzSize]="'large'" [nzPlaceHolder]="'��������� ������'" [nzNotFoundContent]="'������������'" nzShowSearch nzAllowClear>
 							<nz-option *ngFor="let option of item.deviceOptions" [nzLabel]="option.name" [nzValue]="option" ></nz-option>
             			</nz-select>
 					</div>
 				</div>
 			</div>
-			<div nz-col [nzSpan]="6" class="mb-md">
+			<div nz-col [nzSpan]="5" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
 						<label nz-form-item-required>������</label>
 					</div>
 					<div nz-form-control class="flex-1">
-						<nz-datepicker style="width: 100%;" [(ngModel)]="item.time" name="time{{item.id}}" [nzPlaceHolder]="'���������'" [nzFormat]="timeType.format" [nzDisabledDate]="_disabledDate"
+						<nz-datepicker style="width: 100%;" [(ngModel)]="item.time" name="time{{item.id}}" [nzPlaceHolder]="'��������� ������'" [nzFormat]="timeType.format" [nzDisabledDate]="_disabledDate"
 							[nzMode]="timeType.value=='hour'||timeType.value=='day'?'day':'month'" [nzShowTime]="timeType.value=='hour'?true:false" [nzSize]="'large'"></nz-datepicker>
 					</div>
 				</div>
 			</div>
-			<div nz-col [nzSpan]="6" class="mb-md" *ngIf="items.length > 1">
+			<div nz-col [nzSpan]="4" class="mb-md" *ngIf="items.length > 1">
 				<button nz-button type="button" [nzType]="'danger'" [nzSize]="'large'" (click)="items.splice(i, 1)">
 					<i class="anticon anticon-minus-circle-o dynamic-delete-button"></i>
 					<span>������������������</span>
@@ -95,7 +119,9 @@
 
 		<div nz-row [nzGutter]="24">
 			<div nz-col [nzSpan]="6" class="mb-md">
-				<button nz-button type="submit" [nzType]="'primary'" [nzSize]="'large'">������</button>
+				<button nz-button type="submit" [nzType]="'primary'" [nzSize]="'large'">
+					<a target="_blank" [routerLink]="['/report']" (click)="reportQuery()">������</a>
+				</button>
 				<!-- <button nz-button type="reset" [nzSize]="'large'" class="mx-sm" (click)="load()">������</button> -->
 			</div>
 		</div>
diff --git a/src/app/routes/reports/demo/demo.component.ts b/src/app/routes/reports/demo/demo.component.ts
index 37cf5ed..305c4b6 100644
--- a/src/app/routes/reports/demo/demo.component.ts
+++ b/src/app/routes/reports/demo/demo.component.ts
@@ -3,7 +3,10 @@
 import {NzMessageService} from 'ng-zorro-antd';
 import {Component, OnInit} from '@angular/core';
 import {HttpClient} from '@angular/common/http';
-import {Router} from '@angular/router';
+import {CascaderOption} from 'ng-zorro-antd/src/cascader/nz-cascader.component';
+import {AreacodeService} from '@business/services/http/areacode.service';
+import {NzTreeComponent} from 'ng-tree-antd';
+import {Subject} from 'rxjs/Subject';
 
 @Component({
   selector: 'app-demo',
@@ -25,19 +28,27 @@
     {value: 'bar', label: '���������'},
     {value: 'line', label: '���������'}
   ];
-  public monitorPointOptions = [];
-  public items = [{
+
+  public items: any[] = [{
     id: 0,
     monitorPoint: null,
     device: null,
     time: null,
+    monitorPointOptions: [],
     deviceOptions: []
   }];
+
+  private treeClickStream: Subject<any> = new Subject<any>();
+  private _sensors: {[key: string]: string} = {};
+  private _sensorNames: string;
+  get sensorNames(): string {
+    return this._sensorNames;
+  }
 
   constructor(
     public http: HttpClient,
     public dateSrv: DateService,
-    public router: Router,
+    private areacodeService: AreacodeService,
     public msgSrv: NzMessageService
   ) {
     this.timeType = this.typeOptions[1];
@@ -49,9 +60,52 @@
       if (res.code === 0) {
         this.msgSrv.error(res.message);
       } else {
-        this.sensorOptions = res.data;
+        this.sensorOptions.push({id: -1, name: '������', isExpanded: true, children: res.data});
       }
     });
+
+  }
+
+  public onTreeClickSelect(event): void {
+    this.treeClickStream.next(event);
+  }
+
+  public onSensorSelect(event): void {
+    const data = event.node.data;
+    if (data.id === -1 && data.halfChecked === false) {
+      if (!!data.checked) {
+        this.sensorOptions[0].children.forEach(
+          sensor => {
+            this._sensors[sensor.id] = sensor.sensorKey + '-' + sensor.name + '-' + sensor.unit;
+          }
+        );
+      } else {
+        this._sensors = {};
+      }
+    } else {
+      if (!!data.checked) {
+        this._sensors[data.id] = data.sensorKey + '-' + data.name + '-' + data.unit;
+      } else {
+        delete this._sensors[data.id];
+      }
+    }
+    this.reloadSensorNames();
+
+  }
+  private reloadSensorNames(): void {
+    // ������������������������
+    setTimeout(() => {
+      this._sensorNames = '';
+      const sensorNameList = Object.keys(this._sensors).map(
+        id => {
+          const sensor = this.sensorOptions[0].children.find(item => {
+            return Number(id) === Number(item.id);
+          });
+          return sensor.name;
+        }
+      );
+      this._sensorNames = sensorNameList.join(', ');
+    }, 1);
   }
 
   addItem() {
@@ -61,23 +115,70 @@
       monitorPoint: null,
       device: null,
       time: null,
+      monitorPointOptions: [],
       deviceOptions: []
     });
   }
 
-  searchChange(searchText, i) {
-    if (searchText) {
-      const query = encodeURI(searchText);
-      if (query) {
-        this.http.get(environment.SERVER_BASH_URL + '/monitor-point/list/' + query).subscribe((res: any) => {
-          if (res.code === 0) {
-            this.msgSrv.error(res.message);
-          } else {
-            this.monitorPointOptions = res.data;
+  public areaLazyLoad(event: {option: CascaderOption, index: number, resolve: (children: CascaderOption[]) => void, reject: () => void}) {
+    const index = event['index'];
+    const option = event.option;
+    switch (index) {
+      case -1:
+        this.areacodeService.getProvinces().subscribe(
+          (res: {label: string, value: string}[]) => {
+            event.resolve(res);
           }
-        });
-      }
+        ); break;
+      case 0:
+        this.areacodeService.getCities(option.value).subscribe(
+          (res: {label: string, value: string}[]) => {
+            event.resolve(res);
+          }
+        ); break;
+      case 1:
+        this.areacodeService.getAreas(option.value).subscribe(
+          (res: {label: string, value: string}[]) => {
+            event.resolve(res);
+          }
+        ); break;
     }
+  }
+
+  public regionChange(event: {option: CascaderOption, index: number}, i) {
+    let name = '';
+    let areaName = '';
+    const option = event.option;
+    this.items[i].monitorPoint = null;
+    this.items[i].areaCode = null;
+    this.items[i].device = null;
+    
+    switch (event.index) {
+      case 0:
+        name = 'provinceCode';
+        this.items[i].provinceCode = option.value;
+        this.items[i].cityCode = null;
+        areaName = option.label;
+        break;
+      case 1:
+        name = 'cityCode';
+        this.items[i].cityCode = option.value;
+        areaName = option.parent.label + '/' + option.label;
+        break;
+      case 2:
+        name = 'areaCode';
+        this.items[i].areaCode = option.value;
+        areaName = option.parent.parent.label + '/' + option.parent.label + '/' + option.label;
+        break;
+    }
+    this.items[i].areaName = areaName;
+    this.http.get(environment.SERVER_BASH_URL + 'monitor-point/list/region', {params: {name: name, value: option.value}}).subscribe((res: any) => {
+      if (res.code === 0) {
+        this.msgSrv.error(res.message);
+      } else {
+        this.items[i].monitorPointOptions = res.data;
+      }
+    });
   }
 
   monitorPointChange(value, i) {
@@ -103,24 +204,30 @@
     let validate = true;
     const queryItems = [];
     for (let i = 0; i < this.items.length; i++) {
+      let areaName = '';
       let item = this.items[i];
       let queryItem: any = {};
-      if (item.monitorPoint && item.time) {
+      if ((!!item.time) && (item.monitorPointOptions.length > 0)) {
         for (var key in item) {
           if (item[key]) {
             queryItem[key] = item[key];
           }
         }
-        queryItem.monitorPointId = queryItem.monitorPoint.id;
-        queryItem.monitorPointName = queryItem.monitorPoint.name;
-        queryItem.monitorPointAddress = queryItem.monitorPoint.address;
-        delete queryItem.monitorPoint;
+        if (queryItem.monitorPoint) {
+          queryItem.monitorPointId = queryItem.monitorPoint.id;
+          queryItem.monitorPointName = queryItem.monitorPoint.name;
+          queryItem.monitorPointAddress = queryItem.monitorPoint.address;
+          delete queryItem.monitorPoint;
+        }
+        delete queryItem.monitorPointOptions;
         if (queryItem.device) {
           queryItem.mac = queryItem.device.mac;
           queryItem.deviceName = queryItem.device.name;
           delete queryItem.device;
         }
-        queryItem.deviceCount = queryItem.deviceOptions.length;
+        if (queryItem.deviceOptions && queryItem.deviceOptions.length > 0) {
+          queryItem.deviceCount = queryItem.deviceOptions.length;
+        }
         delete queryItem.deviceOptions;
         queryItem.formatTime = this.dateSrv.date_format(queryItem.time, this.timeType.format);
         delete queryItem.time;
@@ -131,14 +238,21 @@
       }
     }
     if (validate && this.timeType && query.reportType) {
-      if (query.sensorKey && query.sensorKey.length > 0) {
-        query.sensors = JSON.stringify(query.sensorKey);
+      if (this._sensors) {
+        const sensors = [];
+        for (var key in this._sensors) {
+          sensors.push(this._sensors[key]);
+        }
+        if (sensors.length > 0) {
+          query.sensors = JSON.stringify(sensors);
+        }
       }
       query.items = JSON.stringify(queryItems);
       query.type = this.timeType.value;
-      this.router.navigate(['report'], {queryParams: query});
+      sessionStorage.setItem("queryParams", JSON.stringify(query));
     } else {
       this.msgSrv.error('���������������������������������������');
+      return false;
     }
   }
 }
diff --git a/src/app/routes/reports/excel/excel.component.html b/src/app/routes/reports/excel/excel.component.html
index 6ba33e1..4c8d63d 100644
--- a/src/app/routes/reports/excel/excel.component.html
+++ b/src/app/routes/reports/excel/excel.component.html
@@ -5,23 +5,43 @@
 			<div nz-col [nzSpan]="6" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
-						<label>&nbsp;&nbsp;������</label>
+						<label>������</label>
 					</div>
 					<div nz-form-control class="flex-1">
-						<nz-select [(ngModel)]="query.sensorKey" name="sensorKey" [nzSize]="'large'" [nzPlaceHolder]="'���������'" [nzMode]="'multiple'">
-							<nz-option *ngFor="let option of sensorOptions" [nzLabel]="option.name" [nzValue]="option.sensorKey + '-' + option.name + '-' + option.unit" ></nz-option>
-            			</nz-select>
+                       <nz-popover [nzPlacement]="'bottomLeft'" [nzTrigger]="'hover'">
+                            <nz-input [nzType]="'input'" nz-popover [ngModel]="sensorNames" name="sensorKeys" [nzReadonly]="true" [nzPlaceHolder]="'��������� ������'">
+                                <ng-template #suffix>
+                                    <i class="anticon anticon-down ant-cascader-picker-arrow "></i>
+                                </ng-template>
+                            </nz-input>
+                            <ng-template #nzTemplate>
+                                <div [ngStyle]="{'width': '240px', 'height': '240px', 'overflow-y' :'auto'}">
+                                    <nz-tree [nzNodes]="sensorOptions" (nzActivate)="onTreeClickSelect($event)" (nzDeactivate)="onTreeClickSelect($event)" [nzCheckable]="true" (nzCheck)="onSensorSelect($event)"></nz-tree>
+                                </div>
+                            </ng-template>
+                        </nz-popover>
 					</div>
 				</div>
 			</div>
 			<div nz-col [nzSpan]="6" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
-						<label nz-form-item-required>���������</label>
+						<label nz-form-item-required>���������</label>
 					</div>
 					<div nz-form-control class="flex-1">
-						<nz-select [(ngModel)]="query.monitorPointId" name="monitorPoint" nzAllowClear [nzPlaceHolder]="'���������'" [nzFilter]="false" [nzSize]="'large'"  
-							(nzSearchChange)="searchChange($event)" [nzNotFoundContent]="'������������'" (ngModelChange)="monitorPointChange($event)" nzShowSearch> 
+                        <nz-cascader (nzLoad)="areaLazyLoad($event)" [nzPlaceHolder]="'��������� ���/���/���'" [nzAllowClear]="false" [nzChangeOnSelect]="true" (nzSelect)="regionChange($event)">
+                        </nz-cascader>
+					</div>
+				</div>
+			</div>
+			<div nz-col [nzSpan]="6" class="mb-md">
+				<div nz-form-item class="d-flex">
+					<div nz-form-label>
+						<label>���������</label>
+					</div>
+					<div nz-form-control class="flex-1">
+						<nz-select [(ngModel)]="query.monitorPointId" name="monitorPoint" [nzPlaceHolder]="'��������� ���������'" [nzSize]="'large'"  
+							[nzNotFoundContent]="'������������'" (ngModelChange)="monitorPointChange($event)" nzShowSearch nzAllowClear> 
 							<nz-option *ngFor="let option of monitorPointOptions"  [nzLabel]="option['name']" [nzValue]="option['id']"> </nz-option> 
 						</nz-select>
 					</div>
@@ -33,7 +53,7 @@
 						<label>������</label>
 					</div>
 					<div nz-form-control class="flex-1">
-						<nz-select [(ngModel)]="query.mac" name="mac" [nzSize]="'large'" nzAllowClear [nzPlaceHolder]="'���������'" >
+						<nz-select [(ngModel)]="query.mac" name="mac" [nzSize]="'large'" [nzPlaceHolder]="'��������� ������'" [nzNotFoundContent]="'������������'" nzShowSearch nzAllowClear>
 							<nz-option *ngFor="let option of deviceOptions" [nzLabel]="option.name" [nzValue]="option.mac" ></nz-option>
             			</nz-select>
 					</div>
@@ -45,7 +65,7 @@
 			<div nz-col [nzSpan]="6" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
-						<label nz-form-item-required>������</label>
+						<label>������</label>
 					</div>
 					<div nz-form-control class="flex-1">
 						<nz-select [(ngModel)]="timeType" name="timeType" [nzSize]="'large'" [nzPlaceHolder]="'���������'">
@@ -60,7 +80,7 @@
 						<label nz-form-item-required>���������</label>
 					</div>
 					<div nz-form-control class="flex-1">
-						<nz-datepicker style="width: 100%;" [(ngModel)]="query.time" name="time" [nzPlaceHolder]="'���������'"  [nzSize]="'large'" [nzFormat]="timeType.format" 
+						<nz-datepicker style="width: 100%;" [(ngModel)]="query.time" name="time" [nzPlaceHolder]="'��������� ������'"  [nzSize]="'large'" [nzFormat]="timeType.format" 
 							[nzMode]="timeType.value=='hour'||timeType.value=='day'?'day':'month'" [nzShowTime]="timeType.value=='hour'?true:false"></nz-datepicker>
 					</div>
 				</div>
@@ -68,10 +88,10 @@
 			<div nz-col [nzSpan]="6" class="mb-md">
 				<div nz-form-item class="d-flex">
 					<div nz-form-label>
-						<label >&nbsp;&nbsp;&nbsp;&nbsp;���</label>
+						<label >���������</label>
 					</div>
 					<div nz-form-control class="flex-1">
-						<nz-datepicker style="width: 100%;" [(ngModel)]="query.timeb" name="timeb" [nzPlaceHolder]="'���������'" [nzSize]="'large'" [nzFormat]="timeType.format" 
+						<nz-datepicker style="width: 100%;" [(ngModel)]="query.timeb" name="timeb" [nzPlaceHolder]="'��������� ������'" [nzSize]="'large'" [nzFormat]="timeType.format" 
 							[nzMode]="timeType.value=='hour'||timeType.value=='day'?'day':'month'" [nzShowTime]="timeType.value=='hour'?true:false"></nz-datepicker>
 					</div>
 				</div>
diff --git a/src/app/routes/reports/excel/excel.component.ts b/src/app/routes/reports/excel/excel.component.ts
index a6fce42..5d882ba 100644
--- a/src/app/routes/reports/excel/excel.component.ts
+++ b/src/app/routes/reports/excel/excel.component.ts
@@ -4,6 +4,10 @@
 import {Component, OnInit, Inject} from '@angular/core';
 import {HttpClient} from '@angular/common/http';
 import {ITokenService, DA_SERVICE_TOKEN} from '@delon/auth';
+import {CascaderOption} from 'ng-zorro-antd/src/cascader/nz-cascader.component';
+import {AreacodeService} from '@business/services/http/areacode.service';
+import {NzTreeComponent} from 'ng-tree-antd';
+import {Subject} from 'rxjs/Subject';
 
 @Component({
   selector: 'app-excel',
@@ -23,10 +27,18 @@
     {value: 'hour', label: '���', format: 'YYYY-MM-DD HH'}
   ];
 
+  private treeClickStream: Subject<any> = new Subject<any>();
+  private _sensors: {[key: string]: string} = {};
+  private _sensorNames: string;
+  get sensorNames(): string {
+    return this._sensorNames;
+  }
+
   constructor(
     public http: HttpClient,
     public dateSrv: DateService,
     public msgSrv: NzMessageService,
+    private areacodeService: AreacodeService,
     @Inject(DA_SERVICE_TOKEN) public tokenService: ITokenService
   ) {
     this.timeType = this.typeOptions[1];
@@ -39,24 +51,106 @@
       if (res.code === 0) {
         this.msgSrv.error(res.message);
       } else {
-        this.sensorOptions = res.data;
+        this.sensorOptions.push({id: -1, name: '������', isExpanded: true, children: res.data});
       }
     });
   }
 
-  searchChange(searchText) {
-    if (searchText) {
-      const query = encodeURI(searchText);
-      if (query) {
-        this.http.get(environment.SERVER_BASH_URL + '/monitor-point/list/' + query).subscribe((res: any) => {
-          if (res.code === 0) {
-            this.msgSrv.error(res.message);
-          } else {
-            this.monitorPointOptions = res.data;
+  public onTreeClickSelect(event): void {
+    this.treeClickStream.next(event);
+  }
+
+  public onSensorSelect(event): void {
+    const data = event.node.data;
+    if (data.id === -1 && data.halfChecked === false) {
+      if (!!data.checked) {
+        this.sensorOptions[0].children.forEach(
+          sensor => {
+            this._sensors[sensor.id] = sensor.sensorKey + '-' + sensor.name + '-' + sensor.unit;
           }
-        });
+        );
+      } else {
+        this._sensors = {};
+      }
+    } else {
+      if (!!data.checked) {
+        this._sensors[data.id] = data.sensorKey + '-' + data.name + '-' + data.unit;
+      } else {
+        delete this._sensors[data.id];
       }
     }
+    this.reloadSensorNames();
+
+  }
+  private reloadSensorNames(): void {
+    // ������������������������
+    setTimeout(() => {
+      this._sensorNames = '';
+      const sensorNameList = Object.keys(this._sensors).map(
+        id => {
+          const sensor = this.sensorOptions[0].children.find(item => {
+            return Number(id) === Number(item.id);
+          });
+          return sensor.name;
+        }
+      );
+      this._sensorNames = sensorNameList.join(', ');
+    }, 1);
+  }
+
+  public areaLazyLoad(event: {option: CascaderOption, index: number, resolve: (children: CascaderOption[]) => void, reject: () => void}) {
+    const index = event['index'];
+    const option = event.option;
+    switch (index) {
+      case -1:
+        this.areacodeService.getProvinces().subscribe(
+          (res: {label: string, value: string}[]) => {
+            event.resolve(res);
+          }
+        ); break;
+      case 0:
+        this.areacodeService.getCities(option.value).subscribe(
+          (res: {label: string, value: string}[]) => {
+            event.resolve(res);
+          }
+        ); break;
+      case 1:
+        this.areacodeService.getAreas(option.value).subscribe(
+          (res: {label: string, value: string}[]) => {
+            event.resolve(res);
+          }
+        ); break;
+    }
+  }
+
+  public regionChange(event: {option: CascaderOption, index: number}) {
+    let name = '';
+    const option = event.option;
+    this.query.areaCode = null;
+    this.query.monitorPointId = null;
+    this.query.mac = null;
+    switch (event.index) {
+      case 0:
+        name = 'provinceCode';
+        this.query.provinceCode = option.value;
+        this.query.cityCode = null;
+        break;
+      case 1:
+        name = 'cityCode';
+        this.query.cityCode = option.value;
+        break;
+      case 2:
+        name = 'areaCode';
+        this.query.areaCode = option.value;
+        break;
+    }
+    this.http.get(environment.SERVER_BASH_URL + 'monitor-point/list/region', {params: {name: name, value: option.value}}).subscribe((res: any) => {
+      if (res.code === 0) {
+        this.msgSrv.error(res.message);
+      } else {
+        this.monitorPointOptions = res.data;
+      }
+    });
   }
 
   monitorPointChange(value) {
@@ -75,15 +169,22 @@
 
   reportQuery() {
     const query = this.query;
-    if (this.timeType && query.monitorPointId && query.time) {
+    if (this.monitorPointOptions.length > 0 && query.time) {
       query.time = this.dateSrv.date_format(query.time, this.timeType.format);
       if (query.timeb) {
         query.timeb = this.dateSrv.date_format(query.timeb, this.timeType.format);
       }
-      if (query.sensorKey && query.sensorKey.length > 0) {
-        query.sensors = JSON.stringify(query.sensorKey);
-      }
       query.type = this.timeType.value;
+      if (this._sensors) {
+        const sensors = [];
+        for (var key in this._sensors) {
+          sensors.push(this._sensors[key]);
+        }
+        if (sensors.length > 0) {
+          query.sensors = JSON.stringify(sensors);
+        }
+      }
+
       let url = environment.SERVER_BASH_URL + 'report/excel?';
       for (const a in query) {
         if (query[a]) {
@@ -92,7 +193,7 @@
       }
       window.location.href = url + '_token=' + this.tokenService.get().token;
     } else {
-      this.msgSrv.error('������������������');
+      this.msgSrv.error('������������������������������������������������������������');
     }
   }
 }
diff --git a/src/app/routes/systems/organization/organization-list/organization-list.component.html b/src/app/routes/systems/organization/organization-list/organization-list.component.html
index 033bdb6..e1ed4eb 100644
--- a/src/app/routes/systems/organization/organization-list/organization-list.component.html
+++ b/src/app/routes/systems/organization/organization-list/organization-list.component.html
@@ -58,6 +58,8 @@
                               <nz-popconfirm [nzTitle]="'������������������'+grid.title+'���?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" >
                                 <a nz-popconfirm>������</a>
                               </nz-popconfirm>
+                            <span nz-table-divider></span>
+                            <a [routerLink]="['/systems/registration']" (click)="registration(row)">���������</a>
                      </td>
                 </tr>
               </tbody>
diff --git a/src/app/routes/systems/organization/organization-list/organization-list.component.ts b/src/app/routes/systems/organization/organization-list/organization-list.component.ts
index abe84f8..b1f794a 100644
--- a/src/app/routes/systems/organization/organization-list/organization-list.component.ts
+++ b/src/app/routes/systems/organization/organization-list/organization-list.component.ts
@@ -227,4 +227,8 @@
       this.organizationService.title = '������������';
     });
   }
+  
+  registration(row){
+      sessionStorage.setItem("organization", JSON.stringify(row));
+  }
 }
diff --git a/src/app/routes/systems/registration/registration.component.html b/src/app/routes/systems/registration/registration.component.html
new file mode 100644
index 0000000..b9ac9c9
--- /dev/null
+++ b/src/app/routes/systems/registration/registration.component.html
@@ -0,0 +1,27 @@
+<div class="content__title">
+	<h1>���������������({{organization.name}})</h1>
+</div>
+<nz-card [nzBordered]="false">
+	<div class="mb-md">
+		<button nz-button [nzType]="'primary'" [nzSize]="'large'" (click)="isVisible=true">
+			<i class="anticon anticon-plus"></i><span>������</span>
+		</button>
+	</div>
+	<simple-table #simpleTable [data]="dataUrl" [extraParams]="extraParams" [columns]="columns" [showTotal]="true" [ps]="10" [reqReName]="{pi: 'pageIndex',ps: 'pageSize'}" [resReName]="{list: 'data',total: 'total'}">
+	</simple-table> 
+</nz-card>
+
+<nz-modal [nzVisible]="isVisible" [nzTitle]="'���������������'" [nzContent]="modalContent" (nzOnCancel)="isVisible=false" (nzOnOk)="registrationOk()">
+    <ng-template #modalContent>
+		<form nz-form >
+			<div nz-form-item nz-row>
+				<div nz-form-label nz-col [nzSm]="6" [nzXs]="24">
+				    <label nz-form-item-required>������������</label>
+				</div>
+				<div nz-col [nzSm]="14" [nzXs]="24">
+					<nz-datepicker style="width: 100%;" [(ngModel)]="_date" name='_date' [nzFormat]="'YYYY-MM-DD'" [nzDisabledDate]="_disabledDate" [nzAllowClear]="false"></nz-datepicker>
+				</div>
+			</div>
+		</form>
+    </ng-template>
+</nz-modal>
diff --git a/src/app/routes/systems/registration/registration.component.ts b/src/app/routes/systems/registration/registration.component.ts
new file mode 100644
index 0000000..7a00abc
--- /dev/null
+++ b/src/app/routes/systems/registration/registration.component.ts
@@ -0,0 +1,72 @@
+import {environment} from "../../../../environments/environment";
+import {Component, OnInit, ViewChild} from '@angular/core';
+import {SimpleTableColumn} from "@delon/abc";
+import {_HttpClient} from '@delon/theme';
+import {Subject} from "rxjs";
+import * as moment from 'moment';
+import {NzMessageService} from "ng-zorro-antd";
+@Component({
+  selector: 'app-registration',
+  templateUrl: './registration.component.html',
+})
+export class RegistrationComponent implements OnInit {
+  constructor(
+    public msgSrv: NzMessageService,
+    private http: _HttpClient
+  ) {}
+
+  @ViewChild('simpleTable') simpleTable: {load: Function};
+
+  dataUrl = environment.SERVER_BASH_URL + 'machineactivate/list';
+
+  queryTextStream: Subject<string> = new Subject<string>();
+
+  extraParams: any = {};
+  organization: any = {};
+  columns: SimpleTableColumn[] = [
+    {title: '���������', index: 'activationCode'},
+    {
+      title: '������������', index: 'isUsed', format: function(machineActivate) {
+        return machineActivate.isUsed == 1 ? '���' : '���';
+      }
+    },
+    {
+      title: '������������', type: 'date', index: 'createTime', format: function(machineActivate) {
+        return moment(machineActivate.createTime).format('YYYY-MM-DD HH:mm:ss');
+      }
+    },
+    {
+      title: '������������', type: 'date', index: 'expireDate', format: function(machineActivate) {
+        return moment(machineActivate.expireDate).format('YYYY-MM-DD');
+      }
+    },
+  ];
+  isVisible: boolean = false;
+  _date = new Date(Date.now() + 3600 * 24 * 1 * 1000);
+
+  ngOnInit() {
+    const organization = this.organization = JSON.parse(sessionStorage.getItem("organization"));
+    this.extraParams.organizationId = organization.id;
+    this.queryTextStream.debounceTime(900).distinctUntilChanged().subscribe(value => {
+      this.load();
+    });
+  }
+
+  load() {
+    this.simpleTable.load();
+  }
+
+  _disabledDate(current: Date): boolean {
+    return current && current.getTime() < Date.now();
+  }
+
+  registrationOk() {
+    this.http.get(environment.SERVER_BASH_URL + '/machineactivate/machine', {organizationId: this.organization.id, expireDate: moment(this._date).format('YYYY-MM-DD')}).subscribe((res: any) => {
+      if (res.code == 1 && res.data == 1) {
+        this.isVisible = false;
+        this.msgSrv.success('������������������������');
+        this.load();
+      }
+    });
+  }
+}
diff --git a/src/app/routes/systems/systems.module.ts b/src/app/routes/systems/systems.module.ts
index d1f3d49..37edebf 100644
--- a/src/app/routes/systems/systems.module.ts
+++ b/src/app/routes/systems/systems.module.ts
@@ -15,6 +15,7 @@
 import { AreacodeService } from '@business/services/http/areacode.service';
 import { OrganizationConfigComponent } from './organization/organization-config/organization-config.component';
 import { OrganizationListComponent } from './organization/organization-list/organization-list.component';
+import { RegistrationComponent } from "./registration/registration.component";
 import { SensorsService } from '@business/services/http/sensors.service';
 import { BusinessModule } from '@business/business.module';
 
@@ -23,7 +24,8 @@
     path: '',
     children: [
       { path: 'account', component: AccountComponent },
-      { path: 'organization', component: OrganizationComponent }
+      { path: 'organization', component: OrganizationComponent },
+      { path: 'registration', component: RegistrationComponent }
     ]
   }
 ];
@@ -45,7 +47,8 @@
     AccountEditComponent,
     OrganizationComponent,
     OrganizationConfigComponent,
-    OrganizationListComponent
+    OrganizationListComponent,
+    RegistrationComponent
   ],
   providers: [ToolsService, SensorsService, OrganizationService, _HttpClient, FormBuilder, AreacodeService],
   entryComponents: COMPONENTS_NOROUNT
diff --git a/src/assets/app-data.json b/src/assets/app-data.json
index 9877414..1e7d1a2 100644
--- a/src/assets/app-data.json
+++ b/src/assets/app-data.json
@@ -79,7 +79,12 @@
                   {
                     "text": "������������",
                     "link": "/systems/organization"
-                    }
+                    },
+	                {
+		                "text": "���������������",
+		                "link": "/systems/registration",
+		                "hide": true
+	                }
                 ]
               }
             ]

--
Gitblit v1.8.0