feat: 添加检查动作点及其库位信息的功能,优化右键菜单显示逻辑

This commit is contained in:
xudan 2025-09-05 01:34:25 +08:00
parent bc836c22c7
commit d105719a07

View File

@ -3,6 +3,8 @@
*
*/
import { MapPointType } from '@api/map';
export interface ParsedEventData {
type: 'robot' | 'point' | 'area' | 'storage' | 'storage-background' | 'default';
id?: string;
@ -408,14 +410,26 @@ export function getMenuConfig(type: string, data: ParsedEventData, storageLocati
};
}
case 'point': {
// 点区域:显示该点关联的库位信息
// 点区域:只有动作点且有库位信息时才显示库位菜单
console.log(`处理点区域类型点ID: ${data.pointId}`);
const pointStorageLocations = getStorageLocationsForPoint(data, storageLocationService);
console.log(`找到 ${pointStorageLocations.length} 个库位:`, pointStorageLocations);
return {
menuType: 'storage-background' as const,
storageLocations: pointStorageLocations,
};
// 检查是否为动作点且有库位信息
const isActionPointWithStorage = checkIfActionPointWithStorage(data);
if (isActionPointWithStorage) {
const pointStorageLocations = getStorageLocationsForPoint(data, storageLocationService);
console.log(`动作点找到 ${pointStorageLocations.length} 个库位:`, pointStorageLocations);
return {
menuType: 'storage-background' as const,
storageLocations: pointStorageLocations,
};
} else {
console.log('非动作点或无库位信息,显示默认菜单');
return {
menuType: 'default' as const,
storageLocations: [],
};
}
}
default:
return {
@ -426,6 +440,42 @@ export function getMenuConfig(type: string, data: ParsedEventData, storageLocati
}
/**
*
* @param data
* @returns
*/
function checkIfActionPointWithStorage(data: ParsedEventData): boolean {
// 从pen数据中获取点信息
const pen = data.pen;
if (!pen) {
console.log('无pen数据不是动作点');
return false;
}
const pointInfo = pen.point as any;
if (!pointInfo) {
console.log('无point信息不是动作点');
return false;
}
// 检查是否为动作点
const isActionPoint = pointInfo.type === MapPointType.;
if (!isActionPoint) {
console.log(`点类型为 ${pointInfo.type},不是动作点`);
return false;
}
// 检查是否有库位信息
const hasStorageLocations = pointInfo.associatedStorageLocations &&
Array.isArray(pointInfo.associatedStorageLocations) &&
pointInfo.associatedStorageLocations.length > 0;
console.log(`动作点检查结果: 是动作点=${isActionPoint}, 有库位信息=${hasStorageLocations}`);
return isActionPoint && hasStorageLocations;
}
/**
* ID的所有库位信息
* @param pointId ID