diff --git a/web/src/pages/tasks/index.tsx b/web/src/pages/tasks/index.tsx index 8d67191..72c37b7 100644 --- a/web/src/pages/tasks/index.tsx +++ b/web/src/pages/tasks/index.tsx @@ -1,7 +1,7 @@ // 任务中心列表:语义对齐 web.archived TasksPage.jsx 的 TaskList。 import { useCallback, useEffect, useState } from 'react'; import { history } from '@umijs/max'; -import { Alert, Button, Card, Flex, Input, Select, Space, Table, Tag, Typography } from 'antd'; +import { Alert, Button, Card, Flex, Select, Space, Table, Tag, Typography } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import { getList } from '@/services/api'; import { dateTime } from '@/utils/helpers'; @@ -48,9 +48,11 @@ const holdText: Record = { export const holdLabel = (reason?: string) => (reason ? holdText[reason] || `未知停止原因:${reason}` : '无'); export default function Page() { - const [accountFilter, setAccountFilter] = useState(''); + const [accountFilter, setAccountFilter] = useState(undefined); const [stateFilter, setStateFilter] = useState(undefined); const [rows, setRows] = useState([]); + const [accountOptions, setAccountOptions] = useState<{ value: string; label: string }[]>([]); + const [accountsPending, setAccountsPending] = useState(false); const [pending, setPending] = useState(true); const [error, setError] = useState(null); @@ -60,7 +62,7 @@ export default function Page() { try { const result = await getList({ resource: 'tasks', - filters: { account_id: accountFilter || undefined, state: stateFilter || undefined }, + filters: { account_id: accountFilter, state: stateFilter || undefined }, }); setRows(result.data ?? []); } catch (loadError) { @@ -74,16 +76,42 @@ export default function Page() { load(); }, [load]); + // 账号筛选下拉:一次性拉取账号列表,无需手输 UUID。 + useEffect(() => { + setAccountsPending(true); + getList({ resource: 'accounts' }) + .then((result) => + setAccountOptions( + (result.data ?? []).map((account: any) => ({ + value: account.id, + label: account.name ? `${account.name}(${account.id})` : account.id, + })), + ), + ) + .catch(() => setAccountOptions([])) + .finally(() => setAccountsPending(false)); + }, []); + const columns: ColumnsType = [ { title: '任务', dataIndex: 'id', - render: (value: string) => history.push(`/tasks/${value}`)}>{value}, + render: (value: string) => ( + + history.push(`/tasks/${value}`)}>{value} + + + ), }, { title: '账号', dataIndex: 'account_id', - render: (value: string) => history.push(`/accounts/${value}`)}>{value}, + render: (value: string) => ( + + history.push(`/accounts/${value}`)}>{value} + + + ), }, { title: '确认', dataIndex: 'confirmation_id', render: (value?: string) => value || '未确认' }, { @@ -115,12 +143,16 @@ export default function Page() { 共 {rows.length} 个任务 - setAccountFilter(event.target.value)} + placeholder="全部账号" allowClear + showSearch + optionFilterProp="label" + loading={accountsPending && accountOptions.length === 0} + value={accountFilter} + onChange={setAccountFilter} + options={accountOptions} />