1
This commit is contained in:
parent
253b106454
commit
1ffd33bc20
@ -1062,6 +1062,44 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
message.success('节点配置已更新');
|
message.success('节点配置已更新');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 首先添加合并 schema 的工具函数
|
||||||
|
const mergeFormVariablesSchemas = (schemas: any[]) => {
|
||||||
|
// 初始化合并后的 schema
|
||||||
|
const mergedSchema = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: []
|
||||||
|
};
|
||||||
|
|
||||||
|
schemas.forEach(schema => {
|
||||||
|
if (!schema) return;
|
||||||
|
|
||||||
|
// 合并 properties
|
||||||
|
if (schema.properties) {
|
||||||
|
Object.entries(schema.properties).forEach(([key, property]) => {
|
||||||
|
// 如果属性已存在,检查是否完全相同
|
||||||
|
if (mergedSchema.properties[key]) {
|
||||||
|
if (JSON.stringify(mergedSchema.properties[key]) !== JSON.stringify(property)) {
|
||||||
|
console.warn(`属性 ${key} 在不同节点中定义不一致,使用第一个定义`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mergedSchema.properties[key] = property;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 合并 required 字段
|
||||||
|
if (schema.required) {
|
||||||
|
schema.required.forEach((field: string) => {
|
||||||
|
if (!mergedSchema.required.includes(field)) {
|
||||||
|
mergedSchema.required.push(field);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return mergedSchema;
|
||||||
|
};
|
||||||
// 处理保存工作流
|
// 处理保存工作流
|
||||||
const handleSaveWorkflow = async () => {
|
const handleSaveWorkflow = async () => {
|
||||||
if (!graph || !definitionData) return;
|
if (!graph || !definitionData) return;
|
||||||
@ -1111,13 +1149,21 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// 收集并合并所有节点的 formVariablesSchema
|
||||||
|
const allFormSchemas = nodes
|
||||||
|
.map(node => node.formVariablesSchema)
|
||||||
|
.filter(schema => schema); // 过滤掉空值
|
||||||
|
|
||||||
|
const mergedFormSchema = mergeFormVariablesSchemas(allFormSchemas);
|
||||||
|
|
||||||
// 构建保存数据
|
// 构建保存数据
|
||||||
const saveData = {
|
const saveData = {
|
||||||
...definitionData,
|
...definitionData,
|
||||||
graph: {
|
graph: {
|
||||||
nodes,
|
nodes,
|
||||||
edges
|
edges
|
||||||
}
|
},
|
||||||
|
formVariablesSchema: mergedFormSchema
|
||||||
};
|
};
|
||||||
|
|
||||||
// 调用保存接口
|
// 调用保存接口
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user