diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index 54b9c296..71af9445 100644 --- a/src/pages/crontab/index.tsx +++ b/src/pages/crontab/index.tsx @@ -36,6 +36,7 @@ import { PlusOutlined, UnorderedListOutlined, CheckOutlined, + CopyOutlined, } from '@ant-design/icons'; import config from '@/utils/config'; import { PageContainer } from '@ant-design/pro-layout'; @@ -57,7 +58,7 @@ import { useVT } from 'virtualizedtableforantd4'; import { ICrontab, OperationName, OperationPath, CrontabStatus } from './type'; import Name from '@/components/name'; import dayjs from 'dayjs'; -import { noop } from 'lodash'; +import { noop, omit } from 'lodash'; const { Text, Paragraph, Link } = Typography; const { Search } = Input; @@ -620,6 +621,7 @@ const Crontab = () => { icon: record.isDisabled === 1 ? : , }, + { label: intl.get('复制'), key: 'copy', icon: }, { label: intl.get('删除'), key: 'delete', icon: }, { label: record.isPinned === 1 ? intl.get('取消置顶') : intl.get('置顶'), @@ -655,6 +657,9 @@ const Crontab = () => { case 'edit': editCron(record, index); break; + case 'copy': + editCron(omit(record, 'id'), index); + break; case 'enableOrDisable': enabledOrDisabledCron(record, index); break; diff --git a/src/pages/crontab/modal.tsx b/src/pages/crontab/modal.tsx index 3bf17016..04c97d44 100644 --- a/src/pages/crontab/modal.tsx +++ b/src/pages/crontab/modal.tsx @@ -21,9 +21,9 @@ const CronModal = ({ const handleOk = async (values: any) => { setLoading(true); - const method = cron ? 'put' : 'post'; + const method = cron?.id ? 'put' : 'post'; const payload = { ...values }; - if (cron) { + if (cron?.id) { payload.id = cron.id; } try { @@ -34,7 +34,7 @@ const CronModal = ({ if (code === 200) { message.success( - cron ? intl.get('更新任务成功') : intl.get('创建任务成功'), + cron?.id ? intl.get('更新任务成功') : intl.get('创建任务成功'), ); handleCancel(data); } @@ -50,7 +50,7 @@ const CronModal = ({ return (