refactor(ai-web): 使用输入节点代替inputSchema

将输入表单放在流程图中一起定义,方便统一参数的处理,不需要单独为输入表单的变量进行合并和操作
This commit is contained in:
2025-07-20 19:27:09 +08:00
parent a5282762ed
commit 267eecbf45
26 changed files with 114 additions and 205 deletions

View File

@@ -30,7 +30,7 @@ export const checkAddNode: (type: string, parentId: string | undefined, nodes: N
throw typeNotFound(type)
}
for (const checker of nodeDefine.checkers.add) {
let checkResult = checker(type, parentId, {}, nodes, edges, undefined)
let checkResult = checker(type, parentId, nodes, edges, undefined)
if (checkResult.error) {
throw addNodeError(checkResult.message)
}
@@ -86,7 +86,7 @@ export const nodeTypeNotFound = () => new CheckError(302, '节点类型不存在
export const saveNodeError = (nodeId: string, reason?: string) => new CheckError(303, reason ?? `节点配置存在错误:${nodeId}`)
// @ts-ignore
export const checkSave: (inputSchema: Record<string, Record<string, any>>, nodes: Node[], edges: Edge[], data: any) => void = (inputSchema, nodes, edges, data) => {
export const checkSave: (nodes: Node[], edges: Edge[], data: any) => void = (nodes, edges, data) => {
if (isEmpty(nodes)) {
throw atLeastOneNode()
}
@@ -102,7 +102,7 @@ export const checkSave: (inputSchema: Record<string, Record<string, any>>, nodes
let nodeType = node.type!
let nodeDefine = NodeRegistryMap[nodeType]
for (let checker of nodeDefine.checkers.save) {
let checkResult = checker(node.id, node.parentId, inputSchema, nodes, edges, data)
let checkResult = checker(node.id, node.parentId, nodes, edges, data)
if (checkResult.error) {
throw saveNodeError(node.id, checkResult.message)
}

View File

@@ -11,7 +11,6 @@ import AddNodeButton from './component/AddNodeButton.tsx'
import {checkAddConnection, checkSave} from './FlowChecker.tsx'
import {useNodeDrag} from './Helper.tsx'
import {NodeRegistryMap} from './NodeRegistry.tsx'
import {useContextStore} from './store/ContextStore.ts'
import {useDataStore} from './store/DataStore.ts'
import {useFlowStore} from './store/FlowStore.ts'
import {flowDotColor, type FlowEditorProps} from './types.ts'
@@ -58,8 +57,6 @@ function FlowEditor(props: FlowEditorProps) {
onConnect,
} = useFlowStore()
const {inputSchema, setInputSchema} = useContextStore()
useEffect(() => {
// language=JSON
// let initialData = JSON.parse('{"nodes":[{"id":"TCxPixrdkI","type":"start-node","position":{"x":-256,"y":109.5},"data":{},"measured":{"width":256,"height":83},"selected":false,"dragging":false},{"id":"tGs78_ietp","type":"llm-node","position":{"x":108,"y":-2.5},"data":{},"measured":{"width":256,"height":105},"selected":false,"dragging":false},{"id":"OeZdaU7LpY","type":"llm-node","position":{"x":111,"y":196},"data":{},"measured":{"width":256,"height":105},"selected":false,"dragging":false},{"id":"LjfoCYZo-E","type":"knowledge-node","position":{"x":497.62196259607214,"y":-10.792497317791003},"data":{},"measured":{"width":256,"height":75},"selected":false,"dragging":false},{"id":"sQM_22GYB5","type":"end-node","position":{"x":874.3164534765615,"y":151.70316541496913},"data":{},"measured":{"width":256,"height":75},"selected":false,"dragging":false},{"id":"KpMH_xc3ZZ","type":"llm-node","position":{"x":529.6286840434341,"y":150.4721376669937},"data":{},"measured":{"width":256,"height":75},"selected":false,"dragging":false},{"id":"pOrR6EMVbe","type":"switch-node","position":{"x":110.33793030183864,"y":373.9551529987239},"data":{},"measured":{"width":256,"height":157},"selected":false,"dragging":false}],"edges":[{"source":"TCxPixrdkI","sourceHandle":"source","target":"tGs78_ietp","targetHandle":"target","id":"xy-edge__TCxPixrdkIsource-tGs78_ietptarget"},{"source":"TCxPixrdkI","sourceHandle":"source","target":"OeZdaU7LpY","targetHandle":"target","id":"xy-edge__TCxPixrdkIsource-OeZdaU7LpYtarget"},{"source":"tGs78_ietp","sourceHandle":"source","target":"LjfoCYZo-E","targetHandle":"target","id":"xy-edge__tGs78_ietpsource-LjfoCYZo-Etarget"},{"source":"LjfoCYZo-E","sourceHandle":"source","target":"KpMH_xc3ZZ","targetHandle":"target","id":"xy-edge__LjfoCYZo-Esource-KpMH_xc3ZZtarget"},{"source":"OeZdaU7LpY","sourceHandle":"source","target":"KpMH_xc3ZZ","targetHandle":"target","id":"xy-edge__OeZdaU7LpYsource-KpMH_xc3ZZtarget"},{"source":"KpMH_xc3ZZ","sourceHandle":"source","target":"sQM_22GYB5","targetHandle":"target","id":"xy-edge__KpMH_xc3ZZsource-sQM_22GYB5target"},{"source":"TCxPixrdkI","sourceHandle":"source","target":"pOrR6EMVbe","id":"xy-edge__TCxPixrdkIsource-pOrR6EMVbe"},{"source":"pOrR6EMVbe","sourceHandle":"3","target":"sQM_22GYB5","targetHandle":"target","id":"xy-edge__pOrR6EMVbe3-sQM_22GYB5target"},{"source":"pOrR6EMVbe","sourceHandle":"1","target":"KpMH_xc3ZZ","targetHandle":"target","id":"xy-edge__pOrR6EMVbe1-KpMH_xc3ZZtarget"}],"data":{"tGs78_ietp":{"model":"qwen3","outputs":{"text":{"type":"string"}},"systemPrompt":"你是个聪明人"},"OeZdaU7LpY":{"model":"qwen3","outputs":{"text":{"type":"string"}},"systemPrompt":"你也是个聪明人"}}}')
@@ -72,7 +69,6 @@ function FlowEditor(props: FlowEditorProps) {
setNodes(initialNodes)
setEdges(initialEdges)
setInputSchema(props.inputSchema)
}, [props.graphData])
const {
@@ -127,7 +123,7 @@ function FlowEditor(props: FlowEditorProps) {
if (commonInfo.debug) {
console.info('Save', JSON.stringify({nodes, edges, data}))
}
checkSave(inputSchema, nodes, edges, data)
checkSave(nodes, edges, data)
props.onGraphDataChange({nodes, edges, data})
} catch (e) {
// @ts-ignore

View File

@@ -3,7 +3,6 @@ import type {Option} from 'amis/lib/Schema'
import {contain, find, has, isEqual, max, min, unique} from 'licia'
import {type DependencyList, type MouseEvent as ReactMouseEvent, useCallback, useRef} from 'react'
import Queue from 'yocto-queue'
import {originTypeMap} from '../../pages/ai/task/InputSchema.tsx'
import {useFlowStore} from './store/FlowStore.ts'
import {type OutputVariable, type OutputVariableType} from './types.ts'
@@ -21,17 +20,10 @@ export const getAllIncomerNodeById: (id: string, nodes: Node[], edges: Edge[]) =
return unique(result, (a, b) => isEqual(a, b))
}
export const getAllIncomerNodeOutputVariables: (id: string, inputSchema: Record<string, Record<string, any>>, nodes: Node[], edges: Edge[], data: any) => OutputVariable[] = (id, inputSchema, nodes, edges, data) => {
let inputSchemaVariables: OutputVariable[] = Object.keys(inputSchema).map(key => ({
group: '流程入参',
name: `${key}${inputSchema[key]?.label ? ` (${inputSchema[key].label})` : ''}`,
type: originTypeMap[inputSchema[key]?.type ?? ''],
variable: key,
}))
export const getAllIncomerNodeOutputVariables: (id: string, nodes: Node[], edges: Edge[], data: any) => OutputVariable[] = (id, nodes, edges, data) => {
let currentNode = find(nodes, n => isEqual(id, n.id))
if (!currentNode) {
return inputSchemaVariables
return []
}
let incomerIds = getAllIncomerNodeById(id, nodes, edges)
@@ -63,7 +55,6 @@ export const getAllIncomerNodeOutputVariables: (id: string, inputSchema: Record<
}
return [
...inputSchemaVariables,
...(currentNode.parentId ? [
{
group: '循环入参',
@@ -82,9 +73,9 @@ export const getAllIncomerNodeOutputVariables: (id: string, inputSchema: Record<
]
}
export const generateAllIncomerOutputVariablesFormOptions: (id: string, inputSchema: Record<string, Record<string, any>>, nodes: Node[], edges: Edge[], data: any, targetTypes?: OutputVariableType[]) => Option[] = (id, inputSchema, nodes, edges, data, targetTypes) => {
export const generateAllIncomerOutputVariablesFormOptions: (id: string, nodes: Node[], edges: Edge[], data: any, targetTypes?: OutputVariableType[]) => Option[] = (id, nodes, edges, data, targetTypes) => {
let optionMap: Record<string, Option[]> = {}
for (const item of getAllIncomerNodeOutputVariables(id, inputSchema, nodes, edges, data)) {
for (const item of getAllIncomerNodeOutputVariables(id, nodes, edges, data)) {
if (targetTypes && !contain(targetTypes, item.type)) {
continue
}
@@ -120,9 +111,9 @@ const numberDefaultOperator: string = 'equal'
const arrayOperators: ConditionOperator[] = ['is_empty', 'is_not_empty']
const arrayDefaultOperator: string = 'is_empty'
export const generateAllIncomerOutputVariablesConditions: (id: string, inputSchema: Record<string, Record<string, any>>, nodes: Node[], edges: Edge[], data: any) => Option[] = (id, inputSchema, nodes, edges, data) => {
export const generateAllIncomerOutputVariablesConditions: (id: string, nodes: Node[], edges: Edge[], data: any) => Option[] = (id, nodes, edges, data) => {
let optionMap: Record<string, Option[]> = {}
for (const item of getAllIncomerNodeOutputVariables(id, inputSchema, nodes, edges, data)) {
for (const item of getAllIncomerNodeOutputVariables(id, nodes, edges, data)) {
if (!optionMap[item.group]) {
optionMap[item.group] = []
}

View File

@@ -11,12 +11,12 @@ import type {AddNodeChecker, NodeDefine, SaveNodeChecker} from './types.ts'
import InputNode from './node/InputNode.tsx'
const inputSingleVariableChecker: (field: string) => SaveNodeChecker = field => {
return (id, _parentId, inputSchema, nodes, edges, data) => {
return (id, _parentId, nodes, edges, data) => {
let nodeData = data[id] ?? {}
if (has(nodeData, field)) {
let expression = nodeData?.[field] ?? ''
if (!isEmpty(expression)) {
let outputVariables = new Set(getAllIncomerNodeOutputVariables(id, inputSchema, nodes, edges, data).map(i => i.variable))
let outputVariables = new Set(getAllIncomerNodeOutputVariables(id, nodes, edges, data).map(i => i.variable))
if (!outputVariables.has(expression)) {
return {
error: true,
@@ -29,12 +29,12 @@ const inputSingleVariableChecker: (field: string) => SaveNodeChecker = field =>
}
}
const inputMultiVariableChecker: SaveNodeChecker = (id, _parentId, inputSchema, nodes, edges, data) => {
const inputMultiVariableChecker: SaveNodeChecker = (id, _parentId, nodes, edges, data) => {
let nodeData = data[id] ?? {}
if (has(nodeData, 'inputs')) {
let inputs = nodeData?.inputs ?? {}
if (!isEmpty(inputs)) {
let outputVariables = new Set(getAllIncomerNodeOutputVariables(id, inputSchema, nodes, edges, data).map(i => i.variable))
let outputVariables = new Set(getAllIncomerNodeOutputVariables(id, nodes, edges, data).map(i => i.variable))
for (const key of Object.keys(inputs)) {
let variable = inputs[key]?.variable ?? ''
if (!outputVariables.has(variable)) {
@@ -49,7 +49,7 @@ const inputMultiVariableChecker: SaveNodeChecker = (id, _parentId, inputSchema,
return {error: false}
}
const noMoreThanOneNodeType: AddNodeChecker = (type, parentId, _inputSchema, nodes) => {
const noMoreThanOneNodeType: AddNodeChecker = (type, parentId, nodes) => {
return {
error: nodes.filter(n => isEqual(n.parentId, parentId) && isEqual(n.type, type)).length > 0,
message: `同一个流程(子流程)中类型为 ${type} 的节点至多有一个`

View File

@@ -12,7 +12,6 @@ import {type FormSchema, OutputVariableTypeMap} from '../types.ts'
export function inputsFormColumns(
nodeId: string,
inputSchema: Record<string, Record<string, any>>,
nodes: Node[],
edges: Edge[],
data: any,
@@ -38,7 +37,6 @@ export function inputsFormColumns(
selectMode: 'group',
options: generateAllIncomerOutputVariablesFormOptions(
nodeId,
inputSchema,
nodes,
edges,
data,

View File

@@ -1,7 +1,6 @@
import type {NodeProps} from '@xyflow/react'
import {Tag} from 'antd'
import React, {useCallback, useMemo} from 'react'
import {useContextStore} from '../store/ContextStore.ts'
import {useDataStore} from '../store/DataStore.ts'
import {useFlowStore} from '../store/FlowStore.ts'
import AmisNode, {inputsFormColumns, nodeClassName, NormalNodeHandler, outputsFormColumns} from './AmisNode.tsx'
@@ -16,13 +15,12 @@ const languageMap: Record<string, string> = {
const CodeNode = (props: NodeProps) => {
const {getNodes, getEdges} = useFlowStore()
const {getData, getDataById} = useDataStore()
const {getInputSchema} = useContextStore()
const nodeData = getDataById(props.id)
const formSchema: () => FormSchema = useCallback(() => ({
columns: [
...inputsFormColumns(props.id, getInputSchema(), getNodes(), getEdges(), getData()),
...inputsFormColumns(props.id, getNodes(), getEdges(), getData()),
{
type: 'divider',
},

View File

@@ -1,7 +1,6 @@
import type {NodeProps} from '@xyflow/react'
import React, {useCallback, useEffect} from 'react'
import {commonInfo} from '../../../util/amis.tsx'
import {useContextStore} from '../store/ContextStore.ts'
import {useDataStore} from '../store/DataStore.ts'
import {useFlowStore} from '../store/FlowStore.ts'
import AmisNode, {inputsFormColumns, nodeClassName, NormalNodeHandler, outputsFormColumns} from './AmisNode.tsx'
@@ -10,7 +9,6 @@ import type {FormSchema} from '../types.ts'
const KnowledgeNode = (props: NodeProps) => {
const {getNodes, getEdges} = useFlowStore()
const {getData, mergeDataById} = useDataStore()
const {getInputSchema} = useContextStore()
useEffect(() => {
mergeDataById(
@@ -27,7 +25,7 @@ const KnowledgeNode = (props: NodeProps) => {
const formSchema: () => FormSchema = useCallback(() => ({
columns: [
...inputsFormColumns(props.id, getInputSchema(), getNodes(), getEdges(), getData()),
...inputsFormColumns(props.id, getNodes(), getEdges(), getData()),
{
type: 'divider',
},

View File

@@ -1,7 +1,6 @@
import type {NodeProps} from '@xyflow/react'
import {Tag} from 'antd'
import React, {useCallback, useEffect, useMemo} from 'react'
import {useContextStore} from '../store/ContextStore.ts'
import {useDataStore} from '../store/DataStore.ts'
import {useFlowStore} from '../store/FlowStore.ts'
import AmisNode, {inputsFormColumns, nodeClassName, NormalNodeHandler, outputsFormColumns} from './AmisNode.tsx'
@@ -15,7 +14,6 @@ const modelMap: Record<string, string> = {
const LlmNode = (props: NodeProps) => {
const {getNodes, getEdges} = useFlowStore()
const {getData, mergeDataById, getDataById} = useDataStore()
const {getInputSchema} = useContextStore()
const nodeData = getDataById(props.id)
@@ -34,7 +32,7 @@ const LlmNode = (props: NodeProps) => {
const formSchema: () => FormSchema = useCallback(() => ({
columns: [
...inputsFormColumns(props.id, getInputSchema(), getNodes(), getEdges(), getData()),
...inputsFormColumns(props.id, getNodes(), getEdges(), getData()),
{
type: 'divider',
},

View File

@@ -3,7 +3,6 @@ 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, type FormSchema} from '../types.ts'
@@ -12,7 +11,6 @@ import AmisNode, {nodeClassName, NormalNodeHandler, outputsFormColumns} from './
const LoopNode = (props: NodeProps) => {
const {getNodes, getEdges} = useFlowStore()
const {getData, mergeDataById} = useDataStore()
const {getInputSchema} = useContextStore()
useEffect(() => {
mergeDataById(
@@ -85,7 +83,6 @@ const LoopNode = (props: NodeProps) => {
selectMode: 'group',
options: generateAllIncomerOutputVariablesFormOptions(
props.id,
getInputSchema(),
getNodes(),
getEdges(),
getData(),
@@ -101,7 +98,6 @@ const LoopNode = (props: NodeProps) => {
selectMode: 'group',
options: generateAllIncomerOutputVariablesFormOptions(
props.id,
getInputSchema(),
getNodes(),
getEdges(),
getData(),

View File

@@ -1,7 +1,6 @@
import type {NodeProps} from '@xyflow/react'
import React, {useCallback} from 'react'
import {generateAllIncomerOutputVariablesFormOptions} from '../Helper.tsx'
import {useContextStore} from '../store/ContextStore.ts'
import {useDataStore} from '../store/DataStore.ts'
import {useFlowStore} from '../store/FlowStore.ts'
import AmisNode, {EndNodeHandler, nodeClassName} from './AmisNode.tsx'
@@ -10,7 +9,6 @@ import type {FormSchema} from '../types.ts'
const OutputNode = (props: NodeProps) => {
const {getNodes, getEdges} = useFlowStore()
const {getData} = useDataStore()
const {getInputSchema} = useContextStore()
const formSchema: () => FormSchema = useCallback(() => ({
columns: [
@@ -22,7 +20,6 @@ const OutputNode = (props: NodeProps) => {
selectMode: 'group',
options: generateAllIncomerOutputVariablesFormOptions(
props.id,
getInputSchema(),
getNodes(),
getEdges(),
getData(),

View File

@@ -4,7 +4,6 @@ import {Tag} from 'antd'
import {contain, isEqual} from 'licia'
import React, {useCallback, useMemo} from 'react'
import {generateAllIncomerOutputVariablesConditions} from '../Helper.tsx'
import {useContextStore} from '../store/ContextStore.ts'
import {useDataStore} from '../store/DataStore.ts'
import {useFlowStore} from '../store/FlowStore.ts'
import AmisNode, {nodeClassName} from './AmisNode.tsx'
@@ -13,7 +12,6 @@ import type {FormSchema} from '../types.ts'
const SwitchNode = (props: NodeProps) => {
const {getNodes, getEdges, removeEdges} = useFlowStore()
const {getData, getDataById} = useDataStore()
const {getInputSchema} = useContextStore()
const nodeData = getDataById(props.id)
// @ts-ignore
@@ -37,7 +35,6 @@ const SwitchNode = (props: NodeProps) => {
showANDOR: true,
fields: generateAllIncomerOutputVariablesConditions(
props.id,
getInputSchema(),
getNodes(),
getEdges(),
getData(),

View File

@@ -1,7 +1,6 @@
import type {NodeProps} from '@xyflow/react'
import {Tag} from 'antd'
import React, {useCallback, useEffect, useMemo} from 'react'
import {useContextStore} from '../store/ContextStore.ts'
import {useDataStore} from '../store/DataStore.ts'
import {useFlowStore} from '../store/FlowStore.ts'
import AmisNode, {inputsFormColumns, nodeClassName, NormalNodeHandler, outputsFormColumns} from './AmisNode.tsx'
@@ -17,7 +16,6 @@ const typeMap: Record<string, string> = {
const TemplateNode = (props: NodeProps) => {
const {getNodes, getEdges} = useFlowStore()
const {getData, getDataById, mergeDataById} = useDataStore()
const {getInputSchema} = useContextStore()
const nodeData = getDataById(props.id)
@@ -36,7 +34,7 @@ const TemplateNode = (props: NodeProps) => {
const formSchema: () => FormSchema = useCallback(() => ({
columns: [
...inputsFormColumns(props.id, getInputSchema(), getNodes(), getEdges(), getData()),
...inputsFormColumns(props.id, getNodes(), getEdges(), getData()),
{
type: 'divider',
},

View File

@@ -1,11 +0,0 @@
import {create} from 'zustand/react'
export const useContextStore = create<{
inputSchema: Record<string, Record<string, any>>,
getInputSchema: () => Record<string, Record<string, any>>,
setInputSchema: (inputSchema: Record<string, Record<string, any>>) => void,
}>((set, get) => ({
inputSchema: {},
getInputSchema: () => get().inputSchema,
setInputSchema: (inputSchema: Record<string, Record<string, any>>) => set({inputSchema}),
}))

View File

@@ -20,13 +20,12 @@ export type NodeError = {
message?: string,
}
export type AddNodeChecker = (type: string, parentId: string | undefined, inputSchema: Record<string, Record<string, any>>, nodes: Node[], edges: Edge[], data: any) => NodeError
export type SaveNodeChecker = (id: string, parentId: string | undefined, inputSchema: Record<string, Record<string, any>>, nodes: Node[], edges: Edge[], data: any) => NodeError
export type AddNodeChecker = (type: string, parentId: string | undefined, nodes: Node[], edges: Edge[], data: any) => NodeError
export type SaveNodeChecker = (id: string, parentId: string | undefined, nodes: Node[], edges: Edge[], data: any) => NodeError
export type GraphData = { nodes: Node[], edges: Edge[], data: any }
export type FlowEditorProps = {
inputSchema: Record<string, Record<string, any>>,
graphData: GraphData,
onGraphDataChange: (graphData: GraphData) => void,
}

View File

@@ -1,5 +1,4 @@
import type {Schema} from 'amis'
import type {OutputVariableType} from '../../../components/flow/types.ts'
import {commonInfo, formInputFileStaticColumns} from '../../../util/amis.tsx'
export const typeMap: Record<string, string> = {
@@ -9,13 +8,6 @@ export const typeMap: Record<string, string> = {
files: '文件',
}
export const originTypeMap: Record<string, OutputVariableType> = {
text: 'text',
textarea: 'text',
number: 'number',
files: 'array-text',
}
export type InputField = {
type: string
label: string

View File

@@ -1,9 +1,8 @@
import {isEmpty, isEqual} from 'licia'
import {isEqual} from 'licia'
import React from 'react'
import {useNavigate, useParams} from 'react-router'
import styled from 'styled-components'
import {amisRender, commonInfo, horizontalFormOptions} from '../../../../util/amis.tsx'
import {generateInputForm, typeMap} from '../InputSchema.tsx'
const TemplateEditDiv = styled.div`
.antd-EditorControl {
@@ -39,31 +38,6 @@ const FlowTaskTemplateEdit: React.FC = () => {
wrapWithPanel: false,
...horizontalFormOptions(),
onEvent: {
change: {
actions: [
{
actionType: 'validate',
},
{
actionType: 'custom',
// @ts-ignore
script: (context, doAction, event) => {
let data = event?.data ?? {}
let inputSchema = data.inputSchema ?? []
if (!isEmpty(inputSchema) && isEmpty(data?.validateResult?.error ?? undefined)) {
doAction({
actionType: 'setValue',
args: {
value: {
inputPreview: generateInputForm(inputSchema, '入参表单预览'),
},
},
})
}
},
},
],
},
submitSucc: {
actions: [
{
@@ -99,71 +73,6 @@ const FlowTaskTemplateEdit: React.FC = () => {
maxLength: 500,
showCounter: true,
},
{
type: 'group',
body: [
{
type: 'wrapper',
size: 'none',
body: [
{
type: 'input-kvs',
name: 'inputSchema',
label: '输入变量',
addButtonText: '新增入参',
draggable: false,
keyItem: {
label: '参数名称',
...horizontalFormOptions(),
validations: {
isAlphanumeric: true,
},
},
valueItems: [
{
...horizontalFormOptions(),
type: 'input-text',
name: 'label',
required: true,
label: '中文名称',
clearValueOnEmpty: true,
clearable: true,
},
{
...horizontalFormOptions(),
type: 'input-text',
name: 'description',
label: '参数描述',
clearValueOnEmpty: true,
clearable: true,
},
{
...horizontalFormOptions(),
type: 'select',
name: 'type',
label: '参数类型',
required: true,
selectFirst: true,
options: Object.keys(typeMap).map(key => ({label: typeMap[key], value: key})),
},
{
...horizontalFormOptions(),
type: 'switch',
name: 'required',
label: '是否必填',
required: true,
value: true,
},
],
},
],
},
{
type: 'amis',
name: 'inputPreview',
},
],
},
{
type: 'button-toolbar',
buttons: [

View File

@@ -13,7 +13,6 @@ const FlowTaskTemplateFlowEditDiv = styled.div`
const FlowTaskTemplateFlowEdit: React.FC = () => {
const navigate = useNavigate()
const {template_id} = useParams()
const [inputSchema, setInputSchema] = useState<Record<string, Record<string, any>>>({})
const [graphData, setGraphData] = useState<GraphData>({nodes: [], edges: [], data: {}})
useMount(async () => {
@@ -23,14 +22,12 @@ const FlowTaskTemplateFlowEdit: React.FC = () => {
headers: commonInfo.authorizationHeaders,
},
)
setInputSchema(data?.data?.inputSchema)
setGraphData(data?.data?.flowGraph)
})
return (
<FlowTaskTemplateFlowEditDiv className="h-full w-full">
<FlowEditor
inputSchema={inputSchema}
graphData={graphData}
onGraphDataChange={async data => {
await axios.post(