feat(ai-web): 增加任务和任务模板

This commit is contained in:
2025-06-28 21:08:31 +08:00
parent 9a3375bd03
commit d08a6babbe
16 changed files with 720 additions and 22 deletions

View File

@@ -0,0 +1,118 @@
import React from 'react'
import {useParams} from 'react-router'
import styled from 'styled-components'
import {amisRender, commonInfo, horizontalFormOptions} from '../../../../util/amis.tsx'
import {isEqual} from 'licia'
const TemplateEditDiv = styled.div`
.antd-EditorControl {
min-height: 500px !important;
}
`
const FlowTaskTemplateEdit: React.FC = () => {
const {template_id} = useParams()
const preloadTemplateId = isEqual(template_id, '-1') ? undefined : template_id
console.log('preloadTemplateId', preloadTemplateId)
return (
<TemplateEditDiv className="task-template-edit h-full">
{amisRender({
type: 'page',
title: '模板编辑',
body: {
debug: commonInfo.debug,
type: 'form',
api: {
method: 'POST',
url: `${commonInfo.baseAiUrl}/flow_task/template/save`,
data: {
name: '${template.name}',
description: '${template.description}',
inputSchema: '${template.inputSchema}',
flow: '${template.flow}',
}
},
initApi: preloadTemplateId
? {
method: 'GET',
url: `${commonInfo.baseAiUrl}/flow_task/template/detail/${preloadTemplateId}`,
// @ts-ignore
adaptor: (payload, response, api, context) => {
return {
...payload,
data: {
template: payload.data,
},
}
},
}
: undefined,
wrapWithPanel: false,
...horizontalFormOptions(),
body: [
{
type: 'input-text',
name: 'template.name',
label: '名称',
required: true,
},
{
type: 'textarea',
name: 'template.description',
label: '描述',
required: true,
},
{
type: 'group',
body: [
{
type: 'editor',
required: true,
label: '入参表单',
description: '使用amis代码编写入参表单结构流程会解析所有name对应的变量传入流程开始阶段只需要编写form的columns部分',
name: 'template.inputSchema',
value: '[]',
language: 'json',
options: {
wordWrap: 'bounded',
},
},
{
type: 'amis',
name: 'template.inputSchema',
}
]
},
{
type: 'editor',
required: true,
label: '任务流程',
name: 'template.flow',
description: '使用标准的LiteFlow语法',
language: 'xml',
options: {
wordWrap: 'bounded',
},
},
{
type: 'button-toolbar',
buttons: [
{
type: 'submit',
label: '提交',
level: 'primary',
},
{
type: 'reset',
label: '重置',
},
],
},
],
},
})}
</TemplateEditDiv>
)
}
export default FlowTaskTemplateEdit