Browse Source

🚀 优化程序

master
wangxiang 3 years ago
parent
commit
067ded646d
  1. 45
      src/components/AMap/src/AMapDesigner/index.vue
  2. 2
      src/components/AMap/src/components/MapTaskPresetModal.vue

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

@ -97,7 +97,7 @@
import { listUser } from '/@/api/platform/system/controller/user'; import { listUser } from '/@/api/platform/system/controller/user';
import { listOrg } from '/@/api/platform/common/controller/org'; import { listOrg } from '/@/api/platform/common/controller/org';
import { useUserStore } from '/@/store/modules/user'; 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 componentSetting from '/@/settings/componentSetting';
import { BasicUpload } from '/@/components/Upload'; import { BasicUpload } from '/@/components/Upload';
import { commonUpload } from '/@/api/platform/core/controller/upload'; import { commonUpload } from '/@/api/platform/core/controller/upload';
@ -607,6 +607,8 @@
/** 绘制地图导航路线 */ /** 绘制地图导航路线 */
function drawMapNavigate(points: Recordable[] = []) { function drawMapNavigate(points: Recordable[] = []) {
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, {
@ -618,6 +620,7 @@
}); });
}); });
} }
}
/** 处理地图任务数据 */ /** 处理地图任务数据 */
async function handleMapTask() { async function handleMapTask() {
@ -625,57 +628,53 @@
// //
const pointData:Recordable[] = []; const pointData:Recordable[] = [];
mapState.mapData.mapTask.forEach(item => { mapState.mapData.mapTask.forEach(item => {
const hospital = mapState.hospitalList.find(e => e.value == item.hospitalId); const hospital = mapState.hospitalList.find(e => e.value == item.hospitalId),
const org = mapState.orgList.find(e => e.value == item.orgId); org = mapState.orgList.find(e => e.value == item.orgId);
// ,, // ,,,
if (!hospital) { if (!hospital) {
throw notification.error({ throw notification.error({
message: '当前机构数据或者医院数据已经更新,请重新刷新页面!', message: '当前机构数据或者医院数据已经更新,请重新刷新页面!',
duration: 2 duration: 2
}); });
} }
pointData.push({ pointData.push(omit(merge(item, {
lng: hospital.mapLng, lng: hospital.mapLng,
lat: hospital.mapLat, lat: hospital.mapLat,
sort: undefined,
type: '0', type: '0',
key: item.key, key: item.key,
taskType: item.taskType, taskType: item.taskType,
hospitalId: hospital.value, hospitalId: hospital.value,
hospitalName: hospital.label hospitalName: hospital.label
}); }), 'id'), omit(merge(item, {
org && pointData.push({ lng: org?.mapLng,
lng: org.mapLng, lat: org?.mapLat,
lat: org.mapLat,
sort: undefined,
type: '1', type: '1',
key: item.key, key: item.key,
taskType: item.taskType, taskType: item.taskType,
hospitalId: org.value, hospitalId: org?.value,
hospitalName: org.label hospitalName: org?.label
}); }), 'id'));
}); });
// , // ,
await listMapTaskPreset({ size: 40, courierUserId: mapState.mapData.courierUserId }).then(res => { await listMapTaskPreset({ size: 40, courierUserId: mapState.mapData.courierUserId }).then(res => {
res.data?.map(item => { res.data?.map(item => {
(item.orginPresetLng && item.orginPresetLat) && pointData.push({ pointData.push(omit(merge(item, {
lng: item.orginPresetLng, lng: item.orginPresetLng,
lat: item.orginPresetLat, lat: item.orginPresetLat,
sort: undefined,
type: '0', type: '0',
key: item.key, taskType: '1',
mapTaskId: item.id,
hospitalId: item.orginPresetId, hospitalId: item.orginPresetId,
hospitalName: item.orginPresetName hospitalName: item.orginPresetName
}); }), 'id'), omit(merge(item, {
(item.destinationPresetLng && item.destinationPresetLat) && pointData.push({
lng: item.destinationPresetLng, lng: item.destinationPresetLng,
lat: item.destinationPresetLat, lat: item.destinationPresetLat,
sort: undefined, type: '1',
type: '0', taskType: '1',
key: item.key, mapTaskId: item.id,
hospitalId: item.destinationPresetId, hospitalId: item.destinationPresetId,
hospitalName: item.destinationPresetName hospitalName: item.destinationPresetName
}); }), 'id'));
}); });
}); });
pointData.forEach((item, index)=> { item.sort = add(index, 1); }); pointData.forEach((item, index)=> { item.sort = add(index, 1); });

2
src/components/AMap/src/components/MapTaskPresetModal.vue

@ -261,7 +261,7 @@
message: '表格行校验未通过,请检查!', message: '表格行校验未通过,请检查!',
duration: 2 duration: 2
}); });
// //
const lastElement = mapTaskPresetData[mapTaskPresetData.length - 1]; const lastElement = mapTaskPresetData[mapTaskPresetData.length - 1];
const option = state.orgList.find(item => item.value == formData.destinationPresetId); const option = state.orgList.find(item => item.value == formData.destinationPresetId);
if (option && lastElement) { if (option && lastElement) {

Loading…
Cancel
Save