移除不必要的节点输出引用相关代码,简化参数处理逻辑。
This commit is contained in:
@@ -222,33 +222,9 @@
|
||||
<span class="input-source-field-name">{{ fieldName }}</span>
|
||||
<el-button type="danger" link size="small" @click="removeInputSource(sourceNode.nodeId, fieldName)">删除</el-button>
|
||||
</div>
|
||||
<!-- 引用节点输出开关 -->
|
||||
<div class="input-source-quote">
|
||||
<el-switch
|
||||
:model-value="sourceNode.quoteOutput === true"
|
||||
@change="(val: boolean) => updateQuoteOutput(sourceNode.nodeId, val)"
|
||||
size="small"
|
||||
active-text="引入输出"
|
||||
inactive-text=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 显示所有上级节点的输出引用选项 -->
|
||||
<div v-if="availableParentNodes.length > 0" class="parent-nodes-output">
|
||||
<div class="parent-nodes-title">上级节点输出</div>
|
||||
<div v-for="parentNode in availableParentNodes" :key="parentNode.id" class="parent-node-output-item">
|
||||
<span class="parent-node-name">{{ parentNode.name }}</span>
|
||||
<el-switch
|
||||
:model-value="isNodeOutputQuoted(parentNode.id)"
|
||||
@change="(val: boolean) => toggleNodeOutput(parentNode.id, val)"
|
||||
size="small"
|
||||
active-text="引入输出"
|
||||
inactive-text=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<el-form-item label="选择参数">
|
||||
<el-select v-model="selectedParentParam" placeholder="选择上级节点的参数" class="w100" @change="addParentParam">
|
||||
<el-option v-for="param in availableParentParams" :key="param.value" :label="param.label" :value="param.value" />
|
||||
@@ -1157,12 +1133,6 @@ const availableParentParams = computed(() => {
|
||||
// 如果是判断节点,跳过不添加其字段
|
||||
if (isJudge) return;
|
||||
|
||||
// 首先添加节点的整体输出选项
|
||||
params.push({
|
||||
label: `${parentNodeName}【整体输出】`,
|
||||
value: `\${${parentId}}`,
|
||||
});
|
||||
|
||||
// 只添加可引用字段(HTTP节点仅允许结果返回结构;其他节点维持原逻辑)
|
||||
if (parentProps.formConfig && Array.isArray(parentProps.formConfig)) {
|
||||
if (nodeCode === 'http') {
|
||||
@@ -1312,7 +1282,8 @@ const workflowDsl = computed(() => ({
|
||||
modelConfig: n.properties?.modelConfig
|
||||
? {
|
||||
...n.properties.modelConfig,
|
||||
modelResponse: n.properties.modelConfig?.modelResponse || n.properties?.modelResponse || null, }
|
||||
modelResponse: n.properties.modelConfig?.modelResponse || n.properties?.modelResponse || null,
|
||||
}
|
||||
: null,
|
||||
isSaveFile: n.properties?.isSaveFileEnabled ?? null,
|
||||
promptContent: n.properties?.promptData?.prompt || null,
|
||||
@@ -2643,7 +2614,9 @@ const getHttpBodyData = (field: string) => {
|
||||
const refNodeId = String(rawItem.value.nodeId || '').trim();
|
||||
const refField = String(rawItem.value.field || '').trim();
|
||||
if (refNodeId) {
|
||||
rawItem.value = refField === 'nodeOutputResult' ? `\${${refNodeId}}` : refField ? `\${${refNodeId}.${refField}}` : rawItem.value;
|
||||
if (refField) {
|
||||
rawItem.value = `\${${refNodeId}.${refField}}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2832,7 +2805,7 @@ const confirmHttpBodyConfig = () => {
|
||||
const rawValue = item?.value;
|
||||
let normalizedValue: any = rawValue;
|
||||
|
||||
// 如果 value 选择了上级参数(形如 ${nodeId.field})或上级节点整体输出(形如 ${nodeId}),转成对象结构传给后端
|
||||
// 如果 value 选择了上级参数(形如 ${nodeId.field}),转成对象结构传给后端
|
||||
if (typeof rawValue === 'string') {
|
||||
const matched = rawValue.match(/^\$\{([^\.}]+)\.([^}]+)\}$/);
|
||||
if (matched) {
|
||||
@@ -2841,15 +2814,6 @@ const confirmHttpBodyConfig = () => {
|
||||
nodeId: matched[1],
|
||||
quoteOutput: false,
|
||||
};
|
||||
} else {
|
||||
const nodeOutputMatched = rawValue.match(/^\$\{([^}]+)\}$/);
|
||||
if (nodeOutputMatched) {
|
||||
normalizedValue = {
|
||||
field: 'nodeOutputResult',
|
||||
nodeId: nodeOutputMatched[1],
|
||||
quoteOutput: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3136,163 +3100,6 @@ const removeInputSource = (nodeId: string, paramName: string) => {
|
||||
syncDsl();
|
||||
ElMessage.success(`已删除参数:${paramName}`);
|
||||
};
|
||||
// 更新指定节点的 quoteOutput 状态
|
||||
const updateQuoteOutput = (nodeId: string, enabled: boolean) => {
|
||||
if (!selectedElement.value || !nodeId) return;
|
||||
const lf = logicFlowInstance.value;
|
||||
if (!lf) return;
|
||||
|
||||
const currentProps = selectedElement.value.properties || {};
|
||||
let inputSource = Array.isArray(currentProps.inputSource) ? [...currentProps.inputSource] : [];
|
||||
|
||||
// 查找该节点
|
||||
const nodeIndex = inputSource.findIndex((item: any) => item.nodeId === nodeId);
|
||||
if (nodeIndex < 0) return;
|
||||
|
||||
// 更新 quoteOutput
|
||||
inputSource[nodeIndex] = {
|
||||
...inputSource[nodeIndex],
|
||||
quoteOutput: enabled,
|
||||
};
|
||||
|
||||
lf.setProperties(selectedElement.value.id, {
|
||||
...currentProps,
|
||||
inputSource,
|
||||
});
|
||||
|
||||
// 只更新 properties,不重新赋值整个 selectedElement,避免触发 watch 重置表单
|
||||
selectedElement.value.properties = {
|
||||
...currentProps,
|
||||
inputSource,
|
||||
};
|
||||
|
||||
syncDsl();
|
||||
|
||||
// 获取节点名称用于提示
|
||||
const nodeName = formatParamReference(`\${${nodeId}.field}`).split('.')[0];
|
||||
ElMessage.success(enabled ? `已开启引入 ${nodeName} 的输出` : `已关闭引入 ${nodeName} 的输出`);
|
||||
};
|
||||
// 获取所有上级节点(用于显示输出引用选项)
|
||||
const availableParentNodes = computed(() => {
|
||||
if (!selectedElement.value) return [];
|
||||
const lf = logicFlowInstance.value;
|
||||
if (!lf) return [];
|
||||
|
||||
const graphData = lf.getGraphData() as { nodes?: Item[]; edges?: Item[] };
|
||||
const edges = graphData.edges || [];
|
||||
const nodes = graphData.nodes || [];
|
||||
|
||||
// 获取已经引用了字段的节点ID列表
|
||||
const inputSource = selectedElement.value.properties?.inputSource;
|
||||
const nodesWithFields = new Set<string>();
|
||||
if (Array.isArray(inputSource)) {
|
||||
inputSource.forEach((item: any) => {
|
||||
if (item.field && item.field.length > 0) {
|
||||
nodesWithFields.add(item.nodeId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 递归查找所有上级节点
|
||||
const findAllParentNodes = (nodeId: string, visited = new Set<string>()): string[] => {
|
||||
if (visited.has(nodeId)) return [];
|
||||
visited.add(nodeId);
|
||||
|
||||
const incomingEdges = edges.filter((e) => e.targetNodeId === nodeId);
|
||||
const parentIds: string[] = [];
|
||||
|
||||
incomingEdges.forEach((edge) => {
|
||||
parentIds.push(edge.sourceNodeId);
|
||||
// 递归查找上级的上级
|
||||
parentIds.push(...findAllParentNodes(edge.sourceNodeId, visited));
|
||||
});
|
||||
|
||||
return parentIds;
|
||||
};
|
||||
|
||||
const allParentIds = findAllParentNodes(selectedElement.value.id);
|
||||
const parentNodes = allParentIds
|
||||
.map((parentId) => {
|
||||
const parentNode = nodes.find((n) => n.id === parentId);
|
||||
if (!parentNode) return null;
|
||||
|
||||
const nodeName = typeof parentNode.text === 'string' ? parentNode.text : parentNode.text?.value || '';
|
||||
const nodeCode = String(parentNode.properties?.nodeCode || '').toLowerCase();
|
||||
const nodeText = nodeName.toLowerCase();
|
||||
|
||||
// 判断是否为判断节点
|
||||
const isJudge = JUDGE_KEYWORDS.some((k) => nodeCode.includes(k) || nodeText.includes(k));
|
||||
|
||||
// 判断是否为开始节点
|
||||
const isStart = nodeCode === START_NODE_CODE || nodeText === START_NODE_TEXT.toLowerCase();
|
||||
|
||||
// 排除判断节点、开始节点、以及已经引用了字段的节点
|
||||
if (isJudge || isStart || nodesWithFields.has(parentId)) return null;
|
||||
|
||||
return {
|
||||
id: parentId,
|
||||
name: nodeName,
|
||||
isJudge: false,
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
return parentNodes as Array<{ id: string; name: string; isJudge: boolean }>;
|
||||
});
|
||||
// 检查节点输出是否被引用
|
||||
const isNodeOutputQuoted = (nodeId: string): boolean => {
|
||||
if (!selectedElement.value) return false;
|
||||
const inputSource = selectedElement.value.properties?.inputSource;
|
||||
if (!Array.isArray(inputSource)) return false;
|
||||
|
||||
const node = inputSource.find((item: any) => item.nodeId === nodeId);
|
||||
return node?.quoteOutput === true;
|
||||
};
|
||||
// 切换节点输出引用
|
||||
const toggleNodeOutput = (nodeId: string, enabled: boolean) => {
|
||||
if (!selectedElement.value || !nodeId) return;
|
||||
const lf = logicFlowInstance.value;
|
||||
if (!lf) return;
|
||||
|
||||
const currentProps = selectedElement.value.properties || {};
|
||||
let inputSource = Array.isArray(currentProps.inputSource) ? [...currentProps.inputSource] : [];
|
||||
|
||||
// 查找该节点
|
||||
const nodeIndex = inputSource.findIndex((item: any) => item.nodeId === nodeId);
|
||||
|
||||
if (nodeIndex >= 0) {
|
||||
// 节点已存在,更新 quoteOutput
|
||||
inputSource[nodeIndex] = {
|
||||
...inputSource[nodeIndex],
|
||||
quoteOutput: enabled,
|
||||
};
|
||||
} else {
|
||||
// 节点不存在,创建新的引用(只引用输出,不引用字段)
|
||||
inputSource.push({
|
||||
nodeId: nodeId,
|
||||
field: [],
|
||||
quoteOutput: enabled,
|
||||
});
|
||||
}
|
||||
|
||||
lf.setProperties(selectedElement.value.id, {
|
||||
...currentProps,
|
||||
inputSource,
|
||||
});
|
||||
|
||||
// 只更新 properties,不重新赋值整个 selectedElement,避免触发 watch 重置表单
|
||||
selectedElement.value.properties = {
|
||||
...currentProps,
|
||||
inputSource,
|
||||
};
|
||||
|
||||
syncDsl();
|
||||
|
||||
// 获取节点名称用于提示
|
||||
const parentNode = availableParentNodes.value.find((p) => p.id === nodeId);
|
||||
const nodeName = parentNode?.name || '节点';
|
||||
ElMessage.success(enabled ? `已开启引入 ${nodeName} 的输出` : `已关闭引入 ${nodeName} 的输出`);
|
||||
};
|
||||
const ensureDefaultStartNode = () => {
|
||||
const lf = logicFlowInstance.value;
|
||||
if (!lf) return;
|
||||
|
||||
Reference in New Issue
Block a user