diff --git a/apps/web-antd/src/views/system/role/data.ts b/apps/web-antd/src/views/system/role/data.ts index 6029ac2fd..bb30d37f3 100644 --- a/apps/web-antd/src/views/system/role/data.ts +++ b/apps/web-antd/src/views/system/role/data.ts @@ -1,12 +1,14 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; -import { CommonStatusEnum, SystemDataScopeEnum } from '@vben/constants'; - -import { z } from '#/adapter/form'; -import { DICT_TYPE } from '@vben/constants'; +import { + CommonStatusEnum, + DICT_TYPE, + SystemDataScopeEnum, +} from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; +import { z } from '#/adapter/form'; import { getRangePickerDefaultProps } from '#/utils'; /** 新增/修改的表单 */ @@ -155,19 +157,28 @@ export function useGridFormSchema(): VbenFormSchema[] { fieldName: 'name', label: '角色名称', component: 'Input', + componentProps: { + placeholder: '请输入角色名称', + allowClear: true, + }, }, { fieldName: 'code', label: '角色标识', component: 'Input', + componentProps: { + placeholder: '请输入角色标识', + allowClear: true, + }, }, { fieldName: 'status', label: '角色状态', component: 'Select', componentProps: { - allowClear: true, options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + placeholder: '请选择角色状态', + allowClear: true, }, }, { @@ -189,14 +200,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'id', title: '角色编号', + minWidth: 100, }, { field: 'name', title: '角色名称', + minWidth: 200, }, { field: 'type', title: '角色类型', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.SYSTEM_ROLE_TYPE }, @@ -205,18 +219,22 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'code', title: '角色标识', + minWidth: 200, }, { field: 'sort', title: '显示顺序', + minWidth: 100, }, { field: 'remark', title: '角色备注', + minWidth: 100, }, { field: 'status', title: '角色状态', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.COMMON_STATUS }, @@ -225,6 +243,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'createTime', title: '创建时间', + minWidth: 180, formatter: 'formatDateTime', }, { diff --git a/apps/web-antd/src/views/system/role/index.vue b/apps/web-antd/src/views/system/role/index.vue index a953945f3..07e14b830 100644 --- a/apps/web-antd/src/views/system/role/index.vue +++ b/apps/web-antd/src/views/system/role/index.vue @@ -4,7 +4,7 @@ import type { SystemRoleApi } from '#/api/system/role'; import { ref } from 'vue'; -import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; +import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { downloadFileFromBlobPart, isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -40,7 +40,7 @@ const [AssignMenuFormModel, assignMenuFormApi] = useVbenModal({ }); /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } @@ -50,29 +50,43 @@ async function handleExport() { downloadFileFromBlobPart({ fileName: '角色.xls', source: data }); } -/** 编辑角色 */ -function handleEdit(row: SystemRoleApi.Role) { - formModalApi.setData(row).open(); -} - /** 创建角色 */ function handleCreate() { formModalApi.setData(null).open(); } +/** 编辑角色 */ +function handleEdit(row: SystemRoleApi.Role) { + formModalApi.setData(row).open(); +} + /** 删除角色 */ async function handleDelete(row: SystemRoleApi.Role) { const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting', [row.name]), - key: 'action_key_msg', + duration: 0, }); try { await deleteRole(row.id as number); - message.success({ - content: $t('ui.actionMessage.deleteSuccess', [row.name]), - key: 'action_key_msg', - }); - onRefresh(); + message.success($t('ui.actionMessage.deleteSuccess', [row.name])); + handleRefresh(); + } finally { + hideLoading(); + } +} + +/** 批量删除角色 */ +async function handleDeleteBatch() { + await confirm($t('ui.actionMessage.deleteBatchConfirm')); + const hideLoading = message.loading({ + content: $t('ui.actionMessage.deletingBatch'), + duration: 0, + }); + try { + await deleteRoleList(checkedIds.value); + checkedIds.value = []; + message.success($t('ui.actionMessage.deleteSuccess')); + handleRefresh(); } finally { hideLoading(); } @@ -87,23 +101,6 @@ function handleRowCheckboxChange({ checkedIds.value = records.map((item) => item.id!); } -/** 批量删除角色 */ -async function handleDeleteBatch() { - const hideLoading = message.loading({ - content: $t('ui.actionMessage.deleting'), - duration: 0, - key: 'action_process_msg', - }); - try { - await deleteRoleList(checkedIds.value); - checkedIds.value = []; - message.success($t('ui.actionMessage.deleteSuccess')); - onRefresh(); - } finally { - hideLoading(); - } -} - /** 分配角色的数据权限 */ function handleAssignDataPermission(row: SystemRoleApi.Role) { assignDataPermissionFormApi.setData(row).open(); @@ -159,9 +156,9 @@ const [Grid, gridApi] = useVbenVxeGrid({ - - - + + +