Browse Source

🚀 优化程序

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

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

@ -97,7 +97,7 @@ @@ -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 @@ @@ -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 @@ @@ -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); });

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

@ -261,7 +261,7 @@ @@ -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) {

Loading…
Cancel
Save