From 3a61da054e5830c90412bcc370b5cb47f7c45596 Mon Sep 17 00:00:00 2001 From: v-zhangjc9 Date: Thu, 17 Jul 2025 18:37:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=20=E5=A2=9E=E5=8A=A0=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E8=8A=82=E7=82=B9=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/flow/node/LoopNode.tsx | 74 ++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/service-web/client/src/components/flow/node/LoopNode.tsx b/service-web/client/src/components/flow/node/LoopNode.tsx index 724fa50..c34069e 100644 --- a/service-web/client/src/components/flow/node/LoopNode.tsx +++ b/service-web/client/src/components/flow/node/LoopNode.tsx @@ -2,17 +2,26 @@ import {Background, BackgroundVariant, type NodeProps} from '@xyflow/react' import {classnames} from 'amis' import React, {useCallback, useEffect, useMemo} from 'react' import AddNodeButton from '../component/AddNodeButton.tsx' +import {generateAllIncomerOutputVariablesFormOptions} from '../Helper.tsx' +import {useContextStore} from '../store/ContextStore.ts' import {useDataStore} from '../store/DataStore.ts' +import {useFlowStore} from '../store/FlowStore.ts' import {flowBackgroundColor, flowDotColor} from '../types.ts' import AmisNode, {nodeClassName, NormalNodeHandler, outputsFormColumns} from './AmisNode.tsx' const LoopNode = (props: NodeProps) => { - const {mergeDataById} = useDataStore() + const {getNodes, getEdges} = useFlowStore() + const {getData, mergeDataById} = useDataStore() + const {getInputSchema} = useContextStore() useEffect(() => { mergeDataById( props.id, { + failFast: true, + parallel: false, + type: 'for', + count: 1, outputs: { output: { type: 'array-object', @@ -27,6 +36,7 @@ const LoopNode = (props: NodeProps) => { type: 'switch', name: 'failFast', label: '快速失败', + required: true, description: '执行过程中一旦出现错误,及时中断循环任务的执行', }, { @@ -34,6 +44,68 @@ const LoopNode = (props: NodeProps) => { type: 'switch', name: 'parallel', label: '并行执行', + required: true, + }, + { + type: 'select', + name: 'type', + label: '循环模式', + required: true, + options: [ + { + label: '次数循环', + value: 'for', + }, + { + label: '次数循环 (引用变量)', + value: 'for-variable', + }, + { + label: '对象循环', + value: 'for-object', + }, + ], + }, + { + visibleOn: '${type === \'for\'}', + type: 'input-number', + name: 'count', + label: '循环次数', + required: true, + min: 1, + precision: 0, + }, + { + visibleOn: '${type === \'for-variable\'}', + type: 'select', + name: 'countVariable', + label: '循环次数', + required: true, + selectMode: 'group', + options: generateAllIncomerOutputVariablesFormOptions( + props.id, + getInputSchema(), + getNodes(), + getEdges(), + getData(), + ['number'], + ), + }, + { + visibleOn: '${type === \'for-object\'}', + type: 'select', + name: 'countObject', + label: '循环对象', + required: true, + selectMode: 'group', + options: generateAllIncomerOutputVariablesFormOptions( + props.id, + getInputSchema(), + getNodes(), + getEdges(), + getData(), + ['array-text', 'array-object'], + ), }, { type: 'divider',