diff --git a/apps/web-antd/src/api/system/notify/message/index.ts b/apps/web-antd/src/api/system/notify/message/index.ts index 5a5c21154..a84b516c3 100644 --- a/apps/web-antd/src/api/system/notify/message/index.ts +++ b/apps/web-antd/src/api/system/notify/message/index.ts @@ -15,8 +15,8 @@ export namespace SystemNotifyMessageApi { templateType: number; templateParams: string; readStatus: boolean; - readTime: string; - createTime: string; + readTime: Date; + createTime: Date; } } @@ -38,7 +38,9 @@ export function getMyNotifyMessagePage(params: PageParam) { /** 批量标记已读 */ export function updateNotifyMessageRead(ids: number[]) { - return requestClient.put('/system/notify-message/update-read', { ids }); + return requestClient.put('/system/notify-message/update-read', {}, { + params: { ids }, + }); } /** 标记所有站内信为已读 */ diff --git a/apps/web-antd/src/router/routes/modules/infra.ts b/apps/web-antd/src/router/routes/modules/infra.ts index 1ff47cb3e..cc6d96def 100644 --- a/apps/web-antd/src/router/routes/modules/infra.ts +++ b/apps/web-antd/src/router/routes/modules/infra.ts @@ -17,10 +17,9 @@ const routes: RouteRecordRaw[] = [ path: '/codegen', name: 'CodegenEdit', meta: { + title: '代码生成', icon: 'ic:baseline-view-in-ar', keepAlive: true, - order: 1000, - title: '代码生成', hideInMenu: true, }, children: [ diff --git a/apps/web-antd/src/router/routes/modules/system.ts b/apps/web-antd/src/router/routes/modules/system.ts new file mode 100644 index 000000000..c75059b29 --- /dev/null +++ b/apps/web-antd/src/router/routes/modules/system.ts @@ -0,0 +1,16 @@ +import type { RouteRecordRaw } from 'vue-router'; + +const routes: RouteRecordRaw[] = [ + { + path: '/system/notify-message', + component: () => import('#/views/system/notify/my/index.vue'), + name: 'MyNotifyMessage', + meta: { + title: '我的站内信', + icon: 'ant-design:message-filled', + hideInMenu: true, + }, + }, +]; + +export default routes; 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 9172b35fd..c594a3d9b 100644 --- a/apps/web-antd/src/views/system/notify/my/data.ts +++ b/apps/web-antd/src/views/system/notify/my/data.ts @@ -4,9 +4,6 @@ import type { SystemNotifyMessageApi } from '#/api/system/notify/message'; import { getRangePickerDefaultProps } from '#/utils/date'; import { DICT_TYPE, getDictOptions } from '#/utils/dict'; -import { useAccess } from '@vben/access'; - -const { hasAccessByCodes } = useAccess(); /** 列表的搜索表单 */ export function useGridFormSchema(): VbenFormSchema[] { @@ -16,8 +13,8 @@ export function useGridFormSchema(): VbenFormSchema[] { label: '是否已读', component: 'Select', componentProps: { - allowClear: true, options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'), + allowClear: true, placeholder: '请选择是否已读', }, }, @@ -38,6 +35,11 @@ export function useGridColumns( onActionClick: OnActionClickFn, ): VxeTableGridOptions['columns'] { return [ + { + title: '', + width: 40, + type: 'checkbox', + }, { field: 'templateNickname', title: '发送人', @@ -94,8 +96,13 @@ export function useGridColumns( options: [ { code: 'detail', - text: '详情', - show: hasAccessByCodes(['system:notify-message:query']), + text: '查看', + show: (row: any) => row.readStatus, + }, + { + code: 'read', + text: '已读', + show: (row: any) => !row.readStatus, }, ], }, 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 2ffb9955c..f6fdb4cb0 100644 --- a/apps/web-antd/src/views/system/notify/my/index.vue +++ b/apps/web-antd/src/views/system/notify/my/index.vue @@ -33,17 +33,27 @@ function onRefresh() { /** 查看站内信详情 */ function onDetail(row: SystemNotifyMessageApi.SystemNotifyMessage) { - // 标记已读 - if (!row.readStatus) { - handleReadOne(row.id); - } detailModalApi.setData(row).open(); } /** 标记一条站内信已读 */ -async function handleReadOne(id: number) { - await updateNotifyMessageRead([id]); +async function onRead(row: SystemNotifyMessageApi.SystemNotifyMessage) { + message.loading({ + content: '正在标记已读...', + duration: 0, + key: 'action_process_msg', + }); + // 执行标记已读操作 + await updateNotifyMessageRead([row.id]); + // 提示成功 + message.success({ + content: '标记已读成功', + key: 'action_process_msg', + }); onRefresh(); + + // 打开详情 + onDetail(row); } /** 标记选中的站内信为已读 */ @@ -58,42 +68,38 @@ async function onMarkRead() { } const ids = rows.map((row: SystemNotifyMessageApi.SystemNotifyMessage) => row.id); - const hideLoading = message.loading({ + message.loading({ content: '正在标记已读...', duration: 0, key: 'action_process_msg', }); - - try { - await updateNotifyMessageRead(ids); - message.success({ - content: '标记已读成功', - key: 'action_process_msg', - }); - onRefresh(); - } finally { - hideLoading(); - } + // 执行标记已读操作 + await updateNotifyMessageRead(ids); + // 提示成功 + message.success({ + content: '标记已读成功', + key: 'action_process_msg', + }); + await gridApi.grid.setAllCheckboxRow(false); + onRefresh(); } /** 标记所有站内信为已读 */ async function onMarkAllRead() { - const hideLoading = message.loading({ + message.loading({ content: '正在标记全部已读...', duration: 0, key: 'action_process_msg', }); - - try { - await updateAllNotifyMessageRead(); - message.success({ - content: '全部标记已读成功', - key: 'action_process_msg', - }); - onRefresh(); - } finally { - hideLoading(); - } + // 执行标记已读操作 + await updateAllNotifyMessageRead(); + // 提示成功 + message.success({ + content: '全部标记已读成功', + key: 'action_process_msg', + }); + await gridApi.grid.setAllCheckboxRow(false); + onRefresh(); } /** 表格操作按钮的回调函数 */ @@ -106,14 +112,13 @@ function onActionClick({ onDetail(row); break; } + case 'read': { + onRead(row); + break; + } } } -// 是否允许勾选的过滤函数(只允许未读的消息被选择) -function checkboxConfig(params: { row: SystemNotifyMessageApi.SystemNotifyMessage }) { - return !params.row.readStatus; -} - const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useGridFormSchema(), @@ -141,23 +146,24 @@ const [Grid, gridApi] = useVbenVxeGrid({ search: true, }, checkboxConfig: { - checkMethod: checkboxConfig, + checkMethod: (params: { row: SystemNotifyMessageApi.SystemNotifyMessage }) => !params.row.readStatus, + highlight: true, }, } as VxeTableGridOptions, });