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,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;