fengxiang
2018-07-06 309d1f9d649daa08bb9b068af014749f6d4a5bce
src/app/routes/devices/monitor-point/monitor-point.component.ts
@@ -14,6 +14,8 @@
import { MonitorPointEditComponent } from 'app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component';
import { MonitorPointService } from '@business/services/http/monitor-point.service';
import { CoordinatesPickerComponent } from 'app/routes/map/coordinates-picker/coordinates-picker.component';
import { OrganizationService } from '@business/services/http/organization.service';
import { ExampleService } from '@business/services/util/example.service';
@Component({
@@ -23,10 +25,10 @@
})
export class MonitorPointComponent implements OnInit {
  public orgOptions = [];
  private monitorPoint: MonitorPoint;
  grid: Grid<MonitorPoint> = new Grid(null);
  queryMap = { text: '请输入名称', value: '' };
  queryMap: { mpointName?: string, organizationId?: number } = { mpointName: null, organizationId: null };
  queryTextStream: Subject<string> = new Subject<string>();
  private initPage() {
    this.monitorPoint = {
@@ -40,7 +42,12 @@
        format: (value: any, col: Column, row: any) => {
          value = value == null ? '' : value;
          if (row['areaNames'] != null) {
            return row['areaNames']['provinceName'] + row['areaNames']['cityName'] + row['areaNames']['areaName'] + value;
            return row['areaNames']['provinceName']
              + (!!row['areaNames']['cityName'] ? row['areaNames']['cityName'] : '')
              + (!!row['areaNames']['areaName'] ? row['areaNames']['areaName'] : '')
              + (!!row['areaNames']['townName'] ? row['areaNames']['townName'] : '')
              + (!!row['areaNames']['villageName'] ? row['areaNames']['villageName'] : '')
              + value;
          } else {
            return value;
          }
@@ -59,10 +66,10 @@
  constructor(
    private coorPickerService: CoorPickerService,
    private monitorPointService: MonitorPointService,
    private confirmServ: NzModalService,
    public msgSrv: NzMessageService,
    private modalHelper: ModalHelper,
    private organizationService: OrganizationService
  ) { }
  ngOnInit() {
@@ -73,9 +80,14 @@
      .subscribe(queryText => {
        this.load();
      });
    this.orgSelectChange();
  }
 public setOrganizationId(orgId) {
    this.queryMap.organizationId = orgId;
    this.load();
  }
  queryTextChanged($event) {
    this.queryTextStream.next(this.queryMap.value);
    this.queryTextStream.next(this.queryMap.mpointName);
  }
  load(reload: boolean = false) {
    if (reload) {
@@ -85,7 +97,13 @@
    setTimeout(() => {
      this.grid.loading = true;
    }, 1);
    this.monitorPointService.getPagingList(this.grid, this.queryMap.value).subscribe(
    const example = new ExampleService();
    const organizationId = !!this.queryMap.organizationId ? this.queryMap.organizationId : null;
    const mpointName = !!this.queryMap.mpointName ? '%' + this.queryMap.mpointName + '%' : null;
    example.or()
    .andEqualTo({name: 'organizationId', value: organizationId })
    .andLike({name: 'name', value: mpointName  });
    this.monitorPointService.getPageByExample(this.grid, example).subscribe(
      (res: PageBean) => {
        this.grid.loading = true;
        if (res != null && res.data != null) {
@@ -105,7 +123,9 @@
    if (d != null) {
      Object.assign(data, d);
    }
    this.modalHelper.static(MonitorPointEditComponent, { data }).subscribe(
    let configMap = {};
    configMap = Object.assign(configMap, this.queryMap);
    this.modalHelper.static(MonitorPointEditComponent, { data, configMap }).subscribe(
      (ret: { data: any, close: Function }) => {
        // 修改状态
        if (ret.data['index'] != null) {
@@ -181,9 +201,15 @@
    Object.assign(this.coorPickerService.data, record);
    const _data = this.coorPickerService.data;
    const areaNames = record.areaNames;
    let adress = null;
    let adress = '';
    if (areaNames != null) {
      adress = areaNames.provinceName + areaNames.cityName + areaNames.areaName + record.address;
      adress += !!areaNames.provinceName ? areaNames.provinceName : '';
      adress += ' ';
      adress += !!areaNames.cityName ? areaNames.cityName : '';
      adress += ' ';
      adress += !!areaNames.areaName ? areaNames.areaName : '';
      adress += ' ';
      adress += !!record.address ? record.address : '';
    }
    this.coorPickerService.data.address = adress;
    this.coorPickerService.data['describe'] = '监控站点名称';
@@ -206,4 +232,14 @@
      }
    );
  }
  orgSelectChange(text?: string) {
    const pageBean: PageBean = {pageIndex: 0, pageSize: 20};
    this.organizationService.getPagingList(pageBean, text).subscribe(
      (res: PageBean) => {
           if (res != null && res.data != null) {
               this.orgOptions = res.data;
           }
      }
   );
  }
}