diff --git a/src/components/card/point-detail-card.vue b/src/components/card/point-detail-card.vue index 98b55b4..7175aef 100644 --- a/src/components/card/point-detail-card.vue +++ b/src/components/card/point-detail-card.vue @@ -6,6 +6,46 @@ import sTheme from '@core/theme.service'; import { isNil } from 'lodash-es'; import { computed, inject, type InjectionKey, type ShallowRef } from 'vue'; +// 库位任务相关类型定义 +interface BinTaskOperation { + operation: string; + recfile?: string; + recognize?: boolean; + use_down_pgv?: boolean; + use_pgv?: boolean; + pgv_x_adjust?: boolean; +} + +interface BinTaskItem { + Load?: BinTaskOperation; + Unload?: BinTaskOperation; +} + +interface BinLocationProperty { + key: string; + type: string; + stringValue: string; +} + +interface BinLocationItem { + className: string; + instanceName: string; + pointName: string; + pos: { + x: number; + y: number; + }; + property: BinLocationProperty[]; +} + +interface BinLocationGroup { + binLocationList: BinLocationItem[]; +} + +interface BinLocationsList { + binLocationsList: BinLocationGroup[]; +} + type Props = { token: InjectionKey>; current?: string; @@ -85,6 +125,46 @@ const getStorageStatusTag = (location: StorageLocationInfo) => { return tags; }; + +// 解析库位任务数据 +const parseBinTask = (binTaskString: string): BinTaskItem[] => { + try { + return JSON.parse(binTaskString.replace(/\n/g, '').trim()); + } catch (error) { + console.error('解析库位任务数据失败:', error); + return []; + } +}; + +// 获取当前动作点对应的库位任务数据 +const binTaskData = computed(() => { + const rawData = editor.value.getBinLocationsList(); + + if (!rawData || !point.value) return []; + + const currentPointName = pen.value?.label || pen.value?.id; + if (!currentPointName) return []; + + // 获取库位组数据 + const binLocationGroups = Array.isArray(rawData) + ? (rawData as BinLocationGroup[]) + : (rawData as BinLocationsList)?.binLocationsList; + + if (!binLocationGroups) return []; + + const allBinLocations = binLocationGroups.flatMap((group) => group.binLocationList); + + return allBinLocations + .filter((item) => item.pointName === currentPointName) + .map((item) => { + const binTaskProperty = item.property.find((prop) => prop.key === 'binTask'); + return { + instanceName: item.instanceName, + binTasks: binTaskProperty ? parseBinTask(binTaskProperty.stringValue) : [], + }; + }) + .filter((item) => item.binTasks.length > 0); +}); @@ -259,5 +375,80 @@ const getStorageStatusTag = (location: StorageLocationInfo) => { } } } + + .bin-task-container { + .bin-task-group { + margin-bottom: 16px; + padding: 12px; + border-radius: 4px; + background-color: get-color(fill1); + border: 1px solid get-color(border1); + + &:last-child { + margin-bottom: 0; + } + + .bin-location-name { + font-weight: 600; + color: get-color(text1); + margin-bottom: 8px; + display: block; + } + + .bin-tasks { + .bin-task-item { + margin-bottom: 12px; + + &:last-child { + margin-bottom: 0; + } + + .task-operation { + margin-bottom: 8px; + padding: 8px; + border-radius: 4px; + background-color: get-color(fill2); + + &:last-child { + margin-bottom: 0; + } + + .operation-title { + font-weight: 500; + color: get-color(primary); + margin-bottom: 6px; + display: block; + } + + .operation-details { + .detail-item { + display: flex; + justify-content: space-between; + margin-bottom: 4px; + font-size: 12px; + + &:last-child { + margin-bottom: 0; + } + + .detail-key { + color: get-color(text2); + font-weight: 500; + flex-shrink: 0; + margin-right: 8px; + } + + .detail-value { + color: get-color(text1); + text-align: right; + word-break: break-all; + } + } + } + } + } + } + } + } } diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index 575d555..27a656e 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -98,6 +98,14 @@ export class EditorService extends Meta2d { return JSON.stringify(scene); } + /** + * 获取库位任务配置数据 + * @returns 库位任务配置列表 + */ + public getBinLocationsList(): unknown { + return (this.#originalSceneData as Record)?.binLocationsList; + } + /** * 加载机器人数据到编辑器 * @param groups 机器人组列表