diff --git a/src/api/platform/common/controller/mapTaskPreset.ts b/src/api/platform/common/controller/mapTaskPreset.ts new file mode 100644 index 0000000..00dcf8b --- /dev/null +++ b/src/api/platform/common/controller/mapTaskPreset.ts @@ -0,0 +1,25 @@ +/** + * 提供api模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 + * Copyright © 2020-2022 entfrm All rights reserved. + * author entfrm开发团队-王翔 + */ +import type { MapTaskPresetParams, MapTaskPreset, MapTaskPresetResult } from '../entity/mapTaskPreset'; +import { defHttp } from '/@/utils/http/axios'; + +enum Api { + list = '/common_proxy/common/mapTaskPreset/list', + get = '/common_proxy/common/mapTaskPreset', + add = '/common_proxy/common/mapTaskPreset/save', + edit = '/common_proxy/common/mapTaskPreset/update', + del = '/common_proxy/common/mapTaskPreset/remove' +} + +export const listMapTaskPreset = (params?: Partial) => defHttp.get({ url: Api.list, params }); + +export const addMapTaskPreset = (params: Partial) => defHttp.post({ url: Api.add, data: params }); + +export const editMapTaskPreset = (params: Partial) => defHttp.put({ url: Api.edit, data: params }); + +export const getMapTaskPreset = (id: string) => defHttp.get({ url: `${Api.get}/${id}` }); + +export const delMapTaskPreset = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` }); diff --git a/src/api/platform/common/entity/mapLogistic.ts b/src/api/platform/common/entity/mapLogistic.ts index 3862464..4790e3b 100644 --- a/src/api/platform/common/entity/mapLogistic.ts +++ b/src/api/platform/common/entity/mapLogistic.ts @@ -26,6 +26,7 @@ export interface MapLogistic extends CommonEntity { estimateTime: string; requireTime: string; batchCode: string; + version: string; } export type MapLogisticResult = R; diff --git a/src/api/platform/common/entity/mapTaskPreset.ts b/src/api/platform/common/entity/mapTaskPreset.ts new file mode 100644 index 0000000..a53a1ab --- /dev/null +++ b/src/api/platform/common/entity/mapTaskPreset.ts @@ -0,0 +1,35 @@ + +/** + * @program: kicc-ui + * @description: 地图任务交接预设表实体类 + * @author: entfrm开发团队-王翔 + * @since: 2022/8/24 + */ + +import type { R } from '/#/axios'; +import type { CommonEntity, Page } from '/@/api/common/data/entity'; + +export type MapTaskPresetParams = Page & MapTaskPreset; + +export interface MapTaskPreset extends CommonEntity { + id: string; + name: string; + orginPresetId: string; + orginPresetName: string; + orginPresetLng: number; + orginPresetLat: number; + destinationPresetId: string; + destinationPresetName: string; + destinationPresetLng: number; + destinationPresetLat: number; + courierUserId: string; + fileId: string; + estimateTime: string; + requireTime: string; + batchCode: string; + mapLogisticId: string; + taskId: string; + version: string; +} + +export type MapTaskPresetResult = R; diff --git a/src/components/AMap/src/AMapDesigner/index.vue b/src/components/AMap/src/AMapDesigner/index.vue index c1fc482..4a19f2c 100644 --- a/src/components/AMap/src/AMapDesigner/index.vue +++ b/src/components/AMap/src/AMapDesigner/index.vue @@ -82,7 +82,10 @@ /> - + ({ /** 遮罩层状态 */ @@ -236,7 +243,7 @@ const ASelect = Select; const ATooltip = Tooltip; const formElRef = ref(); - const [registerTable, { reload }] = useTable({ + const [registerTable, { setTableData }] = useTable({ title: '任务列表', rowKey: 'id', dataSource: mapState.mapData?.mapTask, @@ -273,8 +280,8 @@ label: item.nickName, mapOrientation: item.mapOrientation, // todo: 采用SSE服务器发生事件技术刷新安卓GPS位置 - mapLat: 0, - mapLng: 0 + mapLat: 28.295114, + mapLng: 112.913864 })); }); listOrg({ size: 40 }).then(res => { @@ -557,19 +564,33 @@ destinationPosition = destinationMarker.getPosition(); return Math.round(hospitalPosition.distance(originPosition)) - Math.round(hospitalPosition.distance(destinationPosition)); }); - } else { - console.warn('查找不到发单点数据,请检查发单点!'); - } + mapState.mapData.sendOrderName = hospitalMap.label; + mapState.mapData.sendOrderLng = hospitalMap.mapLng; + mapState.mapData.sendOrderLat = hospitalMap.mapLat; + } else console.warn('查找不到发单点数据,请检查发单点!'); + + } + + /** 处理起点收样员数据 */ + function handleCourierUserData(value) { + const courierUserMap = mapState.courierUserList.find(item => item.value == value); + if (courierUserMap) { + mapState.mapData.courierUserName = courierUserMap.label; + mapState.mapData.courierLng = courierUserMap.mapLng; + mapState.mapData.courierLat = courierUserMap.mapLat; + } else console.warn('查找不到起点数据,请检查起点!'); } /** 处理打开任务配置 */ - function handleOpenTask() { + async function handleOpenTask() { + await formElRef.value.validate(); openModal(true, { mapData: mapState.mapData }); } /** 处理打开地图标记点配置 */ - function handleOpenMapPoint() { - mapPointOpenModal(true, { }); + async function handleOpenMapPoint() { + await formElRef.value.validate(); + mapPointOpenModal(true, { mapData: mapState.mapData }); } /** 处理地图放大 */ @@ -582,14 +603,70 @@ map.zoomOut(); } - /** 处理地图保存并发布 */ - function handleMapSave() { - - } - /** 处理地图任务数据 */ - function handleMapTask() { - + async function handleMapTask() { + setTableData(mapState.mapData.mapTask); + // 生成标记点数据 + 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); + // 下级医院必选,没有数据说明数据被更新过了 + if (!hospital) { + createMessage.error('当前机构数据或者医院数据已经更新,请重新刷新页面!'); + throw Error('当前机构数据或者医院数据已经更新,请重新刷新页面!'); + } + pointData.push({ + lng: hospital.mapLng, + lat: hospital.mapLat, + sort: undefined, + type: '0', + hospitalId: hospital.value, + hospitalName: hospital.label + }); + org && pointData.push({ + lng: org.mapLng, + lat: org.mapLat, + sort: undefined, + type: '1', + hospitalId: org.value, + hospitalName: org.label + }); + }); + // 查找并添加与自己有关的交接预设任务,只能添加设置了位置的标记点 + await listMapTaskPreset({ size: 40, courierUserId: mapState.mapData.courierUserId }).then(res => { + res.data?.map(item => { + (item.orginPresetLng && item.orginPresetLat) && pointData.push({ + lng: item.orginPresetLng, + lat: item.orginPresetLat, + sort: undefined, + type: '0', + hospitalId: item.orginPresetId, + hospitalName: item.orginPresetName + }); + (item.destinationPresetLng && item.destinationPresetLat) && pointData.push({ + lng: item.destinationPresetLng, + lat: item.destinationPresetLat, + sort: undefined, + type: '0', + hospitalId: item.destinationPresetId, + hospitalName: item.destinationPresetName + }); + }); + }); + mapState.mapData.mapLogisticPoint = pointData; + const lngLatData = pointData.map(item => new AMap.LngLat(item.lng, item.lat)); + 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); + } + }); } /** 处理地图标记点数据 */ @@ -597,6 +674,11 @@ } + /** 处理地图保存并发布 */ + function handleMapSave() { + + } + /** 处理地图重置 */ function handleMapReset() { // 清除地图 @@ -605,9 +687,16 @@ // 清除表单数据 formElRef.value.resetFields(); formElRef.value.clearValidate(); - // 清除任务数据 + // 清除地图数据 + mapState.mapData.courierUserName = ''; + mapState.mapData.courierLng = undefined; + mapState.mapData.courierLat = undefined; + mapState.mapData.sendOrderName = ''; + mapState.mapData.sendOrderLng = undefined; + mapState.mapData.sendOrderLat = undefined; mapState.mapData.mapTask = []; mapState.mapData.mapLogisticPoint = []; + setTableData([]); // 重置地图画布 map.setZoomAndCenter(mapState.mapConfig.options.zoom, mapState.mapConfig.options.center); mapState.defaultZoom = mapState.mapConfig.options.zoom;