1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

fix: 计划任务删除弹窗优化 (#1140)

This commit is contained in:
ssongliu 2023-05-25 10:48:10 +08:00 committed by GitHub
parent c2629e3945
commit c8237d59be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 2 deletions

View File

@ -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 {

View File

@ -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<number> = [];
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 () => {