xufenglei
2018-05-17 fdde9a5cb356933bac26b64b67b53167ce2f41bd
行业 优化
5 files modified
190 ■■■■ changed files
src/app/routes/report/report.component.ts 2 ●●● patch | view | raw | blame | history
src/app/routes/reports/demo/demo.component.html 4 ●●●● patch | view | raw | blame | history
src/app/routes/reports/demo/demo.component.ts 61 ●●●●● patch | view | raw | blame | history
src/app/routes/reports/excel/excel.component.html 93 ●●●●● patch | view | raw | blame | history
src/app/routes/reports/excel/excel.component.ts 30 ●●●●● patch | view | raw | blame | history
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,
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>
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;
    }
  }
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>
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() {