diff --git a/src/components/AMap/src/AMapDesigner/index.vue b/src/components/AMap/src/AMapDesigner/index.vue index b5de460..28dd7c6 100644 --- a/src/components/AMap/src/AMapDesigner/index.vue +++ b/src/components/AMap/src/AMapDesigner/index.vue @@ -97,7 +97,7 @@ import { listUser } from '/@/api/platform/system/controller/user'; import { listOrg } from '/@/api/platform/common/controller/org'; import { useUserStore } from '/@/store/modules/user'; - import { split, divide, subtract, merge, isEmpty, cloneDeep, add } from 'lodash-es'; + import { split, divide, subtract, merge, isEmpty, cloneDeep, add, omit } from 'lodash-es'; import componentSetting from '/@/settings/componentSetting'; import { BasicUpload } from '/@/components/Upload'; import { commonUpload } from '/@/api/platform/core/controller/upload'; @@ -607,16 +607,19 @@ /** 绘制地图导航路线 */ function drawMapNavigate(points: Recordable[] = []) { - 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 + 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 + }); }); - }); + } } /** 处理地图任务数据 */ @@ -625,57 +628,53 @@ // 生成标记点数据 const pointData:Recordable[] = []; mapState.mapData.mapTask.forEach(item => { - const hospital = mapState.hospitalList.find(e => e.value == item.hospitalId); - const org = mapState.orgList.find(e => e.value == item.orgId); - // 下级医院必选,所以必须查到,没有数据说明数据被更新过了 + const hospital = mapState.hospitalList.find(e => e.value == item.hospitalId), + org = mapState.orgList.find(e => e.value == item.orgId); + // 下级医院必选,也不能由收样员设置交接位置,所以必须查到,没有数据说明数据被更新过了 if (!hospital) { throw notification.error({ message: '当前机构数据或者医院数据已经更新,请重新刷新页面!', duration: 2 }); } - pointData.push({ + pointData.push(omit(merge(item, { lng: hospital.mapLng, lat: hospital.mapLat, - sort: undefined, type: '0', key: item.key, taskType: item.taskType, hospitalId: hospital.value, hospitalName: hospital.label - }); - org && pointData.push({ - lng: org.mapLng, - lat: org.mapLat, - sort: undefined, + }), 'id'), omit(merge(item, { + lng: org?.mapLng, + lat: org?.mapLat, type: '1', key: item.key, taskType: item.taskType, - hospitalId: org.value, - hospitalName: org.label - }); + hospitalId: org?.value, + hospitalName: org?.label + }), 'id')); }); // 查找并添加与自己有关的交接预设任务,只能添加设置了位置的标记点 await listMapTaskPreset({ size: 40, courierUserId: mapState.mapData.courierUserId }).then(res => { res.data?.map(item => { - (item.orginPresetLng && item.orginPresetLat) && pointData.push({ + pointData.push(omit(merge(item, { lng: item.orginPresetLng, lat: item.orginPresetLat, - sort: undefined, type: '0', - key: item.key, + taskType: '1', + mapTaskId: item.id, hospitalId: item.orginPresetId, hospitalName: item.orginPresetName - }); - (item.destinationPresetLng && item.destinationPresetLat) && pointData.push({ + }), 'id'), omit(merge(item, { lng: item.destinationPresetLng, lat: item.destinationPresetLat, - sort: undefined, - type: '0', - key: item.key, + type: '1', + taskType: '1', + mapTaskId: item.id, hospitalId: item.destinationPresetId, hospitalName: item.destinationPresetName - }); + }), 'id')); }); }); pointData.forEach((item, index)=> { item.sort = add(index, 1); }); diff --git a/src/components/AMap/src/components/MapTaskPresetModal.vue b/src/components/AMap/src/components/MapTaskPresetModal.vue index 2837fb0..0b2f11b 100644 --- a/src/components/AMap/src/components/MapTaskPresetModal.vue +++ b/src/components/AMap/src/components/MapTaskPresetModal.vue @@ -261,7 +261,7 @@ message: '表格行校验未通过,请检查!', duration: 2 }); - // 自动填充交接最终到达上级医检医院 + // 自动设置交接最终到达上级医检医院 const lastElement = mapTaskPresetData[mapTaskPresetData.length - 1]; const option = state.orgList.find(item => item.value == formData.destinationPresetId); if (option && lastElement) {