feat: 支持动态扩展任务操作类型,优化任务操作显示逻辑
This commit is contained in:
parent
26af765dc8
commit
a1e126c471
@ -170,8 +170,8 @@ export interface BinTaskOperation {
|
||||
}
|
||||
|
||||
export interface BinTaskItem {
|
||||
Load?: BinTaskOperation;
|
||||
Unload?: BinTaskOperation;
|
||||
// 支持任意任务类型的动态扩展
|
||||
[key: string]: BinTaskOperation | undefined;
|
||||
}
|
||||
|
||||
export interface BinLocationProperty {
|
||||
|
||||
@ -1,6 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { MapAreaType, type MapPen, type MapPointInfo, MapPointType, type Rect } from '@api/map';
|
||||
import type { BinLocationGroup, BinLocationsList, BinTaskItem, StorageLocationInfo } from '@api/scene';
|
||||
import type {
|
||||
BinLocationGroup,
|
||||
BinLocationsList,
|
||||
BinTaskItem,
|
||||
BinTaskOperation,
|
||||
StorageLocationInfo,
|
||||
} from '@api/scene';
|
||||
import type { EditorService } from '@core/editor.service';
|
||||
import sTheme from '@core/theme.service';
|
||||
import { isNil } from 'lodash-es';
|
||||
@ -96,6 +102,42 @@ const parseBinTask = (binTaskString: string): BinTaskItem[] => {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取任务中的所有操作
|
||||
const getTaskOperations = (task: BinTaskItem) => {
|
||||
if (!task || typeof task !== 'object') return {};
|
||||
|
||||
const operations: Record<string, BinTaskOperation> = {};
|
||||
|
||||
// 遍历任务对象的所有属性,查找操作对象
|
||||
for (const [key, value] of Object.entries(task)) {
|
||||
if (value && typeof value === 'object' && 'operation' in value) {
|
||||
operations[key] = value as BinTaskOperation;
|
||||
}
|
||||
}
|
||||
|
||||
return operations;
|
||||
};
|
||||
|
||||
// 获取操作类型的显示名称
|
||||
const getOperationDisplayName = (operationType: string): string => {
|
||||
const operationNames: Record<string, string> = {
|
||||
Load: '装载',
|
||||
JackLoad: '装载',
|
||||
Unload: '卸载',
|
||||
JackUnload: '卸载',
|
||||
Move: '移动',
|
||||
Pick: '拾取',
|
||||
Place: '放置',
|
||||
Scan: '扫描',
|
||||
Check: '检查',
|
||||
Wait: '等待',
|
||||
Charge: '充电',
|
||||
Clean: '清理',
|
||||
};
|
||||
|
||||
return operationNames[operationType] || operationType || '未知操作';
|
||||
};
|
||||
|
||||
// 获取当前动作点对应的库位任务数据
|
||||
const binTaskData = computed(() => {
|
||||
try {
|
||||
@ -254,31 +296,20 @@ const binTaskData = computed(() => {
|
||||
<a-typography-text class="bin-location-name">{{ binLocation.instanceName }}</a-typography-text>
|
||||
<div class="bin-tasks">
|
||||
<div v-for="(task, taskIndex) in binLocation.binTasks" :key="taskIndex" class="bin-task-item">
|
||||
<div v-if="task && task.Load && typeof task.Load === 'object'" class="task-operation">
|
||||
<a-typography-text class="operation-title">装载</a-typography-text>
|
||||
<div
|
||||
v-for="(operation, operationType) in getTaskOperations(task)"
|
||||
:key="operationType"
|
||||
class="task-operation"
|
||||
>
|
||||
<a-typography-text class="operation-title">
|
||||
{{ getOperationDisplayName(operationType) }}
|
||||
</a-typography-text>
|
||||
<div class="operation-summary">
|
||||
<span class="operation-type">{{ task.Load.operation || '未知操作' }}</span>
|
||||
<span class="operation-type">{{ operation.operation || '未知操作' }}</span>
|
||||
<div class="operation-tooltip">
|
||||
<i class="icon detail" />
|
||||
<div class="tooltip-content">
|
||||
<div v-for="(value, key) in task.Load" :key="key" class="detail-item">
|
||||
<span class="detail-key">{{ key }}:</span>
|
||||
<span class="detail-value">
|
||||
{{ typeof value === 'boolean' ? (value ? '是' : '否') : (value ?? '未知') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="task && task.Unload && typeof task.Unload === 'object'" class="task-operation">
|
||||
<a-typography-text class="operation-title">卸载</a-typography-text>
|
||||
<div class="operation-summary">
|
||||
<span class="operation-type">{{ task.Unload.operation || '未知操作' }}</span>
|
||||
<div class="operation-tooltip">
|
||||
<i class="icon detail" />
|
||||
<div class="tooltip-content">
|
||||
<div v-for="(value, key) in task.Unload" :key="key" class="detail-item">
|
||||
<div v-for="(value, key) in operation" :key="key" class="detail-item">
|
||||
<span class="detail-key">{{ key }}:</span>
|
||||
<span class="detail-value">
|
||||
{{ typeof value === 'boolean' ? (value ? '是' : '否') : (value ?? '未知') }}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user