1
0

feat: 增加任务模板的增删改查

This commit is contained in:
2025-09-05 19:58:12 +08:00
parent 1fc8d3160c
commit 028a578896
15 changed files with 527 additions and 99 deletions

View File

@@ -2,13 +2,15 @@ import {createRoot} from 'react-dom/client'
import {createHashRouter, Navigate, type RouteObject, RouterProvider} from 'react-router'
import './index.scss'
import './components/amis/Registry.ts'
import Overview from "./pages/Overview.tsx";
import Root from "./pages/Root.tsx";
import Test from "./pages/Test.tsx";
import StockList from "./pages/stock/StockList.tsx";
import StockDetail from './pages/stock/StockDetail.tsx';
import TaskList from "./pages/task/TaskList.tsx";
import TaskAdd from './pages/task/TaskAdd.tsx';
import Overview from './pages/Overview.tsx'
import Root from './pages/Root.tsx'
import Test from './pages/Test.tsx'
import StockList from './pages/stock/StockList.tsx'
import StockDetail from './pages/stock/StockDetail.tsx'
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'
const routes: RouteObject[] = [
{
@@ -37,16 +39,12 @@ const routes: RouteObject[] = [
{
path: 'detail/:id',
Component: StockDetail,
}
]
},
],
},
{
path: 'task',
children: [
{
index: true,
element: <Navigate to="/task/list" replace/>,
},
{
path: 'list',
Component: TaskList,
@@ -55,12 +53,25 @@ const routes: RouteObject[] = [
path: 'add',
Component: TaskAdd,
},
]
{
path: 'template',
children: [
{
path: 'list',
Component: TaskTemplateList,
},
{
path: 'save/:id',
Component: TaskTemplateSave,
},
],
},
],
},
{
path: 'test',
Component: Test,
}
},
],
},
]

View File

@@ -44,6 +44,16 @@ const menus = {
path: '/task',
name: '任务',
icon: <UnorderedListOutlined/>,
routes: [
{
path: '/task/list',
name: '任务列表',
},
{
path: '/task/template/list',
name: '任务模板',
}
]
},
{
path: '/test',

View File

@@ -0,0 +1,113 @@
import React from 'react'
import {amisRender, commonInfo, crudCommonOptions, paginationTemplate, remoteMappings} from '../../util/amis.tsx'
import {useNavigate} from 'react-router'
function TaskTemplateList() {
const navigate = useNavigate()
return (
<div className="task-template-list">
{amisRender(
{
type: 'page',
title: '任务模板',
body: [
{
type: 'crud',
api: {
method: 'post',
url: `${commonInfo.baseUrl}/task_template/list`,
data: {
page: {
index: '${page}',
size: '${perPage}',
},
},
},
...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/template/save/-1')
},
},
],
},
},
},
],
),
columns: [
{
name: 'name',
label: '名称',
width: 150,
},
{
name: 'description',
label: '描述',
},
{
name: 'type',
label: '类型',
width: 100,
...remoteMappings('task_template_type', 'type'),
},
{
type: 'operation',
label: '操作',
width: 100,
buttons: [
{
type: 'action',
label: '详情',
level: 'link',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
// @ts-ignore
script: (context, action, event) => {
navigate(`/task/template/save/${context.props.data['id']}`)
},
},
],
},
},
},
{
className: 'text-danger',
type: 'action',
label: '删除',
level: 'link',
actionType: 'ajax',
api: `get:${commonInfo.baseUrl}/task_template/remove/\${id}`,
confirmText: '确认删除模板[${name}]',
confirmTitle: "删除",
}
],
},
],
},
],
},
)}
</div>
)
}
export default React.memo(TaskTemplateList)

View File

@@ -0,0 +1,96 @@
import React from 'react'
import {amisRender, commonInfo, remoteOptions} from '../../util/amis.tsx'
import {useNavigate, useParams} from 'react-router'
function TaskTemplateSave() {
const navigate = useNavigate()
const {id} = useParams()
return (
<div className="task-template-save">
{amisRender(
{
type: 'page',
title: '任务模板添加',
body: [
{
debug: commonInfo.debug,
type: 'form',
api: `post:${commonInfo.baseUrl}/task_template/save`,
initApi: `get:${commonInfo.baseUrl}/task_template/detail/${id}`,
initFetchOn: `${id} !== -1`,
wrapWithPanel: false,
mode: 'horizontal',
labelAlign: 'left',
onEvent: {
submitSucc: {
actions: [
{
actionType: 'custom',
// @ts-ignore
script: (context, action, event) => {
navigate(-1)
},
},
]
}
},
body: [
{
type: 'hidden',
name: 'id',
},
{
type: 'input-text',
name: 'name',
label: '名称',
require: true,
clearable: true,
},
{
type: 'textarea',
name: 'description',
label: '描述',
require: 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,
clearable: true,
},
{
type: 'button-toolbar',
buttons: [
{
type: 'action',
label: '提交',
actionType: 'submit',
level: 'primary',
},
{
type: 'action',
label: '重置',
actionType: 'reset',
},
],
},
],
},
],
},
)}
</div>
)
}
export default React.memo(TaskTemplateSave)