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

Loading…
Cancel
Save