From 48a4636a81bb215392c8f8c037ff39ce48be295c Mon Sep 17 00:00:00 2001 From: 2910410219 <2910410219@qq.com> Date: Thu, 4 Jun 2026 18:04:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E8=8A=82=E7=82=B9=E8=BE=93=E5=87=BA=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=EF=BC=8C=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/settings/creation/index.vue | 205 +------------------------- 1 file changed, 6 insertions(+), 199 deletions(-) diff --git a/src/views/settings/creation/index.vue b/src/views/settings/creation/index.vue index e1c8685..d6d1b0e 100644 --- a/src/views/settings/creation/index.vue +++ b/src/views/settings/creation/index.vue @@ -222,33 +222,9 @@ {{ fieldName }} 删除 - -
- -
- -
-
上级节点输出
-
- {{ parentNode.name }} - -
-
@@ -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(); - 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[] => { - 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;