refactor(ui): open intelligent eval via action-column buttons

Replace the name link and row-click with explicit detail/report
buttons, matching the static-eval table pages. Report button only
shows for completed evals; list pagination now follows the 20-row
threshold.
This commit is contained in:
sinohqb 2026-08-05 21:00:19 +08:00
parent 0832445862
commit 935f0a1f57

View File

@ -1,9 +1,9 @@
import { useState } from 'react'
import {
Button, Empty, Form, Input, InputNumber, Select, Space, Table, Tag, message,
Button, Empty, Form, Input, InputNumber, Select, Space, Table, Tag, Tooltip, message,
} from 'antd'
import type { ColumnsType } from 'antd/es/table'
import { PlusOutlined, ReloadOutlined } from '@ant-design/icons'
import { PlusOutlined, ReloadOutlined, EyeOutlined, FileTextOutlined } from '@ant-design/icons'
import FormDrawer from '../components/FormDrawer'
import PageWrapper from '../components/PageWrapper'
import EvalDetail from '../components/intelligent_eval/EvalDetail'
@ -65,6 +65,11 @@ export default function IntelligentEvalsPage() {
setView('detail')
}
const openReport = (id: string) => {
setSelectedId(id)
setView('report')
}
const submitCreate = async () => {
const values = await form.validateFields()
let seeds: Record<string, unknown> = {}
@ -106,9 +111,7 @@ export default function IntelligentEvalsPage() {
const columns: ColumnsType<IntelligentEval> = [
{
title: '名称', dataIndex: 'name', key: 'name',
render: (name: string, ev) => (
<a onClick={() => openDetail(ev.id)}>{name}</a>
),
render: (name: string) => <span style={{ fontWeight: 500 }}>{name}</span>,
},
{
title: '评测对象', dataIndex: 'target_id', key: 'target', width: 180,
@ -129,6 +132,21 @@ export default function IntelligentEvalsPage() {
title: '创建时间', dataIndex: 'created_at', key: 'created_at', width: 170,
render: (v: string | null) => (v ? formatDateTime(v) : '—'),
},
{
title: '操作', key: 'action', width: 110, fixed: 'right' as const,
render: (_, ev) => (
<Space size={4}>
<Tooltip title="详情">
<Button size="small" type="text" icon={<EyeOutlined />} onClick={() => openDetail(ev.id)} />
</Tooltip>
{ev.status === 'completed' && (
<Tooltip title="查看报告">
<Button size="small" type="text" icon={<FileTextOutlined />} onClick={() => openReport(ev.id)} />
</Tooltip>
)}
</Space>
),
},
]
if (view === 'detail' && selectedId) {
@ -152,7 +170,14 @@ export default function IntelligentEvalsPage() {
)
}
if (view === 'report' && selected) {
if (view === 'report' && selectedId) {
if (!selected) {
return (
<PageWrapper title="智能评估" inline fullHeight>
<div style={{ padding: 16 }}></div>
</PageWrapper>
)
}
return (
<PageWrapper title="智能评估" inline fullHeight>
<EvalReport ev={selected} onBack={() => setView('detail')} />
@ -181,8 +206,7 @@ export default function IntelligentEvalsPage() {
loading={loading}
dataSource={evals ?? []}
columns={columns}
pagination={false}
onRow={(ev) => ({ onClick: () => openDetail(ev.id), style: { cursor: 'pointer' } })}
pagination={(evals?.length ?? 0) > 20 ? { pageSize: 20, showTotal: (t) => `${t}` } : false}
locale={{ emptyText: <Empty description="还没有智能评估" /> }}
/>
</div>