feat(react-web-next): 新增.editorconfig和.prettierrc配置文件,添加public/.gitkeep占位文件

This commit is contained in:
2025-09-23 10:32:35 +08:00
parent 10ddfd6f75
commit 408b500b6a
199 changed files with 16850 additions and 34874 deletions
@@ -0,0 +1,204 @@
import React, { useRef, useState } from 'react';
import { PageContainer, ProForm, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
import type { ActionType } from '@ant-design/pro-components';
import { DatePicker, Form, Input, InputNumber, Modal, Select, Space, Tag, message } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/components/ui';
import { ordersApi } from '@/services/orders';
import moment from 'moment';
const { RangePicker } = DatePicker;
const COUPON_TYPES = [
{ label: '满减券', value: 1 },
{ label: '折扣券', value: 2 },
{ label: '代金券', value: 3 },
];
const STATUS_OPTIONS = [
{ label: '未使用', value: 0 },
{ label: '已使用', value: 1 },
{ label: '已过期', value: 2 },
{ label: '已作废', value: 3 },
];
const SOURCE_OPTIONS = [
{ label: '携程', value: 1 },
{ label: '后台发放', value: 2 },
];
const CouponPage: React.FC = () => {
const actionRef = useRef<ActionType>();
const [searchParams, setSearchParams] = useState<Record<string, any>>({});
const [open, setOpen] = useState(false);
const [editing, setEditing] = useState<any | null>(null);
const [form] = Form.useForm();
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '优惠券编号', dataIndex: 'couponNo', width: 160 },
{ title: '优惠券名称', dataIndex: 'couponName', width: 200 },
{ title: '类型', dataIndex: 'couponType', width: 100, render: (v: number) => COUPON_TYPES.find(i => i.value === v)?.label || '-' },
{ title: '金额/折扣', key: 'amount', width: 120, render: (_: any, r: any) => r.couponType === 2 ? `${r.discountRate}%` : `¥${r.amount}` },
{ title: '使用门槛', dataIndex: 'minAmount', width: 100, render: (v: number) => v ? `¥${v}` : '-' },
{ title: '状态', dataIndex: 'status', width: 100, render: (v: number) => { const color = v === 0 ? 'green' : v === 1 ? 'blue' : v === 2 ? 'orange' : 'red'; return <Tag color={color}>{STATUS_OPTIONS.find(i => i.value === v)?.label || '-'}</Tag>; } },
{ title: '用户手机号', dataIndex: 'userPhone', width: 140 },
{ title: '来源', dataIndex: 'source', width: 100, render: (v: number) => SOURCE_OPTIONS.find(i => i.value === v)?.label || '-' },
{ title: '有效期', key: 'validTime', width: 220, render: (_: any, r: any) => (<div><div>{r.validStartTime ? moment(r.validStartTime).format('YYYY-MM-DD HH:mm') : '-'}</div><div>~</div><div>{r.validEndTime ? moment(r.validEndTime).format('YYYY-MM-DD HH:mm') : '-'}</div></div>) },
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
{ title: '操作', key: 'action', width: 160, fixed: 'right', render: (_: any, record: any) => (
<Space size="small">
<a onClick={() => handleView(record)}>查看</a>
<a onClick={() => handleEdit(record)}>编辑</a>
<a style={{ color: '#1677ff' }} onClick={() => handleDelete(record)}>删除</a>
</Space>
) },
];
const handleView = (record: any) => {
setEditing(record);
form.setFieldsValue({
...record,
validTime: record.validStartTime && record.validEndTime ? [moment(record.validStartTime), moment(record.validEndTime)] : undefined,
});
setOpen(true);
};
const handleEdit = (record: any) => {
setEditing(record);
form.setFieldsValue({
...record,
validTime: record.validStartTime && record.validEndTime ? [moment(record.validStartTime), moment(record.validEndTime)] : undefined,
});
setOpen(true);
};
const handleDelete = async (record: any) => {
Modal.confirm({
title: '确认删除该优惠券?',
onOk: async () => {
const hide = message.loading('正在删除...');
try {
await ordersApi.deleteCoupon(record.id);
message.success('删除成功');
actionRef.current?.reload();
} catch (e) {
message.error('删除失败');
} finally { hide(); }
},
});
};
const handleAdd = () => {
setEditing(null);
form.resetFields();
setOpen(true);
};
return (
<PageContainer header={{ title: '优惠券管理' }}>
<SearchBarPlus
defaultCollapsed={false}
split
span={8}
onTenantChanged={() => actionRef.current?.reload()}
onFinish={async (values) => setSearchParams(values)}
>
<ProFormText name="couponNo" label="优惠券编号" />
<ProFormText name="couponName" label="优惠券名称" />
<ProFormText name="userPhone" label="手机号" />
<ProFormSelect name="couponType" label="类型" options={COUPON_TYPES} />
<ProFormSelect name="status" label="状态" options={STATUS_OPTIONS} />
<ProFormSelect name="source" label="来源" options={SOURCE_OPTIONS} />
</SearchBarPlus>
<ActionBar left={<GradientButton size="middle" type="primary" icon={<PlusOutlined />} onClick={handleAdd}>新增</GradientButton>} />
<GlassCard>
<ProTable<any>
rowKey="id"
actionRef={actionRef}
request={(p) => ordersApi.getCouponList({ ...p, ...searchParams })}
columns={columns}
scroll={{ x: 1200 }}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
toolBarRender={false}
/>
</GlassCard>
<Modal
title={editing ? '编辑优惠券' : '新增优惠券'}
open={open}
onCancel={() => setOpen(false)}
onOk={async () => {
try {
const values = await form.validateFields();
const payload: any = { ...values };
if (values.validTime && values.validTime.length === 2) {
payload.validStartTime = values.validTime[0].format('YYYY-MM-DD HH:mm:ss');
payload.validEndTime = values.validTime[1].format('YYYY-MM-DD HH:mm:ss');
}
delete payload.validTime;
const hide = message.loading('保存中...');
if (editing && editing.id) {
await ordersApi.updateCoupon(editing.id, payload);
} else {
await ordersApi.createCoupon(payload);
}
hide();
message.success('保存成功');
setOpen(false);
actionRef.current?.reload();
} catch (e) {
if ((e as any)?.errorFields) return; // 表单校验
message.error('保存失败');
}
}}
destroyOnClose
maskClosable={false}
>
<Form form={form} layout="vertical" preserve={false}>
<Form.Item name="couponName" label="优惠券名称" rules={[{ required: true, message: '请输入优惠券名称' }]}>
<Input placeholder="请输入优惠券名称" />
</Form.Item>
<Form.Item name="couponType" label="优惠券类型" rules={[{ required: true, message: '请选择优惠券类型' }]}>
<Select options={COUPON_TYPES} style={{ width: '100%' }} placeholder="请选择优惠券类型" />
</Form.Item>
<Form.Item noStyle shouldUpdate={(prev, cur) => prev.couponType !== cur.couponType}>
{({ getFieldValue }) => getFieldValue('couponType') === 2 ? (
<Form.Item name="discountRate" label="折扣率(%)" rules={[{ required: true, message: '请输入折扣率' }]}>
<InputNumber min={1} max={99} style={{ width: '100%' }} placeholder="请输入折扣率" />
</Form.Item>
) : (
<Form.Item name="amount" label="优惠券面额" rules={[{ required: true, message: '请输入优惠券面额' }]}>
<InputNumber min={0} style={{ width: '100%' }} placeholder="请输入优惠券面额" />
</Form.Item>
)}
</Form.Item>
<Form.Item name="minAmount" label="使用门槛">
<InputNumber min={0} style={{ width: '100%' }} placeholder="请输入使用门槛" />
</Form.Item>
<Form.Item name="userPhone" label="用户手机号" rules={[{ required: true, message: '请输入用户手机号' }]}>
<Input placeholder="请输入用户手机号" />
</Form.Item>
<Form.Item name="source" label="来源" rules={[{ required: true, message: '请选择来源' }]}>
<Select options={SOURCE_OPTIONS} style={{ width: '100%' }} placeholder="请选择来源" />
</Form.Item>
<Form.Item name="ctripCouponId" label="携程优惠券ID">
<Input placeholder="当来源为携程时需填写" />
</Form.Item>
<Form.Item name="validTime" label="有效期" rules={[{ required: true, message: '请选择有效期' }]}>
<RangePicker showTime format="YYYY-MM-DD HH:mm:ss" style={{ width: '100%' }} />
</Form.Item>
<Form.Item name="remark" label="备注">
<Input.TextArea rows={3} placeholder="请输入备注" />
</Form.Item>
</Form>
</Modal>
</PageContainer>
);
};
export default CouponPage;
@@ -0,0 +1,65 @@
import React, { useState } from 'react';
import { PageContainer, ProFormText, ProTable, ProFormSelect } from '@ant-design/pro-components';
import { Popconfirm, Space, message } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { ordersApi } from '@/services/orders';
import { ActionBar, GradientButton, SearchBarPlus } from '@/components/ui';
const EditTaskPage: React.FC = () => {
const [params, setParams] = useState<Record<string, any>>({});
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '任务ID', dataIndex: 'id' },
{ title: '订单号', dataIndex: 'orderNo' },
{ title: '状态', dataIndex: 'status' },
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime' },
{
title: '操作', key: 'action',
render: (_: any, record: any) => (
<Space>
<Popconfirm title="确认删除?" onConfirm={async () => { try { await ordersApi.deleteEditTask(record.id); message.success('删除成功'); } catch { message.error('删除失败'); } }}>
<a style={{ color: '#1677ff' }}>删除</a>
</Popconfirm>
</Space>
)
},
];
return (
<PageContainer header={{ title: '剪辑任务' }}>
<SearchBarPlus
defaultCollapsed={false}
split
span={8}
onTenantChanged={() => { /* 后端上下文 */ }}
onFinish={async (values) => setParams(values)}
>
<ProFormText name="orderNo" label="订单号" />
<ProFormSelect name="status" label="状态" valueEnum={{ pending: '待处理', processing: '处理中', done: '完成' }} />
</SearchBarPlus>
<ActionBar
left={
<Space>
<GradientButton size="middle" type="primary" icon={<PlusOutlined />} onClick={async () => {
const hide = message.loading('提交中...');
try { await ordersApi.saveOrUpdateEditTask({ orderNo: 'DEMO' }); message.success('新增成功'); } catch { message.error('新增失败'); } finally { hide(); }
}}>新增</GradientButton>
</Space>
}
/>
<ProTable<any>
rowKey="id"
request={(p) => ordersApi.getEditTaskList({ ...p, ...params } as any)}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
/>
</PageContainer>
);
};
export default EditTaskPage;
@@ -0,0 +1,38 @@
import React from 'react';
import { ModalForm, ProFormDigit, ProFormSelect, ProFormText } from '@ant-design/pro-components';
export interface HomeCarouselItem {
id?: number;
imageUrl?: string;
linkUrl?: string;
sort?: number;
status?: number;
}
export interface HomeCarouselFormProps {
open: boolean;
title: string;
initialValues?: Partial<HomeCarouselItem>;
onOpenChange: (v: boolean) => void;
onFinish: (values: HomeCarouselItem) => Promise<boolean>;
}
const HomeCarouselForm: React.FC<HomeCarouselFormProps> = ({ open, title, initialValues, onOpenChange, onFinish }) => {
return (
<ModalForm<HomeCarouselItem>
title={title}
visible={open}
onVisibleChange={onOpenChange}
onFinish={onFinish}
initialValues={initialValues}
modalProps={{ destroyOnClose: true }}
>
<ProFormText name="imageUrl" label="图片地址" rules={[{ required: true, message: '请输入图片地址' }]} />
<ProFormText name="linkUrl" label="跳转链接" />
<ProFormDigit name="sort" label="排序" min={1} fieldProps={{ precision: 0 }} initialValue={1} />
<ProFormSelect name="status" label="状态" valueEnum={{ 1: '启用', 0: '禁用' }} initialValue={1} />
</ModalForm>
);
};
export default HomeCarouselForm;
@@ -0,0 +1,96 @@
import React, { useState } from 'react';
import { PageContainer, ProTable } from '@ant-design/pro-components';
import { Popconfirm, Space, Tag, message } from 'antd';
import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/components/ui';
import { PlusOutlined } from '@ant-design/icons';
import { ordersApi } from '@/services/orders';
import HomeCarouselForm, { HomeCarouselItem } from './components/HomeCarouselForm';
const HomeCarouselPage: React.FC = () => {
const [createOpen, setCreateOpen] = useState(false);
const [editOpen, setEditOpen] = useState(false);
const [current, setCurrent] = useState<HomeCarouselItem | undefined>(undefined);
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '图片', dataIndex: 'imageUrl', render: (v: string) => <img src={v} alt="img" style={{ width: 80, height: 40, objectFit: 'cover' }} /> },
{ title: '跳转链接', dataIndex: 'linkUrl', ellipsis: true },
{ title: '排序', dataIndex: 'sort' },
{ title: '状态', dataIndex: 'status', render: (v: number) => <Tag color={v === 1 ? 'green' : 'default'}>{v === 1 ? '启用' : '禁用'}</Tag> },
{
title: '操作', key: 'action',
render: (_: any, record: HomeCarouselItem) => (
<Space>
<a onClick={() => { setCurrent(record); setEditOpen(true); }}>编辑</a>
<Popconfirm title={`确认删除?`} onConfirm={async () => {
const hide = message.loading('删除中...');
try {
await ordersApi.deleteHomeCarousel(record.id!);
message.success('删除成功');
} catch (e) {
message.error('删除失败');
} finally { hide(); }
}}>
<a style={{ color: '#1677ff' }}>删除</a>
</Popconfirm>
</Space>
)
},
];
return (
<PageContainer header={{ title: '首页轮播' }}>
<SearchBarPlus defaultCollapsed split span={8} onTenantChanged={() => { /* 切换后后端生效 */ }} />
<ActionBar left={<GradientButton size="middle" type="primary" icon={<PlusOutlined />} onClick={() => setCreateOpen(true)}>新增</GradientButton>} />
<GlassCard>
<ProTable<HomeCarouselItem>
rowKey="id"
request={(p) => ordersApi.homeCarouselList(p as any)}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
/>
</GlassCard>
<HomeCarouselForm
title="新增轮播"
open={createOpen}
onOpenChange={setCreateOpen}
onFinish={async (values) => {
const hide = message.loading('保存中...');
try {
await ordersApi.saveOrUpdateHomeCarousel(values);
message.success('新增成功');
return true;
} catch (e) {
message.error('保存失败');
return false;
} finally { hide(); }
}}
/>
<HomeCarouselForm
title="编辑轮播"
open={editOpen}
initialValues={current}
onOpenChange={setEditOpen}
onFinish={async (values) => {
const hide = message.loading('保存中...');
try {
await ordersApi.saveOrUpdateHomeCarousel({ ...(current as any), ...values });
message.success('修改成功');
return true;
} catch (e) {
message.error('修改失败');
return false;
} finally { hide(); }
}}
/>
</PageContainer>
);
};
export default HomeCarouselPage;
@@ -0,0 +1,63 @@
import React, { useRef, useState } from 'react';
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
import type { ActionType } from '@ant-design/pro-components';
import { Tag } from 'antd';
import { ordersApi, OrderItem } from '@/services/orders';
import { GlassCard, SearchBarPlus } from '@/components/ui';
const STATUS_OPTIONS = [
{ label: '未支付', value: 0 },
{ label: '已支付', value: 1 },
{ label: '已退款', value: 2 },
{ label: '已取消', value: 3 },
];
const PAY_TYPE_OPTIONS = [
{ label: '微信支付', value: 1 },
{ label: '优惠券支付', value: 2 },
];
const OrderPage: React.FC = () => {
const [params, setParams] = useState<Record<string, any>>({});
const actionRef = useRef<ActionType>();
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '订单编号', dataIndex: 'orderNo' },
{ title: '金额', dataIndex: 'amount' },
{ title: '支付方式', dataIndex: 'payType', render: (v: number) => <Tag color={v === 1 ? 'green' : 'blue'}>{PAY_TYPE_OPTIONS.find(o => o.value === v)?.label || '未知'}</Tag> },
{ title: '状态', dataIndex: 'orderStatus', render: (v: number) => <Tag>{STATUS_OPTIONS.find(o => o.value === v)?.label || '未知'}</Tag> },
{ title: '旅游项目', dataIndex: 'tourismName' },
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime' },
];
return (
<PageContainer header={{ title: '订单管理' }}>
<SearchBarPlus
defaultCollapsed={false}
split
span={6}
onTenantChanged={() => actionRef.current?.reload()}
onFinish={async (values) => setParams(values)}
>
<ProFormText name="orderNo" label="订单编号" placeholder="请输入订单编号" />
<ProFormSelect name="orderStatus" label="订单状态" options={STATUS_OPTIONS} allowClear />
<ProFormSelect name="payType" label="支付方式" options={PAY_TYPE_OPTIONS} allowClear />
</SearchBarPlus>
<GlassCard>
<ProTable<OrderItem>
rowKey="id"
headerTitle="订单列表"
actionRef={actionRef}
request={(p) => ordersApi.order({ ...p, ...params } as any)}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true, defaultPageSize: 20 }}
/>
</GlassCard>
</PageContainer>
);
};
export default OrderPage;
@@ -0,0 +1,115 @@
import React, { useRef, useState } from 'react';
import { PageContainer, ProFormDateRangePicker, ProFormText, ProTable } from '@ant-design/pro-components';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { Image, Popconfirm, Space, Tag, message, Typography } from 'antd';
import { SearchBarPlus, GlassCard } from '@/components/ui';
import { ordersApi } from '@/services/orders';
import { downloadByUrl } from '@/utils/download';
const { Link } = Typography;
const TYPE_COLORS: Record<string, string> = {
'image/jpeg': 'blue',
'image/png': 'blue',
'image/gif': 'blue',
'video/mp4': 'green',
'video/mpeg': 'green',
'application/pdf': 'orange',
'application/msword': 'orange',
default: 'default',
};
const isImageType = (t?: string | null) => !!t && t.startsWith('image/');
const typeLabel = (t?: string | null) => {
if (!t) return 'UNKNOWN';
const parts = String(t).split('/');
return parts.length > 1 ? parts[1].toUpperCase() : String(t).toUpperCase();
};
const OrderFilePage: React.FC = () => {
const actionRef = useRef<ActionType>();
const [params, setParams] = useState<Record<string, any>>({});
const columns: ProColumns<any>[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '订单编号', dataIndex: 'orderNo', copyable: true, ellipsis: true },
{
title: '文件预览', dataIndex: 'viewUrl', search: false, width: 220,
render: (_, record) => (
<Space direction="vertical">
{isImageType(record.fileType) ? (
<Image src={record.viewUrl} width={120} height={80} style={{ objectFit: 'cover' }} />
) : (
<Tag color={TYPE_COLORS[record.fileType as string] || TYPE_COLORS.default}>
{typeLabel(record.fileType)}
</Tag>
)}
<Space>
<a href={record.viewUrl} onClick={(e) => { e.preventDefault(); downloadByUrl(record.viewUrl); }}>下载</a>
<Link href={record.viewUrl} target="_blank" rel="noopener noreferrer">预览</Link>
</Space>
</Space>
)
},
{ title: '文件类型', dataIndex: 'fileType', width: 120, render: (t) => (<Tag color={TYPE_COLORS[t as string] || TYPE_COLORS.default}>{typeLabel(t as string)}</Tag>) },
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
{
title: '操作', valueType: 'option', width: 100,
render: (_, record) => (
<Popconfirm
title={`确认删除文件[${record.id}]?`}
onConfirm={async () => {
const hide = message.loading('正在删除...');
try {
await ordersApi.deleteOrderFile(record.id);
message.success('删除成功');
actionRef.current?.reload();
} catch (e) {
message.error('删除失败');
} finally { hide(); }
}}
>
<a>删除</a>
</Popconfirm>
)
},
];
return (
<PageContainer header={{ title: '订单文件' }}>
<SearchBarPlus
defaultCollapsed={false}
split
span={8}
onTenantChanged={() => actionRef.current?.reload?.()}
onFinish={async (values) => {
const p: Record<string, any> = { ...values };
if (values.createTime?.length === 2) {
p.startTime = values.createTime?.[0]?.format?.('YYYY-MM-DD 00:00:00') || values.createTime?.[0];
p.endTime = values.createTime?.[1]?.format?.('YYYY-MM-DD 23:59:59') || values.createTime?.[1];
delete p.createTime;
}
setParams(p);
}}
>
<ProFormText name="orderNo" label="订单编号" placeholder="请输入订单编号" />
<ProFormDateRangePicker name="createTime" label="创建时间" />
</SearchBarPlus>
<GlassCard>
<ProTable<any>
rowKey="id"
headerTitle="文件列表"
actionRef={actionRef}
request={(p) => ordersApi.orderFiles({ ...p, ...params })}
columns={columns}
search={false}
pagination={{ defaultPageSize: 10, showSizeChanger: true, showQuickJumper: true }}
/>
</GlassCard>
</PageContainer>
);
};
export default OrderFilePage;
@@ -0,0 +1,37 @@
import React, { useEffect, useState } from 'react';
import { PageContainer } from '@ant-design/pro-components';
import { Card, Col, Row, Statistic, message, Button } from 'antd';
import TenantScopeFilter from '@/components/TenantScopeFilter';
import { ordersApi } from '@/services/orders';
import { ActionBar } from '@/components/ui';
const ProfitSharingStatisticsPage: React.FC = () => {
const [loading, setLoading] = useState(false);
const [stat, setStat] = useState<any>({});
const load = async () => {
setLoading(true);
try {
const res = await ordersApi.getProfitSharingStatistics();
setStat(res?.data || res);
} catch (e) {
message.error('加载统计失败');
} finally { setLoading(false); }
};
useEffect(() => { load(); }, []);
return (
<PageContainer header={{ title: '分账统计' }} extra={<TenantScopeFilter onChanged={() => load()} /> }>
<ActionBar right={<Button size="middle" onClick={() => load()}>刷新</Button>} />
<Row gutter={16}>
<Col span={6}><Card loading={loading}><Statistic title="总分账额" value={stat?.totalSharingAmount || 0} precision={2} /></Card></Col>
<Col span={6}><Card loading={loading}><Statistic title="分账笔数" value={stat?.sharingCount || 0} /></Card></Col>
<Col span={6}><Card loading={loading}><Statistic title="成功笔数" value={stat?.successCount || 0} /></Card></Col>
<Col span={6}><Card loading={loading}><Statistic title="失败笔数" value={stat?.failedCount || 0} /></Card></Col>
</Row>
</PageContainer>
);
};
export default ProfitSharingStatisticsPage;
@@ -0,0 +1,65 @@
import { GlassCard, GradientButton, ActionBar, SearchBarPlus } from '@/components/ui';
import React, { useState } from 'react';
import { PageContainer, ProFormText } from '@ant-design/pro-components';
import { Descriptions, message, Space } from 'antd';
import { ordersApi } from '@/services/orders';
const ProfitSharingPage: React.FC = () => {
const [orderNo, setOrderNo] = useState<string>('');
const [detail, setDetail] = useState<any>();
const load = async (no: string) => {
try {
const res = await ordersApi.getProfitSharingDetail(no);
setDetail(res?.data || res);
} catch (e) {
message.error('加载分账明细失败');
}
};
const exec = async (no: string) => {
try {
await ordersApi.executeProfitSharing(no);
message.success('已发起分账');
load(no);
} catch (e) {
message.error('分账执行失败');
}
};
return (
<PageContainer header={{ title: '分账管理' }}>
<SearchBarPlus
defaultCollapsed={false}
split
span={8}
onTenantChanged={() => orderNo && load(orderNo)}
onFinish={async (v) => { setOrderNo(v.orderNo); load(v.orderNo); }}
>
<ProFormText name="orderNo" label="订单号" placeholder="请输入订单号" />
</SearchBarPlus>
<ActionBar
left={
<Space>
<GradientButton size="middle" type="primary" disabled={!orderNo} onClick={() => exec(orderNo)}>执行分账</GradientButton>
</Space>
}
/>
<GlassCard title="分账明细">
{detail ? (
<Descriptions column={2}>
<Descriptions.Item label="订单号">{detail.orderNo}</Descriptions.Item>
<Descriptions.Item label="总金额">{detail.totalAmount}</Descriptions.Item>
<Descriptions.Item label="状态">{detail.status}</Descriptions.Item>
<Descriptions.Item label="分账笔数">{detail.items?.length || 0}</Descriptions.Item>
</Descriptions>
) : '请输入订单号后查询'}
</GlassCard>
</PageContainer>
);
};
export default ProfitSharingPage;
@@ -0,0 +1,38 @@
import React from 'react';
import { ModalForm, ProFormSelect, ProFormText } from '@ant-design/pro-components';
export interface QrcodeItem {
id?: number;
name?: string;
type?: number;
url?: string;
status?: number;
}
export interface QrcodeFormProps {
open: boolean;
title: string;
initialValues?: Partial<QrcodeItem>;
onOpenChange: (v: boolean) => void;
onFinish: (values: QrcodeItem) => Promise<boolean>;
}
const QrcodeForm: React.FC<QrcodeFormProps> = ({ open, title, initialValues, onOpenChange, onFinish }) => {
return (
<ModalForm<QrcodeItem>
title={title}
visible={open}
onVisibleChange={onOpenChange}
onFinish={onFinish}
initialValues={initialValues}
modalProps={{ destroyOnClose: true }}
>
<ProFormText name="name" label="名称" rules={[{ required: true, message: '请输入名称' }]} />
<ProFormText name="url" label="地址" />
<ProFormSelect name="type" label="类型" valueEnum={{ 1: '类型一', 2: '类型二' }} />
<ProFormSelect name="status" label="状态" valueEnum={{ 1: '启用', 0: '禁用' }} initialValue={1} />
</ModalForm>
);
};
export default QrcodeForm;
@@ -0,0 +1,94 @@
import React, { useState } from 'react';
import { PageContainer, ProTable } from '@ant-design/pro-components';
import { Popconfirm, Space, Tag, message } from 'antd';
import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/components/ui';
import { PlusOutlined } from '@ant-design/icons';
import { ordersApi } from '@/services/orders';
import QrcodeForm, { QrcodeItem } from './components/QrcodeForm';
const QrcodePage: React.FC = () => {
const [createOpen, setCreateOpen] = useState(false);
const [editOpen, setEditOpen] = useState(false);
const [current, setCurrent] = useState<QrcodeItem | undefined>(undefined);
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '名称', dataIndex: 'name' },
{ title: '链接', dataIndex: 'url', ellipsis: true },
{ title: '类型', dataIndex: 'type' },
{ title: '状态', dataIndex: 'status', render: (v: number) => <Tag color={v === 1 ? 'green' : 'default'}>{v === 1 ? '启用' : '禁用'}</Tag> },
{
title: '操作', key: 'action',
render: (_: any, record: QrcodeItem) => (
<Space>
<a onClick={() => { setCurrent(record); setEditOpen(true); }}>编辑</a>
<Popconfirm title={`确认删除二维码[${record.name}]?`} onConfirm={async () => {
const hide = message.loading('删除中...');
try {
await ordersApi.deleteQrcode(record.id!);
message.success('删除成功');
} catch (e) {
message.error('删除失败');
} finally { hide(); }
}}>
<a style={{ color: '#1677ff' }}>删除</a>
</Popconfirm>
</Space>
)
},
];
return (
<PageContainer header={{ title: '二维码管理' }}>
<SearchBarPlus defaultCollapsed split span={8} onTenantChanged={() => { /* 租户切换 */ }} />
<ActionBar left={<GradientButton size="middle" type="primary" icon={<PlusOutlined />} onClick={() => setCreateOpen(true)}>新增</GradientButton>} />
<GlassCard>
<ProTable<QrcodeItem>
rowKey="id"
request={(p) => ordersApi.qrcodeList(p as any)}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
/>
</GlassCard>
<QrcodeForm
title="新增二维码"
open={createOpen}
onOpenChange={setCreateOpen}
onFinish={async (values) => {
const hide = message.loading('保存中...');
try {
await ordersApi.saveOrUpdateQrcode(values);
message.success('新增成功');
return true;
} catch (e) {
message.error('保存失败');
return false;
} finally { hide(); }
}}
/>
<QrcodeForm
title="编辑二维码"
open={editOpen}
initialValues={current}
onOpenChange={setEditOpen}
onFinish={async (values) => {
const hide = message.loading('保存中...');
try {
await ordersApi.saveOrUpdateQrcode({ ...(current as any), ...values });
message.success('修改成功');
return true;
} catch (e) {
message.error('修改失败');
return false;
} finally { hide(); }
}}
/>
</PageContainer>
);
};
export default QrcodePage;
@@ -0,0 +1,88 @@
import React, { useRef, useState } from 'react';
import type { ActionType } from '@ant-design/pro-components';
import { PageContainer, ProForm, ProFormText, ProTable } from '@ant-design/pro-components';
import { Popconfirm, Space, message } from 'antd';
import { ActionBar, GradientButton, SearchBarPlus } from '@/components/ui';
import { ordersApi } from '@/services/orders';
const RefundPage: React.FC = () => {
const [params, setParams] = useState<Record<string, any>>({});
const [creating, setCreating] = useState(false);
const actionRef = useRef<ActionType>();
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '订单号', dataIndex: 'orderNo' },
{ title: '退款单号', dataIndex: 'refundNo' },
{ title: '金额', dataIndex: 'amount' },
{ title: '状态', dataIndex: 'status' },
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime' },
{
title: '操作', key: 'action',
render: (_: any, record: any) => (
<Space>
<Popconfirm
title="确认审核通过?"
onConfirm={async () => {
const hide = message.loading('正在处理...');
try {
await ordersApi.updateRefund({ id: record.id, status: 1 });
message.success('审核通过');
actionRef.current?.reload();
} catch (e) {
message.error('操作失败');
} finally {
hide();
}
}}
>
<a>审核通过</a>
</Popconfirm>
</Space>
),
},
];
return (
<PageContainer header={{ title: '退款管理' }}>
<SearchBarPlus
defaultCollapsed={false}
split
span={8}
onTenantChanged={() => actionRef.current?.reload()}
onFinish={async (values) => setParams(values)}
>
<ProFormText name="orderNo" label="订单号" placeholder="请输入订单号" />
</SearchBarPlus>
<div style={{ display: 'flex', gap: 12, alignItems: 'center', margin: '8px 0 12px' }}>
<ProForm layout="inline" onFinish={async (values) => {
if (!values.orderNo) return message.warning('请输入订单号');
setCreating(true);
try {
await ordersApi.createRefund({ orderNo: values.orderNo });
message.success('已提交自动退款');
actionRef.current?.reload();
} catch (e) {
message.error('提交失败');
} finally { setCreating(false); }
}} submitter={{ render: (props) => <GradientButton type="primary" loading={creating} onClick={() => props.submit?.()}>创建退款</GradientButton> }}>
<ProFormText name="orderNo" label="订单号" placeholder="请输入订单号" />
</ProForm>
</div>
<ProTable<any>
rowKey="id"
headerTitle="退款列表"
actionRef={actionRef}
request={(p) => ordersApi.refund({ ...p, ...params } as any)}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
/>
</PageContainer>
);
};
export default RefundPage;
@@ -0,0 +1,56 @@
import React, { useEffect, useState } from 'react';
import { PageContainer } from '@ant-design/pro-components';
import { Card, Col, Row, Statistic, DatePicker, Space, message, Form } from 'antd';
import { SearchBarPlus } from '@/components/ui';
import { ordersApi } from '@/services/orders';
const { RangePicker } = DatePicker;
const StatisticsPage: React.FC = () => {
const [loading, setLoading] = useState(false);
const [stat, setStat] = useState<any>({});
const [range, setRange] = useState<any>();
const load = async (p?: any) => {
setLoading(true);
try {
const res = await ordersApi.dashboard(p);
setStat(res?.data || res);
} catch (e) {
message.error('加载统计失败');
} finally { setLoading(false); }
};
useEffect(() => { load(); }, []);
return (
<PageContainer header={{ title: '订单统计' }}>
<SearchBarPlus
defaultCollapsed
split
span={8}
onTenantChanged={() => load(range)}
onFinish={async (values) => {
const v = values?.timeRange;
const r = v && v.length === 2 ? { startTime: v[0]?.toISOString(), endTime: v[1]?.toISOString() } : undefined;
setRange(r);
await load(r);
}}
>
<Form.Item name="timeRange" label="时间范围">
<RangePicker showTime />
</Form.Item>
</SearchBarPlus>
<Row gutter={16}>
<Col span={6}><Card loading={loading}><Statistic title="订单总数" value={stat?.totalOrders || 0} /></Card></Col>
<Col span={6}><Card loading={loading}><Statistic title="支付总额" value={stat?.totalAmount || 0} precision={2} /></Card></Col>
<Col span={6}><Card loading={loading}><Statistic title="退款总额" value={stat?.refundAmount || 0} precision={2} /></Card></Col>
<Col span={6}><Card loading={loading}><Statistic title="转化率" value={stat?.conversionRate || 0} suffix="%" /></Card></Col>
</Row>
</PageContainer>
);
};
export default StatisticsPage;
@@ -0,0 +1,42 @@
import React from 'react';
import { ModalForm, ProForm, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
export interface TourismItem {
id?: number;
tourismName?: string;
address?: string;
contactPerson?: string;
contactPhone?: string;
status?: number;
description?: string;
}
export interface TourismFormProps {
open: boolean;
title: string;
initialValues?: Partial<TourismItem>;
onOpenChange: (v: boolean) => void;
onFinish: (values: TourismItem) => Promise<boolean>;
}
const TourismForm: React.FC<TourismFormProps> = ({ open, title, initialValues, onOpenChange, onFinish }) => {
return (
<ModalForm<TourismItem>
title={title}
visible={open}
onVisibleChange={onOpenChange}
onFinish={onFinish}
initialValues={initialValues}
modalProps={{ destroyOnClose: true }}
>
<ProFormText name="tourismName" label="景区名称" rules={[{ required: true, message: '请输入景区名称' }]} />
<ProFormText name="address" label="地址" />
<ProFormText name="contactPerson" label="联系人" />
<ProFormText name="contactPhone" label="联系电话" />
<ProFormSelect name="status" label="状态" valueEnum={{ 1: '启用', 0: '禁用' }} initialValue={1} />
<ProFormTextArea name="description" label="描述" />
</ModalForm>
);
};
export default TourismForm;
@@ -0,0 +1,95 @@
import React, { useState } from 'react';
import { PageContainer, ProTable } from '@ant-design/pro-components';
import { Popconfirm, Space, Tag, message } from 'antd';
import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/components/ui';
import { PlusOutlined } from '@ant-design/icons';
import { ordersApi } from '@/services/orders';
import TourismForm, { TourismItem } from './components/TourismForm';
const TourismPage: React.FC = () => {
const [createOpen, setCreateOpen] = useState(false);
const [editOpen, setEditOpen] = useState(false);
const [current, setCurrent] = useState<TourismItem | undefined>(undefined);
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '旅游项目', dataIndex: 'tourismName' },
{ title: '地址', dataIndex: 'address' },
{ title: '联系人', dataIndex: 'contactPerson' },
{ title: '联系电话', dataIndex: 'contactPhone' },
{ title: '状态', dataIndex: 'status', render: (v: number) => <Tag color={v === 1 ? 'green' : 'default'}>{v === 1 ? '启用' : '禁用'}</Tag> },
{
title: '操作', key: 'action',
render: (_: any, record: TourismItem) => (
<Space>
<a onClick={() => { setCurrent(record); setEditOpen(true); }}>编辑</a>
<Popconfirm title={`确认删除项目[${record.tourismName}]?`} onConfirm={async () => {
const hide = message.loading('删除中...');
try {
await ordersApi.deleteTourism(record.id!);
message.success('删除成功');
} catch (e) {
message.error('删除失败');
} finally { hide(); }
}}>
<a style={{ color: '#1677ff' }}>删除</a>
</Popconfirm>
</Space>
)
},
];
return (
<PageContainer header={{ title: '旅游项目' }}>
<SearchBarPlus defaultCollapsed split span={8} onTenantChanged={() => { /* 租户切换 */ }} />
<ActionBar left={<GradientButton size="middle" type="primary" icon={<PlusOutlined />} onClick={() => setCreateOpen(true)}>新增</GradientButton>} />
<GlassCard>
<ProTable<TourismItem>
rowKey="id"
request={(p) => ordersApi.tourism(p as any)}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
/>
</GlassCard>
<TourismForm
title="新增项目"
open={createOpen}
onOpenChange={setCreateOpen}
onFinish={async (values) => {
const hide = message.loading('保存中...');
try {
await ordersApi.saveOrUpdateTourism(values);
message.success('新增成功');
return true;
} catch (e) {
message.error('保存失败');
return false;
} finally { hide(); }
}}
/>
<TourismForm
title="编辑项目"
open={editOpen}
initialValues={current}
onOpenChange={setEditOpen}
onFinish={async (values) => {
const hide = message.loading('保存中...');
try {
await ordersApi.saveOrUpdateTourism({ ...(current as any), ...values });
message.success('修改成功');
return true;
} catch (e) {
message.error('修改失败');
return false;
} finally { hide(); }
}}
/>
</PageContainer>
);
};
export default TourismPage;
@@ -0,0 +1,289 @@
import React, { useEffect, useRef, useState } from 'react';
import type { ActionType } from '@ant-design/pro-components';
import { ActionBar, GlassCard, SearchBarPlus } from '@/components/ui';
import {
ModalForm,
PageContainer,
ProForm,
ProFormSelect,
ProFormText,
ProTable,
} from '@ant-design/pro-components';
import { Button, Image, Popconfirm, Space, Tag, Upload, message, Form } from 'antd';
import { PlusOutlined, UploadOutlined } from '@ant-design/icons';
import { ordersApi } from '@/services/orders';
const TYPE_OPTIONS = [
{ label: '视频', value: 5, color: '#f5222d' },
{ label: '首页 Banner', value: 6, color: '#2f54eb' },
{ label: '展示封面', value: 4, color: '#52c41a' },
{ label: '入口引导', value: 3, color: '#722ed1' },
{ label: '服务小结展示', value: 2, color: '#13c2c2' },
{ label: '活动', value: 1, color: '#1890ff' },
] as const;
const STATUS_OPTIONS = [
{ label: '启用', value: 0 },
{ label: '禁用', value: 1 },
] as const;
const TourismFilePage: React.FC = () => {
const actionRef = useRef<ActionType>();
const [query, setQuery] = useState<Record<string, any>>({});
const [tourismOptions, setTourismOptions] = useState<Array<{ label: string; value: number }>>([]);
const [createOpen, setCreateOpen] = useState(false);
const [editOpen, setEditOpen] = useState(false);
const [current, setCurrent] = useState<any>();
const [uploadPreviewUrl, setUploadPreviewUrl] = useState<string | undefined>();
const [uploadPath, setUploadPath] = useState<string | undefined>();
const [editUploadPreviewUrl, setEditUploadPreviewUrl] = useState<string | undefined>();
const [editUploadPath, setEditUploadPath] = useState<string | undefined>();
useEffect(() => {
(async () => {
try {
const res = await ordersApi.tourism({ page: 1, limit: 1000 });
const list: Array<{ id: number; tourismName: string }> = (res as any).data || res?.data || [];
setTourismOptions(list.map((it) => ({ label: (it as any).tourismName, value: (it as any).id })));
} catch (e) {
// 忽略错误以不影响页面
}
})();
}, []);
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{
title: '旅游项目',
dataIndex: 'tourismId',
render: (_: any, record: any) => tourismOptions.find((o) => o.value === record.tourismId)?.label || record.tourismName || '-',
},
{
title: '图片/预览',
dataIndex: 'imageUrl',
search: false,
width: 140,
render: (_: any, record: any) =>
record.type === 5 ? (
<video src={record.imageUrl} controls style={{ width: 120, height: 80, objectFit: 'cover' }} />
) : (
<Image src={record.imageUrl} width={120} height={80} style={{ objectFit: 'cover' }} />
),
},
{ title: '页面链接', dataIndex: 'linkUrl', ellipsis: true, copyable: true },
{ title: '描述', dataIndex: 'description', ellipsis: true },
{
title: '状态',
dataIndex: 'status',
width: 90,
render: (v: number) => <Tag color={v === 0 ? 'green' : 'default'}>{v === 0 ? '启用' : '禁用'}</Tag>,
},
{
title: '类型',
dataIndex: 'type',
width: 120,
render: (v: number) => {
const t = TYPE_OPTIONS.find((i) => i.value === Number(v));
return t ? <Tag color={t.color}>{t.label}</Tag> : '-';
},
},
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
{
title: '操作',
key: 'action',
width: 160,
render: (_: any, record: any) => (
<Space>
<a
onClick={() => {
setCurrent(record);
setEditOpen(true);
setEditUploadPreviewUrl(undefined);
setEditUploadPath(undefined);
}}
>
编辑
</a>
<Popconfirm
title={`确认删除资源[${record.id}]?`}
onConfirm={async () => {
const hide = message.loading('正在删除...');
try {
await ordersApi.deleteTourismFile(record.id);
message.success('删除成功');
actionRef.current?.reload();
} catch (e) {
message.error('删除失败');
} finally {
hide();
}
}}
>
<a style={{ color: '#1677ff' }}>删除</a>
</Popconfirm>
</Space>
),
},
];
const doUpload = async (file: File) => {
const formData = new FormData();
formData.append('file', file);
const resp = await fetch('/api-file/files-anon', { method: 'POST', body: formData });
const data = await resp.json();
if (!data || (!data.url && !data.path)) throw new Error('上传失败');
return data as { url: string; path: string };
};
return (
<PageContainer header={{ title: '旅游资源管理' }}>
<SearchBarPlus defaultCollapsed split span={8} onTenantChanged={() => actionRef.current?.reload()} onFinish={async (values) => setQuery(values)}>
<ProFormText name="description" label="资源描述" placeholder="请输入关键字" />
<ProFormSelect name="tourismId" label="项目" placeholder="请选择" options={tourismOptions} showSearch />
<ProFormSelect name="type" label="资源类型" placeholder="请选择" options={TYPE_OPTIONS as any} />
</SearchBarPlus>
<ActionBar left={<Button size="middle" type="primary" icon={<PlusOutlined />} onClick={() => setCreateOpen(true)}>新增</Button>} />
<GlassCard>
<ProTable<any>
rowKey="id"
headerTitle="资源列表"
actionRef={actionRef}
request={(p) => ordersApi.tourismFile({ ...p, ...query })}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true, defaultPageSize: 10 }}
/>
</GlassCard>
{/* 新建 */}
<ModalForm
title="新增资源"
open={createOpen}
onOpenChange={(v: boolean) => {
if (!v) {
setUploadPreviewUrl(undefined);
setUploadPath(undefined);
}
setCreateOpen(v);
}}
onFinish={async (values) => {
if (!uploadPath) {
message.warning('请先上传资源');
return false;
}
const hide = message.loading('保存中...');
try {
await ordersApi.saveOrUpdateTourismFile({ ...values, imageUrl: uploadPath, status: values.status ?? 0 });
message.success('新增成功');
actionRef.current?.reload();
return true;
} catch (e) {
message.error('保存失败');
return false;
} finally {
hide();
}
}}
>
<ProForm.Group>
<ProFormSelect rules={[{ required: true, message: '请选择项目' }]} width="md" name="tourismId" label="项目" options={tourismOptions} showSearch />
<ProFormSelect rules={[{ required: true, message: '请选择资源类型' }]} width="md" name="type" label="资源类型" options={TYPE_OPTIONS as any} />
<ProFormSelect width="md" name="status" label="状态" options={STATUS_OPTIONS as any} initialValue={0} />
<ProFormText width="md" name="linkUrl" label="页面链接" placeholder="可为空" />
<ProFormText rules={[{ required: true, message: '请输入资源描述' }]} width="md" name="description" label="资源描述" placeholder="请输入资源描述" />
</ProForm.Group>
<Upload
maxCount={1}
showUploadList={false}
customRequest={async ({ file, onSuccess, onError }) => {
try {
if (file instanceof File) {
const r = await doUpload(file as File);
setUploadPreviewUrl(r.url);
setUploadPath(r.path);
onSuccess?.('ok');
}
} catch (err) {
onError?.(err as any);
}
}}
accept="image/*,video/*"
>
<Button icon={<UploadOutlined />}>上传图片/视频</Button>
</Upload>
{uploadPreviewUrl && (
<div style={{ marginTop: 12 }}>
{(ProForm as any) && <Image src={uploadPreviewUrl} width={200} />}
</div>
)}
</ModalForm>
{/* 编辑 */}
<ModalForm
title="编辑资源"
open={editOpen}
initialValues={current}
onOpenChange={(v: boolean) => {
if (!v) {
setEditUploadPreviewUrl(undefined);
setEditUploadPath(undefined);
}
setEditOpen(v);
}}
onFinish={async (values) => {
const payload = { ...(current || {}), ...values } as any;
if (editUploadPath) payload.imageUrl = editUploadPath;
const hide = message.loading('保存中...');
try {
await ordersApi.saveOrUpdateTourismFile(payload);
message.success('修改成功');
actionRef.current?.reload();
return true;
} catch (e) {
message.error('修改失败');
return false;
} finally {
hide();
}
}}
>
<ProForm.Group>
<ProFormSelect rules={[{ required: true, message: '请选择项目' }]} width="md" name="tourismId" label="项目" options={tourismOptions} showSearch />
<ProFormSelect rules={[{ required: true, message: '请选择资源类型' }]} width="md" name="type" label="资源类型" options={TYPE_OPTIONS as any} />
<ProFormSelect width="md" name="status" label="状态" options={STATUS_OPTIONS as any} />
<ProFormText width="md" name="linkUrl" label="页面链接" placeholder="可为空" />
<ProFormText rules={[{ required: true, message: '请输入资源描述' }]} width="md" name="description" label="资源描述" placeholder="请输入资源描述" />
</ProForm.Group>
<Upload
maxCount={1}
showUploadList={false}
customRequest={async ({ file, onSuccess, onError }) => {
try {
if (file instanceof File) {
const r = await doUpload(file as File);
setEditUploadPreviewUrl(r.url);
setEditUploadPath(r.path);
onSuccess?.('ok');
}
} catch (err) {
onError?.(err as any);
}
}}
accept="image/*,video/*"
>
<Button icon={<UploadOutlined />}>上传图片/视频</Button>
</Upload>
{(editUploadPreviewUrl || current?.imageUrl) && (
<div style={{ marginTop: 12 }}>
<Image src={editUploadPreviewUrl || current?.imageUrl} width={200} />
</div>
)}
</ModalForm>
</PageContainer>
);
};
export default TourismFilePage;
@@ -0,0 +1,52 @@
import React, { useState } from 'react';
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
import { Space, Switch, message } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { ordersApi } from '@/services/orders';
import { ActionBar, GradientButton, SearchBarPlus } from '@/components/ui';
const VideoTemplatePage: React.FC = () => {
const [params, setParams] = useState<Record<string, any>>({});
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '模板名称', dataIndex: 'name' },
{ title: '描述', dataIndex: 'description' },
{ title: '状态', dataIndex: 'status', render: (v: number, r: any) => <Switch checked={v === 1} onChange={(c) => ordersApi.updateVideoTemplateStatus(r.id, c ? 1 : 0)} /> },
{
title: '操作', key: 'action',
render: (_: any, record: any) => (
<Space>
<a onClick={async () => { message.info('演示环境暂不提供修改参数'); }}>编辑</a>
<a style={{ color: '#1677ff' }} onClick={async () => { try { await ordersApi.deleteVideoTemplate(record.id); message.success('删除成功'); } catch { message.error('删除失败'); } }}>删除</a>
</Space>
)
},
];
return (
<PageContainer header={{ title: '视频模板' }}>
<SearchBarPlus defaultCollapsed split span={8} onTenantChanged={() => { /* 租户切换 */ }} onFinish={async (values) => setParams(values)}>
<ProFormText name="name" label="模板名称" />
<ProFormSelect name="status" label="状态" valueEnum={{ 1: '启用', 0: '禁用' }} allowClear />
</SearchBarPlus>
<ActionBar left={<GradientButton size="middle" type="primary" onClick={async () => {
const hide = message.loading('保存中...');
try { await ordersApi.saveVideoTemplate({ name: '新模板', status: 1 }); message.success('新增成功'); }
catch { message.error('新增失败'); } finally { hide(); }
}}><PlusOutlined /> 新增</GradientButton>} />
<ProTable<any>
rowKey="id"
request={(p) => ordersApi.getVideoTemplateList({ ...p, ...params } as any)}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
/>
</PageContainer>
);
};
export default VideoTemplatePage;
@@ -0,0 +1,54 @@
import React, { useRef, useState } from 'react';
import type { ActionType } from '@ant-design/pro-components';
import { PageContainer, ProFormDateTimeRangePicker, ProTable } from '@ant-design/pro-components';
import { Card, Statistic, Row, Col, message } from 'antd';
import { ordersApi } from '@/services/orders';
import { ActionBar, SearchBarPlus } from '@/components/ui';
const WxMessagePage: React.FC = () => {
const [range, setRange] = useState<{ startTime?: string; endTime?: string }>({});
const [stat, setStat] = useState<any>({});
const actionRef = useRef<ActionType>();
const load = async (p?: any) => {
try { const res = await ordersApi.getWxMessageStatistics(p || range); setStat(res?.data || res); } catch { message.error('加载统计失败'); }
};
return (
<PageContainer header={{ title: '微信消息' }}>
<SearchBarPlus
defaultCollapsed={false}
split
span={8}
onTenantChanged={() => { load(); actionRef.current?.reload(); }}
onFinish={async (v) => { const [a,b] = v.timeRange || []; const p = { startTime: a?.toISOString(), endTime: b?.toISOString() }; setRange(p); await load(p); }}
>
<ProFormDateTimeRangePicker name="timeRange" label="时间范围" />
</SearchBarPlus>
<Row gutter={16} style={{ marginTop: 12 }}>
<Col span={6}><Card><Statistic title="消息总数" value={stat?.total || 0} /></Card></Col>
<Col span={6}><Card><Statistic title="成功数" value={stat?.success || 0} /></Card></Col>
<Col span={6}><Card><Statistic title="失败数" value={stat?.failed || 0} /></Card></Col>
</Row>
<ProTable<any>
actionRef={actionRef}
rowKey="id"
request={(p) => ordersApi.getWxMessageRecords({ ...p, ...range } as any)}
columns={[
{ dataIndex: 'index', valueType: 'indexBorder' },
{ title: '消息ID', dataIndex: 'id' },
{ title: '用户', dataIndex: 'user' },
{ title: '类型', dataIndex: 'type' },
{ title: '状态', dataIndex: 'status' },
{ title: '时间', dataIndex: 'createTime', valueType: 'dateTime' },
]}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
/>
</PageContainer>
);
};
export default WxMessagePage;