Skip to content

Commit

Permalink
定时任务支持复制
Browse files Browse the repository at this point in the history
  • Loading branch information
whyour committed Sep 24, 2024
1 parent 4c5223b commit 418695c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/pages/crontab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -620,6 +621,7 @@ const Crontab = () => {
icon:
record.isDisabled === 1 ? <CheckCircleOutlined /> : <StopOutlined />,
},
{ label: intl.get('复制'), key: 'copy', icon: <CopyOutlined /> },
{ label: intl.get('删除'), key: 'delete', icon: <DeleteOutlined /> },
{
label: record.isPinned === 1 ? intl.get('取消置顶') : intl.get('置顶'),
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/pages/crontab/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,7 +34,7 @@ const CronModal = ({

if (code === 200) {
message.success(
cron ? intl.get('更新任务成功') : intl.get('创建任务成功'),
cron?.id ? intl.get('更新任务成功') : intl.get('创建任务成功'),
);
handleCancel(data);
}
Expand All @@ -50,7 +50,7 @@ const CronModal = ({

return (
<Modal
title={cron ? intl.get('编辑任务') : intl.get('创建任务')}
title={cron?.id ? intl.get('编辑任务') : intl.get('创建任务')}
open={visible}
forceRender
centered
Expand Down

0 comments on commit 418695c

Please sign in to comment.