perf(format): code format
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
"use client"
|
||||
|
||||
import { getProjectList, getProjectTypeList } from "@/components/label/api/project"
|
||||
import {
|
||||
getProjectList,
|
||||
getProjectTypeList,
|
||||
} from "@/components/label/api/project"
|
||||
import { getTaskList } from "@/components/label/api/task"
|
||||
import { Task } from "@/components/label/api/task/typing"
|
||||
import TaskStatusTag from "@/components/label/components/TaskStatusTag"
|
||||
@@ -18,7 +21,13 @@ import {
|
||||
Text,
|
||||
} from "@mantine/core"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import { IconChevronDown, IconChevronUp, IconDownload, IconRefresh, IconSearch } from "@tabler/icons-react"
|
||||
import {
|
||||
IconChevronDown,
|
||||
IconChevronUp,
|
||||
IconDownload,
|
||||
IconRefresh,
|
||||
IconSearch,
|
||||
} from "@tabler/icons-react"
|
||||
import { DataTable, DataTableColumn } from "mantine-datatable"
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import * as XLSX from "xlsx-js-style"
|
||||
@@ -37,24 +46,25 @@ const emptyFilters = {
|
||||
|
||||
function toNumberArray(values?: string[]) {
|
||||
if (!values || values.length === 0) return undefined
|
||||
const arr = values
|
||||
.map((v) => Number(v))
|
||||
.filter((v) => Number.isFinite(v))
|
||||
const arr = values.map((v) => Number(v)).filter((v) => Number.isFinite(v))
|
||||
return arr.length > 0 ? arr : undefined
|
||||
}
|
||||
|
||||
export default function TaskListTable() {
|
||||
const treeData = useAllUserStore((s) => s.treeData)
|
||||
const userOptions = useMemo(() => flattenLeaderTree(treeData ?? []), [treeData])
|
||||
const userOptions = useMemo(
|
||||
() => flattenLeaderTree(treeData ?? []),
|
||||
[treeData]
|
||||
)
|
||||
|
||||
const [collapsed, setCollapsed] = useState(true)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [projectTypeOpts, setProjectTypeOpts] = useState<Array<{ label: string; value: string }>>(
|
||||
[]
|
||||
)
|
||||
const [projectNameOpts, setProjectNameOpts] = useState<Array<{ label: string; value: string }>>(
|
||||
[]
|
||||
)
|
||||
const [projectTypeOpts, setProjectTypeOpts] = useState<
|
||||
Array<{ label: string; value: string }>
|
||||
>([])
|
||||
const [projectNameOpts, setProjectNameOpts] = useState<
|
||||
Array<{ label: string; value: string }>
|
||||
>([])
|
||||
const [filters, setFilters] = useState(emptyFilters)
|
||||
|
||||
const [records, setRecords] = useState<Task.DataProps[]>([])
|
||||
@@ -69,14 +79,18 @@ export default function TaskListTable() {
|
||||
])
|
||||
|
||||
if (typesRes.status === "fulfilled") {
|
||||
setProjectTypeOpts((typesRes.value ?? []).map((t) => ({ label: t, value: t })))
|
||||
setProjectTypeOpts(
|
||||
(typesRes.value ?? []).map((t) => ({ label: t, value: t }))
|
||||
)
|
||||
} else {
|
||||
setProjectTypeOpts([])
|
||||
}
|
||||
|
||||
if (projectsRes.status === "fulfilled") {
|
||||
const list = projectsRes.value?.project_list ?? []
|
||||
setProjectNameOpts(list.map((p) => ({ label: p.name, value: String(p.id) })))
|
||||
setProjectNameOpts(
|
||||
list.map((p) => ({ label: p.name, value: String(p.id) }))
|
||||
)
|
||||
} else {
|
||||
setProjectNameOpts([])
|
||||
}
|
||||
@@ -101,7 +115,8 @@ export default function TaskListTable() {
|
||||
page_size: nextFilters.page_size,
|
||||
get_data: false,
|
||||
}
|
||||
if (nextFilters.project_type.length > 0) payload.project_type = nextFilters.project_type
|
||||
if (nextFilters.project_type.length > 0)
|
||||
payload.project_type = nextFilters.project_type
|
||||
if (nextFilters.project_id.length > 0) {
|
||||
payload.project_id = toNumberArray(nextFilters.project_id)
|
||||
}
|
||||
@@ -153,7 +168,10 @@ export default function TaskListTable() {
|
||||
title: "状态",
|
||||
width: 160,
|
||||
render: (record) => (
|
||||
<TaskStatusTag status={record.label_status} rejected={record.rejected} />
|
||||
<TaskStatusTag
|
||||
status={record.label_status}
|
||||
rejected={record.rejected}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{ accessor: "current_username", title: "当前负责人", width: 120 },
|
||||
@@ -214,8 +232,16 @@ export default function TaskListTable() {
|
||||
width: 120,
|
||||
render: (record) => record.label_object_size?.second_comment_size ?? 0,
|
||||
},
|
||||
{ accessor: "first_commit_label_time", title: "标注首次提交时间", width: 180 },
|
||||
{ accessor: "first_commit_review1_time", title: "审核首次提交时间", width: 180 },
|
||||
{
|
||||
accessor: "first_commit_label_time",
|
||||
title: "标注首次提交时间",
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
accessor: "first_commit_review1_time",
|
||||
title: "审核首次提交时间",
|
||||
width: 180,
|
||||
},
|
||||
{ accessor: "reject_times", title: "驳回次数", width: 100 },
|
||||
{
|
||||
accessor: "label_work_time",
|
||||
@@ -329,7 +355,13 @@ export default function TaskListTable() {
|
||||
variant="subtle"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
rightSection={collapsed ? <IconChevronDown size={14} /> : <IconChevronUp size={14} />}
|
||||
rightSection={
|
||||
collapsed ? (
|
||||
<IconChevronDown size={14} />
|
||||
) : (
|
||||
<IconChevronUp size={14} />
|
||||
)
|
||||
}
|
||||
onClick={() => setCollapsed((v) => !v)}>
|
||||
{collapsed ? "展开筛选" : "收起筛选"}
|
||||
</Button>
|
||||
@@ -387,10 +419,12 @@ export default function TaskListTable() {
|
||||
label="任务状态"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
data={Array.from(TaskStatusEnum.entries()).map(([value, label]) => ({
|
||||
label,
|
||||
value: String(value),
|
||||
}))}
|
||||
data={Array.from(TaskStatusEnum.entries()).map(
|
||||
([value, label]) => ({
|
||||
label,
|
||||
value: String(value),
|
||||
})
|
||||
)}
|
||||
searchable
|
||||
clearable
|
||||
value={filters.label_status}
|
||||
@@ -445,7 +479,11 @@ export default function TaskListTable() {
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
<Paper withBorder p="sm" radius="sm" style={{ flex: 1, minHeight: 0, display: "flex" }}>
|
||||
<Paper
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="sm"
|
||||
style={{ flex: 1, minHeight: 0, display: "flex" }}>
|
||||
<DataTable<Task.DataProps>
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
@@ -453,7 +491,7 @@ export default function TaskListTable() {
|
||||
records={records}
|
||||
columns={columns}
|
||||
noRecordsText="暂无数据"
|
||||
rowKey="id"
|
||||
idAccessor="id"
|
||||
scrollAreaProps={{ type: "auto" }}
|
||||
style={{ width: "100%" }}
|
||||
/>
|
||||
@@ -472,7 +510,9 @@ export default function TaskListTable() {
|
||||
<Text size="sm">问题数:{totalSize?.question_size ?? 0}</Text>
|
||||
<Text size="sm">审核对象数:{totalSize?.review_size ?? 0}</Text>
|
||||
<Text size="sm">批注数(1):{totalSize?.first_comment_size ?? 0}</Text>
|
||||
<Text size="sm">批注数(2):{totalSize?.second_comment_size ?? 0}</Text>
|
||||
<Text size="sm">
|
||||
批注数(2):{totalSize?.second_comment_size ?? 0}
|
||||
</Text>
|
||||
</Group>
|
||||
</Paper>
|
||||
</Stack>
|
||||
|
||||
Reference in New Issue
Block a user