修复定时任务状态筛选

This commit is contained in:
whyour
2022-09-07 11:30:11 +08:00
parent bd28682769
commit dc27856441
2 changed files with 43 additions and 14 deletions
+17 -8
View File
@@ -181,6 +181,8 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
{
title: '最后运行时间',
align: 'center' as const,
dataIndex: 'last_execution_time',
key: 'last_execution_time',
width: 150,
sorter: {
compare: (a: any, b: any) => {
@@ -210,6 +212,8 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
title: '最后运行时长',
align: 'center' as const,
width: 120,
dataIndex: 'last_running_time',
key: 'last_running_time',
sorter: {
compare: (a: any, b: any) => {
return a.last_running_time - b.last_running_time;
@@ -366,6 +370,7 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
page: number;
size: number;
sorter: any;
filters: any;
}>({} as any);
const [viewConf, setViewConf] = useState<any>();
const [tableScrollHeight, setTableScrollHeight] = useState<number>();
@@ -388,9 +393,13 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
cmd[1] = cmd[1].replace('/ql/data/scripts/', '');
}
let [p, s] = cmd[1].split('/');
if (!s) {
s = p;
let p: string, s: string;
let index = cmd[1].lastIndexOf('/');
if (index >= 0) {
s = cmd[1].slice(index + 1);
p = cmd[1].slice(0, index);
} else {
s = cmd[1];
p = '';
}
history.push(`/script?p=${p}&s=${s}`);
@@ -401,11 +410,10 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
const getCrons = () => {
setLoading(true);
const { page, size, sorter } = pageConf;
let url = `${config.apiPrefix}crons?searchValue=${searchText}&page=${page}&size=${size}`;
const { page, size, sorter, filters } = pageConf;
let url = `${config.apiPrefix}crons?searchValue=${searchText}&page=${page}&size=${size}&filters=${JSON.stringify(filters)}`;
if (sorter && sorter.field) {
url += `&sortField=${sorter.field}&sortType=${sorter.order === 'ascend' ? 'ASC' : 'DESC'
}`;
url += `&sorter=${JSON.stringify({ field: sorter.field, type: sorter.order === 'ascend' ? 'ASC' : 'DESC' })}`;
}
if (viewConf) {
url += `&queryString=${JSON.stringify({
@@ -820,7 +828,7 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
sorter: SorterResult<any> | SorterResult<any>[],
) => {
const { current, pageSize } = pagination;
setPageConf({ page: current as number, size: pageSize as number, sorter });
setPageConf({ page: current as number, size: pageSize as number, sorter, filters });
localStorage.setItem('pageSize', String(pageSize));
};
@@ -857,6 +865,7 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
page: 1,
size: parseInt(localStorage.getItem('pageSize') || '20'),
sorter: {},
filters: {}
});
setTimeout(() => {
setTableScrollHeight(getTableScroll());