feat(table): sum

This commit is contained in:
zhangheng
2026-04-16 15:13:26 +08:00
parent 7358306488
commit 1f9436864b
2 changed files with 76 additions and 2 deletions

View File

@@ -122,6 +122,31 @@ const SORTABLE_TASK_SIZE_COLUMNS: Array<{
{ accessor: "second_comment_size", title: "批注数(2)", width: 120 },
]
const EMPTY_TASK_SIZE: Task.SizeProps = Object.freeze({
object_size: 0,
valid_size: 0,
first_comment_size: 0,
second_comment_size: 0,
new_size: 0,
prelabel_size: 0,
prelabel_modify_size: 0,
dynamic_size: 0,
static_size: 0,
review_size: 0,
review_dynamic_size: 0,
review_static_size: 0,
key_frame_size: 0,
question_size: 0,
total_qa_group_size: 0,
single_qa_group_size: 0,
multiple_qa_group_size: 0,
new_qa_group_size: 0,
new_single_qa_group_size: 0,
new_multiple_qa_group_size: 0,
review_question_size: 0,
comment_question_size: 0,
})
export interface selectedDataProps {
status: number
uid: number | null
@@ -195,6 +220,7 @@ export default function TaskTableContainer(props: {
const { setBackProps } = useBackUrlStore()
const [total, setTotal] = useState(0)
const [totalSize, setTotalSize] = useState<Task.SizeProps>(EMPTY_TASK_SIZE)
const [pageNumber, setPageNumber] = useState(1)
const [pageSize, setPageSize] = useState(15)
@@ -324,9 +350,11 @@ export default function TaskTableContainer(props: {
const res = await getTaskList(appliedParams)
setRecords(res?.task_list ?? [])
setTotal(res?.total_items ?? 0)
setTotalSize(res?.total_size ?? EMPTY_TASK_SIZE)
} catch (e) {
setRecords([])
setTotal(0)
setTotalSize(EMPTY_TASK_SIZE)
notifications.show({
color: "red",
title: "加载失败",
@@ -621,6 +649,7 @@ export default function TaskTableContainer(props: {
width,
sortable: true,
render: (record) => record.label_object_size?.[accessor] ?? "-",
footer: totalSize[accessor] ?? 0,
})
const cols: DataTableColumn<Task.DataProps>[] = [
@@ -628,6 +657,7 @@ export default function TaskTableContainer(props: {
accessor: "id",
title: "任务ID",
width: 90,
footer: "总计",
render: (record) => (
<Button
variant="transparent"
@@ -805,7 +835,15 @@ export default function TaskTableContainer(props: {
},
]
return cols
}, [hasRolePermissions, info, projectId, router, setBackProps, type])
}, [
hasRolePermissions,
info,
projectId,
router,
setBackProps,
totalSize,
type,
])
return (
<>