refactor: (web-ele)优化多个组件的删除操作和确认逻辑

- 将 ElMessageBox 替换为自定义 confirm 函数- 添加全局 loading 功能
- 优化错误处理和消息提示- 调整部分组件属性和样式
This commit is contained in:
lrl
2025-08-01 13:56:55 +08:00
parent c447145d62
commit 38daaa2934
63 changed files with 674 additions and 662 deletions

View File

@@ -7,10 +7,10 @@ import type { SystemDictDataApi } from '#/api/system/dict/data';
import { ref, watch } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { confirm, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart, 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 {
@@ -59,23 +59,22 @@ function onEdit(row: any) {
/** 删除字典数据 */
async function onDelete(row: any) {
await ElMessageBox.confirm('确定要删除该字典数据吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.name]),
fullscreen: true,
});
await deleteDictData(row.id);
ElMessage.success($t('common.operationSuccess'));
onRefresh();
try {
await deleteDictData(row.id);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
onRefresh();
} finally {
loadingInstance.close();
}
}
/** 批量删除字典数据 */
async function onDeleteBatch() {
await ElMessageBox.confirm('确定要删除该字典数据吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
});
await confirm('确定要批量删除该字典数据吗?');
await deleteDictDataList(checkedIds.value);
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
onRefresh();

View File

@@ -7,10 +7,10 @@ import type { SystemDictTypeApi } from '#/api/system/dict/type';
import { ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { confirm, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart, 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 {
@@ -54,23 +54,22 @@ function onEdit(row: any) {
/** 删除字典类型 */
async function onDelete(row: SystemDictTypeApi.DictType) {
await ElMessageBox.confirm('确定要删除该字典类型吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.name]),
fullscreen: true,
});
await deleteDictType(row.id as number);
ElMessage.success($t('common.operationSuccess'));
onRefresh();
try {
await deleteDictType(row.id as number);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
onRefresh();
} finally {
loadingInstance.close();
}
}
/** 批量删除字典类型 */
async function onDeleteBatch() {
await ElMessageBox.confirm('确定要删除该字典类型吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
});
await confirm('确定要批量删除该字典类型吗?');
await deleteDictTypeList(checkedIds.value);
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
onRefresh();