feat:完善我的站内信 50%(列表界面)
parent
555dc1c063
commit
d3d250f16f
|
@ -15,8 +15,8 @@ export namespace SystemNotifyMessageApi {
|
||||||
templateType: number;
|
templateType: number;
|
||||||
templateParams: string;
|
templateParams: string;
|
||||||
readStatus: boolean;
|
readStatus: boolean;
|
||||||
readTime: string;
|
readTime: Date;
|
||||||
createTime: string;
|
createTime: Date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,9 @@ export function getMyNotifyMessagePage(params: PageParam) {
|
||||||
|
|
||||||
/** 批量标记已读 */
|
/** 批量标记已读 */
|
||||||
export function updateNotifyMessageRead(ids: number[]) {
|
export function updateNotifyMessageRead(ids: number[]) {
|
||||||
return requestClient.put('/system/notify-message/update-read', { ids });
|
return requestClient.put('/system/notify-message/update-read', {}, {
|
||||||
|
params: { ids },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 标记所有站内信为已读 */
|
/** 标记所有站内信为已读 */
|
||||||
|
|
|
@ -17,10 +17,9 @@ const routes: RouteRecordRaw[] = [
|
||||||
path: '/codegen',
|
path: '/codegen',
|
||||||
name: 'CodegenEdit',
|
name: 'CodegenEdit',
|
||||||
meta: {
|
meta: {
|
||||||
|
title: '代码生成',
|
||||||
icon: 'ic:baseline-view-in-ar',
|
icon: 'ic:baseline-view-in-ar',
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
order: 1000,
|
|
||||||
title: '代码生成',
|
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -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;
|
|
@ -4,9 +4,6 @@ import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
|
||||||
import { getRangePickerDefaultProps } from '#/utils/date';
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
import { useAccess } from '@vben/access';
|
|
||||||
|
|
||||||
const { hasAccessByCodes } = useAccess();
|
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
@ -16,8 +13,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '是否已读',
|
label: '是否已读',
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
allowClear: true,
|
|
||||||
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
||||||
|
allowClear: true,
|
||||||
placeholder: '请选择是否已读',
|
placeholder: '请选择是否已读',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -38,6 +35,11 @@ export function useGridColumns<T = SystemNotifyMessageApi.SystemNotifyMessage>(
|
||||||
onActionClick: OnActionClickFn<T>,
|
onActionClick: OnActionClickFn<T>,
|
||||||
): VxeTableGridOptions['columns'] {
|
): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
|
{
|
||||||
|
title: '',
|
||||||
|
width: 40,
|
||||||
|
type: 'checkbox',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'templateNickname',
|
field: 'templateNickname',
|
||||||
title: '发送人',
|
title: '发送人',
|
||||||
|
@ -94,8 +96,13 @@ export function useGridColumns<T = SystemNotifyMessageApi.SystemNotifyMessage>(
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
code: 'detail',
|
code: 'detail',
|
||||||
text: '详情',
|
text: '查看',
|
||||||
show: hasAccessByCodes(['system:notify-message:query']),
|
show: (row: any) => row.readStatus,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'read',
|
||||||
|
text: '已读',
|
||||||
|
show: (row: any) => !row.readStatus,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -33,17 +33,27 @@ function onRefresh() {
|
||||||
|
|
||||||
/** 查看站内信详情 */
|
/** 查看站内信详情 */
|
||||||
function onDetail(row: SystemNotifyMessageApi.SystemNotifyMessage) {
|
function onDetail(row: SystemNotifyMessageApi.SystemNotifyMessage) {
|
||||||
// 标记已读
|
|
||||||
if (!row.readStatus) {
|
|
||||||
handleReadOne(row.id);
|
|
||||||
}
|
|
||||||
detailModalApi.setData(row).open();
|
detailModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 标记一条站内信已读 */
|
/** 标记一条站内信已读 */
|
||||||
async function handleReadOne(id: number) {
|
async function onRead(row: SystemNotifyMessageApi.SystemNotifyMessage) {
|
||||||
await updateNotifyMessageRead([id]);
|
message.loading({
|
||||||
|
content: '正在标记已读...',
|
||||||
|
duration: 0,
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
// 执行标记已读操作
|
||||||
|
await updateNotifyMessageRead([row.id]);
|
||||||
|
// 提示成功
|
||||||
|
message.success({
|
||||||
|
content: '标记已读成功',
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
onRefresh();
|
onRefresh();
|
||||||
|
|
||||||
|
// 打开详情
|
||||||
|
onDetail(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 标记选中的站内信为已读 */
|
/** 标记选中的站内信为已读 */
|
||||||
|
@ -58,42 +68,38 @@ async function onMarkRead() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ids = rows.map((row: SystemNotifyMessageApi.SystemNotifyMessage) => row.id);
|
const ids = rows.map((row: SystemNotifyMessageApi.SystemNotifyMessage) => row.id);
|
||||||
const hideLoading = message.loading({
|
message.loading({
|
||||||
content: '正在标记已读...',
|
content: '正在标记已读...',
|
||||||
duration: 0,
|
duration: 0,
|
||||||
key: 'action_process_msg',
|
key: 'action_process_msg',
|
||||||
});
|
});
|
||||||
|
// 执行标记已读操作
|
||||||
try {
|
|
||||||
await updateNotifyMessageRead(ids);
|
await updateNotifyMessageRead(ids);
|
||||||
|
// 提示成功
|
||||||
message.success({
|
message.success({
|
||||||
content: '标记已读成功',
|
content: '标记已读成功',
|
||||||
key: 'action_process_msg',
|
key: 'action_process_msg',
|
||||||
});
|
});
|
||||||
|
await gridApi.grid.setAllCheckboxRow(false);
|
||||||
onRefresh();
|
onRefresh();
|
||||||
} finally {
|
|
||||||
hideLoading();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 标记所有站内信为已读 */
|
/** 标记所有站内信为已读 */
|
||||||
async function onMarkAllRead() {
|
async function onMarkAllRead() {
|
||||||
const hideLoading = message.loading({
|
message.loading({
|
||||||
content: '正在标记全部已读...',
|
content: '正在标记全部已读...',
|
||||||
duration: 0,
|
duration: 0,
|
||||||
key: 'action_process_msg',
|
key: 'action_process_msg',
|
||||||
});
|
});
|
||||||
|
// 执行标记已读操作
|
||||||
try {
|
|
||||||
await updateAllNotifyMessageRead();
|
await updateAllNotifyMessageRead();
|
||||||
|
// 提示成功
|
||||||
message.success({
|
message.success({
|
||||||
content: '全部标记已读成功',
|
content: '全部标记已读成功',
|
||||||
key: 'action_process_msg',
|
key: 'action_process_msg',
|
||||||
});
|
});
|
||||||
|
await gridApi.grid.setAllCheckboxRow(false);
|
||||||
onRefresh();
|
onRefresh();
|
||||||
} finally {
|
|
||||||
hideLoading();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 表格操作按钮的回调函数 */
|
/** 表格操作按钮的回调函数 */
|
||||||
|
@ -106,12 +112,11 @@ function onActionClick({
|
||||||
onDetail(row);
|
onDetail(row);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'read': {
|
||||||
|
onRead(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 是否允许勾选的过滤函数(只允许未读的消息被选择)
|
|
||||||
function checkboxConfig(params: { row: SystemNotifyMessageApi.SystemNotifyMessage }) {
|
|
||||||
return !params.row.readStatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
@ -141,23 +146,24 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
search: true,
|
search: true,
|
||||||
},
|
},
|
||||||
checkboxConfig: {
|
checkboxConfig: {
|
||||||
checkMethod: checkboxConfig,
|
checkMethod: (params: { row: SystemNotifyMessageApi.SystemNotifyMessage }) => !params.row.readStatus,
|
||||||
|
highlight: true,
|
||||||
},
|
},
|
||||||
} as VxeTableGridOptions<SystemNotifyMessageApi.SystemNotifyMessage>,
|
} as VxeTableGridOptions<SystemNotifyMessageApi.SystemNotifyMessage>,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<DocAlert title="短信配置" url="https://doc.iocoder.cn/sms/" />
|
<DocAlert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
|
||||||
|
|
||||||
<DetailModal @success="onRefresh" />
|
<DetailModal @success="onRefresh" />
|
||||||
<Grid table-title="我的站内信">
|
<Grid table-title="我的站内信">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<Button type="primary" @click="onMarkRead" v-access:code="['system:notify-message:update-read']">
|
<Button type="primary" @click="onMarkRead">
|
||||||
<MdiCheckboxMarkedCircleOutline />
|
<MdiCheckboxMarkedCircleOutline />
|
||||||
标记已读
|
标记已读
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="primary" class="ml-2" @click="onMarkAllRead" v-access:code="['system:notify-message:update-all-read']">
|
<Button type="primary" class="ml-2" @click="onMarkAllRead">
|
||||||
<MdiCheckboxMarkedCircleOutline />
|
<MdiCheckboxMarkedCircleOutline />
|
||||||
全部已读
|
全部已读
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -32,31 +32,15 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal title="我的站内信">
|
<Modal title="消息详情" :show-cancel-button="false" :show-confirm-button="false">
|
||||||
<Descriptions bordered :column="1" size="middle" class="mx-4">
|
<Descriptions bordered :column="1" size="middle" class="mx-4">
|
||||||
<Descriptions.Item label="编号">{{ formData?.id }}</Descriptions.Item>
|
<Descriptions.Item label="发送人">
|
||||||
<Descriptions.Item label="用户类型">
|
|
||||||
<DictTag :type="DICT_TYPE.USER_TYPE" :value="formData?.userType" />
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="用户编号">
|
|
||||||
{{ formData?.userId }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="模版编号">
|
|
||||||
{{ formData?.templateId }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="模板编码">
|
|
||||||
{{ formData?.templateCode }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="发送人名称">
|
|
||||||
{{ formData?.templateNickname }}
|
{{ formData?.templateNickname }}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="模版内容">
|
<Descriptions.Item label="发送时间">
|
||||||
{{ formData?.templateContent }}
|
{{ formatDateTime(formData?.createTime) }}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="模版参数">
|
<Descriptions.Item label="消息类型">
|
||||||
{{ formData?.templateParams }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="模版类型">
|
|
||||||
<DictTag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="formData?.templateType" />
|
<DictTag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="formData?.templateType" />
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="是否已读">
|
<Descriptions.Item label="是否已读">
|
||||||
|
@ -65,8 +49,8 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
<Descriptions.Item label="阅读时间">
|
<Descriptions.Item label="阅读时间">
|
||||||
{{ formatDateTime(formData?.readTime || '') }}
|
{{ formatDateTime(formData?.readTime || '') }}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="创建时间">
|
<Descriptions.Item label="消息内容">
|
||||||
{{ formatDateTime(formData?.createTime || '') }}
|
{{ formData?.templateContent }}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
Loading…
Reference in New Issue