修改更新列表后刷新逻辑

This commit is contained in:
whyour
2023-01-31 23:52:02 +08:00
parent 4d34e0dd96
commit b01f27f2d3
2 changed files with 3 additions and 36 deletions
+2 -21
View File
@@ -721,34 +721,15 @@ const Crontab = () => {
}
};
const handleCancel = (cron?: any) => {
const handleCancel = () => {
setIsModalVisible(false);
if (cron) {
handleCrons(cron);
}
getCrons();
};
const onSearch = (value: string) => {
setSearchText(value.trim());
};
const handleCrons = (cron: any) => {
const index = value.findIndex((x) => x.id === cron.id);
const result = [...value];
cron.nextRunTime = cron_parser
.parseExpression(cron.schedule)
.next()
.toDate();
if (index === -1) {
result.unshift(cron);
} else {
result.splice(index, 1, {
...cron,
});
}
setValue(result);
};
const getCronDetail = (cron: any) => {
request
.get(`${config.apiPrefix}crons/${cron.id}`)