修复转换数据不完整问题
This commit is contained in:
@@ -72,7 +72,7 @@ import { createGraphScenarioElement, createGraphTaskElementFromScenario } from '
|
||||
|
||||
import PlatformCard from './platform-card.vue';
|
||||
import NodesCard from './nodes-card.vue';
|
||||
import { findOneScenarioById, saveScenario, findRelations, getAllBehaviorTreesBySceneId } from './api';
|
||||
import { findOneScenarioById, saveScenario, findRelations, getAllBehaviorTreesBySceneId, findPlatformWithComponents } from './api';
|
||||
import { resolveConnectionRelation } from './relation';
|
||||
import { generateRandomCommunicationData } from './random-data-generator';
|
||||
import { convertRecordsToGraphContainer, type CommunicationRecord } from './data-converter';
|
||||
@@ -278,8 +278,45 @@ export default defineComponent({
|
||||
|
||||
console.log('标准化后的第一条记录:', normalizedRelations[0]);
|
||||
|
||||
// 转换为图数据
|
||||
const convertedGraph = convertRecordsToGraphContainer(normalizedRelations);
|
||||
// 获取平台列表(包含完整的组件信息)
|
||||
message.loading({ content: '正在获取平台信息...', key: 'loading-platforms' });
|
||||
const platformResponse = await findPlatformWithComponents(currentScenario.value.id);
|
||||
|
||||
if (!platformResponse.data || platformResponse.data.length === 0) {
|
||||
console.warn('未能获取平台列表,将使用简化的组件信息');
|
||||
message.destroy('loading-platforms');
|
||||
|
||||
// 即使没有平台数据也继续转换(传入场景ID)
|
||||
const convertedGraph = convertRecordsToGraphContainer(
|
||||
normalizedRelations,
|
||||
undefined,
|
||||
undefined,
|
||||
currentScenario.value.id
|
||||
);
|
||||
console.log('转换后的图数据:', convertedGraph);
|
||||
|
||||
currentScenario.value.graph = convertedGraph;
|
||||
currentScenario.value.communicationGraph = JSON.stringify(convertedGraph);
|
||||
|
||||
message.success({ content: `成功加载 ${normalizedRelations.length} 条通信关系(无详细组件信息)`, key: 'loading-relations' });
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`获取到 ${platformResponse.data.length} 个平台的完整数据`);
|
||||
platformResponse.data.forEach(platform => {
|
||||
console.log(` 平台 "${platform.name}" (ID=${platform.id}) 有 ${platform.components?.length || 0} 个组件:`,
|
||||
platform.components?.map(c => c.name));
|
||||
});
|
||||
|
||||
// 转换为图数据(传入完整的平台数据数组和场景ID)
|
||||
const convertedGraph = convertRecordsToGraphContainer(
|
||||
normalizedRelations,
|
||||
undefined,
|
||||
platformResponse.data,
|
||||
currentScenario.value.id
|
||||
);
|
||||
|
||||
// 验证转换后的节点数据结构
|
||||
console.log('转换后的图数据:', convertedGraph);
|
||||
|
||||
// 更新当前场景的图数据
|
||||
@@ -469,10 +506,12 @@ export default defineComponent({
|
||||
|
||||
const handleSave = () => {
|
||||
const graphData: GraphContainer = resolveGraph(graph.value as Graph);
|
||||
console.log(graph.value);
|
||||
|
||||
|
||||
|
||||
const relations = resolveConnectionRelation(graph.value as Graph);
|
||||
console.error('relations',relations)
|
||||
|
||||
console.info('handleSave', graphData);
|
||||
if (!currentScenario.value) {
|
||||
message.error('当前决策树不存在');
|
||||
|
||||
Reference in New Issue
Block a user