定时任务支持复制

This commit is contained in:
whyour 2024-09-24 23:33:04 +08:00
parent 4c5223ba11
commit 418695c4aa
2 changed files with 10 additions and 5 deletions

View File

@ -36,6 +36,7 @@ import {
PlusOutlined, PlusOutlined,
UnorderedListOutlined, UnorderedListOutlined,
CheckOutlined, CheckOutlined,
CopyOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import config from '@/utils/config'; import config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
@ -57,7 +58,7 @@ import { useVT } from 'virtualizedtableforantd4';
import { ICrontab, OperationName, OperationPath, CrontabStatus } from './type'; import { ICrontab, OperationName, OperationPath, CrontabStatus } from './type';
import Name from '@/components/name'; import Name from '@/components/name';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { noop } from 'lodash'; import { noop, omit } from 'lodash';
const { Text, Paragraph, Link } = Typography; const { Text, Paragraph, Link } = Typography;
const { Search } = Input; const { Search } = Input;
@ -620,6 +621,7 @@ const Crontab = () => {
icon: icon:
record.isDisabled === 1 ? <CheckCircleOutlined /> : <StopOutlined />, record.isDisabled === 1 ? <CheckCircleOutlined /> : <StopOutlined />,
}, },
{ label: intl.get('复制'), key: 'copy', icon: <CopyOutlined /> },
{ label: intl.get('删除'), key: 'delete', icon: <DeleteOutlined /> }, { label: intl.get('删除'), key: 'delete', icon: <DeleteOutlined /> },
{ {
label: record.isPinned === 1 ? intl.get('取消置顶') : intl.get('置顶'), label: record.isPinned === 1 ? intl.get('取消置顶') : intl.get('置顶'),
@ -655,6 +657,9 @@ const Crontab = () => {
case 'edit': case 'edit':
editCron(record, index); editCron(record, index);
break; break;
case 'copy':
editCron(omit(record, 'id'), index);
break;
case 'enableOrDisable': case 'enableOrDisable':
enabledOrDisabledCron(record, index); enabledOrDisabledCron(record, index);
break; break;

View File

@ -21,9 +21,9 @@ const CronModal = ({
const handleOk = async (values: any) => { const handleOk = async (values: any) => {
setLoading(true); setLoading(true);
const method = cron ? 'put' : 'post'; const method = cron?.id ? 'put' : 'post';
const payload = { ...values }; const payload = { ...values };
if (cron) { if (cron?.id) {
payload.id = cron.id; payload.id = cron.id;
} }
try { try {
@ -34,7 +34,7 @@ const CronModal = ({
if (code === 200) { if (code === 200) {
message.success( message.success(
cron ? intl.get('更新任务成功') : intl.get('创建任务成功'), cron?.id ? intl.get('更新任务成功') : intl.get('创建任务成功'),
); );
handleCancel(data); handleCancel(data);
} }
@ -50,7 +50,7 @@ const CronModal = ({
return ( return (
<Modal <Modal
title={cron ? intl.get('编辑任务') : intl.get('创建任务')} title={cron?.id ? intl.get('编辑任务') : intl.get('创建任务')}
open={visible} open={visible}
forceRender forceRender
centered centered