feat: 添加库位任务配置功能,解析并展示库位任务数据,优化组件结构和样式
This commit is contained in:
parent
0d1308b3b9
commit
d20376c435
@ -6,6 +6,46 @@ import sTheme from '@core/theme.service';
|
|||||||
import { isNil } from 'lodash-es';
|
import { isNil } from 'lodash-es';
|
||||||
import { computed, inject, type InjectionKey, type ShallowRef } from 'vue';
|
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 = {
|
type Props = {
|
||||||
token: InjectionKey<ShallowRef<EditorService>>;
|
token: InjectionKey<ShallowRef<EditorService>>;
|
||||||
current?: string;
|
current?: string;
|
||||||
@ -85,6 +125,46 @@ const getStorageStatusTag = (location: StorageLocationInfo) => {
|
|||||||
|
|
||||||
return tags;
|
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);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -183,6 +263,42 @@ const getStorageStatusTag = (location: StorageLocationInfo) => {
|
|||||||
</div>
|
</div>
|
||||||
</a-flex>
|
</a-flex>
|
||||||
</a-list-item>
|
</a-list-item>
|
||||||
|
<a-list-item v-if="MapPointType.动作点 === point.type && binTaskData.length">
|
||||||
|
<a-flex :gap="8" vertical>
|
||||||
|
<a-typography-text type="secondary">{{ $t('库位任务配置') }}</a-typography-text>
|
||||||
|
<div class="bin-task-container">
|
||||||
|
<div v-for="binLocation in binTaskData" :key="binLocation.instanceName" class="bin-task-group">
|
||||||
|
<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.Load" class="task-operation">
|
||||||
|
<a-typography-text class="operation-title">装载</a-typography-text>
|
||||||
|
<div class="operation-details">
|
||||||
|
<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 v-if="task.Unload" class="task-operation">
|
||||||
|
<a-typography-text class="operation-title">卸载</a-typography-text>
|
||||||
|
<div class="operation-details">
|
||||||
|
<div v-for="(value, key) in task.Unload" :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>
|
||||||
|
</div>
|
||||||
|
</a-flex>
|
||||||
|
</a-list-item>
|
||||||
</a-list>
|
</a-list>
|
||||||
</template>
|
</template>
|
||||||
<a-empty v-else :image="sTheme.empty" />
|
<a-empty v-else :image="sTheme.empty" />
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -98,6 +98,14 @@ export class EditorService extends Meta2d {
|
|||||||
return JSON.stringify(scene);
|
return JSON.stringify(scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取库位任务配置数据
|
||||||
|
* @returns 库位任务配置列表
|
||||||
|
*/
|
||||||
|
public getBinLocationsList(): unknown {
|
||||||
|
return (this.#originalSceneData as Record<string, unknown>)?.binLocationsList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载机器人数据到编辑器
|
* 加载机器人数据到编辑器
|
||||||
* @param groups 机器人组列表
|
* @param groups 机器人组列表
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user