feat: 消息中心-站内信管理

This commit is contained in:
2025-09-18 17:47:35 +08:00
parent 73bc5aec6b
commit 8afdb0d09e
26 changed files with 1929 additions and 135 deletions

View File

@@ -0,0 +1,105 @@
import type {
ProColumns,
ProDescriptionsItemProps,
ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { NoticeVO } from '@/services/system/message/notice';
export const baseTenantColumns: ProColumns<NoticeVO>[] = [
{
title: '公告编号',
dataIndex: 'id',
width: 100,
hideInSearch: true,
},
{
title: '公告标题',
dataIndex: 'title',
},
{
title: '公告类型',
dataIndex: 'type',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '状态',
dataIndex: 'status',
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
hideInSearch: true,
render: (_, record: NoticeVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (type: string): ProFormColumnsType[] => [
{
title: '公告标题',
dataIndex: 'title',
tip: '公告标题', // 提示信息
formItemProps: {
rules: [
{
required: true,
message: '请输入用户名',
},
],
},
},
{
title: '公告内容',
dataIndex: 'content',
formItemProps: {
rules: [
{
required: true,
message: '请输入公告内容',
},
],
},
},
{
title: '公告类型',
dataIndex: 'type',
formItemProps: {
rules: [
{
required: true,
message: '请输入公告类型',
},
],
},
},
{
title: '状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
options: [
{
label: '正常',
value: 1,
},
{
label: '禁用',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请选择状态',
},
],
},
},
{
title: '备注',
dataIndex: 'username',
},
];

View File

@@ -0,0 +1,126 @@
import type {
ActionType,
ProColumns,
ProCoreActionType,
} from '@ant-design/pro-components';
import { Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import { formStatusType } from '@/constants';
import {
createNotice,
deleteNotice,
getNoticePage,
type NoticeVO,
pushNotice,
updateNotice,
} from '@/services/system/message/notice';
import { baseTenantColumns, formColumns } from './config';
const SyStemMessageNotice = () => {
const tableRef = useRef<ActionType>(null);
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
const onFetch = async (
params: NoticeVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getNoticePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleSend = async (record: NoticeVO) => {
await pushNotice(record.id);
tableRef.current?.reload();
};
const handleEdit = (record: NoticeVO) => {
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const handleSubmit = useCallback(
async (values: NoticeVO) => {
if (type === 'create') {
await createNotice(values);
} else {
await updateNotice({
...values,
id,
});
}
tableRef.current?.reload();
return true;
},
[type, id],
);
const actionColumns: ProColumns<NoticeVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (
text: React.ReactNode,
record: NoticeVO,
_: number,
action: ProCoreActionType | undefined,
) => [
<a key="edit" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteNotice(record.id);
action?.reload?.();
}}
okText="是"
cancelText="否"
>
<a style={{ color: 'var(--ant-red)' }} key="delete">
</a>
</Popconfirm>,
<a key="detail" onClick={() => handleSend(record)}>
</a>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<NoticeVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
</>
);
};
export default SyStemMessageNotice;

View File

@@ -0,0 +1,142 @@
import type {
ProColumns,
ProDescriptionsItemProps,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { NotifyMessageVO } from '@/services/system/message/notify/message';
export const baseTenantColumns: ProColumns<NotifyMessageVO>[] = [
{
title: '编号',
dataIndex: 'id',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '用户类型',
dataIndex: 'userType',
},
{
title: '用户编号',
dataIndex: 'userId',
},
{
title: '模板编码',
dataIndex: 'templateCode',
},
{
title: '发送人名称',
dataIndex: 'templateNickname',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '模版内容',
dataIndex: 'templateContent',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '模版参数',
dataIndex: 'templateParams',
hideInSearch: true,
},
{
title: '模版类型',
dataIndex: 'templateType',
valueType: 'select',
},
{
title: '是否已读',
dataIndex: 'readStatus',
hideInSearch: true,
},
{
title: '阅读时间',
dataIndex: 'readTime',
hideInSearch: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: NotifyMessageVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const descriptionsColumns = (): ProDescriptionsItemProps<
Record<string, any>,
'text'
>[] => [
{
title: '编号',
key: 'id',
dataIndex: 'id',
},
{
title: '用户类型',
key: 'userType',
dataIndex: 'userType',
},
{
title: '用户编号',
key: 'userId',
dataIndex: 'userId',
},
{
title: '模版编号',
key: 'templateId',
dataIndex: 'templateId',
},
{
title: '模板编码',
key: 'templateCode',
dataIndex: 'templateCode',
},
{
title: '发送人名称',
key: 'templateNickname',
dataIndex: 'templateNickname',
},
{
title: '模版内容',
key: 'templateContent',
dataIndex: 'templateContent',
},
{
title: '模版参数',
key: 'createTime',
dataIndex: 'createTime',
},
{
title: '模版类型',
key: 'templateType',
dataIndex: 'templateType',
},
{
title: '是否已读',
key: 'readStatus',
dataIndex: 'readStatus',
},
{
title: '阅读时间',
key: 'readTime',
dataIndex: 'readTime',
},
{
title: '创建时间',
key: 'createTime',
dataIndex: 'createTime',
},
];

View File

@@ -0,0 +1,70 @@
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import React, { useRef } from 'react';
import EnhancedProTable from '@/components/EnhancedProTable';
import ModalDescriptions, {
type DescriptionsFormRef,
} from '@/components/ModalDescriptions';
import {
getNotifyMessagePage,
type NotifyMessageVO,
} from '@/services/system/message/notify/message';
import { baseTenantColumns, descriptionsColumns } from './config';
const SyStemMessageNotifyMessage = () => {
const tableRef = useRef<ActionType>(null);
const descriptionsRef = useRef<DescriptionsFormRef>(null);
const onFetch = async (
params: NotifyMessageVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getNotifyMessagePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleDetail = (record: NotifyMessageVO) => {
descriptionsRef.current?.open(record);
};
const actionColumns: ProColumns<NotifyMessageVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 80,
render: (text: React.ReactNode, record: NotifyMessageVO) => [
<a key="editable" onClick={() => handleDetail(record)}>
</a>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<NotifyMessageVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
showSelection={false}
/>
<ModalDescriptions
ref={descriptionsRef}
title="登录日志详情"
columns={descriptionsColumns()}
/>
</>
);
};
export default SyStemMessageNotifyMessage;

View File

@@ -0,0 +1,193 @@
import type {
ProColumns,
ProDescriptionsItemProps,
ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { NotifyTemplateVO } from '@/services/system/message/notify/template';
export const baseTenantColumns: ProColumns<NotifyTemplateVO>[] = [
{
title: '模板编码',
dataIndex: 'code',
width: 100,
},
{
title: '模板名称',
dataIndex: 'name',
},
{
title: '类型',
dataIndex: 'type',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '发送人名称',
dataIndex: 'nickname',
hideInSearch: true,
},
{
title: '模板内容',
dataIndex: 'content',
hideInSearch: true,
},
{
title: '开启状态',
dataIndex: 'status',
},
{
title: '备注',
dataIndex: 'remark',
hideInSearch: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateRange',
hideInSearch: true,
render: (_, record: NotifyTemplateVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const formColumns = (type: string): ProFormColumnsType[] => [
{
title: '模版编码',
dataIndex: 'code',
tip: '模版编码', // 提示信息
formItemProps: {
rules: [
{
required: true,
message: '请输入模版编码',
},
],
},
},
{
title: '模板名称',
dataIndex: 'name',
formItemProps: {
rules: [
{
required: true,
message: '请输入模版名称',
},
],
},
},
{
title: '发件人名称',
dataIndex: 'nickname',
formItemProps: {
rules: [
{
required: true,
message: '请输入发件人名称',
},
],
},
},
{
title: '模板内容',
dataIndex: 'content',
formItemProps: {
rules: [
{
required: true,
message: '请输入模板内容',
},
],
},
},
{
title: '类型',
dataIndex: 'type',
formItemProps: {
rules: [
{
required: true,
message: '请选择类型',
},
],
},
},
{
title: '开启状态',
dataIndex: 'status',
valueType: 'select',
fieldProps: {
placeholder: '请选择开启状态',
options: [
{
label: '正常',
value: 1,
},
{
label: '禁用',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请选择状态',
},
],
},
},
{
title: '备注',
dataIndex: 'remark',
fieldProps: {
placeholder: '请输入备注',
},
},
];
export const formTestColumns = (type: string): ProFormColumnsType[] => [
{
title: '模板内容',
dataIndex: 'content',
},
{
title: '用户类型',
dataIndex: 'userType',
valueType: 'radio',
fieldProps: {
options: [
{
label: '用户',
value: 1,
},
{
label: '管理员',
value: 2,
},
],
},
formItemProps: {
rules: [
{
required: true,
message: '请输入模版名称',
},
],
},
},
{
title: '接收人ID',
dataIndex: 'userId',
formItemProps: {
rules: [
{
required: true,
message: '请输入接收人ID',
},
],
},
},
];

View File

@@ -0,0 +1,174 @@
import { PlusOutlined } from '@ant-design/icons';
import type {
ActionType,
ProColumns,
ProCoreActionType,
} from '@ant-design/pro-components';
import { message, Popconfirm } from 'antd';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
createNotifyTemplate,
deleteNotifyTemplate,
getNotifyTemplatePage,
type NotifyTemplateVO,
sendNotify,
updateNotifyTemplate,
} from '@/services/system/message/notify/template';
import { baseTenantColumns, formColumns, formTestColumns } from './config';
const SyStemMessageNotifyTemplate = () => {
const tableRef = useRef<ActionType>(null);
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const [type, setType] = useState<'create' | 'update' | 'test'>('create');
const testRef = useRef<ConfigurableDrawerFormRef>(null);
const [currentItem, setCurrentItem] = useState<NotifyTemplateVO>();
const onFetch = async (
params: NotifyTemplateVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getNotifyTemplatePage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleSend = async (record: NotifyTemplateVO) => {
setType('test');
setCurrentItem(record);
testRef.current?.open(record);
};
const handleEdit = (record: NotifyTemplateVO) => {
setType('update');
setCurrentItem(record);
configurableDrawerRef.current?.open(record);
};
const handleAdd = () => {
setType('create');
configurableDrawerRef.current?.open();
};
const handleSubmit = useCallback(
async (values: NotifyTemplateVO) => {
if (type === 'create') {
await createNotifyTemplate(values);
message.success('创建成功');
} else {
await updateNotifyTemplate({
...values,
id: currentItem!.id,
});
message.success('编辑成功');
}
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const handleTestSubmit = useCallback(
async (values: NotifyTemplateVO) => {
if (currentItem?.status === 1) {
return message.error('请先开启状态');
}
const res = await sendNotify({
...currentItem,
...values,
mobile: '',
templateParams: new Map(),
templateCode: currentItem!.code,
});
message.success('提交发送成功!发送结果,见发送日志编号:' + res);
tableRef.current?.reload();
return true;
},
[type, currentItem],
);
const toolbarActions: ToolbarAction[] = [
{
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<NotifyTemplateVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (
text: React.ReactNode,
record: NotifyTemplateVO,
_: number,
action: ProCoreActionType | undefined,
) => [
<a key="edit" onClick={() => handleEdit(record)}>
</a>,
<a key="detail" onClick={() => handleSend(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteNotifyTemplate(record.id);
message.success('删除成功');
action?.reload?.();
}}
okText="是"
cancelText="否"
>
<a style={{ color: 'var(--ant-red)' }} key="delete">
</a>
</Popconfirm>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<NotifyTemplateVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
toolbarActions={toolbarActions}
showSelection={false}
/>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns(type)}
onSubmit={handleSubmit}
/>
<ConfigurableDrawerForm
ref={testRef}
title={formStatusType[type]}
columns={formTestColumns(type)}
onSubmit={handleTestSubmit}
/>
</>
);
};
export default SyStemMessageNotifyTemplate;

View File

@@ -0,0 +1,105 @@
import type {
ProColumns,
ProDescriptionsItemProps,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { LoginLogVO } from '@/services/system/log/login';
export const baseTenantColumns: ProColumns<LoginLogVO>[] = [
{
title: '日志编号',
dataIndex: 'id',
tip: '日志编号',
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '操作类型',
dataIndex: 'logType',
hideInSearch: true, // 在搜索表单中隐藏
tip: '操作类型', // 提示信息
},
{
title: '操作模块',
dataIndex: 'type',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '用户名称',
dataIndex: 'username',
},
{
title: '登录地址',
dataIndex: 'userIp',
},
{
title: '浏览器',
dataIndex: 'userAgent',
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: '登录结果',
dataIndex: 'result',
hideInSearch: true,
},
{
title: '登录日期',
dataIndex: 'createTime',
valueType: 'dateRange',
search: {
transform: (value) => {
return {
[`createTime[0]`]: dayjs(value[0])
.startOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
[`createTime[1]`]: dayjs(value[1])
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss'),
};
},
},
render: (_, record: LoginLogVO) =>
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
];
export const descriptionsColumns = (): ProDescriptionsItemProps<
Record<string, any>,
'text'
>[] => [
{
title: '日志编号',
key: 'id',
dataIndex: 'id',
},
{
title: '操作类型',
key: 'logType',
dataIndex: 'logType',
},
{
title: '用户名称',
key: 'username',
dataIndex: 'username',
},
{
title: '登录地址',
key: 'userIp',
dataIndex: 'userIp',
},
{
title: '浏览器',
key: 'userAgent',
dataIndex: 'userAgent',
},
{
title: '登录结果',
key: 'result',
dataIndex: 'result',
},
{
title: '登录日期',
key: 'createTime',
dataIndex: 'createTime',
},
];

View File

@@ -0,0 +1,67 @@
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import React, { useRef } from 'react';
import EnhancedProTable from '@/components/EnhancedProTable';
import ModalDescriptions, {
type DescriptionsFormRef,
} from '@/components/ModalDescriptions';
import { getLoginLogPage, type LoginLogVO } from '@/services/system/log/login';
import { baseTenantColumns, descriptionsColumns } from './config';
const SyStemLogLogin = () => {
const tableRef = useRef<ActionType>(null);
const descriptionsRef = useRef<DescriptionsFormRef>(null);
const onFetch = async (
params: LoginLogVO & {
pageSize?: number;
current?: number;
},
) => {
const data = await getLoginLogPage({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
return {
data: data.list,
success: true,
total: data.total,
};
};
const handleDetail = (record: LoginLogVO) => {
descriptionsRef.current?.open(record);
};
const actionColumns: ProColumns<LoginLogVO> = {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 80,
render: (text: React.ReactNode, record: LoginLogVO) => [
<a key="editable" onClick={() => handleDetail(record)}>
</a>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<>
<EnhancedProTable<LoginLogVO>
ref={tableRef}
columns={columns}
request={onFetch}
headerTitle="登录日志"
showIndex={false}
showSelection={false}
/>
<ModalDescriptions
ref={descriptionsRef}
title="登录日志详情"
columns={descriptionsColumns()}
/>
</>
);
};
export default SyStemLogLogin;