feat: 消息中心-站内信管理
This commit is contained in:
105
src/pages/system/log/login/config.tsx
Normal file
105
src/pages/system/log/login/config.tsx
Normal 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',
|
||||
},
|
||||
];
|
||||
@@ -1,5 +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 = () => {
|
||||
return <>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;
|
||||
|
||||
105
src/pages/system/messages/notice/config.tsx
Normal file
105
src/pages/system/messages/notice/config.tsx
Normal 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',
|
||||
},
|
||||
];
|
||||
126
src/pages/system/messages/notice/index.tsx
Normal file
126
src/pages/system/messages/notice/index.tsx
Normal 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;
|
||||
142
src/pages/system/messages/notify/message/config.tsx
Normal file
142
src/pages/system/messages/notify/message/config.tsx
Normal 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',
|
||||
},
|
||||
];
|
||||
70
src/pages/system/messages/notify/message/index.tsx
Normal file
70
src/pages/system/messages/notify/message/index.tsx
Normal 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;
|
||||
193
src/pages/system/messages/notify/template/config.tsx
Normal file
193
src/pages/system/messages/notify/template/config.tsx
Normal 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',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
174
src/pages/system/messages/notify/template/index.tsx
Normal file
174
src/pages/system/messages/notify/template/index.tsx
Normal 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;
|
||||
105
src/pages/system/messages/sms/channel/config.tsx
Normal file
105
src/pages/system/messages/sms/channel/config.tsx
Normal 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',
|
||||
},
|
||||
];
|
||||
67
src/pages/system/messages/sms/channel/index.tsx
Normal file
67
src/pages/system/messages/sms/channel/index.tsx
Normal 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;
|
||||
@@ -1,25 +1,24 @@
|
||||
import EnhancedProTable from "@/components/EnhancedProTable";
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||
import { Modal, Popconfirm } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import { ref } from 'process';
|
||||
import React, { createContext, 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 {
|
||||
getTenantPage,
|
||||
createTenant,
|
||||
deleteTenant,
|
||||
getTenantPage,
|
||||
type TenantPageReqVO,
|
||||
type TenantVO,
|
||||
deleteTenant,
|
||||
updateTenant,
|
||||
} from "@/services/system/tenant/list";
|
||||
import React, { createContext, useCallback } from "react";
|
||||
import ConfigurableDrawerForm, {
|
||||
ConfigurableDrawerFormRef,
|
||||
} from "@/components/DrawerForm";
|
||||
import { useRef, useState } from "react";
|
||||
import { formColumns, baseTenantColumns } from "./config";
|
||||
import { PlusOutlined } from "@ant-design/icons";
|
||||
import { ref } from "process";
|
||||
import { ActionType, ProColumns } from "@ant-design/pro-components";
|
||||
import { ToolbarAction } from "@/components/EnhancedProTable/types";
|
||||
import { Modal, Popconfirm } from "antd";
|
||||
import { formStatusType } from "@/constants";
|
||||
import dayjs from "dayjs";
|
||||
} from '@/services/system/tenant/list';
|
||||
import { baseTenantColumns, formColumns } from './config';
|
||||
export const waitTimePromise = async (time: number = 90) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
@@ -30,13 +29,13 @@ export const waitTimePromise = async (time: number = 90) => {
|
||||
const TenantList = () => {
|
||||
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
|
||||
const tableRef = useRef<ActionType>(null);
|
||||
const [type, setType] = useState<"create" | "update">("create");
|
||||
const [type, setType] = useState<'create' | 'update'>('create');
|
||||
const [id, setId] = useState<number>(0);
|
||||
const onFetch = async (
|
||||
params: TenantPageReqVO & {
|
||||
pageSize?: number;
|
||||
current?: number;
|
||||
}
|
||||
},
|
||||
) => {
|
||||
await waitTimePromise();
|
||||
const data = await getTenantPage({
|
||||
@@ -53,7 +52,7 @@ const TenantList = () => {
|
||||
|
||||
const handleSubmit = useCallback(
|
||||
async (values: TenantVO) => {
|
||||
if (type === "create") {
|
||||
if (type === 'create') {
|
||||
await createTenant(values);
|
||||
} else {
|
||||
await updateTenant({
|
||||
@@ -65,34 +64,34 @@ const TenantList = () => {
|
||||
tableRef.current?.reload();
|
||||
return true;
|
||||
},
|
||||
[type]
|
||||
[type, id],
|
||||
);
|
||||
|
||||
const handleAdd = () => {
|
||||
setType("create");
|
||||
setType('create');
|
||||
configurableDrawerRef.current?.open({});
|
||||
};
|
||||
const handleEdit = (record: TenantVO) => {
|
||||
setType("update");
|
||||
setType('update');
|
||||
setId(record.id);
|
||||
|
||||
configurableDrawerRef.current?.open(record);
|
||||
};
|
||||
const toolbarActions: ToolbarAction[] = [
|
||||
{
|
||||
key: "add",
|
||||
label: "新建",
|
||||
type: "primary",
|
||||
key: 'add',
|
||||
label: '新建',
|
||||
type: 'primary',
|
||||
icon: <PlusOutlined />,
|
||||
onClick: handleAdd,
|
||||
},
|
||||
];
|
||||
|
||||
const actionColumns: ProColumns<TenantVO> = {
|
||||
title: "操作",
|
||||
dataIndex: "option",
|
||||
valueType: "option",
|
||||
fixed: "right",
|
||||
title: '操作',
|
||||
dataIndex: 'option',
|
||||
valueType: 'option',
|
||||
fixed: 'right',
|
||||
width: 120,
|
||||
render: (text: React.ReactNode, record: TenantVO, _: any, action: any) => [
|
||||
<a key="editable" onClick={() => handleEdit(record)}>
|
||||
|
||||
Reference in New Issue
Block a user