From 21ec9878f8687d3da75b4fd424ffa4ee8d73d448 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Mon, 28 May 2018 11:48:34 +0800 Subject: [PATCH] 坐标完善 --- src/app/routes/devices/basic-info/basic-info.component.ts | 83 ++++++++++++++++++++++++----------------- 1 files changed, 49 insertions(+), 34 deletions(-) diff --git a/src/app/routes/devices/basic-info/basic-info.component.ts b/src/app/routes/devices/basic-info/basic-info.component.ts index 5d9b915..526253c 100644 --- a/src/app/routes/devices/basic-info/basic-info.component.ts +++ b/src/app/routes/devices/basic-info/basic-info.component.ts @@ -23,7 +23,7 @@ { title: '������', index: 'name' }, { title: 'mac', index: 'mac' }, { title: '������', index: 'deviceVersion.name' }, - { title: '���������', index: 'monitorPoint.name' }, + { title: '������������', index: 'monitorPoint.name' }, { title: '���������', index: 'operateUser.name' }, { title: '������������', width: '100px', type: 'date', index: 'createTime' }, { title: '������������', width: '100px', type: 'date', index: 'installTime' }, @@ -126,7 +126,7 @@ } addOrModify(d) { const data = {}; - if (d != null) { + if (d != null) { Object.assign(data, d); } this.modalHelper.static(DeviceEditComponent, { data }).subscribe( @@ -157,39 +157,54 @@ ); }); } - configCoord(record: Device): void { - 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; + configCoord(record: Device): void { + // ������������������������������������������adress������������ + Object.assign(this.coorPickerService.data, record); + this.coorPickerService.data['describe'] = '������������'; + // ������ ��������������� ������������������ + 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); } - this.coorPickerService.data.address = adress; - this.coorPickerService.data['describe'] = '������������'; - } - this.modalHelper.static(CoordinatesPickerComponent).subscribe( - (staticComp) => { - const data: Device = { - id: record.id, - longitude: _data.longitude, - latitude: _data.latitude, - }; - this.deviceService.save(data).subscribe( - (resp: any) => { - if (resp.code === 1) { - this.load(); - this.msgSrv.success('���������������������'); - } - } - ); - } - ); - } - ); + ); + }else { + this.openMap(record); + } + } + private openMap(record: Device) { + const _data = this.coorPickerService.data; + 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('���������������������'); + } + } + ); + } + ); } } -- Gitblit v1.8.0