'use client' import { useState, useEffect, useCallback } from 'react' import { Download, Calendar, Filter } from 'lucide-react' import { USE_MOCK } from '@/contexts/AuthContext' import { api } from '@/lib/api' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/Card' import { Button } from '@/components/ui/Button' import { Select } from '@/components/ui/Select' import { SuccessTag, WarningTag, ErrorTag } from '@/components/ui/Tag' // 模拟报表数据 const mockReportData = [ { id: '1', date: '2024-02-04', submitted: 45, passed: 40, failed: 5, avgScore: 82 }, { id: '2', date: '2024-02-03', submitted: 52, passed: 48, failed: 4, avgScore: 85 }, { id: '3', date: '2024-02-02', submitted: 38, passed: 32, failed: 6, avgScore: 78 }, { id: '4', date: '2024-02-01', submitted: 61, passed: 55, failed: 6, avgScore: 84 }, { id: '5', date: '2024-01-31', submitted: 55, passed: 50, failed: 5, avgScore: 83 }, { id: '6', date: '2024-01-30', submitted: 48, passed: 44, failed: 4, avgScore: 86 }, { id: '7', date: '2024-01-29', submitted: 42, passed: 38, failed: 4, avgScore: 81 }, ] // 模拟详细审核记录 const mockReviewRecords = [ { id: '1', videoTitle: '夏日护肤推荐', creator: '小美护肤', platform: '抖音', score: 95, status: 'passed', reviewedAt: '2024-02-04 15:30' }, { id: '2', videoTitle: '新品口红试色', creator: '美妆达人Lisa', platform: '小红书', score: 72, status: 'warning', reviewedAt: '2024-02-04 14:20' }, { id: '3', videoTitle: '健身器材开箱', creator: '健身教练王', platform: '抖音', score: 45, status: 'failed', reviewedAt: '2024-02-04 13:15' }, { id: '4', videoTitle: '美食探店vlog', creator: '吃货小胖', platform: '小红书', score: 88, status: 'passed', reviewedAt: '2024-02-04 12:00' }, { id: '5', videoTitle: '数码产品评测', creator: '科技宅', platform: 'B站', score: 91, status: 'passed', reviewedAt: '2024-02-04 11:30' }, ] const periodOptions = [ { value: '7d', label: '最近 7 天' }, { value: '30d', label: '最近 30 天' }, { value: '90d', label: '最近 90 天' }, ] const platformOptions = [ { value: 'all', label: '全部平台' }, { value: 'douyin', label: '抖音' }, { value: 'xiaohongshu', label: '小红书' }, { value: 'bilibili', label: 'B站' }, ] export default function ReportsPage() { const [period, setPeriod] = useState('7d') const [platform, setPlatform] = useState('all') const [reportData, setReportData] = useState(mockReportData) const [reviewRecords, setReviewRecords] = useState(mockReviewRecords) const [loading, setLoading] = useState(true) const loadData = useCallback(async () => { if (USE_MOCK) { // Mock 模式:直接使用本地 mock 数据 setReportData(mockReportData) setReviewRecords(mockReviewRecords) setLoading(false) return } // TODO: 后端报表 API 待实现 (GET /api/v1/reports),暂时使用 mock 数据 try { setReportData(mockReportData) setReviewRecords(mockReviewRecords) } finally { setLoading(false) } }, []) useEffect(() => { loadData() }, [loadData]) // 计算汇总数据 const summary = reportData.reduce( (acc, day) => ({ totalSubmitted: acc.totalSubmitted + day.submitted, totalPassed: acc.totalPassed + day.passed, totalFailed: acc.totalFailed + day.failed, }), { totalSubmitted: 0, totalPassed: 0, totalFailed: 0 } ) const passRate = summary.totalSubmitted > 0 ? Math.round((summary.totalPassed / summary.totalSubmitted) * 100) : 0 return (

审核报表

{/* 筛选器 */}
setPlatform(e.target.value)} />
{/* 汇总卡片 */}
提交总数
{summary.totalSubmitted}
通过数
{summary.totalPassed}
驳回数
{summary.totalFailed}
通过率
{passRate}%
{/* 每日数据表格 */} 每日统计
{reportData.map((row) => ( ))}
日期 提交数 通过数 驳回数 通过率 平均分
{row.date} {row.submitted} {row.passed} {row.failed} {Math.round((row.passed / row.submitted) * 100)}% = 80 ? 'text-green-600' : 'text-yellow-600'}`}> {row.avgScore}
{/* 详细审核记录 */} 审核记录
{reviewRecords.map((record) => ( ))}
视频标题 达人 平台 合规分 状态 审核时间
{record.videoTitle} {record.creator} {record.platform} = 80 ? 'text-green-600' : record.score >= 60 ? 'text-yellow-600' : 'text-red-600' }`}> {record.score} {record.status === 'passed' && 通过} {record.status === 'warning' && 待改进} {record.status === 'failed' && 驳回} {record.reviewedAt}
) }