diff --git a/apps/web-antd/src/views/system/notify/my/data.ts b/apps/web-antd/src/views/system/notify/my/data.ts index 7427bcc07..821c2901b 100644 --- a/apps/web-antd/src/views/system/notify/my/data.ts +++ b/apps/web-antd/src/views/system/notify/my/data.ts @@ -4,12 +4,11 @@ import type { DescriptionItemSchema } from '#/components/description'; import { h } from 'vue'; +import { DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; import { formatDateTime } from '@vben/utils'; import { DictTag } from '#/components/dict-tag'; -import { DICT_TYPE } from '@vben/constants'; -import { getDictOptions } from '@vben/hooks'; - import { getRangePickerDefaultProps } from '#/utils'; /** 列表的搜索表单 */ @@ -21,8 +20,8 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'), - allowClear: true, placeholder: '请选择是否已读', + allowClear: true, }, }, { @@ -30,8 +29,8 @@ export function useGridFormSchema(): VbenFormSchema[] { label: '发送时间', component: 'RangePicker', componentProps: { - allowClear: true, ...getRangePickerDefaultProps(), + allowClear: true, }, }, ]; @@ -48,15 +47,18 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'templateNickname', title: '发送人', + minWidth: 180, }, { field: 'createTime', title: '发送时间', + minWidth: 180, formatter: 'formatDateTime', }, { field: 'templateType', title: '类型', + minWidth: 120, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE }, @@ -65,10 +67,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'templateContent', title: '消息内容', + minWidth: 300, }, { field: 'readStatus', title: '是否已读', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING }, @@ -77,6 +81,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'readTime', title: '阅读时间', + minWidth: 180, formatter: 'formatDateTime', }, { diff --git a/apps/web-antd/src/views/system/notify/my/index.vue b/apps/web-antd/src/views/system/notify/my/index.vue index 2ed5db6fe..5df46381e 100644 --- a/apps/web-antd/src/views/system/notify/my/index.vue +++ b/apps/web-antd/src/views/system/notify/my/index.vue @@ -2,7 +2,10 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { SystemNotifyMessageApi } from '#/api/system/notify/message'; +import { ref } from 'vue'; + import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; +import { isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -22,7 +25,7 @@ const [DetailModal, detailModalApi] = useVbenModal({ }); /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } @@ -33,22 +36,19 @@ function handleDetail(row: SystemNotifyMessageApi.NotifyMessage) { /** 标记一条站内信已读 */ async function handleRead(row: SystemNotifyMessageApi.NotifyMessage) { - message.loading({ + const hideLoading = message.loading({ content: '正在标记已读...', duration: 0, - key: 'action_process_msg', }); - // 执行标记已读操作 - await updateNotifyMessageRead([row.id]); - // 提示成功 - message.success({ - content: '标记已读成功', - key: 'action_process_msg', - }); - onRefresh(); - - // 打开详情 - handleDetail(row); + try { + await updateNotifyMessageRead([row.id]); + message.success('标记已读成功'); + handleRefresh(); + // 打开详情 + handleDetail(row); + } finally { + hideLoading(); + } } /** 标记选中的站内信为已读 */ @@ -62,39 +62,40 @@ async function handleMarkRead() { const ids = rows.map((row: SystemNotifyMessageApi.NotifyMessage) => row.id); const hideLoading = message.loading({ content: '正在标记已读...', - key: 'action_key_msg', + duration: 0, }); try { - // 执行标记已读操作 await updateNotifyMessageRead(ids); - // 提示成功 - message.success({ - content: '标记已读成功', - key: 'action_key_msg', - }); + checkedIds.value = []; + message.success('标记已读成功'); await gridApi.grid.setAllCheckboxRow(false); - onRefresh(); + handleRefresh(); } finally { hideLoading(); } } +const checkedIds = ref([]); +function handleRowCheckboxChange({ + records, +}: { + records: SystemNotifyMessageApi.NotifyMessage[]; +}) { + checkedIds.value = records.map((item) => item.id); +} + /** 标记所有站内信为已读 */ async function handleMarkAllRead() { const hideLoading = message.loading({ content: '正在标记全部已读...', - key: 'action_key_msg', + duration: 0, }); try { - // 执行标记已读操作 await updateAllNotifyMessageRead(); - // 提示成功 - message.success({ - content: '全部标记已读成功', - key: 'action_key_msg', - }); + message.success('全部标记已读成功'); + checkedIds.value = []; await gridApi.grid.setAllCheckboxRow(false); - onRefresh(); + handleRefresh(); } finally { hideLoading(); } @@ -121,6 +122,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, rowConfig: { keyField: 'id', + isHover: true, }, toolbarConfig: { refresh: true, @@ -132,6 +134,10 @@ const [Grid, gridApi] = useVbenVxeGrid({ highlight: true, }, } as VxeTableGridOptions, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); - +