feat(推流管理):推流、拉流地址管理功能
This commit is contained in:
@@ -120,6 +120,10 @@
|
||||
path: '/orders/editTask.html',
|
||||
component: './orders/EditTask',
|
||||
},
|
||||
{
|
||||
path: '/orders/wxMessage.html',
|
||||
component: './orders/WxMessage',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -105,7 +105,6 @@ const TableList: React.FC = () => {
|
||||
return handleApiRequest(
|
||||
() => saveOrUpdateQrcode({
|
||||
...fields,
|
||||
templateName: template?.label,
|
||||
}),
|
||||
'正在添加',
|
||||
'添加成功'
|
||||
@@ -118,8 +117,7 @@ const TableList: React.FC = () => {
|
||||
return handleApiRequest(
|
||||
() => saveOrUpdateQrcode({
|
||||
id: original.id,
|
||||
...fields,
|
||||
templateName: template?.label,
|
||||
...fields
|
||||
}),
|
||||
'正在更新',
|
||||
'修改成功'
|
||||
|
||||
@@ -75,20 +75,32 @@ const handleApiRequest = async (
|
||||
|
||||
// 处理函数优化
|
||||
const handleAdd = async (fields: ORDERS.TourismFile) => {
|
||||
// 删除 key 字段
|
||||
const { key, ...rest } = fields;
|
||||
return handleApiRequest(
|
||||
() => saveOrUpdateTourismFile({ ...fields }),
|
||||
() => saveOrUpdateTourismFile(rest),
|
||||
'正在添加',
|
||||
'添加成功'
|
||||
);
|
||||
};
|
||||
|
||||
const handleEdit = async (original: ORDERS.TourismFile, fields: Partial<ORDERS.TourismFile>) => {
|
||||
// 合并参数
|
||||
const params = {
|
||||
...original,
|
||||
...fields,
|
||||
id: original.id,
|
||||
};
|
||||
// 删除 key 字段
|
||||
const { key, ...rest } = params;
|
||||
|
||||
// 如果没有上传新图片,则不更新 imageUrl 字段
|
||||
if (!fields.imageUrl) {
|
||||
delete rest.imageUrl;
|
||||
}
|
||||
|
||||
return handleApiRequest(
|
||||
() => saveOrUpdateTourismFile({
|
||||
...original, // 保留原有数据
|
||||
...fields, // 使用新的数据覆盖
|
||||
id: original.id,
|
||||
}),
|
||||
() => saveOrUpdateTourismFile(rest),
|
||||
'正在更新',
|
||||
'修改成功'
|
||||
);
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
import React, { useRef, useState, useEffect } from 'react';
|
||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
PageContainer,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
ProFormDateTimeRangePicker,
|
||||
ProFormSelect,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Card, message, Tag, Typography, Tooltip } from 'antd';
|
||||
import { getWxMessageRecords, getWxMessageStatistics } from '@/services/orders/api';
|
||||
import { StatisticCard } from '@ant-design/pro-components';
|
||||
|
||||
const { Statistic } = StatisticCard;
|
||||
|
||||
// 状态选项定义
|
||||
const STATUS_OPTIONS = [
|
||||
{ label: '成功', value: 0 },
|
||||
{ label: '失败', value: 1 },
|
||||
] as const;
|
||||
|
||||
// 状态渲染函数
|
||||
const renderStatus = (status: number) => {
|
||||
const statusMap = {
|
||||
0: { color: 'success', text: '成功' },
|
||||
1: { color: 'error', text: '失败' },
|
||||
};
|
||||
const { color, text } = statusMap[status] || { color: 'default', text: '未知' };
|
||||
return <Tag color={color}>{text}</Tag>;
|
||||
};
|
||||
|
||||
const WxMessageList: React.FC = () => {
|
||||
const actionRef = useRef<ActionType>();
|
||||
const [params, setParams] = useState<Record<string, any>>({});
|
||||
const [statistics, setStatistics] = useState<Record<string, number>>({});
|
||||
|
||||
// 获取统计数据
|
||||
const fetchStatistics = async (startTime: string, endTime: string) => {
|
||||
if (!startTime || !endTime) {
|
||||
message.warning('请选择时间范围');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const result = await getWxMessageStatistics({
|
||||
startTime,
|
||||
endTime,
|
||||
});
|
||||
if (result.resp_code === 0) {
|
||||
setStatistics(result.data || {});
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('获取统计数据失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化加载统计数据
|
||||
useEffect(() => {
|
||||
fetchStatistics('', '');
|
||||
}, []);
|
||||
|
||||
const columns: ProColumns<ORDERS.WxMessageRecord>[] = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: 'OpenID',
|
||||
dataIndex: 'openId',
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '模板ID',
|
||||
dataIndex: 'templateId',
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '消息ID',
|
||||
dataIndex: 'msgId',
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '消息内容',
|
||||
dataIndex: 'content',
|
||||
width: 300,
|
||||
ellipsis: true,
|
||||
render: (content) => (
|
||||
<Tooltip title={content}>
|
||||
<Typography.Text ellipsis style={{ width: 280 }}>
|
||||
{content}
|
||||
</Typography.Text>
|
||||
</Tooltip>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
width: 100,
|
||||
render: (status) => renderStatus(status as number),
|
||||
valueEnum: {
|
||||
0: { text: '成功' },
|
||||
1: { text: '失败' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '错误信息',
|
||||
dataIndex: 'errorMsg',
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
render: (errorMsg) => errorMsg ? (
|
||||
<Tooltip title={errorMsg}>
|
||||
<Typography.Text type="danger" ellipsis style={{ width: 180 }}>
|
||||
{errorMsg}
|
||||
</Typography.Text>
|
||||
</Tooltip>
|
||||
) : '-',
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 180,
|
||||
valueType: 'dateTime',
|
||||
},
|
||||
{
|
||||
title: '更新时间',
|
||||
dataIndex: 'updateTime',
|
||||
width: 180,
|
||||
valueType: 'dateTime',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer header={{ title: '微信消息记录' }}>
|
||||
<Card style={{ marginBottom: 24 }}>
|
||||
<StatisticCard.Group direction="row">
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: '总消息数',
|
||||
value: statistics.total || 0,
|
||||
valueStyle: { color: '#1890ff' },
|
||||
}}
|
||||
/>
|
||||
<StatisticCard.Divider type="vertical" />
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: '成功消息',
|
||||
value: statistics.success || 0,
|
||||
valueStyle: { color: '#52c41a' },
|
||||
}}
|
||||
/>
|
||||
<StatisticCard.Divider type="vertical" />
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: '失败消息',
|
||||
value: statistics.failed || 0,
|
||||
valueStyle: { color: '#ff4d4f' },
|
||||
}}
|
||||
/>
|
||||
</StatisticCard.Group>
|
||||
</Card>
|
||||
|
||||
<QueryFilter
|
||||
defaultCollapsed={false}
|
||||
split
|
||||
span={6}
|
||||
className="query-filter"
|
||||
onFinish={async (values) => {
|
||||
setParams(values);
|
||||
if (values.timeRange && values.timeRange.length === 2) {
|
||||
await fetchStatistics(
|
||||
values.timeRange[0].format('YYYY-MM-DD HH:mm:ss'),
|
||||
values.timeRange[1].format('YYYY-MM-DD HH:mm:ss')
|
||||
);
|
||||
} else {
|
||||
message.warning('请先选择时间范围');
|
||||
}
|
||||
}}
|
||||
>
|
||||
<ProFormDateTimeRangePicker
|
||||
name="timeRange"
|
||||
label="时间范围"
|
||||
rules={[{ required: true, message: '请选择时间范围' }]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="status"
|
||||
label="状态"
|
||||
options={STATUS_OPTIONS}
|
||||
/>
|
||||
</QueryFilter>
|
||||
|
||||
<ProTable<ORDERS.WxMessageRecord>
|
||||
rowKey="id"
|
||||
actionRef={actionRef}
|
||||
columns={columns}
|
||||
request={async (params) => {
|
||||
const response = await getWxMessageRecords(params);
|
||||
return {
|
||||
data: response.data || [],
|
||||
success: response.resp_code === 0,
|
||||
total: response.count || 0,
|
||||
};
|
||||
}}
|
||||
search={false}
|
||||
params={params}
|
||||
scroll={{ x: 1500 }}
|
||||
pagination={{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
defaultPageSize: 10,
|
||||
}}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default WxMessageList;
|
||||
@@ -288,3 +288,36 @@ export async function deleteEditTask(id: number) {
|
||||
});
|
||||
}
|
||||
|
||||
// 获取微信消息记录列表
|
||||
export async function getWxMessageRecords(params: {
|
||||
current?: number;
|
||||
pageSize?: number;
|
||||
status?: number;
|
||||
timeRange?: [string, string];
|
||||
}) {
|
||||
return request('/api-order/wx/message/records', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
page: params.current,
|
||||
limit: params.pageSize,
|
||||
status: params.status,
|
||||
startTime: params.timeRange?.[0],
|
||||
endTime: params.timeRange?.[1],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 获取微信消息统计数据
|
||||
export async function getWxMessageStatistics(params: {
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}) {
|
||||
return request('/api-order/wx/message/statistics', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
startTime: params.startTime,
|
||||
endTime: params.endTime,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,18 @@ declare namespace ORDERS {
|
||||
tenantId: number;
|
||||
remark: string;
|
||||
}
|
||||
|
||||
interface WxMessageRecord {
|
||||
id: number;
|
||||
openId: string;
|
||||
templateId: string;
|
||||
msgId: string;
|
||||
content: string;
|
||||
status: number;
|
||||
errorMsg?: string;
|
||||
createTime: string;
|
||||
updateTime: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace API {
|
||||
|
||||
Reference in New Issue
Block a user