feat(web): 增加循环节点参数
This commit is contained in:
@@ -2,17 +2,26 @@ import {Background, BackgroundVariant, type NodeProps} from '@xyflow/react'
|
|||||||
import {classnames} from 'amis'
|
import {classnames} from 'amis'
|
||||||
import React, {useCallback, useEffect, useMemo} from 'react'
|
import React, {useCallback, useEffect, useMemo} from 'react'
|
||||||
import AddNodeButton from '../component/AddNodeButton.tsx'
|
import AddNodeButton from '../component/AddNodeButton.tsx'
|
||||||
|
import {generateAllIncomerOutputVariablesFormOptions} from '../Helper.tsx'
|
||||||
|
import {useContextStore} from '../store/ContextStore.ts'
|
||||||
import {useDataStore} from '../store/DataStore.ts'
|
import {useDataStore} from '../store/DataStore.ts'
|
||||||
|
import {useFlowStore} from '../store/FlowStore.ts'
|
||||||
import {flowBackgroundColor, flowDotColor} from '../types.ts'
|
import {flowBackgroundColor, flowDotColor} from '../types.ts'
|
||||||
import AmisNode, {nodeClassName, NormalNodeHandler, outputsFormColumns} from './AmisNode.tsx'
|
import AmisNode, {nodeClassName, NormalNodeHandler, outputsFormColumns} from './AmisNode.tsx'
|
||||||
|
|
||||||
const LoopNode = (props: NodeProps) => {
|
const LoopNode = (props: NodeProps) => {
|
||||||
const {mergeDataById} = useDataStore()
|
const {getNodes, getEdges} = useFlowStore()
|
||||||
|
const {getData, mergeDataById} = useDataStore()
|
||||||
|
const {getInputSchema} = useContextStore()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
mergeDataById(
|
mergeDataById(
|
||||||
props.id,
|
props.id,
|
||||||
{
|
{
|
||||||
|
failFast: true,
|
||||||
|
parallel: false,
|
||||||
|
type: 'for',
|
||||||
|
count: 1,
|
||||||
outputs: {
|
outputs: {
|
||||||
output: {
|
output: {
|
||||||
type: 'array-object',
|
type: 'array-object',
|
||||||
@@ -27,6 +36,7 @@ const LoopNode = (props: NodeProps) => {
|
|||||||
type: 'switch',
|
type: 'switch',
|
||||||
name: 'failFast',
|
name: 'failFast',
|
||||||
label: '快速失败',
|
label: '快速失败',
|
||||||
|
required: true,
|
||||||
description: '执行过程中一旦出现错误,及时中断循环任务的执行',
|
description: '执行过程中一旦出现错误,及时中断循环任务的执行',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -34,6 +44,68 @@ const LoopNode = (props: NodeProps) => {
|
|||||||
type: 'switch',
|
type: 'switch',
|
||||||
name: 'parallel',
|
name: 'parallel',
|
||||||
label: '并行执行',
|
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',
|
type: 'divider',
|
||||||
|
|||||||
Reference in New Issue
Block a user