修改编辑cron数据交互

This commit is contained in:
whyour 2021-04-06 17:18:26 +08:00
parent a6abc15126
commit 1d1eee3513

View File

@ -338,7 +338,7 @@ const Crontab = () => {
const handleCancel = (needUpdate?: boolean) => { const handleCancel = (needUpdate?: boolean) => {
setIsModalVisible(false); setIsModalVisible(false);
if (needUpdate) { if (needUpdate) {
getCrons(); getCronDetail(editedCron);
} }
}; };
@ -346,15 +346,15 @@ const Crontab = () => {
setSearchText(value); setSearchText(value);
}; };
const getCronDetail = () => { const getCronDetail = (cron: any) => {
request request
.get(`${config.apiPrefix}crons/${logCron._id}`) .get(`${config.apiPrefix}crons/${cron._id}`)
.then((data: any) => { .then((data: any) => {
const index = value.findIndex((x) => x._id === logCron._id); const index = value.findIndex((x) => x._id === cron._id);
const result = [...value]; const result = [...value];
result.splice(index, 1, { result.splice(index, 1, {
...logCron, ...cron,
status: data.data.status, ...data.data,
}); });
setValue(result); setValue(result);
}) })
@ -423,7 +423,7 @@ const Crontab = () => {
<CronLogModal <CronLogModal
visible={isLogModalVisible} visible={isLogModalVisible}
handleCancel={() => { handleCancel={() => {
getCronDetail(); getCronDetail(logCron);
setIsLogModalVisible(false); setIsLogModalVisible(false);
}} }}
cron={logCron} cron={logCron}