From 418695c4aa8987a609204a528956c67db7770261 Mon Sep 17 00:00:00 2001 From: whyour Date: Tue, 24 Sep 2024 23:33:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/crontab/index.tsx | 7 ++++++- src/pages/crontab/modal.tsx | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index 54b9c296939..71af9445592 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 3bf170162ab..04c97d44e0c 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 (