fengxiang
2018-05-15 008baf1470f2aaf6fe388a20b9a61069270a1471
src/app/routes/devices/basic-info/basic-info.component.ts
@@ -157,39 +157,53 @@
        );
      });
  }
  configCoord(record: Device): void {
  configCoord(record: Device): void {
      //当前 坐标未设置 取监控点地址
      if((!!record.latitude||!!record.longitude)&&!!record.monitorPointId){
            this.monitorPointService.getEntity(record.monitorPointId).subscribe(
              res => {
                if (res != null && res.code === 1 && res.data != null) {
                    const areaNames = res.data.areaNames;
                    let adress = '';
                    if (areaNames != null) {
                      adress += !!areaNames.provinceName?areaNames.provinceName:'';
                      adress += ' ';
                      adress += !!areaNames.cityName?areaNames.cityName:'';
                      adress += ' ';
                      adress += !!areaNames.areaName?areaNames.areaName:'';
                      adress += ' ';
                      adress += !!res.data.address?res.data.address:'';
                    }
                    this.coorPickerService.data.address = adress;
                    this.openMap(record);
                }
              }
        );
      }else{
        this.openMap(record);
      }
  }
  private openMap(record: Device){
    Object.assign(this.coorPickerService.data, record);
    const _data = this.coorPickerService.data;
    this.monitorPointService.getEntity(record.monitorPointId).subscribe(
         res => {
            if (res != null && res.code === 1 && res.data != null) {
                const areaNames = res.data.areaNames;
                let adress = null;
                if (areaNames != null) {
                  adress = areaNames.provinceName + areaNames.cityName + areaNames.areaName + res.data.address;
    this.coorPickerService.data['describe'] = '设备名称';
    this.modalHelper.static(CoordinatesPickerComponent).subscribe(
      (staticComp) => {
             const data: Device = {
                id: record.id,
                mac: record.mac,
                longitude: _data.longitude,
                latitude: _data.latitude,
             };
             this.deviceService.save(data).subscribe(
              (resp: any) => {
                if (resp.code === 1) {
                  this.load();
                  this.msgSrv.success('坐标配置成功!');
                }
                this.coorPickerService.data.address = adress;
                this.coorPickerService.data['describe'] = '设备名称';
            }
            this.modalHelper.static(CoordinatesPickerComponent).subscribe(
              (staticComp) => {
                     const data: Device = {
                        id: record.id,
                        mac: record.mac,
                        longitude: _data.longitude,
                        latitude: _data.latitude,
                     };
                     this.deviceService.save(data).subscribe(
                      (resp: any) => {
                        if (resp.code === 1) {
                          this.load();
                          this.msgSrv.success('坐标配置成功!');
                        }
                      }
                     );
              }
           );
         }
    );
             );
      }
   );
  }
}