refactor: (web-ele)优化多个组件的删除操作和确认逻辑
- 将 ElMessageBox 替换为自定义 confirm 函数- 添加全局 loading 功能 - 优化错误处理和消息提示- 调整部分组件属性和样式
This commit is contained in:
@@ -7,10 +7,10 @@ import type { SystemOAuth2ClientApi } from '#/api/system/oauth2/client';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
@@ -45,23 +45,22 @@ function onEdit(row: SystemOAuth2ClientApi.OAuth2Client) {
|
||||
|
||||
/** 删除 OAuth2 客户端 */
|
||||
async function onDelete(row: SystemOAuth2ClientApi.OAuth2Client) {
|
||||
await ElMessageBox.confirm('确定要删除该 OAuth2 客户端吗?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||
fullscreen: true,
|
||||
});
|
||||
await deleteOAuth2Client(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
try {
|
||||
await deleteOAuth2Client(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除 OAuth2 客户端 */
|
||||
async function onDeleteBatch() {
|
||||
await ElMessageBox.confirm('确定要删除该 OAuth2 客户端吗?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
});
|
||||
await confirm('确定要批量删除该 OAuth2 客户端吗?');
|
||||
await deleteOAuth2ClientList(checkedIds.value);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||
onRefresh();
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { SystemOAuth2TokenApi } from '#/api/system/oauth2/token';
|
||||
|
||||
import { DocAlert, Page } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
@@ -25,14 +25,17 @@ function onRefresh() {
|
||||
|
||||
/** 删除 OAuth2 令牌 */
|
||||
async function onDelete(row: SystemOAuth2TokenApi.OAuth2Token) {
|
||||
await ElMessageBox.confirm('确定要删除该令牌吗?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.accessToken]),
|
||||
fullscreen: true,
|
||||
});
|
||||
await deleteOAuth2Token(row.accessToken);
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
onRefresh();
|
||||
try {
|
||||
await deleteOAuth2Token(row.accessToken);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.accessToken]));
|
||||
onRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
|
||||
Reference in New Issue
Block a user