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:
parent
0832445862
commit
935f0a1f57
@ -1,9 +1,9 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import {
|
import {
|
||||||
Button, Empty, Form, Input, InputNumber, Select, Space, Table, Tag, message,
|
Button, Empty, Form, Input, InputNumber, Select, Space, Table, Tag, Tooltip, message,
|
||||||
} from 'antd'
|
} from 'antd'
|
||||||
import type { ColumnsType } from 'antd/es/table'
|
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 FormDrawer from '../components/FormDrawer'
|
||||||
import PageWrapper from '../components/PageWrapper'
|
import PageWrapper from '../components/PageWrapper'
|
||||||
import EvalDetail from '../components/intelligent_eval/EvalDetail'
|
import EvalDetail from '../components/intelligent_eval/EvalDetail'
|
||||||
@ -65,6 +65,11 @@ export default function IntelligentEvalsPage() {
|
|||||||
setView('detail')
|
setView('detail')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openReport = (id: string) => {
|
||||||
|
setSelectedId(id)
|
||||||
|
setView('report')
|
||||||
|
}
|
||||||
|
|
||||||
const submitCreate = async () => {
|
const submitCreate = async () => {
|
||||||
const values = await form.validateFields()
|
const values = await form.validateFields()
|
||||||
let seeds: Record<string, unknown> = {}
|
let seeds: Record<string, unknown> = {}
|
||||||
@ -106,9 +111,7 @@ export default function IntelligentEvalsPage() {
|
|||||||
const columns: ColumnsType<IntelligentEval> = [
|
const columns: ColumnsType<IntelligentEval> = [
|
||||||
{
|
{
|
||||||
title: '名称', dataIndex: 'name', key: 'name',
|
title: '名称', dataIndex: 'name', key: 'name',
|
||||||
render: (name: string, ev) => (
|
render: (name: string) => <span style={{ fontWeight: 500 }}>{name}</span>,
|
||||||
<a onClick={() => openDetail(ev.id)}>{name}</a>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '评测对象', dataIndex: 'target_id', key: 'target', width: 180,
|
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,
|
title: '创建时间', dataIndex: 'created_at', key: 'created_at', width: 170,
|
||||||
render: (v: string | null) => (v ? formatDateTime(v) : '—'),
|
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) {
|
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 (
|
return (
|
||||||
<PageWrapper title="智能评估" inline fullHeight>
|
<PageWrapper title="智能评估" inline fullHeight>
|
||||||
<EvalReport ev={selected} onBack={() => setView('detail')} />
|
<EvalReport ev={selected} onBack={() => setView('detail')} />
|
||||||
@ -181,8 +206,7 @@ export default function IntelligentEvalsPage() {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
dataSource={evals ?? []}
|
dataSource={evals ?? []}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
pagination={false}
|
pagination={(evals?.length ?? 0) > 20 ? { pageSize: 20, showTotal: (t) => `共 ${t} 个` } : false}
|
||||||
onRow={(ev) => ({ onClick: () => openDetail(ev.id), style: { cursor: 'pointer' } })}
|
|
||||||
locale={{ emptyText: <Empty description="还没有智能评估" /> }}
|
locale={{ emptyText: <Empty description="还没有智能评估" /> }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user