'use client'; import { Eye, Clock, CheckCircle, XCircle, AlertCircle, HelpCircle, User, FileText } from 'lucide-react'; // 1. 引入 LocalTime 组件 import LocalTime from '@/components/common/LocalTime'; // 定义工单数据结构 (对应 API: VasTicketOut) export interface AdminTicket { id: number; order_id: string; user_id: string; type: string; // refund, dispute, change_request status: string; // pending, info_required, resolved, rejected reason: string; admin_comment?: string; created_at: string; updated_at: string; } interface TicketTableProps { tickets: AdminTicket[]; loading: boolean; onViewDetail: (ticket: AdminTicket) => void; } export default function TicketTable({ tickets, loading, onViewDetail }: TicketTableProps) { if (loading) { return (
加载工单数据中...
); } if (tickets.length === 0) { return (
暂无工单记录
); } // 状态徽章 const getStatusBadge = (status: string) => { switch (status) { case 'pending': return 待处理; case 'info_required': return 需补充资料; case 'resolved': return 已解决; case 'rejected': return 已拒绝; default: return {status}; } }; const getTypeText = (type: string) => { const map: Record = { refund: '退款申请', dispute: '交易纠纷', change_request: '变更请求' }; return map[type] || type; }; return (
{/* ======================= */} {/* 1. Desktop View (Table) - 仅在中大屏幕显示 */} {/* ======================= */}
{tickets.map((ticket) => ( ))}
ID 类型 关联订单 / 用户 描述摘要 状态 创建时间 操作
#{ticket.id} {getTypeText(ticket.type)}
{ticket.order_id}
{ticket.user_id}
{ticket.reason}
{getStatusBadge(ticket.status)}
{/* ======================= */} {/* 2. Mobile View (Cards) - 仅在小屏幕显示 */} {/* ======================= */}
{tickets.map((ticket) => (
{/* Header: ID + Status */}
#{ticket.id} {getTypeText(ticket.type)}
{getStatusBadge(ticket.status)}
{/* Info Grid */}
订单号 {ticket.order_id}
用户 {ticket.user_id}
时间
{/* 描述摘要 */}
描述:

{ticket.reason}

{/* Action Button */}
))}
); }