修复回显问题

This commit is contained in:
2026-06-06 10:10:12 +08:00
parent ee8ba0a5d9
commit 367cd98018

View File

@@ -734,10 +734,15 @@
allow-create allow-create
default-first-option default-first-option
clearable clearable
placeholder="可手动输入或选择上级参数" placeholder="可手动输入或选择上级字段"
class="w100" class="w100"
> >
<el-option v-for="param in availableParentParams" :key="param.value" :label="param.label" :value="param.value" /> <el-option
v-for="param in getHttpBodyReferenceOptions(fieldValue.value)"
:key="param.value"
:label="param.label"
:value="param.value"
/>
</el-select> </el-select>
</div> </div>
@@ -1183,6 +1188,32 @@ const availableParentParams = computed(() => {
return params; return params;
}); });
const availableParentFieldParams = computed(() =>
availableParentParams.value.filter((item) => {
const value = String(item.value || '').trim();
const label = String(item.label || '').trim();
return value !== '${}' && !value.endsWith('.nodeOutputResult}') && !label.endsWith('.输出结果');
})
);
const getReferenceDisplayLabel = (value: string) => {
const formatted = formatParamReference(value);
return formatted === value ? value : formatted;
};
const getHttpBodyReferenceOptions = (currentValue?: string) => {
const options = [...availableParentFieldParams.value];
const normalizedValue = String(currentValue || '').trim();
if (!normalizedValue) return options;
if (options.some((item) => item.value === normalizedValue)) return options;
const isReferenceValue = /^\$\{[^.}]+\.[^}]+\}$/.test(normalizedValue);
if (!isReferenceValue) return options;
return [
...options,
{
label: getReferenceDisplayLabel(normalizedValue),
value: normalizedValue,
},
];
};
const treeProps = { children: 'children', label: 'label' }; const treeProps = { children: 'children', label: 'label' };
const apiBaseUrl = (import.meta.env.VITE_API_URL || '').replace(/\/$/, ''); const apiBaseUrl = (import.meta.env.VITE_API_URL || '').replace(/\/$/, '');
const nodeLibraryGroups = ref<NodeLibraryGroup[]>([]); const nodeLibraryGroups = ref<NodeLibraryGroup[]>([]);
@@ -2649,11 +2680,9 @@ const getHttpBodyData = (field: string) => {
if (rawItem.value && typeof rawItem.value === 'object' && !Array.isArray(rawItem.value)) { if (rawItem.value && typeof rawItem.value === 'object' && !Array.isArray(rawItem.value)) {
const refNodeId = String(rawItem.value.nodeId || '').trim(); const refNodeId = String(rawItem.value.nodeId || '').trim();
const refField = String(rawItem.value.field || '').trim(); const refField = String(rawItem.value.field || '').trim();
if (refNodeId) { if (refNodeId && refField) {
if (refField) {
rawItem.value = `\${${refNodeId}.${refField}}`; rawItem.value = `\${${refNodeId}.${refField}}`;
} }
}
} }
} }
}); });