Browse Source

🅰 支持交接 上级下级 ID查找 优先级为上级下级 ID —> 收样员自定义交接点

master
wangxiang 3 years ago
parent
commit
c1d210b161
  1. 61
      src/components/AMap/src/AMapDesigner/index.vue

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

@ -119,9 +119,11 @@ @@ -119,9 +119,11 @@
import { buildUUID } from '/@/utils/uuid';
import { RuleObject } from 'ant-design-vue/es/form/interface';
import { MapLogisticPoint } from '/@/api/platform/common/entity/mapLogisticPoint';
import { isArray, isString } from '/@/utils/is';
/** 类型规范统一声明定义区域 */
interface MapState {
first: boolean;
loading: boolean;
defaultZoom: number;
toggleOperatePanelClass: Recordable;
@ -171,6 +173,8 @@ @@ -171,6 +173,8 @@
const { notification } = useMessage();
const { mapDesigner } = componentSetting;
const mapState = reactive<MapState>({
/** 首次初始化 */
first: false,
/** 遮罩层状态 */
loading: false,
/** 默认缩放大小 */
@ -492,6 +496,8 @@ @@ -492,6 +496,8 @@
if (map) {
map.on('complete', () => {
mapState.loading = false;
mapState.first = true;
setMapDataJson(mapProps.options);
});
}
}
@ -503,12 +509,11 @@ @@ -503,12 +509,11 @@
if (!mapProps.sidebarControl) mapState.toggleOperatePanelClass.siderWidth = 0;
if (!mapProps.toolbarControl) mapState.toggleOperatePanelClass.toolbarHeight = 0;
});
watch(toRefs(mapProps).options, (newValue: MapLogistic) => {
nextTick(() => setMapDataJson(newValue));
}, {
immediate: true,
deep: true
});
watch(toRefs(mapProps).options, (newValue) => {
if (mapState.first) {
setMapDataJson(newValue);
}
}, { deep: true });
watch([() => mapState.mapData.sendOrderId, () => mapState.mapData.sendOrderTaskType],
([sendOrderIdValue,sendOrderTaskTypeValue], [sendOrderIdOldValue, sendOrderTaskTypeOldValue]) => {
if (!sendOrderIdValue || !sendOrderTaskTypeValue) return;
@ -547,7 +552,7 @@ @@ -547,7 +552,7 @@
mapState.mapData.mapTask = [...taskOrdinaryData, ...taskPresetData];
}
}
nextTick(() => handleMapPointGenerate());
handleMapPointGenerate();
});
/** 处理切换操作面板 */
@ -651,8 +656,8 @@ @@ -651,8 +656,8 @@
}
/** 设置地图数据json */
function setMapDataJson(mapData: MapLogistic) {
let options: Nullable<MapLogistic> = mapData;
function setMapDataJson(mapData: MapLogistic | string) {
let options: Nullable<MapLogistic | string> = mapData;
if (typeof options === 'string') {
try {
options = eval('(' + options + ')');
@ -667,6 +672,16 @@ @@ -667,6 +672,16 @@
handleMapReset();
nextTick(() => {
mapState.mapData = cloneDeep(merge(defaultMapData(), options));
//
isString(mapState.mapData.fileId) && (mapState.mapData.fileId = mapState.mapData.fileId.split(','));
mapState.mapData.mapTask.forEach(item => {
isString(item.fileId) && (item.fileId = item.fileId.split(','));
if (~~item.taskType == 1) {
item?.mapTaskPreset?.forEach(childItem => {
isString(childItem.fileId) && (childItem.fileId = childItem.fileId.split(','));
});
}
});
setTableData(mapState.mapData.mapTask);
if (!isEmpty(mapState.mapData.mapLogisticPoint)) {
drawMapNavigate(mapState.mapData.mapLogisticPoint);
@ -707,7 +722,7 @@ @@ -707,7 +722,7 @@
const pointData:MapLogisticPoint[] = [];
mapState.mapData.mapTask.forEach(item => {
const hospital = mapState.hospitalList.find(e => e.value == item.hospitalId),
org = mapState.orgList.find(e => e.value == item.orgId);
org = item.orgId ? mapState.orgList.find(e => e.value == item.orgId) : {} as MapPointType;
// ,,,
if (!hospital) {
throw notification.error({
@ -731,28 +746,30 @@ @@ -731,28 +746,30 @@
key: item.key,
taskType: item.taskType,
hospitalId: org?.value,
hospitalName: org?.label
hospitalName: org?.label ?? item.orgName
});
});
// ,
await listMapTaskPreset({ size: 40, courierUserId: mapState.mapData.courierUserId }).then(res => {
res.data?.map(item => {
const taskPresetHospital = item.orginPresetId ? mapState.hospitalList.find(e => e.value == item.orginPresetId) : {} as MapPointType,
taskPresetOrg = item.destinationPresetId ? mapState.orgList.find(e => e.value == item.destinationPresetId) : {} as MapPointType;
pointData.push({
lng: item.orginPresetLng,
lat: item.orginPresetLat,
lng: taskPresetHospital?.mapLng ?? item.orginPresetLng,
lat: taskPresetHospital?.mapLat ?? item.orginPresetLat,
type: '0',
taskType: '1',
mapTaskId: item.id,
hospitalId: item.orginPresetId,
hospitalName: item.orginPresetName
hospitalId: taskPresetHospital?.value ?? item.orginPresetId,
hospitalName: taskPresetHospital?.label ?? item.orginPresetName
}, {
lng: item.destinationPresetLng,
lat: item.destinationPresetLat,
lng: taskPresetOrg?.mapLng ?? item.destinationPresetLng,
lat: taskPresetOrg?.mapLat ?? item.destinationPresetLat,
type: '1',
taskType: '1',
mapTaskId: item.id,
hospitalId: item.destinationPresetId,
hospitalName: item.destinationPresetName
hospitalId: taskPresetOrg?.value ?? item.destinationPresetId,
hospitalName: taskPresetOrg?.label ?? item.destinationPresetName
});
});
});
@ -773,7 +790,7 @@ @@ -773,7 +790,7 @@
async function handleMapSave() {
await formElRef.value.validate();
const mapData = toRaw(mapState.mapData);
mapData.fileId = (mapData.fileId as[])?.join(',');
isArray(mapData.fileId) && (mapData.fileId = mapData.fileId.join(','));
mapData.mapTask.forEach(item => {
const hospital = item.hospitalId && mapState.hospitalList.find(e => e.value == item.hospitalId),
org = item.orgId && mapState.orgList.find(e => e.value == item.orgId);
@ -788,7 +805,7 @@ @@ -788,7 +805,7 @@
orgLng: org.mapLng,
orgLat: org.mapLat
});
item.fileId = (item.fileId as [])?.join(',');
isArray(item.fileId) && (item.fileId = item.fileId.join(','));
if (~~item.taskType == 1) {
item?.mapTaskPreset?.forEach(childItem => {
const childHospital = childItem.orginPresetId && mapState.hospitalList.find(e => e.value == childItem.orginPresetId),
@ -804,7 +821,7 @@ @@ -804,7 +821,7 @@
destinationPresetLng: childOrg.mapLng,
destinationPresetLat: childOrg.mapLat
});
childItem.fileId = (childItem.fileId as [])?.join(',');
isArray(childItem.fileId) && (childItem.fileId = childItem.fileId.join(','));
});
}
});

Loading…
Cancel
Save