refactor: (web-ele)优化多个组件的删除操作和确认逻辑
- 将 ElMessageBox 替换为自定义 confirm 函数- 添加全局 loading 功能 - 优化错误处理和消息提示- 调整部分组件属性和样式
This commit is contained in:
@@ -4,7 +4,7 @@ import type { MemberGroupApi } from '#/api/member/group';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteGroup, getGroupPage } from '#/api/member/group';
|
||||
@@ -35,14 +35,17 @@ function handleEdit(row: MemberGroupApi.Group) {
|
||||
|
||||
/** 删除分组 */
|
||||
async function handleDelete(row: MemberGroupApi.Group) {
|
||||
await ElMessageBox.confirm('确定要删除该分组吗?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||
fullscreen: true,
|
||||
});
|
||||
await deleteGroup(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
try {
|
||||
await deleteGroup(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { MemberLevelApi } from '#/api/member/level';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteLevel, getLevelList } from '#/api/member/level';
|
||||
@@ -35,14 +35,17 @@ function handleEdit(row: MemberLevelApi.Level) {
|
||||
|
||||
/** 删除等级 */
|
||||
async function handleDelete(row: MemberLevelApi.Level) {
|
||||
await ElMessageBox.confirm('确定要删除该等级吗?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||
fullscreen: true,
|
||||
});
|
||||
await deleteLevel(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
try {
|
||||
await deleteLevel(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { MemberTagApi } from '#/api/member/tag';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteMemberTag, getMemberTagPage } from '#/api/member/tag';
|
||||
@@ -35,14 +35,17 @@ function handleEdit(row: MemberTagApi.Tag) {
|
||||
|
||||
/** 删除会员标签 */
|
||||
async function handleDelete(row: MemberTagApi.Tag) {
|
||||
await ElMessageBox.confirm('确定要删除该会员标签吗?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||
fullscreen: true,
|
||||
});
|
||||
await deleteMemberTag(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
try {
|
||||
await deleteMemberTag(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
||||
Reference in New Issue
Block a user