From c8237d59be7aff86fa3716af380917ec795fa7ca Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 25 May 2023 10:48:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=BC=B9=E7=AA=97=E4=BC=98=E5=8C=96=20(#1140?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/cornjob.go | 2 +- frontend/src/views/cronjob/index.vue | 39 +++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/backend/app/service/cornjob.go b/backend/app/service/cornjob.go index bd918d306..669c73bf9 100644 --- a/backend/app/service/cornjob.go +++ b/backend/app/service/cornjob.go @@ -85,7 +85,7 @@ func (u *CronjobService) CleanRecord(req dto.CronjobClean) error { if err != nil { return err } - if req.CleanData && cronjob.Type != "shell" && cronjob.Type != "curl" { + if req.CleanData && (cronjob.Type == "database" || cronjob.Type == "website" || cronjob.Type == "directory") { cronjob.RetainCopies = 0 backup, err := backupRepo.Get(commonRepo.WithByID(uint(cronjob.TargetDirID))) if err != nil { diff --git a/frontend/src/views/cronjob/index.vue b/frontend/src/views/cronjob/index.vue index f06cfe492..6a2274044 100644 --- a/frontend/src/views/cronjob/index.vue +++ b/frontend/src/views/cronjob/index.vue @@ -243,10 +243,47 @@ const onOpenDialog = async ( const onDelete = async (row: Cronjob.CronjobInfo | null) => { if (row) { deleteCronjobID.value = row.id; + if (row.type !== 'database' && row.type !== 'website' && row.type !== 'directory') { + deleteMessageBox(); + return; + } + deleteVisiable.value = true; } else { deleteCronjobID.value = 0; + for (const item of selects.value) { + if (item.type === 'database' || item.type === 'website' || item.type === 'directory') { + deleteVisiable.value = true; + return; + } + } + deleteMessageBox(); } - deleteVisiable.value = true; +}; + +const deleteMessageBox = async () => { + let ids: Array = []; + if (deleteCronjobID.value) { + ids.push(deleteCronjobID.value); + } else { + selects.value.forEach((item: Cronjob.CronjobInfo) => { + ids.push(item.id); + }); + } + ElMessageBox.confirm(i18n.global.t('commons.msg.delete'), i18n.global.t('commons.msg.deleteTitle'), { + confirmButtonText: i18n.global.t('commons.button.confirm'), + cancelButtonText: i18n.global.t('commons.button.cancel'), + type: 'info', + }).then(async () => { + await deleteCronjob(ids, false) + .then(() => { + delLoading.value = false; + MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); + search(); + }) + .catch(() => { + delLoading.value = false; + }); + }); }; const onSubmitDelete = async () => {