Merge branch 'develop' of https://gitlab.eascs.com/tms-ui/tms-obc-web into develop

This commit is contained in:
wangshiming
2022-03-04 15:08:34 +08:00
3 changed files with 36 additions and 21 deletions

View File

@ -75,7 +75,7 @@
<input <input
nz-input nz-input
[(ngModel)]="data1.detailedAddress" [(ngModel)]="data1.detailedAddress"
(click)="openMap('start', idx)" (click)="openMap('start', idx,data1.detailedAddress)"
formControlName="loadAddress{{ idx }}" formControlName="loadAddress{{ idx }}"
placeholder="请输入装货地" placeholder="请输入装货地"
readonly="true" readonly="true"
@ -126,7 +126,7 @@
<input <input
nz-input nz-input
[(ngModel)]="data2.detailedAddress" [(ngModel)]="data2.detailedAddress"
(click)="openMap('end', idx)" (click)="openMap('end', idx,data2.detailedAddress)"
formControlName="unloadAddress{{ idx }}" formControlName="unloadAddress{{ idx }}"
placeholder="请输入卸货地" placeholder="请输入卸货地"
readonly="true" readonly="true"

View File

@ -443,13 +443,13 @@ export class OrderManagementVehicleDetailChangeComponent implements OnInit {
this.loadTime = res.loadTime; this.loadTime = res.loadTime;
this.unloadTime = res.unloadTime; this.unloadTime = res.unloadTime;
this.dirvingMessage = res.billExpenseDetails; this.dirvingMessage = res.billExpenseDetails;
// 计算里程,时间 // 计算里程,时间
if (this.startInfo?.[0]?.area && this.endInfo?.[0]?.area) { if (this.startInfo?.[0]?.area && this.endInfo?.[0]?.area) {
this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => { this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => {
this.totalDistance = res.distance; this.totalDistance = res.distance;
this.totalTime = res.time; this.totalTime = res.time;
}); });
} }
} }
}); });
} }
@ -560,12 +560,13 @@ export class OrderManagementVehicleDetailChangeComponent implements OnInit {
} }
// -------------------装卸货信息处理 // -------------------装卸货信息处理
// 打开地图 // 打开地图
openMap(type: string, index: number) { openMap(type: string, index: number, address: string) {
console.log(type); console.log(type);
console.log(index); console.log(index);
const modalRef = this.modalService.create({ const modalRef = this.modalService.create({
nzTitle: '', nzTitle: '',
nzComponentParams: { selectedAddress: address },
nzContent: AmapPoiPickerComponent, nzContent: AmapPoiPickerComponent,
nzWidth: 900, nzWidth: 900,
nzOnOk: item => { nzOnOk: item => {
@ -883,8 +884,8 @@ export class OrderManagementVehicleDetailChangeComponent implements OnInit {
} }
console.log(elf); console.log(elf);
} }
// 装卸货地址互换 // 装卸货地址互换
swapAddress() { swapAddress() {
this.startInfo.forEach((element: any, index: any) => { this.startInfo.forEach((element: any, index: any) => {
this.validateForm1.removeControl(`loadAddress${index}`); this.validateForm1.removeControl(`loadAddress${index}`);
this.validateForm1.removeControl(`loadName${index}`); this.validateForm1.removeControl(`loadName${index}`);

View File

@ -1,5 +1,5 @@
import AMapLoader from '@amap/amap-jsapi-loader'; import AMapLoader from '@amap/amap-jsapi-loader';
import { Component, OnInit, ViewChild } from '@angular/core'; import { ChangeDetectorRef, Component, Input, OnInit, ViewChild } from '@angular/core';
import { amapConf } from '@conf/amap.config'; import { amapConf } from '@conf/amap.config';
import { NzModalRef } from 'ng-zorro-antd/modal'; import { NzModalRef } from 'ng-zorro-antd/modal';
import { throwError } from 'rxjs'; import { throwError } from 'rxjs';
@ -27,7 +27,10 @@ export class AmapPoiPickerComponent implements OnInit {
infoWindow: any; infoWindow: any;
geocoder: any; geocoder: any;
constructor(private modalRef: NzModalRef, private service: AmapService) {} @Input()
selectedAddress!: string;
constructor(private modalRef: NzModalRef, private service: AmapService, private cdr: ChangeDetectorRef) {}
ngOnInit(): void { ngOnInit(): void {
this.mapInit(); this.mapInit();
// this.PoiPicker(); // this.PoiPicker();
@ -77,6 +80,8 @@ export class AmapPoiPickerComponent implements OnInit {
// 地图创建成功 // 地图创建成功
this.aMap.on('complete', () => { this.aMap.on('complete', () => {
console.log('地图创建成功');
this.cdr.detectChanges();
this.poiPickerReady(poiPicker); this.poiPickerReady(poiPicker);
}); });
@ -113,12 +118,21 @@ export class AmapPoiPickerComponent implements OnInit {
radius: 1000 //范围默认500 radius: 1000 //范围默认500
}); });
// 获取当前定位 if (this.selectedAddress) {
this.service.getCurrentPosition().subscribe(res => { this.geocoder.getLocation(this.selectedAddress, (status: any, result: any) => {
if (res) { if (status === 'complete' && result.info === 'OK') {
this.selectedPOI(res.position); // result中对应详细地理坐标信息
} this.selectedPOI(result.geocodes?.[0].location);
}); }
});
} else {
// 获取当前定位
this.service.getCurrentPosition().subscribe(res => {
if (res) {
this.selectedPOI(res.position);
}
});
}
//选取了某个POI //选取了某个POI
poiPicker.on('poiPicked', (poiResult: any) => { poiPicker.on('poiPicked', (poiResult: any) => {