工作流 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:
2026-08-19 23:18:03 +08:00
co-authored by Claude
parent 68850c40fe
commit 998e13e6be
4 changed files with 42 additions and 22 deletions
@@ -217,7 +217,10 @@ export function collectExposedFields(params: any, prefix = ''): ExposedField[] {
const templates = arrayTemplatesOf(def);
templates.forEach((tpl: any, i: number) => {
if (tpl && typeof tpl === 'object' && tpl.attrs && typeof tpl.attrs === 'object' && !Array.isArray(tpl.attrs)) {
result.push(...collectExposedFields(tpl.attrs, `${path}.enumValues[${i}].attrs`));
// 索引与 collectAllLeafFields 一致:优先用 strip 时记录的原始模板索引 __originIndex
// 保证 modelFormFields 与 modelRequestParamsPath 的 path 索引对齐后端模型完整定义
const originIdx = typeof tpl.__originIndex === 'number' ? tpl.__originIndex : i;
result.push(...collectExposedFields(tpl.attrs, `${path}.enumValues[${originIdx}].attrs`));
}
});
} else if (def.runtimeShow === true) {
@@ -232,7 +235,11 @@ export function collectExposedFields(params: any, prefix = ''): ExposedField[] {
value: def.value,
defaultValue: def.defaultValue,
fieldConstraint: def.fieldConstraint && typeof def.fieldConstraint === 'object' ? def.fieldConstraint : undefined,
valueSource: Array.isArray(def.valueSource) ? def.valueSource : undefined,
valueSource: (() => {
const vs = def.valueSource;
// 契约统一数组;兼容旧 DSL 单对象 { nodeId, field }
return Array.isArray(vs) ? vs : vs && typeof vs === 'object' ? [vs] : undefined;
})(),
multiple: def.multiple || def.fieldType === 'uploadMultiple' || undefined,
});
}
@@ -299,12 +306,11 @@ export function buildModelRequestParamsPath(
outputIndex?: Map<string, { name: string; fields: Map<string, string> }>
): ModelRequestParamsPathItem[] {
const fields = collectAllLeafFields(params);
// 引用来源 label节点名.字段label无索引/未命中时兜底 field
// 引用来源 label字段中文名(不带「节点名.」前缀;无索引/未命中时兜底 field
const resolveRefLabel = (nodeId: string, field: string): string => {
const info = outputIndex?.get(nodeId);
if (!info) return field;
const fieldLabel = info.fields.get(field) || field;
return info.name ? `${info.name}.${fieldLabel}` : fieldLabel;
return info.fields.get(field) || field;
};
return fields.map(({ path, def }) => {
let valueSource: any;
@@ -348,10 +354,12 @@ export function restoreRuntimeShow(params: any, fields: ExposedField[] | null |
const cur = resolvePath(params, f.path);
if (cur && typeof cur === 'object' && !Array.isArray(cur)) {
cur.runtimeShow = true;
if (startNodeId && Array.isArray(cur.valueSource)) {
// 移除指向开始节点(表单展示标记)的引用;全部移除后删除整个 valueSource
cur.valueSource = cur.valueSource.filter((r: any) => !(r && r.nodeId === startNodeId));
if (cur.valueSource.length === 0) delete cur.valueSource;
if (startNodeId && cur.valueSource && typeof cur.valueSource === 'object') {
// 移除指向开始节点(表单展示标记)的引用;兼容旧 DSL 单对象(统一数组化),全部移除后删除整个 valueSource
const arr = Array.isArray(cur.valueSource) ? cur.valueSource : [cur.valueSource];
const keep = arr.filter((r: any) => !(r && r.nodeId === startNodeId));
if (keep.length === 0) delete cur.valueSource;
else cur.valueSource = keep;
}
}
}
@@ -392,8 +400,12 @@ function resolvePath(params: any, path: string): any {
if (me) {
const idx = Number(me[1]);
const templates = arrayTemplatesOf(cur);
if (idx >= templates.length) return undefined;
cur = templates[idx];
// 路径索引可能为 strip 压缩前记录的原始索引(__originIndex),优先按原始索引匹配;
// 未带 __originIndex 时退化为按数组位置匹配(未压缩场景)
const byOrigin = templates.find((t: any) => t && typeof t.__originIndex === 'number' && t.__originIndex === idx);
if (byOrigin !== undefined) cur = byOrigin;
else if (idx < templates.length) cur = templates[idx];
else return undefined;
continue;
}
cur = cur[seg];