修改定时任务排序

This commit is contained in:
whyour 2022-01-30 09:59:33 +08:00
parent 27eb0a21e4
commit 74b258e1b6

View File

@ -31,7 +31,7 @@ import {
import config from '@/utils/config'; import config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { request } from '@/utils/http'; import { request } from '@/utils/http';
import CronModal,{ CronLabelModal } from './modal'; import CronModal, { CronLabelModal } from './modal';
import CronLogModal from './logModal'; import CronLogModal from './logModal';
import cron_parser from 'cron-parser'; import cron_parser from 'cron-parser';
import { diffTime } from '@/utils/date'; import { diffTime } from '@/utils/date';
@ -49,7 +49,7 @@ enum CrontabStatus {
'queued', 'queued',
} }
const CrontabSort: any = { 0: 0, 3: 1, 1: 2, 4: 3 }; const CrontabSort: any = { 0: 0, 5: 1, 3: 2, 1: 3, 4: 4 };
enum OperationName { enum OperationName {
'启用', '启用',
@ -94,21 +94,30 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
)} )}
</a> </a>
<span> <span>
{record.labels?.length > 0 && record.labels[0] !== '' ? {record.labels?.length > 0 && record.labels[0] !== '' ? (
<Popover placement='right' trigger={isPhone ? 'click' : 'hover'} <Popover
placement="right"
trigger={isPhone ? 'click' : 'hover'}
content={ content={
<div> <div>
{record.labels?.map((label: string, i: number) => ( {record.labels?.map((label: string, i: number) => (
<Tag color="blue" <Tag
onClick={() => { onSearch(`label:${label}`) }}> color="blue"
onClick={() => {
onSearch(`label:${label}`);
}}
>
{label} {label}
</Tag> </Tag>
))} ))}
</div> </div>
}> }
>
<Tag color="blue">{record.labels[0]}</Tag> <Tag color="blue">{record.labels[0]}</Tag>
</Popover> </Popover>
: ''} ) : (
''
)}
</span> </span>
</> </>
), ),
@ -381,14 +390,19 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
setValue( setValue(
data.data data.data
.sort((a: any, b: any) => { .sort((a: any, b: any) => {
const sortA = a.isDisabled ? 4 : a.status; const sortA =
const sortB = b.isDisabled ? 4 : b.status; a.isDisabled && a.status !== 0
a.isPinned = a.isPinned ? a.isPinned : 0; ? 4
b.isPinned = b.isPinned ? b.isPinned : 0; : a.isPinned && a.status !== 0
if (a.isPinned === b.isPinned) { ? 5
: a.status;
const sortB =
b.isDisabled && b.status !== 0
? 4
: b.isPinned && b.status !== 0
? 5
: b.status;
return CrontabSort[sortA] - CrontabSort[sortB]; return CrontabSort[sortA] - CrontabSort[sortB];
}
return b.isPinned - a.isPinned;
}) })
.map((x) => { .map((x) => {
return { return {