Browse Source

调整地图设计器数据结构

master
wangxiang 3 years ago
parent
commit
24629be8aa
  1. 2
      src/api/platform/common/controller/mapLogistic.ts
  2. 2
      src/api/platform/common/controller/mapTaskPreset.ts
  3. 80
      src/components/AMap/src/AMapDesigner/index.vue

2
src/api/platform/common/controller/mapLogistic.ts

@ -14,7 +14,7 @@ enum Api { @@ -14,7 +14,7 @@ enum Api {
del = '/common_proxy/common/mapLogistic/remove'
}
export const listMapLogistic = (params?: Partial<MapLogisticParams>) => defHttp.get({ url: Api.list, params });
export const listMapLogistic = (params?: Partial<MapLogisticParams>) => defHttp.get({ url: Api.list, params }, { isReturnResultResponse: true });
export const addMapLogistic = (params: Partial<MapLogistic>) => defHttp.post({ url: Api.add, data: params });

2
src/api/platform/common/controller/mapTaskPreset.ts

@ -14,7 +14,7 @@ enum Api { @@ -14,7 +14,7 @@ enum Api {
del = '/common_proxy/common/mapTaskPreset/remove'
}
export const listMapTaskPreset = (params?: Partial<MapTaskPresetParams>) => defHttp.get({ url: Api.list, params });
export const listMapTaskPreset = (params?: Partial<MapTaskPresetParams>) => defHttp.get({ url: Api.list, params }, { isReturnResultResponse: true });
export const addMapTaskPreset = (params: Partial<MapTaskPreset>) => defHttp.post({ url: Api.add, data: params });

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

@ -111,7 +111,7 @@ @@ -111,7 +111,7 @@
</template>
<script lang="ts" setup>
import AMapLoader from '@amap/amap-jsapi-loader';
import { reactive, watchEffect, getCurrentInstance, onBeforeMount, onUnmounted, ref } from 'vue';
import {reactive, watchEffect, getCurrentInstance, onBeforeMount, onUnmounted, ref, PropType} from 'vue';
import { operatePanelColumns, MapData, MapPointType } from '../amap.data';
import hospital from '/@/assets/images/hospital.svg';
import medicalKit from '/@/assets/images/medical-kit.svg';
@ -129,12 +129,13 @@ @@ -129,12 +129,13 @@
import AButton from '/@/components/Button/src/BasicButton.vue';
import { Icon } from '/@/components/Icon';
import { useUserStore } from '/@/store/modules/user';
import { split, divide, subtract } from 'lodash-es';
import { split, divide, subtract, merge, isEmpty } from 'lodash-es';
import componentSetting from '/@/settings/componentSetting';
import { BasicUpload } from '/@/components/Upload';
import { commonUpload } from '/@/api/platform/core/controller/upload';
import { useMessage } from '/@/hooks/web/useMessage';
import { listMapTaskPreset } from '/@/api/platform/common/controller/mapTaskPreset';
import { getMapLogistic } from '/@/api/platform/common/controller/mapLogistic';
/** 类型规范统一声明定义区域 */
interface MapState {
@ -155,6 +156,13 @@ @@ -155,6 +156,13 @@
const mapProps = defineProps({
mapId: propTypes.string.def(''),
mapPoint: {
type: Array as PropType<{
lng: number | string;
lat: number | string;
}[]>,
default: () => [],
},
sidebarControl: propTypes.bool.def(true)
});
@ -361,9 +369,9 @@ @@ -361,9 +369,9 @@
const { lnglat } = ctx;
map.setZoomAndCenter(18, lnglat);
});
const orgPoints = mapState.orgList.map((v: any) => ({
lnglat: [v.mapLng, v.mapLat],
...v
const orgPoints = mapState.orgList.map((e: any) => ({
lnglat: [e.mapLng, e.mapLat],
...e
}));
orgMarkerCluster?.setData(orgPoints);
@ -412,9 +420,9 @@ @@ -412,9 +420,9 @@
const { lnglat } = ctx;
map.setZoomAndCenter(18, lnglat);
});
const hospitalPoints = mapState.hospitalList.map((v: any) => ({
lnglat: [v.mapLng, v.mapLat],
...v
const hospitalPoints = mapState.hospitalList.map((e: any) => ({
lnglat: [e.mapLng, e.mapLat],
...e
}));
hospitalMarkerCluster?.setData(hospitalPoints);
@ -457,9 +465,9 @@ @@ -457,9 +465,9 @@
const { lnglat } = ctx;
map.setZoomAndCenter(18, lnglat);
});
const courierUserPoints = mapState.courierUserList.map((v: any) => ({
lnglat: [v.mapLng, v.mapLat],
...v
const courierUserPoints = mapState.courierUserList.map((e: any) => ({
lnglat: [e.mapLng, e.mapLat],
...e
}));
courierUserMarkerCluster?.setData(courierUserPoints);
@ -483,18 +491,39 @@ @@ -483,18 +491,39 @@
panel: instance.refs.mapPanel
});
// todo:
// 线
driving.search(new AMap.LngLat(112.913864, 28.295114), new AMap.LngLat(112.918119, 28.282891), {
waypoints:[new AMap.LngLat(112.919165, 28.289924)]
}, function(status, result) {
if (status === 'complete') {
console.log('绘制驾车路线完成');
} else {
console.error('获取驾车数据失败:' + result);
}
});
// ,线
handleMapReset();
if (mapProps.mapId) {
getMapLogistic(mapProps.mapId).then(mapLogistic => {
if (!isEmpty(mapLogistic)) {
mapState.mapData = merge(mapState.mapData, mapLogistic);
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);
}
});
}
});
} else {
// 线,ID
const lngLatData = mapProps.mapPoint.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);
}
});
}
//
complete();
@ -662,9 +691,9 @@ @@ -662,9 +691,9 @@
waypoints: lngLatData
}, function(status, result) {
if (status === 'complete') {
console.log('绘制驾车路线完成');
console.log('绘制地图路线完成');
} else {
console.error('获取驾车数据失败:' + result);
console.error('获取地图数据失败:' + result);
}
});
}
@ -682,7 +711,6 @@ @@ -682,7 +711,6 @@
/** 处理地图重置 */
function handleMapReset() {
//
map.resize();
map.clearMap();
//
formElRef.value.resetFields();

Loading…
Cancel
Save