feat(annotation): 添加标注类型显示功能

- 在前端页面中新增标注类型列并使用Tag组件展示
- 添加AnnotationTypeMap常量用于标注类型的映射
- 修改接口定义支持labelingType字段的传递
- 更新后端项目创建和更新逻辑以存储标注类型
- 添加标注类型配置键常量统一管理
- 扩展数据传输对象支持标注类型属性
- 实现模板标注类型的继承逻辑
This commit is contained in:
2026-02-01 19:08:11 +08:00
parent d135a7f336
commit 0bb9abb200
5 changed files with 66 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
import { useState } from "react";
import { Card, Button, Table, message, Modal, Tabs } from "antd";
import { Card, Button, Table, Tag, message, Modal, Tabs } from "antd";
import {
PlusOutlined,
EditOutlined,
@@ -15,7 +15,11 @@ import {
deleteAnnotationTaskByIdUsingDelete,
queryAnnotationTasksUsingGet,
} from "../annotation.api";
import { mapAnnotationTask, type AnnotationTaskListItem } from "../annotation.const";
import {
AnnotationTypeMap,
mapAnnotationTask,
type AnnotationTaskListItem,
} from "../annotation.const";
import CreateAnnotationTask from "../Create/components/CreateAnnotationTaskDialog";
import ExportAnnotationDialog from "./ExportAnnotationDialog";
import { ColumnType } from "antd/es/table";
@@ -168,6 +172,21 @@ export default function DataAnnotation() {
key: "datasetName",
width: 180,
},
{
title: "标注类型",
dataIndex: "labelingType",
key: "labelingType",
width: 160,
render: (value?: string) => {
if (!value) {
return "-";
}
const label =
AnnotationTypeMap[value as keyof typeof AnnotationTypeMap]?.label ||
value;
return <Tag color="geekblue">{label}</Tag>;
},
},
{
title: "数据量",
dataIndex: "totalCount",

View File

@@ -23,6 +23,12 @@ type AnnotationTaskPayload = {
datasetId?: string;
datasetName?: string;
dataset_name?: string;
labelingType?: string;
labeling_type?: string;
template?: {
labelingType?: string;
labeling_type?: string;
};
totalCount?: number;
total_count?: number;
annotatedCount?: number;
@@ -48,6 +54,7 @@ export type AnnotationTaskListItem = {
description?: string;
datasetId?: string;
datasetName?: string;
labelingType?: string;
totalCount?: number;
annotatedCount?: number;
inProgressCount?: number;
@@ -90,6 +97,11 @@ export function mapAnnotationTask(task: AnnotationTaskPayload): AnnotationTaskLi
const labelingProjId = task?.labelingProjId || task?.labelingProjectId || task?.projId || task?.labeling_project_id || "";
const segmentationEnabled = task?.segmentationEnabled ?? task?.segmentation_enabled ?? false;
const inProgressCount = task?.inProgressCount ?? task?.in_progress_count ?? 0;
const labelingType =
task?.labelingType ||
task?.labeling_type ||
task?.template?.labelingType ||
task?.template?.labeling_type;
const statsArray = task?.statistics
? [
@@ -107,6 +119,7 @@ export function mapAnnotationTask(task: AnnotationTaskPayload): AnnotationTaskLi
projId: labelingProjId,
segmentationEnabled,
inProgressCount,
labelingType,
name: task.name,
description: task.description || "",
datasetName: task.datasetName || task.dataset_name || "-",