diff --git a/frontend/components/scan/scheduled/scheduled-scan-columns.tsx b/frontend/components/scan/scheduled/scheduled-scan-columns.tsx index dd62be84..a02c61d9 100644 --- a/frontend/components/scan/scheduled/scheduled-scan-columns.tsx +++ b/frontend/components/scan/scheduled/scheduled-scan-columns.tsx @@ -25,6 +25,8 @@ import { ChevronUp, ChevronDown, Edit, + Building2, + Target, } from "lucide-react" @@ -179,7 +181,7 @@ export const createScheduledScanColumns = ({ // 任务名称列 { accessorKey: "name", - size: 650, + size: 350, minSize: 250, header: ({ column }) => ( @@ -238,12 +240,12 @@ export const createScheduledScanColumns = ({ enableSorting: false, }, - // 目标列(根据 scanMode 显示组织或目标) + // 扫描范围列(用图标区分组织/目标) { accessorKey: "scanMode", - header: "Target", - size: 180, - minSize: 120, + header: "Scope", + size: 200, + minSize: 150, cell: ({ row }) => { const scanMode = row.original.scanMode const organizationName = row.original.organizationName @@ -252,21 +254,24 @@ export const createScheduledScanColumns = ({ // 组织扫描模式 if (scanMode === 'organization' && organizationName) { return ( - - 组织: {organizationName} - +
+ + {organizationName} +
) } - // 目标扫描模式:显示单个目标 - if (!targetName) { - return
-
+ // 目标扫描模式 + if (targetName) { + return ( +
+ + {targetName} +
+ ) } - return ( - - {targetName} - - ) + + return - }, enableSorting: false, }, diff --git a/frontend/components/scan/scheduled/scheduled-scan-data-table.tsx b/frontend/components/scan/scheduled/scheduled-scan-data-table.tsx index ebd79846..30766071 100644 --- a/frontend/components/scan/scheduled/scheduled-scan-data-table.tsx +++ b/frontend/components/scan/scheduled/scheduled-scan-data-table.tsx @@ -44,6 +44,14 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select" +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table" import type { ScheduledScan } from "@/types/scheduled-scan.types" @@ -77,7 +85,6 @@ export function ScheduledScanDataTable({ columns, onAddNew, searchPlaceholder = "搜索任务名称...", - searchColumn = "name", searchValue, onSearch, isSearching = false, @@ -115,9 +122,6 @@ export function ScheduledScanDataTable({ const [sorting, setSorting] = React.useState([]) const [columnSizing, setColumnSizing] = React.useState({}) - // 服务端分页:不使用 TanStack Table 的分页,而是手动控制 - const isServerPagination = !!onPageChange - // 过滤有效数据 const validData = React.useMemo(() => { return (data || []).filter( @@ -133,33 +137,28 @@ export function ScheduledScanDataTable({ sorting, columnVisibility, columnFilters, - // 服务端分页时不使用内部分页状态 - ...(isServerPagination ? {} : { - pagination: { pageIndex: page - 1, pageSize } - }), + pagination: { pageIndex: page - 1, pageSize }, columnSizing, }, enableColumnResizing: true, columnResizeMode: 'onChange', onColumnSizingChange: setColumnSizing, + pageCount: totalPages, + manualPagination: true, getRowId: (row) => row.id.toString(), onSortingChange: setSorting, onColumnFiltersChange: setColumnFilters, onColumnVisibilityChange: setColumnVisibility, getCoreRowModel: getCoreRowModel(), getFilteredRowModel: getFilteredRowModel(), - // 服务端分页时不使用客户端分页 - ...(isServerPagination ? {} : { getPaginationRowModel: getPaginationRowModel() }), + getPaginationRowModel: getPaginationRowModel(), getSortedRowModel: getSortedRowModel(), getFacetedRowModel: getFacetedRowModel(), getFacetedUniqueValues: getFacetedUniqueValues(), - // 服务端分页:告诉 table 总行数 - ...(isServerPagination ? { manualPagination: true, pageCount: totalPages } : {}), }) - return ( -
+
{/* 工具栏 */}
{/* 搜索框 */} @@ -201,13 +200,13 @@ export function ScheduledScanDataTable({ .map((column) => { const columnNameMap: Record = { name: "任务名称", - engine_name: "扫描引擎", - frequency: "执行频率", - target_domains: "目标域名", - is_enabled: "状态", - next_run_time: "下次执行", - run_count: "执行次数", - last_run_time: "上次执行", + engineName: "扫描引擎", + cronExpression: "Cron 表达式", + scanMode: "扫描范围", + isEnabled: "状态", + nextRunTime: "下次执行", + runCount: "执行次数", + lastRunTime: "上次执行", } return ( @@ -236,26 +235,29 @@ export function ScheduledScanDataTable({
+
+ {/* 表格容器 */}
- +
{/* 表头 */} - + {table.getHeaderGroups().map((headerGroup) => ( - {headerGroup.headers.map((header) => { return ( - + ) })} - + ))} - + {/* 表体 */} - + {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( - {row.getVisibleCells().map((cell) => ( - + ))} - + )) ) : ( - - - + + )} - -
{header.isPlaceholder ? null @@ -273,53 +275,51 @@ export function ScheduledScanDataTable({
)} -
+ {flexRender( cell.column.columnDef.cell, cell.getContext() )} -
+ 暂无数据 -
+ +
{/* 分页控制 */} -
- {/* 分页控制器 */} +
{/* 每页显示数量选择 */}
@@ -349,7 +349,7 @@ export function ScheduledScanDataTable({ {/* 页码信息 */}
- Page {page} of {totalPages} ({total} items) + Page {page} of {totalPages}
{/* 分页按钮 */}