工作流 valueSource label 契约统一:去节点名前缀 + outputConfig/subConfig 补全
- resolveRefLabel 去掉「节点名.」前缀,valueSource label 只保留字段中文名 - ModelField 引用 tag 展示同步去前缀 - buildOutputConfig(http/form/其它节点)与 serializeSubFlowConfig(subConfig)的 valueSource 补 label,subConfig 引用上游分支经 outputIndex 查上游字段中文名 - 取消引用改用 delete(避免写空数组),enumValues 按 __originIndex 统一索引 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1110,7 +1110,7 @@ const buildOutputConfig = (node: Node<NodeData>, startNodeId = '') => {
|
||||
const entry = formConfig.find((f: any) => f.field === def.field);
|
||||
const value = entry?.value ?? '';
|
||||
// 勾选「表单展示」的字段:值来自开始节点表单,补 valueSource 标记(后端契约)
|
||||
const valueSource = def.isFormField === true ? [{ nodeId: startNodeId, field: def.field }] : undefined;
|
||||
const valueSource = def.isFormField === true ? [{ nodeId: startNodeId, field: def.field, label: def.label || def.field }] : undefined;
|
||||
if (def.field === 'responseType') {
|
||||
const expand = entry?.expand || [];
|
||||
return {
|
||||
@@ -1139,7 +1139,7 @@ const buildOutputConfig = (node: Node<NodeData>, startNodeId = '') => {
|
||||
label: f.label || f.field || '',
|
||||
value: f.value ?? '',
|
||||
required: Boolean(f.required),
|
||||
...(fieldName ? { valueSource: [{ nodeId: startNodeId, field: fieldName }] } : {}),
|
||||
...(fieldName ? { valueSource: [{ nodeId: startNodeId, field: fieldName, label: f.label || f.field || fieldName }] } : {}),
|
||||
...(f.type === 'uploadMultiple'
|
||||
? {
|
||||
fieldConstraint: {
|
||||
@@ -1177,14 +1177,20 @@ const buildOutputConfig = (node: Node<NodeData>, startNodeId = '') => {
|
||||
label: def.label || def.field,
|
||||
// isFormField 字段值在开始节点运行表单,不重复保存(回显从开始节点反查)
|
||||
...(isForm ? {} : { value: entry?.value ?? '' }),
|
||||
...(isForm ? { valueSource: [{ nodeId: startNodeId, field: def.field }] } : {}),
|
||||
...(isForm ? { valueSource: [{ nodeId: startNodeId, field: def.field, label: def.label || def.field }] } : {}),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
// 子流程节点:编辑器态 subFlowConfig → DSL 保存态 subConfig(runtimeShow → isFormField)
|
||||
const serializeSubFlowConfig = (config: SubFlowConfig | null | undefined, node?: Node<NodeData>, startNodeId = '') => {
|
||||
const serializeSubFlowConfig = (config: SubFlowConfig | null | undefined, node?: Node<NodeData>, startNodeId = '', outputIndex?: Map<string, { name: string; fields: Map<string, string> }>) => {
|
||||
if (!config || !config.workflowId) return null;
|
||||
// 引用来源 label:字段中文名(不带「节点名.」前缀;无索引/未命中时兜底 field)
|
||||
const resolveRefLabel = (nodeId: string, field: string): string => {
|
||||
const info = outputIndex?.get(nodeId);
|
||||
if (!info) return field;
|
||||
return info.fields.get(field) || field;
|
||||
};
|
||||
// 生成次数(节点库 presetOption 的 maxConcurrency):勾选表单展示时聚合进开始节点表单,
|
||||
// 此处同步保存到 subConfig,保证 sub_flow 节点自身也带该配置(后端执行时可读)
|
||||
const formConfig = Array.isArray(node?.data?.formConfig) ? node.data.formConfig : [];
|
||||
@@ -1211,9 +1217,9 @@ const serializeSubFlowConfig = (config: SubFlowConfig | null | undefined, node?:
|
||||
// - 引用上级输出:值来自主工作流上游节点,统一转 field
|
||||
// - 其余:无引用(静态默认值)
|
||||
valueSource: f.runtimeShow
|
||||
? [{ nodeId: startNodeId, field: f.field }]
|
||||
? [{ nodeId: startNodeId, field: f.field, label: f.label || f.field }]
|
||||
: Array.isArray(f.valueSource)
|
||||
? f.valueSource.map((vs: any) => ({ nodeId: vs.nodeId, field: vs.field }))
|
||||
? f.valueSource.map((vs: any) => ({ nodeId: vs.nodeId, field: vs.field, label: resolveRefLabel(vs?.nodeId, vs?.field) }))
|
||||
: null,
|
||||
isFormField: Boolean(f.runtimeShow),
|
||||
})),
|
||||
@@ -1455,7 +1461,7 @@ const confirmSaveWorkflow = async () => {
|
||||
...(n.data?.postTool ? { postTool: n.data.postTool } : {}),
|
||||
isSaveFile: Boolean(n.data?.isSaveFile),
|
||||
// 子流程节点:序列化引入的工作流配置(含 workflowId 与 isFormField 标记);其余节点保持 null
|
||||
subConfig: nodeCode === 'sub_flow' ? serializeSubFlowConfig(n.data?.subFlowConfig, n, startNode?.id || '') : null,
|
||||
subConfig: nodeCode === 'sub_flow' ? serializeSubFlowConfig(n.data?.subFlowConfig, n, startNode?.id || '', outputFieldsIndex) : null,
|
||||
modelConfig: {
|
||||
modelId: n.data?.modelConfig?.modelId || '',
|
||||
// 模型名称/类型随工作流保存,供首页补全弹窗展示模型名与「同类型模型」过滤
|
||||
|
||||
Reference in New Issue
Block a user