"use client" import { ProjectDetail } from "@/components/label/api/project/typing" import { Badge, Group, Paper, Stack, Text } from "@mantine/core" import { DataTable, DataTableColumn } from "mantine-datatable" import { useMemo } from "react" export default function LabelSchemeContainer(props: { info: ProjectDetail.DataProps | undefined }) { const schemas = props.info?.label_schema_list ?? [] const columns = useMemo(() => { const cols: DataTableColumn[] = [ { accessor: "category_id", title: "ID", width: 70 }, { accessor: "label_class", title: "类别", width: 140 }, { accessor: "color", title: "颜色", width: 120, render: (record) => { const color = Array.isArray(record.color) ? record.color : [] const bg = color.length >= 3 ? `rgb(${color[0]}, ${color[1]}, ${color[2]})` : "rgba(0,0,0,0.15)" return (
{color.length >= 3 ? `${color[0]},${color[1]},${color[2]}` : "-"} ) }, }, { accessor: "label_type", title: "类型", width: 90, render: (record) => {record.label_type}, }, { accessor: "sub_attributes", title: "子属性", width: 240, render: (record) => ( {(record.sub_attributes ?? []).join("、") || "-"} ), }, ] return cols }, []) return ( 标注方案 withTableBorder withRowBorders idAccessor="category_id" records={schemas} columns={columns} minHeight={160} noRecordsText="暂无数据" /> ) }