fix(data-annotation): 修复数据标注任务进度计算问题

- 添加 toSafeCount 工具函数确保数值安全处理
- 支持 totalCount 和 total_count 字段兼容性
-
This commit is contained in:
2026-02-01 23:42:06 +08:00
parent 2f2e0d6a8d
commit 626c0fcd9a

View File

@@ -57,6 +57,9 @@ export default function DataAnnotation() {
const [selectedRowKeys, setSelectedRowKeys] = useState<AnnotationTaskRowKey[]>([]);
const [selectedRows, setSelectedRows] = useState<AnnotationTaskListItem[]>([]);
const toSafeCount = (value: unknown) =>
typeof value === "number" && Number.isFinite(value) ? value : 0;
const handleAnnotate = (task: AnnotationTaskListItem) => {
const projectId = task.id;
if (!projectId) {
@@ -207,8 +210,20 @@ export default function DataAnnotation() {
width: 100,
align: "center" as const,
render: (value: number, record: AnnotationTaskListItem) => {
const total = record.totalCount || 0;
const annotated = value || 0;
const total = toSafeCount(record.totalCount ?? record.total_count);
const annotatedRaw = toSafeCount(
value ?? record.annotatedCount ?? record.annotated_count
);
const segmentationEnabled =
record.segmentationEnabled ?? record.segmentation_enabled;
const inProgressRaw = segmentationEnabled
? toSafeCount(record.inProgressCount ?? record.in_progress_count)
: 0;
const shouldExcludeInProgress =
total > 0 && annotatedRaw + inProgressRaw > total;
const annotated = shouldExcludeInProgress
? Math.max(annotatedRaw - inProgressRaw, 0)
: annotatedRaw;
const percent = total > 0 ? Math.round((annotated / total) * 100) : 0;
return (
<span title={`${annotated}/${total} (${percent}%)`}>