1
0

feat: 使用liteflow替换自定义的任务执行

This commit is contained in:
2025-09-06 14:54:47 +08:00
parent 550692e281
commit 0ad9d8239c
22 changed files with 763 additions and 428 deletions

View File

@@ -11,6 +11,8 @@ import TaskList from './pages/task/TaskList.tsx'
import TaskAdd from './pages/task/TaskAdd.tsx'
import TaskTemplateList from './pages/task/TaskTemplateList.tsx'
import TaskTemplateSave from './pages/task/TaskTemplateSave.tsx'
import TaskScheduleList from './pages/task/TaskScheduleList.tsx'
import TaskScheduleSave from './pages/task/TaskScheduleSave.tsx'
const routes: RouteObject[] = [
{
@@ -66,6 +68,19 @@ const routes: RouteObject[] = [
},
],
},
{
path: 'schedule',
children: [
{
path: 'list',
Component: TaskScheduleList,
},
{
path: 'save',
Component: TaskScheduleSave,
},
],
},
],
},
{

View File

@@ -2,8 +2,8 @@ import {
DeploymentUnitOutlined,
InfoCircleOutlined,
MoneyCollectOutlined,
UnorderedListOutlined
} from "@ant-design/icons";
UnorderedListOutlined,
} from '@ant-design/icons'
import {type AppItemProps, ProLayout} from '@ant-design/pro-components'
import {ConfigProvider} from 'antd'
import {dateFormat} from 'licia'
@@ -52,8 +52,12 @@ const menus = {
{
path: '/task/template/list',
name: '任务模板',
}
]
},
{
path: '/task/schedule/list',
name: '定时任务',
},
],
},
{
path: '/test',

View File

@@ -0,0 +1,125 @@
import React from 'react'
import {amisRender, commonInfo, crudCommonOptions, paginationTemplate, remoteMappings, time} from '../../util/amis.tsx'
import {useNavigate} from 'react-router'
function TaskScheduleList() {
const navigate = useNavigate()
return (
<div className="task-schedule-list">
{amisRender(
{
type: 'page',
title: '定时任务',
body: [
{
type: 'crud',
api: `get:${commonInfo.baseUrl}/task_schedule/list`,
...crudCommonOptions(),
...paginationTemplate(
15,
undefined,
[
{
type: 'action',
label: '',
icon: 'fa fa-plus',
tooltip: '添加定时任务',
tooltipPlacement: 'top',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
// @ts-ignore
script: (context, action, event) => {
navigate('/task/schedule/save')
},
},
],
},
},
},
],
),
columns: [
{
name: 'templateName',
label: '模板名称',
width: 150,
},
{
name: 'templateDescription',
label: '模板描述',
},
{
name: 'cron',
label: '定时策略',
width: 150,
},
{
name: 'status',
label: '状态',
width: 100,
...remoteMappings('trigger_status', 'status'),
},
{
name: 'previousFireTime',
label: '上次启动时间',
width: 150,
align: 'center',
...time('previousFireTime'),
},
{
name: 'nextFireTime',
label: '下次启动时间',
width: 150,
align: 'center',
...time('nextFireTime'),
},
{
type: 'operation',
label: '操作',
width: 150,
buttons: [
{
visibleOn: 'status !== \'PAUSED\' ',
type: 'action',
label: '暂停',
level: 'link',
actionType: 'ajax',
api: `get:${commonInfo.baseUrl}/task_schedule/pause/\${key}`,
confirmText: '确认暂停定时任务<span class="text-lg font-bold mx-2">${templateName}</span>',
confirmTitle: '暂停',
},
{
visibleOn: 'status === \'PAUSED\' ',
type: 'action',
label: '恢复',
level: 'link',
actionType: 'ajax',
api: `get:${commonInfo.baseUrl}/task_schedule/resume/\${key}`,
confirmText: '确认恢复定时任务<span class="text-lg font-bold mx-2">${templateName}</span>',
confirmTitle: '恢复',
},
{
className: 'text-danger',
type: 'action',
label: '删除',
level: 'link',
actionType: 'ajax',
api: `get:${commonInfo.baseUrl}/task_schedule/remove/\${key}`,
confirmText: '确认删除定时任务<span class="text-lg font-bold mx-2">${templateName}</span>',
confirmTitle: '删除',
},
],
},
],
},
],
},
)}
</div>
)
}
export default React.memo(TaskScheduleList)

View File

@@ -0,0 +1,74 @@
import React from 'react'
import {amisRender, commonInfo, remoteOptions} from '../../util/amis.tsx'
import {useNavigate} from 'react-router'
function TaskScheduleSave() {
const navigate = useNavigate()
return (
<div className="task-template-save">
{amisRender(
{
type: 'page',
title: '任务模板添加',
body: [
{
debug: commonInfo.debug,
type: 'form',
api: `post:${commonInfo.baseUrl}/task_schedule/save`,
wrapWithPanel: false,
mode: 'horizontal',
labelAlign: 'left',
onEvent: {
submitSucc: {
actions: [
{
actionType: 'custom',
// @ts-ignore
script: (context, action, event) => {
navigate(-1)
},
},
],
},
},
body: [
{
name: 'templateId',
label: '名称',
required: true,
selectFirst: true,
...remoteOptions('select', 'task_template_id'),
},
{
type: 'input-text',
name: 'cron',
label: '定时策略',
required: true,
clearable: true,
},
{
type: 'button-toolbar',
buttons: [
{
type: 'action',
label: '提交',
actionType: 'submit',
level: 'primary',
},
{
type: 'action',
label: '重置',
actionType: 'reset',
},
],
},
],
},
],
},
)}
</div>
)
}
export default React.memo(TaskScheduleSave)

View File

@@ -1,5 +1,5 @@
import React from 'react'
import {amisRender, commonInfo, crudCommonOptions, paginationTemplate, remoteMappings} from '../../util/amis.tsx'
import {amisRender, commonInfo, crudCommonOptions, paginationTemplate} from '../../util/amis.tsx'
import {useNavigate} from 'react-router'
function TaskTemplateList() {
@@ -60,12 +60,6 @@ function TaskTemplateList() {
name: 'description',
label: '描述',
},
{
name: 'type',
label: '类型',
width: 100,
...remoteMappings('task_template_type', 'type'),
},
{
type: 'operation',
label: '操作',

View File

@@ -1,5 +1,5 @@
import React from 'react'
import {amisRender, commonInfo, remoteOptions} from '../../util/amis.tsx'
import {amisRender, commonInfo} from '../../util/amis.tsx'
import {useNavigate, useParams} from 'react-router'
function TaskTemplateSave() {
@@ -31,8 +31,8 @@ function TaskTemplateSave() {
navigate(-1)
},
},
]
}
],
},
},
body: [
{
@@ -43,29 +43,21 @@ function TaskTemplateSave() {
type: 'input-text',
name: 'name',
label: '名称',
require: true,
required: true,
clearable: true,
},
{
type: 'textarea',
name: 'description',
label: '描述',
require: true,
required: true,
clearable: true,
},
{
name: 'type',
label: '任务类型',
require: true,
selectFirst: true,
...remoteOptions('select', 'task_template_type'),
},
{
visibleOn: 'type === \'CLASS\'',
type: 'input-text',
name: 'clazz',
label: '类路径',
require: true,
name: 'chain',
label: '流程编号',
required: true,
clearable: true,
},
{