feat: 添加检查动作点及其库位信息的功能,优化右键菜单显示逻辑
This commit is contained in:
parent
bc836c22c7
commit
d105719a07
@ -3,6 +3,8 @@
|
|||||||
* 提供纯函数和状态管理工具,避免单例模式的问题
|
* 提供纯函数和状态管理工具,避免单例模式的问题
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { MapPointType } from '@api/map';
|
||||||
|
|
||||||
export interface ParsedEventData {
|
export interface ParsedEventData {
|
||||||
type: 'robot' | 'point' | 'area' | 'storage' | 'storage-background' | 'default';
|
type: 'robot' | 'point' | 'area' | 'storage' | 'storage-background' | 'default';
|
||||||
id?: string;
|
id?: string;
|
||||||
@ -408,14 +410,26 @@ export function getMenuConfig(type: string, data: ParsedEventData, storageLocati
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'point': {
|
case 'point': {
|
||||||
// 点区域:显示该点关联的库位信息
|
// 点区域:只有动作点且有库位信息时才显示库位菜单
|
||||||
console.log(`处理点区域类型,点ID: ${data.pointId}`);
|
console.log(`处理点区域类型,点ID: ${data.pointId}`);
|
||||||
|
|
||||||
|
// 检查是否为动作点且有库位信息
|
||||||
|
const isActionPointWithStorage = checkIfActionPointWithStorage(data);
|
||||||
|
|
||||||
|
if (isActionPointWithStorage) {
|
||||||
const pointStorageLocations = getStorageLocationsForPoint(data, storageLocationService);
|
const pointStorageLocations = getStorageLocationsForPoint(data, storageLocationService);
|
||||||
console.log(`找到 ${pointStorageLocations.length} 个库位:`, pointStorageLocations);
|
console.log(`动作点找到 ${pointStorageLocations.length} 个库位:`, pointStorageLocations);
|
||||||
return {
|
return {
|
||||||
menuType: 'storage-background' as const,
|
menuType: 'storage-background' as const,
|
||||||
storageLocations: pointStorageLocations,
|
storageLocations: pointStorageLocations,
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
console.log('非动作点或无库位信息,显示默认菜单');
|
||||||
|
return {
|
||||||
|
menuType: 'default' as const,
|
||||||
|
storageLocations: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return {
|
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的所有库位信息
|
* 查找指定点ID的所有库位信息
|
||||||
* @param pointId 点ID
|
* @param pointId 点ID
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user