feat(ai-web): 完成执行任务的创建(提交漏的文件)

This commit is contained in:
v-zhangjc9
2025-07-05 14:48:53 +08:00
parent 64ef5514b4
commit 051b3dbad2
5 changed files with 282 additions and 23 deletions

View File

@@ -21,6 +21,7 @@ const ProLayoutDiv = styled.div`
const defaultAppIcon =
<img
src={'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAMAUExURUdwTBR20EyHx1iq5EWJ1hNyy0mR1EhzwnbB/8P5/Fx/vVuj5zyO4lCY102P0L3u/3K88dz4/8v1/0fW/jLh/013ujN4wBliuEuEy0FrqT13wFmCvkaH0GSLyBVVqe38/0il4FKu7crr/eL3/7Ls/zd3t1WN1TZcnTloojx6whpYpTdfoDVwtVeS1WeOyiNhsTFyuy50wHCPxDFgqLjK5G2Ow2Gy5ylpvB9uxA5x03W/71Wh4E2U2tr2/i6C3G7J+Gex7KTI8eb9/cbz/yC+/srl++P7/Znf+MPv/cn3/rz6/dL8/2fe/8v+/s/6/knN87f5/jx5uRZtwjRppU6I1liM2Bhcrmyl2kZ5uA9vzjd0wj95yjVstqze9hiD2zOH1kqv7Wqv5K7S7LLn/YfT+sfp/bPf+4jb/YbX+735/SjQ/T7J+VjV9rTs+0ns/6Dk/mPJ7eD9/b/8/Q9YxA5Zxw5Zwg5dwg5byhdn0kSO2xFezg5gwg1XwRBjwkqW4EeT3kuY20mV2BBVtg5avxFoxQ9Yu0+g3xJYslWi5h2q9SKA4AtTwAxjzUGN2UiN0VOm4yKj8NX7/0WQ3RFtyUaR1h95zSOc706J0Bt34VCi5yqw9F6s6SOI5Bx02h2M6Rh13SCX7k2c3E6a4lCd5EeQ2iVtyCJ54BVt3ROV8x+0+jS9+hGq+Ra0/WK37sPy/iOR6R1w2A5p0y9nrjJ/1EaO1yV1yDt+zBaJ4hF83FuJyg5nyhei9hJ96BN35ByV5ymq8S151muu5UCr6hzE/xS+/47h/3/r/xyG5SKV6yJ43BlswBJivA5z2A9duw5s1C590CZXpDVvuhec9BGM7xJQrxKE61yo4DOF4DeZ64jG8bbp/h/Q/j2F0xpr1xliyROA4CRst1mc10d8whNQqDqb3Sig5qrh/qLW9iZ/5UeY5pDU9UWf6J7O9oju/mDV/aXp/orj/6P7/4z3/2Pr/iLa/kaDxnuw57rf9ZfW+2Sd5G3X/7LW9zyR51TI+Dao7Zno//A+0MwAAADpdFJOUwD7Lv/+/v4CAQIK/v7+/P7+b/7+/iKh/f5LjBv8z/4d/v5cNf6A5piF/Pts9PST/tP+Qd0Oc/72Pf5B/Pv0/vv7zqD6/4qU+5JjlCv7ff79/lz628SK/pmm+/5cnh/+/vPht/r+pPKX44z7+/z7/P7+wNL////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+///////////////////////+1awirQAAA+BJREFUOMtjYCAXcMIAAVW4OKjKgJjDW8nXyytT0NOKCyjAgUudt29RwMdPb48dO/b2aEa6MkQvpjrlQqCqz3ki/j4+2VnCv44+S5XHVAm0xHPixHXuOSIiX4TfHeo87OJin/IjTYmBgwNdndvEibkF/sIiX26/+7f6yJo1K/fPtL/53BXDPKeJQkLvPx87Knz79qzOI2tWr959acFaAYE3rii2cwDVOQutU8k/+uHv4cNrQMpWrFgxTXHtWoc3gkgqORkEJzqvW3fr/f8Paye4rFzZufvSisuXr95QVJw9W+C3MlwlB4O87Tp+fn6VV2sVgOo6wequ7tkz4zWP3QHrm45IBroJJd/if37w0CygaZ0Tpi1YMO/qnr17b7yeMePFAZufSlAjQQbeyle5qbBq1apZIGUn1s87DlS3/DrPsj8vr/McdES48Lv7q4NPVq3avx+sbP2cOV0zZsxfftfuZcdsbm6Bb1YM7BATk64pPHk6C6hqGljVnK6uZSfnzl2+bObMmR3csx0OhkIUMpgkHgKatW/fvO3HjwMVdXWdPHly7oYNd3mA6jo6uLm5Q0ABDcSxCU/37du+/f79HfPnz507dwNQ0Ya7dyuudyzu6Fi8eNGiOjUukEp2BqZDcXE7dpw5c+bcuY0bK+CgbtEioLK6+kmVLKIQhRZP4iwtgWp6gKCqpwoCyivqQACorLeXhQnkSKDC83a7dgEVlfeUw0BJScm9SfVAAFTHwjIdqpBpafyuspISIEICxSWV9ZMmLQGr0wVbzcEgbb518+YDFcWlxUAAUgMGNXfqKisrl1QCFaqZgL3NwGkgzsbb2LC5u7sYAUprWu/UL2HZto1FZrosJGbYGWIMbdjYpjRuvtddU1MDVAMB3U3bljZdubJNZqceJMDZGSQv8vX1TZnS2HCguwaqqrS5ubm1CQiuRE3faQSNGQYu469glVMalnZ315SBAUghUGX7Y/3psrD0yM6gvQmoEGh5Y0Pv+Xs1pdUQlUCF7e2PzXeawgwEGQm0nI2tsaFhYdvC3qVl1WClZ1vb2+XkHskisgLQlRc0IeoWtrUxn2+urT5dXVt99ixQ4UWEC8EqNS5o8jaClLX191bXQsDps+1hWo+QLAYnIfULMrxAdf39s6dWt4BB7enT4lqb9Bg40DK2+iZea2tmZub+qbsmA0HLqZZT4vqbpBgYMIoKbZ2H166Z1U9mhYKgUw+CJdHVgd0pGvHwmllvJCMYsJ56oKPBheI+hEoGpnDdrVungsBWQwNVaQas6oCWAIWlo6WkxMTEVAOZQFo5cJW57Mgm4FYGMRUGyK0tAGzv0vrmaa6xAAAAAElFTkSuQmCC'}
alt=""
/>
const apps: AppItemProps[] = [
{

View File

@@ -1,6 +1,41 @@
import {amisRender, commonInfo} from '../util/amis.tsx'
function Test() {
return (
<div>Test</div>
<div>
{amisRender(
{
debug: commonInfo.debug,
type: 'form',
canAccessSuperData: false,
actions: [
{
type: 'reset',
label: '重置',
},
{
type: 'submit',
label: '提交',
},
],
body: [
{
type: 'input-file',
required: true,
name: 'files',
label: '数据文件',
autoUpload: false,
drag: true,
multiple: true,
accept: '*',
maxSize: 104857600,
receiver: `${commonInfo.baseAiUrl}/upload`,
useChunk: false,
},
],
},
)}
</div>
)
}

View File

@@ -1,6 +1,21 @@
import React from 'react'
import {amisRender, commonInfo, crudCommonOptions, paginationTemplate,} from '../../../util/amis.tsx'
import {useNavigate} from 'react-router'
import {
amisRender,
commonInfo,
crudCommonOptions,
mappingField,
mappingItem,
paginationTemplate,
readOnlyDialogOptions,
} from '../../../util/amis.tsx'
import {generateInputForm} from './InputSchema.tsx'
const statusMapping = [
mappingItem('完成', 'FINISHED', 'label-success'),
mappingItem('执行中', 'RUNNING', 'label-warning'),
mappingItem('错误', 'ERROR', 'label-danger'),
]
const FlowTask: React.FC = () => {
const navigate = useNavigate()
@@ -20,8 +35,8 @@ const FlowTask: React.FC = () => {
page: {
index: '${page}',
size: '${perPage}',
}
}
},
},
},
...crudCommonOptions(),
...paginationTemplate(
@@ -55,15 +70,67 @@ const FlowTask: React.FC = () => {
label: '任务ID',
width: 200,
},
{
name: 'templateName',
label: '模板',
},
{
name: 'status',
label: '状态',
width: 50,
align: 'center',
...mappingField('status', statusMapping),
},
{
type: 'operation',
label: '操作',
width: 200,
buttons: [
{
type: 'action',
label: '查看',
level: 'link',
size: 'sm',
actionType: 'dialog',
dialog: {
title: '查看',
size: 'md',
...readOnlyDialogOptions(),
body: [
{
type: 'service',
schemaApi: {
method: 'get',
url: `${commonInfo.baseAiUrl}/flow_task/template/input_schema/\${templateId}`,
// @ts-ignore
adaptor: (payload, response, api, context) => {
return {
...payload,
data: {
...generateInputForm(payload.data, undefined, false),
id: 'db8a4d10-0c47-4e27-b1a4-d0f2e1c15992',
initApi: {
method: 'get',
url: `${commonInfo.baseAiUrl}/flow_task/input_data/\${id}`,
// @ts-ignore
adaptor: (payload, response, api, context) => {
return {
...payload,
data: {
inputData: payload.data,
}
}
}
},
static: true,
},
}
},
},
},
],
},
},
{
type: 'action',
label: '重新执行',

View File

@@ -1,5 +1,7 @@
import {isEmpty} from 'licia'
import React from 'react'
import {amisRender,} from '../../../util/amis.tsx'
import {amisRender, commonInfo} from '../../../util/amis.tsx'
import {generateInputForm} from './InputSchema.tsx'
const FlowTaskAdd: React.FC = () => {
// const navigate = useNavigate()
@@ -7,25 +9,166 @@ const FlowTaskAdd: React.FC = () => {
<div className="task-template">
{amisRender(
{
id: 'e81515a4-8a73-457a-974d-7e9196eeb524',
type: 'page',
title: '发起任务',
body: {
id: '74a1a3e5-41a6-4979-88e7-65f15bce4d4c',
type: 'wizard',
wrapWithPanel: false,
steps: [
{
title: '选择任务模板',
body: []
actions: [
{
type: 'action',
level: 'primary',
actionType: 'next',
label: '下一步',
disabledOn: '${templateId === undefined}',
},
],
body: [
{
type: 'service',
api: `get:${commonInfo.baseAiUrl}/flow_task/template/list`,
body: [
{
type: 'table2',
source: '$items',
rowSelection: {
type: 'radio',
keyField: 'id',
rowClick: true,
fixed: true,
},
onEvent: {
selectedChange: {
actions: [
{
actionType: 'custom',
// @ts-ignore
script: (context, doAction, event) => {
console.log(event)
let selectedIds = (event?.data?.selectedItems ?? []).map((item: any) => item.id)
if (!isEmpty(selectedIds)) {
doAction({
actionType: 'setValue',
componentId: 'e81515a4-8a73-457a-974d-7e9196eeb524',
args: {
value: {
templateId: selectedIds[0],
},
},
})
} else {
doAction({
actionType: 'setValue',
componentId: 'e81515a4-8a73-457a-974d-7e9196eeb524',
args: {
value: {
templateId: undefined,
},
},
})
}
},
},
],
},
},
columns: [
{
name: 'name',
title: '名称',
width: 200,
},
{
name: 'description',
title: '模板描述',
},
],
},
],
},
],
},
{
title: '填写任务信息',
body: []
actions: [
{
type: 'action',
actionType: 'prev',
label: '上一步',
onEvent: {
click: {
actions: [
{
actionType: 'setValue',
componentId: 'e81515a4-8a73-457a-974d-7e9196eeb524',
args: {
value: {
templateId: undefined,
},
},
},
],
},
},
},
{
title: '完成',
body: []
type: 'action',
level: 'primary',
label: '提交',
onEvent: {
click: {
actions: [
{
actionType: 'validate',
componentId: 'db8a4d10-0c47-4e27-b1a4-d0f2e1c15992',
},
]
{
actionType: 'stopPropagation',
expression: '${event.data.validateResult.error !== \'\'}',
},
{
actionType: 'submit',
componentId: 'db8a4d10-0c47-4e27-b1a4-d0f2e1c15992',
},
],
},
},
},
],
body: [
{
type: 'service',
schemaApi: {
method: 'get',
url: `${commonInfo.baseAiUrl}/flow_task/template/input_schema/\${templateId}`,
// @ts-ignore
adaptor: (payload, response, api, context) => {
return {
...payload,
data: {
id: 'db8a4d10-0c47-4e27-b1a4-d0f2e1c15992',
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/flow_task/save`,
data: {
templateId: '${templateId|default:undefined}',
input: '${inputData|default:undefined}',
}
},
...generateInputForm(payload.data, undefined, false),
},
}
},
},
},
],
},
],
},
},
)}

View File

@@ -1,4 +1,5 @@
import type {Schema} from 'amis'
import {commonInfo} from '../../../util/amis.tsx'
export const typeMap: Record<string, string> = {
text: '文本',
@@ -12,35 +13,47 @@ export type InputField = {
description?: string
}
export const generateInputForm: (inputSchema: Record<string, InputField>) => Schema = inputSchema => {
export const generateInputForm: (inputSchema: Record<string, InputField>, title?: string, border?: boolean, staticView?: boolean) => Schema = (inputSchema, title, border) => {
let items: Schema[] = []
for (const name of Object.keys(inputSchema)) {
let field = inputSchema[name]
// @ts-ignore
let formItem: Schema = {
name: name,
let commonMeta: Schema = {
name: `inputData.${name}`,
...field,
}
switch (field.type) {
case 'text':
formItem = {
...formItem,
items.push({
...commonMeta,
type: 'input-text',
clearValueOnEmpty: true,
}
})
break
case 'number':
formItem.type = 'input-number'
commonMeta.type = 'input-number'
break
case 'files':
formItem.type = 'input-file'
items.push({
...commonMeta,
type: 'input-file',
autoUpload: false,
drag: true,
multiple: true,
joinValues: false,
extractValue: true,
accept: '*',
maxSize: 104857600,
receiver: `${commonInfo.baseAiUrl}/upload`,
})
break
}
items.push(formItem)
}
return {
debug: commonInfo.debug,
type: 'form',
title: '入参表单预览',
title: title,
wrapWithPanel: border,
canAccessSuperData: false,
actions: [],
body: items,