'use client'; import { useState } from 'react'; import { useParams, useRouter } from 'next/navigation'; import { Box, Container, Typography, Button, Grid, CircularProgress, Alert, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, TablePagination } from '@mui/material'; import AddIcon from '@mui/icons-material/Add'; import CompareArrowsIcon from '@mui/icons-material/CompareArrows'; import { useTranslation } from 'react-i18next'; import useBlindTestTasks from './hooks/useBlindTestTasks'; import BlindTestTaskCard from './components/BlindTestTaskCard'; import CreateBlindTestDialog from './components/CreateBlindTestDialog'; export default function BlindTestTasksPage() { const { projectId } = useParams(); const router = useRouter(); const { t } = useTranslation(); const { tasks, loading, error, setError, deleteTask, interruptTask, createTask, page, setPage, pageSize, setPageSize, total } = useBlindTestTasks(projectId); const [createDialogOpen, setCreateDialogOpen] = useState(false); const [deleteDialog, setDeleteDialog] = useState({ open: false, task: null }); const [interruptDialog, setInterruptDialog] = useState({ open: false, task: null }); const handleView = task => router.push(`/projects/${projectId}/blind-test-tasks/${task.id}`); const handleContinue = task => router.push(`/projects/${projectId}/blind-test-tasks/${task.id}`); const handleDelete = task => setDeleteDialog({ open: true, task }); const handleInterrupt = task => setInterruptDialog({ open: true, task }); const handlePageChange = (event, newPage) => { setPage(newPage + 1); }; const handlePageSizeChange = event => { setPageSize(parseInt(event.target.value, 10)); setPage(1); }; const confirmDelete = async () => { if (deleteDialog.task) { await deleteTask(deleteDialog.task.id); } setDeleteDialog({ open: false, task: null }); }; const confirmInterrupt = async () => { if (interruptDialog.task) { await interruptTask(interruptDialog.task.id); } setInterruptDialog({ open: false, task: null }); }; const handleCreate = async taskData => { const result = await createTask(taskData); if (result.success) { // 创建成功后跳转到任务详情页开始盲测 router.push(`/projects/${projectId}/blind-test-tasks/${result.data.id}`); } return result; }; return ( {/* 页面标题 */} {t('blindTest.title', '人工盲测任务')} {/* 错误提示 */} {error && ( setError('')}> {error} )} {/* 加载状态 */} {loading && ( )} {/* 空状态 */} {!loading && tasks.length === 0 && ( {t('blindTest.noTasks', '暂无盲测任务')} {t('blindTest.noTasksHint', '创建盲测任务来对比两个模型的回答质量')} )} {/* 任务列表 */} {!loading && tasks.length > 0 && ( <> {tasks.map(task => ( ))} )} {/* 创建对话框 */} setCreateDialogOpen(false)} projectId={projectId} onCreate={handleCreate} /> {/* 删除确认对话框 */} setDeleteDialog({ open: false, task: null })}> {t('blindTest.deleteConfirmTitle', '确认删除')} {t('blindTest.deleteConfirmMessage', '确定要删除这个盲测任务吗?此操作不可撤销。')} {/* 中断确认对话框 */} setInterruptDialog({ open: false, task: null })}> {t('blindTest.interruptConfirmTitle', '确认中断')} {t('blindTest.interruptConfirmMessage', '确定要中断这个盲测任务吗?已完成的评判结果将保留。')} ); }