|
|
@ -69,7 +69,7 @@ |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import AMapLoader from '@amap/amap-jsapi-loader'; |
|
|
|
import AMapLoader from '@amap/amap-jsapi-loader'; |
|
|
|
import { reactive, watchEffect, getCurrentInstance, onBeforeMount, onUnmounted, ref, PropType, watch, toRefs, nextTick, onMounted } from 'vue'; |
|
|
|
import { reactive, watchEffect, getCurrentInstance, onBeforeMount, onUnmounted, ref, PropType, watch, toRefs, nextTick } from 'vue'; |
|
|
|
import { operatePanelColumns, MapData, MapPointType } from '../amap.data'; |
|
|
|
import { operatePanelColumns, MapData, MapPointType } from '../amap.data'; |
|
|
|
import hospital from '/@/assets/images/hospital.svg'; |
|
|
|
import hospital from '/@/assets/images/hospital.svg'; |
|
|
|
import medicalKit from '/@/assets/images/medical-kit.svg'; |
|
|
|
import medicalKit from '/@/assets/images/medical-kit.svg'; |
|
|
@ -435,26 +435,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|
|
|
|
// 加载地图设计器默认配置 |
|
|
|
|
|
|
|
mapState.mapData = defaultMapData(); |
|
|
|
|
|
|
|
setTableData(mapState.mapData.mapTask); |
|
|
|
|
|
|
|
// 加载地图数据,并且绘制路线 |
|
|
|
|
|
|
|
if (!isEmpty(mapState.mapData.mapLogisticPoint)) { |
|
|
|
|
|
|
|
const lngLatData = mapState.mapData.mapLogisticPoint.map(item => new AMap.LngLat(item.lng, item.lat)); |
|
|
|
|
|
|
|
const destination = lngLatData.pop(); |
|
|
|
|
|
|
|
destination && driving.search(new AMap.LngLat(mapState.mapData.courierLng, mapState.mapData.courierLat), destination, { |
|
|
|
|
|
|
|
waypoints: lngLatData |
|
|
|
|
|
|
|
}, function(status, result) { |
|
|
|
|
|
|
|
if (status === 'complete') { |
|
|
|
|
|
|
|
console.log('绘制地图路线完成'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
console.error('获取地图数据失败:' + result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => { |
|
|
|
onUnmounted(() => { |
|
|
|
if (map) { |
|
|
|
if (map) { |
|
|
|
// 销毁地图实例 |
|
|
|
// 销毁地图实例 |
|
|
@ -462,7 +442,6 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 地图创建完成(动画关闭) */ |
|
|
|
/** 地图创建完成(动画关闭) */ |
|
|
|
function complete () { |
|
|
|
function complete () { |
|
|
|
if (map) { |
|
|
|
if (map) { |
|
|
@ -479,7 +458,7 @@ |
|
|
|
if (!mapProps.sidebarControl) mapState.toggleOperatePanelClass.siderWidth = 0; |
|
|
|
if (!mapProps.sidebarControl) mapState.toggleOperatePanelClass.siderWidth = 0; |
|
|
|
if (!mapProps.toolbarControl) mapState.toggleOperatePanelClass.toolbarHeight = 0; |
|
|
|
if (!mapProps.toolbarControl) mapState.toggleOperatePanelClass.toolbarHeight = 0; |
|
|
|
}); |
|
|
|
}); |
|
|
|
watch(toRefs(mapProps).options, (newValue)=>{ |
|
|
|
watch(toRefs(mapProps).options, (newValue) => { |
|
|
|
setMapDataJson(newValue); |
|
|
|
setMapDataJson(newValue); |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
immediate: true, |
|
|
|
immediate: true, |
|
|
@ -578,14 +557,32 @@ |
|
|
|
nextTick(() => { |
|
|
|
nextTick(() => { |
|
|
|
mapState.mapData = cloneDeep(merge(defaultMapData(), options)); |
|
|
|
mapState.mapData = cloneDeep(merge(defaultMapData(), options)); |
|
|
|
setTableData(mapState.mapData.mapTask); |
|
|
|
setTableData(mapState.mapData.mapTask); |
|
|
|
|
|
|
|
if (!isEmpty(mapState.mapData.mapLogisticPoint)) { |
|
|
|
|
|
|
|
drawMapNavigate(mapState.mapData.mapLogisticPoint); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 获取部件表单数据 */ |
|
|
|
/** 获取部件表单数据 */ |
|
|
|
function getMapDataJson () { |
|
|
|
function getMapDataJson() { |
|
|
|
return cloneDeep(mapState.mapData); |
|
|
|
return cloneDeep(mapState.mapData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 绘制地图导航路线 */ |
|
|
|
|
|
|
|
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) { |
|
|
|
|
|
|
|
if (status === 'complete') { |
|
|
|
|
|
|
|
console.log('绘制地图路线完成'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
console.error('获取地图数据失败:' + result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 处理地图任务数据 */ |
|
|
|
/** 处理地图任务数据 */ |
|
|
|
async function handleMapTask() { |
|
|
|
async function handleMapTask() { |
|
|
|
setTableData(mapState.mapData.mapTask); |
|
|
|
setTableData(mapState.mapData.mapTask); |
|
|
@ -638,23 +635,15 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
mapState.mapData.mapLogisticPoint = pointData; |
|
|
|
mapState.mapData.mapLogisticPoint = pointData; |
|
|
|
const lngLatData = pointData.map(item => new AMap.LngLat(item.lng, item.lat)); |
|
|
|
drawMapNavigate(pointData); |
|
|
|
const last = lngLatData.pop(); |
|
|
|
|
|
|
|
// 重新导航路线 |
|
|
|
|
|
|
|
driving.search(new AMap.LngLat(mapState.mapData.courierLng, mapState.mapData.courierLat), last, { |
|
|
|
|
|
|
|
waypoints: lngLatData |
|
|
|
|
|
|
|
}, function(status, result) { |
|
|
|
|
|
|
|
if (status === 'complete') { |
|
|
|
|
|
|
|
console.log('绘制地图路线完成'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
console.error('获取地图数据失败:' + result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 处理地图标记点数据 */ |
|
|
|
/** 处理地图标记点数据 */ |
|
|
|
function handleMapPoint() { |
|
|
|
function handleMapPoint(mapLogisticPoint: Recordable[] = []) { |
|
|
|
|
|
|
|
if (!isEmpty(mapLogisticPoint)) { |
|
|
|
|
|
|
|
mapState.mapData.mapLogisticPoint = mapLogisticPoint; |
|
|
|
|
|
|
|
drawMapNavigate(mapLogisticPoint); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 处理地图保存并发布 */ |
|
|
|
/** 处理地图保存并发布 */ |
|
|
@ -686,6 +675,12 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 对外提供Api */ |
|
|
|
|
|
|
|
defineExpose({ |
|
|
|
|
|
|
|
drawMapNavigate, |
|
|
|
|
|
|
|
getMapDataJson, |
|
|
|
|
|
|
|
setMapDataJson |
|
|
|
|
|
|
|
}); |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
<style lang="less" scoped> |
|
|
|
<style lang="less" scoped> |
|
|
|
|
|
|
|
|
|
|
|