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

@@ -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: [