import {} from '@/servers/api/subscription'; import { DeleteFilled, EditOutlined, PlusOutlined } from '@ant-design/icons'; import { ActionType, PageContainer, ProColumns, ProTable, } from '@ant-design/pro-components'; import { useParams } from '@umijs/max'; import { App, Button, Drawer, List, Popconfirm, Space, Tag } from 'antd'; import dayjs from 'dayjs'; import React, { useRef, useState } from 'react'; import { request } from 'umi'; /** * 订阅状态枚举(用于筛选与展示) * 保持与后端同步的原始状态值 */ const SUBSCRIPTION_STATUS_ENUM: Record = { active: { text: '激活' }, cancelled: { text: '已取消' }, expired: { text: '已过期' }, pending: { text: '待处理' }, 'on-hold': { text: '暂停' }, }; /** * 订阅列表页:展示,筛选,触发订阅同步 */ const SubscriptionsPage: React.FC = () => { // 表格操作引用:用于在同步后触发表格刷新 const actionRef = useRef(); const { message } = App.useApp(); const { siteId } = useParams<{ siteId: string }>(); // 监听 siteId 变化并重新加载表格 React.useEffect(() => { actionRef.current?.reload(); }, [siteId]); // 关联订单抽屉状态 const [drawerOpen, setDrawerOpen] = useState(false); const [drawerTitle, setDrawerTitle] = useState('详情'); const [relatedOrders, setRelatedOrders] = useState([]); // 表格列定义(尽量与项目风格保持一致) const [editing, setEditing] = useState(null); const [selectedRowKeys, setSelectedRowKeys] = useState([]); const columns: ProColumns[] = [ // Site column removed { title: '订阅ID', dataIndex: 'id', hideInSearch: true, }, { title: '状态', dataIndex: 'status', valueType: 'select', valueEnum: SUBSCRIPTION_STATUS_ENUM, // 以 Tag 形式展示,更易辨识 render: (_, row) => row?.status ? ( {SUBSCRIPTION_STATUS_ENUM[row.status]?.text || row.status} ) : ( '-' ), }, { title: '客户ID', dataIndex: 'customer_id', hideInSearch: true, }, { title: '计费周期', dataIndex: 'billing_period', hideInSearch: true, }, { title: '计费间隔', dataIndex: 'billing_interval', hideInSearch: true, }, { title: '开始时间', dataIndex: 'start_date', hideInSearch: true, width: 160, }, { title: '下次支付', dataIndex: 'next_payment_date', hideInSearch: true, width: 160, }, { // 创建时间 title: '创建时间', dataIndex: 'date_created', valueType: 'dateTime', hideInSearch: true, }, { // 修改时间 title: '修改时间', dataIndex: 'date_modified', valueType: 'dateTime', hideInSearch: true, }, { title: '操作', valueType: 'option', render: (_, row) => (