From fdde9a5cb356933bac26b64b67b53167ce2f41bd Mon Sep 17 00:00:00 2001 From: xufenglei <xufenglei> Date: Thu, 17 May 2018 10:03:29 +0800 Subject: [PATCH] 行业 优化 --- src/app/routes/report/report.component.ts | 2 src/app/routes/reports/demo/demo.component.ts | 61 ++++++--------- src/app/routes/reports/excel/excel.component.html | 93 +++++++++++++---------- src/app/routes/reports/excel/excel.component.ts | 30 ++++--- src/app/routes/reports/demo/demo.component.html | 4 5 files changed, 97 insertions(+), 93 deletions(-) diff --git a/src/app/routes/report/report.component.ts b/src/app/routes/report/report.component.ts index 49d5917..85643f5 100644 --- a/src/app/routes/report/report.component.ts +++ b/src/app/routes/report/report.component.ts @@ -234,7 +234,7 @@ for (const key in res.data.sortList[i]) { const split = key.split('-'); this.sensorKeys.forEach(sensor => { - if (sensor.key === split[0]) { + if (sensor.key === split[0] && res.data.sortList[i][key] != 0) { this.resultArr.push({ sensorName: sensor.name, monitorPointName: this.items[split[1]].showName, diff --git a/src/app/routes/reports/demo/demo.component.html b/src/app/routes/reports/demo/demo.component.html index cfc510a..5114441 100644 --- a/src/app/routes/reports/demo/demo.component.html +++ b/src/app/routes/reports/demo/demo.component.html @@ -92,7 +92,7 @@ </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> + [nzNotFoundContent]="'������������'" (ngModelChange)="getDevices(i)" nzShowSearch nzAllowClear> <nz-option *ngFor="let option of item.monitorPointOptions" [nzLabel]="option['name']" [nzValue]="option"> </nz-option> </nz-select> </div> @@ -104,7 +104,7 @@ <label >������</label> </div> <div nz-form-control class="flex-1"> - <nz-select [(ngModel)]="item.profession" name="profession{{item.id}}" [nzSize]="'large'" [nzPlaceHolder]="'��������� ������'" nzAllowClear (ngModelChange)="professionChange($event,i)" > + <nz-select [(ngModel)]="item.profession" name="profession{{item.id}}" [nzSize]="'large'" [nzPlaceHolder]="'��������� ������'" nzAllowClear (ngModelChange)="getDevices(i)" > <nz-option *ngFor="let option of professionOptions" [nzLabel]="option.name" [nzValue]="option" ></nz-option> </nz-select> </div> diff --git a/src/app/routes/reports/demo/demo.component.ts b/src/app/routes/reports/demo/demo.component.ts index ee873aa..50cbc76 100644 --- a/src/app/routes/reports/demo/demo.component.ts +++ b/src/app/routes/reports/demo/demo.component.ts @@ -82,10 +82,10 @@ } dimensionChange(value) { - this.items.forEach((item,index) => { + this.items.forEach((item, index) => { item.profession = null; item.monitorPoint = null; - item.device = null; + this.getDevices(index); }); if (value === 'monitorPoint') { this.professionShow = false; @@ -181,9 +181,8 @@ let areaName = ''; const option = event.option; this.items[i].monitorPoint = null; - this.items[i].profession = null; + //this.items[i].profession = null; this.items[i].areaCode = null; - this.items[i].device = null; switch (event.index) { case 0: @@ -211,42 +210,30 @@ this.items[i].monitorPointOptions = res.data; } }); + this.getDevices(i); } - - monitorPointChange(value, i) { - this.items[i].deviceOptions = []; + + getDevices(i) { this.items[i].device = null; - if (value) { - this.http.get(environment.SERVER_BASH_URL + 'device/monitorPointId', {params: {monitorPointId: value.id}}).subscribe((res: any) => { - if (res.code === 0) { - this.msgSrv.error(res.message); - } else { - this.items[i].deviceOptions = res.data; - } - }); + if (!!this.items[i].profession) { + this.items[i].professionId = this.items[i].profession.id; + } else { + this.items[i].professionId = null; } - } - - 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; - } - }); + if (!!this.items[i].monitorPoint) { + this.items[i].monitorPointId = this.items[i].monitorPoint.id; + } else { + this.items[i].monitorPointId = null; + } + return 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.msgSrv.error('������������ ������������'); + this.items[i].deviceOptions = res.data; } - } - + }); } - + _disabledDate(current: Date): boolean { return current && current.getTime() > Date.now(); } @@ -259,7 +246,7 @@ const areaName = ''; const item = this.items[i]; const queryItem: any = {}; - if (item.monitorPointOptions.length > 0) { + if (item.monitorPointOptions.length > 0 && item.deviceOptions.length > 0) { for (const key in item) { if (item[key]) { queryItem[key] = item[key]; @@ -296,7 +283,7 @@ break; } } - if (validate && this.timeType && query.reportType) { + if (validate) { delete query.sensors; if (this._sensors) { const sensors = []; @@ -311,7 +298,7 @@ query.type = this.timeType.value; sessionStorage.setItem('queryParams', JSON.stringify(query)); } else { - this.msgSrv.error('���������������������������������������'); + 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 dfd4b34..f0245c9 100644 --- a/src/app/routes/reports/excel/excel.component.html +++ b/src/app/routes/reports/excel/excel.component.html @@ -9,59 +9,21 @@ </div> <div nz-form-control class="flex-1"> <nz-popover [nzPlacement]="'bottomLeft'" [nzTrigger]="'click'"> - <nz-input [nzType]="'input'" nz-popover [ngModel]="sensorNames" name="sensorKeys" [nzReadonly]="true" [nzPlaceHolder]="'��������� ������'"> + <nz-input [nzType]="'input'" nz-popover [ngModel]="sensorNames" name="sensorKeys" [nzReadonly]="true" [nzPlaceHolder]="'��������� ������'" [nzSize]="'large'"> <ng-template #suffix> <i class="anticon anticon-down ant-cascader-picker-arrow" style="right: 1px;"></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> + <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 class="label-width-70"> - <label nz-form-item-required>���������</label> - </div> - <div nz-form-control class="flex-1"> - <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 class="label-width-70"> - <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> - </div> - </div> - <div nz-col [nzSpan]="6" class="mb-md"> - <div nz-form-item class="d-flex"> - <div nz-form-label class="label-width-70"> - <label>������</label> - </div> - <div nz-form-control class="flex-1"> - <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> - </div> - </div> - </div> - - <div nz-row [nzGutter]="24"> <div nz-col [nzSpan]="6" class="mb-md"> <div nz-form-item class="d-flex"> <div nz-form-label class="label-width-70"> @@ -99,7 +61,56 @@ </div> <div nz-row [nzGutter]="24"> + <div nz-col [nzSpan]="6" class="mb-md"> + <div nz-form-item class="d-flex"> + <div nz-form-label class="label-width-70"> + <label nz-form-item-required>���������</label> + </div> + <div nz-form-control class="flex-1"> + <nz-cascader (nzLoad)="areaLazyLoad($event)" [nzPlaceHolder]="'��������� ���/���/���'" [nzAllowClear]="false" [nzChangeOnSelect]="true" (nzSelect)="regionChange($event)" [nzSize]="'large'"> + </nz-cascader> + </div> + </div> + </div> + <div nz-col [nzSpan]="6" class="mb-md"> + <div nz-form-item class="d-flex"> + <div nz-form-label class="label-width-70"> + <label >������</label> + </div> + <div nz-form-control class="flex-1"> + <nz-select [(ngModel)]="query.professionId" name="profession" [nzSize]="'large'" [nzPlaceHolder]="'��������� ������'" nzAllowClear (ngModelChange)="getDevices()" > + <nz-option *ngFor="let option of professionOptions" [nzLabel]="option.name" [nzValue]="option.id" ></nz-option> + </nz-select> + </div> + </div> + </div> + <div nz-col [nzSpan]="6" class="mb-md"> + <div nz-form-item class="d-flex"> + <div nz-form-label class="label-width-70"> + <label>������������</label> + </div> + <div nz-form-control class="flex-1"> + <nz-select [(ngModel)]="query.monitorPointId" name="monitorPoint" [nzPlaceHolder]="'��������� ������������'" [nzSize]="'large'" + [nzNotFoundContent]="'������������'" (ngModelChange)="getDevices()" nzShowSearch nzAllowClear> + <nz-option *ngFor="let option of monitorPointOptions" [nzLabel]="option['name']" [nzValue]="option['id']"> </nz-option> + </nz-select> + </div> + </div> + </div> + <div nz-col [nzSpan]="6" class="mb-md"> + <div nz-form-item class="d-flex"> + <div nz-form-label class="label-width-70"> + <label>������</label> + </div> + <div nz-form-control class="flex-1"> + <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> + </div> + </div> </div> + <div nz-row [nzGutter]="24"> <div nz-col [nzSpan]="6" class="mb-md"> <button nz-button type="submit" [nzType]="'primary'" [nzSize]="'large'">������</button> diff --git a/src/app/routes/reports/excel/excel.component.ts b/src/app/routes/reports/excel/excel.component.ts index 0d8244e..8e4dba4 100644 --- a/src/app/routes/reports/excel/excel.component.ts +++ b/src/app/routes/reports/excel/excel.component.ts @@ -26,6 +26,7 @@ {value: 'day', label: '���', format: 'YYYY-MM-DD'}, {value: 'hour', label: '���', format: 'YYYY-MM-DD HH'} ]; + public professionOptions = []; private treeClickStream: Subject<any> = new Subject<any>(); private _sensors: {[key: string]: string} = {}; @@ -52,6 +53,13 @@ this.msgSrv.error(res.message); } else { this.sensorOptions.push({id: -1, name: '������', isExpanded: true, children: res.data}); + } + }); + 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; } }); } @@ -128,7 +136,6 @@ const option = event.option; this.query.areaCode = null; this.query.monitorPointId = null; - this.query.mac = null; switch (event.index) { case 0: name = 'provinceCode'; @@ -151,20 +158,19 @@ this.monitorPointOptions = res.data; } }); + this.getDevices(); + } - monitorPointChange(value) { + getDevices() { this.query.mac = null; - this.deviceOptions = []; - if (value) { - this.http.get(environment.SERVER_BASH_URL + 'device/monitorPointId', {params: {monitorPointId: value}}).subscribe((res: any) => { - if (res.code === 0) { - this.msgSrv.error(res.message); - } else { - this.deviceOptions = res.data; - } - }); - } + return this.http.get(environment.SERVER_BASH_URL + 'device/professionId', {params: this.query}).subscribe((res: any) => { + if (res.code === 0) { + this.msgSrv.error(res.message); + } else { + this.deviceOptions = res.data; + } + }); } reportQuery() { -- Gitblit v1.8.0