feat: 站内信我的消息
parent
b0b986c152
commit
663d3d0e9d
|
@ -0,0 +1,98 @@
|
||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
|
||||||
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'readStatus',
|
||||||
|
label: '是否已读',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
||||||
|
placeholder: '请选择是否已读',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'createTime',
|
||||||
|
label: '发送时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns<T = SystemNotifyMessageApi.NotifyMessage>(
|
||||||
|
onActionClick: OnActionClickFn<T>,
|
||||||
|
): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
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 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'templateContent',
|
||||||
|
title: '消息内容',
|
||||||
|
minWidth: 300,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'readStatus',
|
||||||
|
title: '是否已读',
|
||||||
|
minWidth: 100,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'readTime',
|
||||||
|
title: '阅读时间',
|
||||||
|
minWidth: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'operation',
|
||||||
|
title: '操作',
|
||||||
|
minWidth: 180,
|
||||||
|
align: 'center',
|
||||||
|
fixed: 'right',
|
||||||
|
cellRender: {
|
||||||
|
attrs: {
|
||||||
|
nameField: 'id',
|
||||||
|
nameTitle: '站内信',
|
||||||
|
onClick: onActionClick,
|
||||||
|
},
|
||||||
|
name: 'CellOperation',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
code: 'view',
|
||||||
|
text: '查看',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,163 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type {
|
||||||
|
OnActionClickParams,
|
||||||
|
VxeTableGridOptions,
|
||||||
|
} from '#/adapter/vxe-table';
|
||||||
|
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
|
||||||
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { MdiCheckboxMarkedCircleOutline } from '@vben/icons';
|
||||||
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
import Detail from './modules/detail.vue';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
getMyNotifyMessagePage,
|
||||||
|
updateAllNotifyMessageRead,
|
||||||
|
updateNotifyMessageRead,
|
||||||
|
} from '#/api/system/notify/message';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
|
||||||
|
const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Detail,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function onRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看站内信详情 */
|
||||||
|
function onView(row: SystemNotifyMessageApi.NotifyMessage) {
|
||||||
|
// 标记已读
|
||||||
|
if (!row.readStatus) {
|
||||||
|
handleReadOne(row.id);
|
||||||
|
}
|
||||||
|
detailModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 标记一条站内信已读 */
|
||||||
|
async function handleReadOne(id: number) {
|
||||||
|
await updateNotifyMessageRead([id]);
|
||||||
|
onRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 标记选中的站内信为已读 */
|
||||||
|
async function onMarkRead() {
|
||||||
|
const rows = gridApi.grid.getCheckboxRecords();
|
||||||
|
if (!rows || rows.length === 0) {
|
||||||
|
message.warning({
|
||||||
|
content: '请选择需要标记的站内信',
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ids = rows.map((row: SystemNotifyMessageApi.NotifyMessage) => row.id);
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: '正在标记已读...',
|
||||||
|
duration: 0,
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateNotifyMessageRead(ids);
|
||||||
|
message.success({
|
||||||
|
content: '标记已读成功',
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
onRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 标记所有站内信为已读 */
|
||||||
|
async function onMarkAllRead() {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: '正在标记全部已读...',
|
||||||
|
duration: 0,
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateAllNotifyMessageRead();
|
||||||
|
message.success({
|
||||||
|
content: '全部标记已读成功',
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
onRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表格操作按钮的回调函数 */
|
||||||
|
function onActionClick({
|
||||||
|
code,
|
||||||
|
row,
|
||||||
|
}: OnActionClickParams<SystemNotifyMessageApi.NotifyMessage>) {
|
||||||
|
switch (code) {
|
||||||
|
case 'view': {
|
||||||
|
onView(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否允许勾选的过滤函数(只允许未读的消息被选择)
|
||||||
|
function checkboxConfig(params: { row: SystemNotifyMessageApi.NotifyMessage }) {
|
||||||
|
return !params.row.readStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(onActionClick),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getMyNotifyMessagePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
checkboxConfig: {
|
||||||
|
checkMethod: checkboxConfig,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<SystemNotifyMessageApi.NotifyMessage>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<DetailModal @success="onRefresh" />
|
||||||
|
<Grid table-title="我的站内信">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<Button type="primary" @click="onMarkRead">
|
||||||
|
<MdiCheckboxMarkedCircleOutline />
|
||||||
|
标记已读
|
||||||
|
</Button>
|
||||||
|
<Button type="primary" class="ml-2" @click="onMarkAllRead">
|
||||||
|
<MdiCheckboxMarkedCircleOutline />
|
||||||
|
全部已读
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
|
@ -0,0 +1,91 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { Descriptions, Tag } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { formatDateTime } from '@vben/utils';
|
||||||
|
import { DICT_TYPE, getDictLabel } from '#/utils/dict';
|
||||||
|
|
||||||
|
const messageData = ref<SystemNotifyMessageApi.NotifyMessage>();
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<SystemNotifyMessageApi.NotifyMessage>();
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
messageData.value = data;
|
||||||
|
} finally {
|
||||||
|
modalApi.lock(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal title="我的站内信">
|
||||||
|
<Descriptions bordered :column="1" size="middle" class="mx-4">
|
||||||
|
<Descriptions.Item label="编号">{{ messageData?.id }}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="用户类型">
|
||||||
|
<!-- TODO @芋艿: 数据字典-->
|
||||||
|
<Tag color="processing">
|
||||||
|
{{ getDictLabel(DICT_TYPE.USER_TYPE, messageData?.userType) }}
|
||||||
|
</Tag>
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="用户编号">
|
||||||
|
{{ messageData?.userId }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="模版编号">
|
||||||
|
{{ messageData?.templateId }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="模板编码">
|
||||||
|
{{ messageData?.templateCode }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="发送人名称">
|
||||||
|
{{ messageData?.templateNickname }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="模版内容">
|
||||||
|
{{ messageData?.templateContent }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="模版参数">
|
||||||
|
{{ messageData?.templateParams }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="模版类型">
|
||||||
|
<!-- TODO @芋艿: 数据字典-->
|
||||||
|
<Tag color="processing">
|
||||||
|
{{
|
||||||
|
getDictLabel(
|
||||||
|
DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
|
||||||
|
messageData?.templateType,
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</Tag>
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="是否已读">
|
||||||
|
<!-- TODO @芋艿: 数据字典-->
|
||||||
|
<Tag color="processing">
|
||||||
|
{{
|
||||||
|
getDictLabel(
|
||||||
|
DICT_TYPE.INFRA_BOOLEAN_STRING,
|
||||||
|
messageData?.readStatus,
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</Tag>
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="阅读时间">
|
||||||
|
{{ formatDateTime(messageData?.readTime || '') }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="创建时间">
|
||||||
|
{{ formatDateTime(messageData?.createTime || '') }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
|
@ -11,3 +11,7 @@ export const MdiGithub = createIconifyIcon('mdi:github');
|
||||||
export const MdiGoogle = createIconifyIcon('mdi:google');
|
export const MdiGoogle = createIconifyIcon('mdi:google');
|
||||||
|
|
||||||
export const MdiQqchat = createIconifyIcon('mdi:qqchat');
|
export const MdiQqchat = createIconifyIcon('mdi:qqchat');
|
||||||
|
|
||||||
|
export const MdiCheckboxMarkedCircleOutline = createIconifyIcon(
|
||||||
|
'mdi:checkbox-marked-circle-outline',
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue