Browse Source

🚑 交接点没有地图数据也能展示处理

master
wangxiang 3 years ago
parent
commit
0d755823ed
  1. 95
      src/components/AMap/src/AMapDesigner/index.vue

95
src/components/AMap/src/AMapDesigner/index.vue

@ -633,7 +633,7 @@ @@ -633,7 +633,7 @@
mapState.mapData.courierUserName = courierUserMap.label;
mapState.mapData.courierLng = courierUserMap.mapLng;
mapState.mapData.courierLat = courierUserMap.mapLat;
drawMapNavigate(concat(mapState.mapData.mapLogisticPoint, mapState.mapData.mapTaskPresetLogisticPoint));
handleMapPointGenerate();
} else notification.warn({
message: '查找不到起点数据,请检查起点!',
duration: 2
@ -744,62 +744,63 @@ @@ -744,62 +744,63 @@
/** 绘制地图导航路线 */
function drawMapNavigate(points: MapLogisticPoint[] = []) {
debugger
if (isEmpty(points) && mapState.mapData.courierUserId && mapState.mapData.courierLng && mapState.mapData.courierLat)
throw console.warn('检查到当前起点数据为空或标记点集合为空,请选择起点!');
points = points.filter(item => item.lng && item.lat);
if (points.length > 0 && mapState.mapData.courierLng && mapState.mapData.courierLat) {
const lngLats = points.map(item => new AMap.LngLat(item.lng, item.lat));
const destination = lngLats.pop();
destination && driving.search(new AMap.LngLat(mapState.mapData.courierLng, mapState.mapData.courierLat), destination, {
waypoints: lngLats
}, function(status, result) {
notification.success({
message: status === 'complete' ? '绘制地图路线完成!' : `获取地图数据失败:${result}`,
duration: 2
});
const lngLats = points.map(item => new AMap.LngLat(item.lng, item.lat));
const destination = lngLats.pop();
destination && driving.search(new AMap.LngLat(mapState.mapData.courierLng, mapState.mapData.courierLat), destination, {
waypoints: lngLats
}, function(status, result) {
notification.success({
message: status === 'complete' ? '绘制地图路线完成!' : `获取地图数据失败:${result}`,
duration: 2
});
}
});
}
/** 处理地图标记点生成 */
async function handleMapPointGenerate() {
setTableData(mapState.mapData.mapTask);
const pointData:MapLogisticPoint[] = [];
mapState.mapData.mapTask.forEach(item => {
const hospital = mapState.hospitalList.find(e => e.value == item.hospitalId),
if (mapState.mapData.courierUserId) {
const pointData:MapLogisticPoint[] = [];
mapState.mapData.mapTask.forEach(item => {
const hospital = mapState.hospitalList.find(e => e.value == item.hospitalId),
org = item.orgId ? mapState.orgList.find(e => e.value == item.orgId) : {} as MapPointType;
// ,,,
if (!hospital) {
throw notification.error({
message: '地图标记点生成错误',
description: '当前机构数据或者医院数据已经更新,请重新刷新页面!',
duration: 2
// ,,,
if (!hospital) {
throw notification.error({
message: '地图标记点生成错误',
description: '当前机构数据或者医院数据已经更新,请重新刷新页面!',
duration: 2
});
}
pointData.push({
lng: hospital.mapLng,
lat: hospital.mapLat,
type: '0',
key: item.key,
taskType: item.taskType,
hospitalId: hospital.value,
hospitalName: hospital.label,
courierUserId: mapState.mapData.courierUserId
}, {
lng: org?.mapLng,
lat: org?.mapLat,
type: '1',
key: item.key,
taskType: item.taskType,
hospitalId: org?.value,
hospitalName: org?.label ?? item.orgName,
courierUserId: mapState.mapData.courierUserId,
});
}
pointData.push({
lng: hospital.mapLng,
lat: hospital.mapLat,
type: '0',
key: item.key,
taskType: item.taskType,
hospitalId: hospital.value,
hospitalName: hospital.label,
courierUserId: mapState.mapData.courierUserId
}, {
lng: org?.mapLng,
lat: org?.mapLat,
type: '1',
key: item.key,
taskType: item.taskType,
hospitalId: org?.value,
hospitalName: org?.label ?? item.orgName,
courierUserId: mapState.mapData.courierUserId,
});
});
// ,
mapState.mapData.mapTaskPresetLogisticPoint = await getTaskPresetPointByCourierUserId(mapState.mapData.courierUserId);
pointData.forEach((item, index)=> item.sort = add(index, 1));
mapState.mapData.mapLogisticPoint = pointData;
drawMapNavigate(concat(mapState.mapData.mapLogisticPoint, mapState.mapData.mapTaskPresetLogisticPoint));
// ,
pointData.forEach((item, index)=> item.sort = add(index, 1));
mapState.mapData.mapLogisticPoint = pointData;
mapState.mapData.courierUserId && (mapState.mapData.mapTaskPresetLogisticPoint = await getTaskPresetPointByCourierUserId(mapState.mapData.courierUserId));
drawMapNavigate(concat(mapState.mapData.mapLogisticPoint, mapState.mapData.mapTaskPresetLogisticPoint));
}
}
/** 处理地图标记点数据 */

Loading…
Cancel
Save