fix: 统一修改删除操作提示

This commit is contained in:
zhengkunwang223 2022-12-02 10:59:07 +08:00 committed by zhengkunwang223
parent 42a9d34e3d
commit e45f5e3369
24 changed files with 24 additions and 30 deletions

View File

@ -7,7 +7,6 @@ import i18n from '@/lang';
* @param {Function} api 操作数据接口的api方法(必传)
* @param {Object} params 携带的操作数据参数 {id,params}(必传)
* @param {String} message 提示信息(必传)
* @param {String} loading 页面loading
* @param {String} confirmType icon类型(不必传,默认为 warning)
* @return Promise
*/
@ -15,11 +14,9 @@ export const useDeleteData = <P = any, R = any>(
api: (params: P) => Promise<R>,
params: Parameters<typeof api>[0],
message: string,
loading: boolean,
confirmType: HandleData.MessageType = 'error',
) => {
return new Promise((resolve, reject) => {
loading = true;
ElMessageBox.confirm(i18n.global.t(`${message}`) + '?', i18n.global.t('commons.msg.deleteTitle'), {
confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'),
@ -35,9 +32,6 @@ export const useDeleteData = <P = any, R = any>(
});
resolve(true);
})
.finally(() => {
loading = false;
})
.catch(() => {});
});
};

View File

@ -60,7 +60,7 @@ export default {
interval: '耗时',
},
msg: {
delete: '此操作不可回滚,是否继续',
delete: '删除 操作不可回滚是否继续',
deleteTitle: '删除',
deleteSuccess: '删除成功',
loginSuccess: '登录成功',

View File

@ -167,7 +167,7 @@ const restore = async () => {
};
const deleteBackup = async (ids: number[]) => {
await useDeleteData(DelAppBackups, { ids: ids }, 'commons.msg.delete', loading.value);
await useDeleteData(DelAppBackups, { ids: ids }, 'commons.msg.delete');
search();
};

View File

@ -157,7 +157,7 @@ const batchDelete = async (option: string) => {
ids.push(item);
}
}
await useDeleteData(imageRemove, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(imageRemove, { ids: ids }, 'commons.msg.delete');
deleteVisiable.value = false;
search();
};

View File

@ -111,7 +111,7 @@ const batchDelete = async (row: Container.NetworkInfo | null) => {
} else {
ids.push(row.id);
}
await useDeleteData(deleteNetwork, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteNetwork, { ids: ids }, 'commons.msg.delete');
search();
};

View File

@ -87,7 +87,7 @@ const onBatchDelete = async (row: Container.RepoInfo | null) => {
ids.push(item.id);
});
}
await useDeleteData(deleteImageRepo, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteImageRepo, { ids: ids }, 'commons.msg.delete');
search();
};

View File

@ -141,7 +141,7 @@ const onBatchDelete = async (row: Container.RepoInfo | null) => {
ids.push(item.id);
});
}
await useDeleteData(deleteComposeTemplate, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteComposeTemplate, { ids: ids }, 'commons.msg.delete');
search();
};

View File

@ -103,7 +103,7 @@ const batchDelete = async (row: Container.VolumeInfo | null) => {
} else {
ids.push(row.name);
}
await useDeleteData(deleteVolume, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteVolume, { ids: ids }, 'commons.msg.delete');
search();
};

View File

@ -164,7 +164,7 @@ const onBatchDelete = async (row: Cronjob.CronjobInfo | null) => {
ids.push(item.id);
});
}
await useDeleteData(deleteCronjob, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteCronjob, { ids: ids }, 'commons.msg.delete');
search();
};
const beforeChangeStatus = () => {

View File

@ -123,7 +123,7 @@ const onBatchDelete = async (row: Backup.RecordInfo | null) => {
ids.push(item.id);
});
}
await useDeleteData(deleteBackupRecord, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteBackupRecord, { ids: ids }, 'commons.msg.delete');
search();
};

View File

@ -227,7 +227,7 @@ const onBatchDelete = async (row: Database.MysqlDBInfo | null) => {
ids.push(item.id);
});
}
await useDeleteData(deleteMysqlDB, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteMysqlDB, { ids: ids }, 'commons.msg.delete');
search();
};
const buttons = [

View File

@ -173,7 +173,7 @@ const onBatchDelete = async (row: File.File | null) => {
files.push(baseDir + item.name);
});
}
await useDeleteData(BatchDeleteFile, { paths: files, isDir: false }, 'commons.msg.delete', true);
await useDeleteData(BatchDeleteFile, { paths: files, isDir: false }, 'commons.msg.delete');
search();
};

View File

@ -215,7 +215,7 @@ const onBatchDelete = async (row: Database.FileRecord | null) => {
files.push(item.fileDir + '/' + item.fileName);
});
}
await useDeleteData(BatchDeleteFile, { isDir: false, paths: files }, 'commons.msg.delete', true);
await useDeleteData(BatchDeleteFile, { isDir: false, paths: files }, 'commons.msg.delete');
loadBackupRecords();
};
const buttons = [

View File

@ -341,7 +341,7 @@ const handleCreate = (commnad: string) => {
};
const delFile = async (row: File.File | null) => {
await useDeleteData(DeleteFile, row as File.FileDelete, 'commons.msg.delete', loading.value);
await useDeleteData(DeleteFile, row as File.FileDelete, 'commons.msg.delete');
search();
};

View File

@ -115,7 +115,7 @@ const batchDelete = async (row: Command.CommandInfo | null) => {
} else {
ids.push(row.id);
}
await useDeleteData(deleteCommand, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteCommand, { ids: ids }, 'commons.msg.delete');
search();
};

View File

@ -279,10 +279,10 @@ const onDelete = async (node: Node, data: Tree) => {
return;
}
if (node.level === 1) {
await useDeleteData(deleteGroup, data.id - 10000, i18n.global.t('terminal.groupDeleteHelper'), true);
await useDeleteData(deleteGroup, data.id - 10000, i18n.global.t('terminal.groupDeleteHelper'));
loadGroups();
} else {
await useDeleteData(deleteHost, data.id, 'commons.msg.delete', true);
await useDeleteData(deleteHost, data.id, 'commons.msg.delete');
}
loadHostTree();
loadGroups();

View File

@ -224,7 +224,7 @@ const onBatchDelete = async (row: Backup.BackupInfo | null) => {
} else {
ids.push(row.id);
}
await useDeleteData(deleteBackup, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteBackup, { ids: ids }, 'commons.msg.delete');
search();
restForm();
};

View File

@ -72,6 +72,6 @@ function onSave(formEl: FormInstance | undefined, key: string, val: any) {
}
const onClean = async () => {
await useDeleteData(cleanMonitors, {}, 'commons.msg.delete', true);
await useDeleteData(cleanMonitors, {}, 'commons.msg.delete');
};
</script>

View File

@ -71,7 +71,7 @@ const openCreate = () => {
};
const deleteAccount = async (id: number) => {
await useDeleteData(DeleteAcmeAccount, id, 'commons.msg.delete', loading.value);
await useDeleteData(DeleteAcmeAccount, id, 'commons.msg.delete');
search();
};

View File

@ -87,7 +87,7 @@ const openEdit = (form: WebSite.DnsAccount) => {
const deleteAccount = async (id: number) => {
loading.value = true;
await useDeleteData(DeleteDnsAccount, id, 'commons.msg.delete', false);
await useDeleteData(DeleteDnsAccount, id, 'commons.msg.delete');
loading.value = false;
search();
};

View File

@ -124,7 +124,7 @@ const openRenewSSL = (id: number) => {
const deleteSSL = async (id: number) => {
loading.value = true;
await useDeleteData(DeleteSSL, id, 'commons.msg.delete', false);
await useDeleteData(DeleteSSL, id, 'commons.msg.delete');
loading.value = false;
search();
};

View File

@ -144,7 +144,7 @@ const onBatchDelete = async (row: Backup.RecordInfo | null) => {
ids.push(item.id);
});
}
await useDeleteData(deleteBackupRecord, { ids: ids }, 'commons.msg.delete', true);
await useDeleteData(deleteBackupRecord, { ids: ids }, 'commons.msg.delete');
search();
};

View File

@ -49,7 +49,7 @@ const openCreate = () => {
};
const deleteDoamin = async (domainId: number) => {
await useDeleteData(DeleteDomain, domainId, 'commons.msg.delete', loading.value);
await useDeleteData(DeleteDomain, domainId, 'commons.msg.delete');
search(id.value);
};

View File

@ -183,7 +183,7 @@ const onBatchDelete = async (row: File.File | null) => {
files.push(baseDir.value + '/' + item.name);
});
}
await useDeleteData(BatchDeleteFile, { isDir: false, paths: files }, 'commons.msg.delete', true);
await useDeleteData(BatchDeleteFile, { isDir: false, paths: files }, 'commons.msg.delete');
search();
};