'use client';
import { useParams, useRouter } from 'next/navigation';
import {
Container,
Box,
Button,
CircularProgress,
Alert,
Typography,
LinearProgress,
Paper,
Grid,
Pagination
} from '@mui/material';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
import RefreshIcon from '@mui/icons-material/Refresh';
import { useTranslation } from 'react-i18next';
import useEvalTaskDetail from '../hooks/useEvalTaskDetail';
import { detailStyles } from './detailStyles';
import EvalHeader from './components/EvalHeader';
import EvalStats from './components/EvalStats';
import QuestionCard from './components/QuestionCard';
export default function EvalTaskDetailPage() {
const { projectId, taskId } = useParams();
const router = useRouter();
const { t } = useTranslation();
const {
task,
results,
stats,
total,
page,
setPage,
pageSize,
filterType,
setFilterType,
filterCorrect,
setFilterCorrect,
loading,
error,
setError,
loadData
} = useEvalTaskDetail(projectId, taskId);
const handleFilterSelect = type => {
setFilterType(type);
setPage(1); // 切换筛选时重置到第一页
};
const handleFilterCorrectSelect = isCorrect => {
setFilterCorrect(isCorrect);
setPage(1); // 切换筛选时重置到第一页
};
const handlePageChange = (event, value) => {
setPage(value);
// 滚动到试卷顶部
document.getElementById('paper-top')?.scrollIntoView({ behavior: 'smooth' });
};
if (loading && !task) {
return (
);
}
return (
{/* 顶部导航栏 */}
}
onClick={() => router.back()}
sx={{ color: 'text.secondary', fontWeight: 600 }}
>
{t('common.back')}
}
onClick={loadData}
disabled={loading}
size="small"
sx={{ bgcolor: 'white' }}
>
{t('common.refresh')}
{/* 错误提示 */}
{error && (
setError('')}>
{error}
)}
{/* 任务进度(仅进行中时显示) */}
{task?.status === 0 && (
{t('evalTasks.statusProcessing')}...
{task.completedCount}/{task.totalCount}
0 ? (task.completedCount / task.totalCount) * 100 : 0}
sx={{ height: 10, borderRadius: 5 }}
/>
)}
{/* 核心内容区 */}
{task && (
<>
{/* 头部概览 */}
{/* 统计图表 & 筛选 */}
{/* 试卷主体 */}
{/* 试卷抬头 */}
{t('evalTasks.reportTitle', '模型能力评估报告')}
{t('evalTasks.taskIdLabel', '任务 ID')}: {taskId}
{t('evalTasks.pageInfo', '第 {{page}} / {{totalPages}} 页', {
page,
totalPages: Math.ceil(total / pageSize)
})}
{/* 题目列表 (双列布局) */}
{loading ? (
) : (
{results?.map((result, index) => (
))}
)}
{!loading && results?.length === 0 && (
{t('evalTasks.noMatchingResults', '暂无符合条件的评估结果')}
)}
{/* 分页控制 */}
{/* 试卷底部 */}
{t('evalTasks.reportFooter', 'Easy Dataset Evaluation System · Generated by AI')}
>
)}
);
}