feat(person/collection): collection
This commit is contained in:
60
app/management/person/collection/config.ts
Normal file
60
app/management/person/collection/config.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
export const dispatchOpts: Record<
|
||||
number,
|
||||
{ label: string; opts: Array<{ label: string; value: number }> }
|
||||
> = {
|
||||
1: {
|
||||
label: "待领取",
|
||||
opts: [{ label: "标注中", value: 2 }],
|
||||
},
|
||||
2: {
|
||||
label: "标注中",
|
||||
opts: [
|
||||
{ label: "标注中", value: 2 },
|
||||
{ label: "审核中", value: 4 },
|
||||
],
|
||||
},
|
||||
3: {
|
||||
label: "标注完成",
|
||||
opts: [
|
||||
{ label: "标注中", value: 2 },
|
||||
{ label: "审核中", value: 4 },
|
||||
],
|
||||
},
|
||||
4: {
|
||||
label: "审核中",
|
||||
opts: [
|
||||
{ label: "标注中", value: 2 },
|
||||
{ label: "审核中", value: 4 },
|
||||
{ label: "复审中", value: 6 },
|
||||
],
|
||||
},
|
||||
5: {
|
||||
label: "审核完成",
|
||||
opts: [
|
||||
{ label: "标注中", value: 2 },
|
||||
{ label: "审核中", value: 4 },
|
||||
{ label: "复审中", value: 6 },
|
||||
{ label: "复审完成", value: 7 },
|
||||
],
|
||||
},
|
||||
6: {
|
||||
label: "复审中",
|
||||
opts: [
|
||||
{ label: "标注中", value: 2 },
|
||||
{ label: "审核中", value: 4 },
|
||||
{ label: "复审中", value: 6 },
|
||||
],
|
||||
},
|
||||
7: {
|
||||
label: "复审完成",
|
||||
opts: [
|
||||
{ label: "标注中", value: 2 },
|
||||
{ label: "审核中", value: 4 },
|
||||
{ label: "复审中", value: 6 },
|
||||
],
|
||||
},
|
||||
8: {
|
||||
label: "无法标注",
|
||||
opts: [{ label: "标注中", value: 2 }],
|
||||
},
|
||||
}
|
||||
173
app/management/person/collection/detail/InfoSettingContainer.tsx
Normal file
173
app/management/person/collection/detail/InfoSettingContainer.tsx
Normal file
@@ -0,0 +1,173 @@
|
||||
"use client"
|
||||
|
||||
import { projectConfig } from "@/components/label/api/project"
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import { useAllUserStore } from "@/components/label/store/auth"
|
||||
import { Button, Group, Paper, Stack, Switch, Text } from "@mantine/core"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import { useMemo, useState } from "react"
|
||||
import AdminUserModal from "./components/AdminUserModal"
|
||||
import LabelSchemeContainer from "./components/LabelSchemeContainer"
|
||||
import NoteRulesTable from "./components/NoteRulesTable"
|
||||
import SamplingPlanContainer from "./components/SamplingPlanContainer"
|
||||
import TaskStageTabsContainer from "./components/TaskStageTabsContainer"
|
||||
|
||||
export default function InfoSettingContainer(props: {
|
||||
info: ProjectDetail.DataProps | undefined
|
||||
userEnums: {
|
||||
allEnum: Map<any, any>
|
||||
labelEnum: Map<any, any>
|
||||
review1Enum: Map<any, any>
|
||||
review2Enum: Map<any, any>
|
||||
}
|
||||
update: () => void
|
||||
}) {
|
||||
const { info, userEnums, update } = props
|
||||
const projectId = info?.id ?? -1
|
||||
|
||||
const { userOpts } = useAllUserStore()
|
||||
const userOptions = useMemo(() => {
|
||||
return userOpts.map((o) => ({ label: o.label, value: String(o.value) }))
|
||||
}, [userOpts])
|
||||
|
||||
const [adminModalOpen, setAdminModalOpen] = useState(false)
|
||||
const [lockingValue, setLockingValue] = useState<boolean>(
|
||||
!!info?.is_lock_object
|
||||
)
|
||||
const [savingLock, setSavingLock] = useState(false)
|
||||
|
||||
const adminText = useMemo(() => {
|
||||
const adminUids = info?.admin_user ?? []
|
||||
const names = adminUids.map((uid) => {
|
||||
const opt = userOpts.find((o) => o.value === uid)
|
||||
return opt?.label ?? String(uid)
|
||||
})
|
||||
return names.length ? names.join("、") : "-"
|
||||
}, [info?.admin_user, userOpts])
|
||||
|
||||
const saveLock = async () => {
|
||||
if (projectId === -1) return
|
||||
setSavingLock(true)
|
||||
try {
|
||||
await projectConfig({
|
||||
project_id: projectId,
|
||||
is_lock_object: lockingValue,
|
||||
})
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: "已保存配置",
|
||||
})
|
||||
update()
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
} finally {
|
||||
setSavingLock(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack gap="md" style={{ flex: 1, minHeight: 0 }}>
|
||||
<Paper
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="md"
|
||||
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Stack gap="sm">
|
||||
<Group justify="space-between" wrap="wrap">
|
||||
<Text fw={700}>基础配置</Text>
|
||||
<Button size="xs" variant="default" onClick={update}>
|
||||
刷新项目详情
|
||||
</Button>
|
||||
</Group>
|
||||
|
||||
<Group justify="space-between" wrap="wrap">
|
||||
<Stack gap={2}>
|
||||
<Text size="sm" fw={600}>
|
||||
项目管理员
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
{adminText}
|
||||
</Text>
|
||||
</Stack>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="default"
|
||||
onClick={() => setAdminModalOpen(true)}>
|
||||
编辑
|
||||
</Button>
|
||||
</Group>
|
||||
|
||||
<Group justify="space-between" wrap="wrap">
|
||||
<Stack gap={2}>
|
||||
<Text size="sm" fw={600}>
|
||||
图片对象锁定
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
开启后对象可被锁定,避免多人同时标注冲突
|
||||
</Text>
|
||||
</Stack>
|
||||
<Group gap="sm">
|
||||
<Switch
|
||||
checked={lockingValue}
|
||||
onChange={(e) => setLockingValue(e.currentTarget.checked)}
|
||||
/>
|
||||
<Button size="xs" loading={savingLock} onClick={saveLock}>
|
||||
保存
|
||||
</Button>
|
||||
</Group>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
<TaskStageTabsContainer
|
||||
projectId={projectId}
|
||||
info={info}
|
||||
userOptions={userOptions}
|
||||
userEnums={userEnums}
|
||||
onUpdated={update}
|
||||
/>
|
||||
|
||||
<SamplingPlanContainer
|
||||
projectId={projectId}
|
||||
info={info}
|
||||
onUpdated={update}
|
||||
/>
|
||||
|
||||
<LabelSchemeContainer info={info} />
|
||||
|
||||
<NoteRulesTable info={info} />
|
||||
</Stack>
|
||||
|
||||
<AdminUserModal
|
||||
opened={adminModalOpen}
|
||||
value={info?.admin_user ?? []}
|
||||
options={userOptions}
|
||||
onClose={async (next) => {
|
||||
setAdminModalOpen(false)
|
||||
if (!next || projectId === -1) return
|
||||
try {
|
||||
await projectConfig({ project_id: projectId, admin_user: next })
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: "已保存项目管理员",
|
||||
})
|
||||
update()
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,348 @@
|
||||
"use client"
|
||||
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import { getTaskList, taskAcquire } from "@/components/label/api/task"
|
||||
import { Task } from "@/components/label/api/task/typing"
|
||||
import {
|
||||
useBackUrlStore,
|
||||
useOwnTaskStore,
|
||||
usePermissionStore,
|
||||
} from "@/components/label/store/auth"
|
||||
import { OwnTaskStatusOpts } from "@/components/label/utils/constants"
|
||||
import { Button, Group, Paper, Select, Stack, TextInput } from "@mantine/core"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import { IconRefresh } from "@tabler/icons-react"
|
||||
import { DataTable, DataTableColumn } from "mantine-datatable"
|
||||
import { useRouter, useSearchParams } from "next/navigation"
|
||||
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||
import TaskStatusTag from "./components/TaskStatusTag"
|
||||
import { runCommand } from "./util"
|
||||
|
||||
export default function OwnTaskTableContainer(props: {
|
||||
info: ProjectDetail.DataProps | undefined
|
||||
userEnums: {
|
||||
allEnum: Map<any, any>
|
||||
labelEnum: Map<any, any>
|
||||
review1Enum: Map<any, any>
|
||||
review2Enum: Map<any, any>
|
||||
}
|
||||
}) {
|
||||
const { info, userEnums } = props
|
||||
const urlParams = useSearchParams()
|
||||
const id = urlParams.get("id")
|
||||
const type = urlParams.get("type")
|
||||
const projectId =
|
||||
typeof id === "string" && !isNaN(Number(id)) ? Number(id) : -1
|
||||
|
||||
const router = useRouter()
|
||||
const { setBackProps } = useBackUrlStore()
|
||||
const user_id = usePermissionStore((s) => s.user_id)
|
||||
const user_name = usePermissionStore((s) => s.user_name)
|
||||
const user_password = usePermissionStore((s) => s.user_password)
|
||||
|
||||
const { params, total, setParams, resetParams, setPagination, setTotal } =
|
||||
useOwnTaskStore()
|
||||
|
||||
const [form, setForm] = useState<{
|
||||
search_id: string
|
||||
search_status: string
|
||||
}>({
|
||||
search_id: "",
|
||||
search_status: "0",
|
||||
})
|
||||
|
||||
const [records, setRecords] = useState<Task.DataProps[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [queryTrigger, setQueryTrigger] = useState(0)
|
||||
|
||||
const [isLabel, isReview1, isReview2] = useMemo(() => {
|
||||
const uid = typeof user_id === "number" ? user_id : Number(user_id ?? 0)
|
||||
return [
|
||||
userEnums.labelEnum?.has(uid),
|
||||
userEnums.review1Enum?.has(uid),
|
||||
userEnums.review2Enum?.has(uid),
|
||||
]
|
||||
}, [userEnums, user_id])
|
||||
|
||||
const appliedParams = useMemo(() => {
|
||||
const uid = typeof user_id === "number" ? user_id : Number(user_id ?? 0)
|
||||
const next: Task.ListRequest = {
|
||||
...params,
|
||||
page_number: params.page_number ?? 1,
|
||||
page_size: params.page_size ?? 20,
|
||||
current_uid: uid ? [uid] : undefined,
|
||||
project_id: projectId !== -1 ? [projectId] : undefined,
|
||||
get_data: false,
|
||||
}
|
||||
|
||||
if (form.search_id) {
|
||||
const idValue = Number(form.search_id)
|
||||
if (Number.isFinite(idValue)) next.id = [idValue]
|
||||
}
|
||||
if (form.search_status !== "0") {
|
||||
const statusValue = Number(form.search_status)
|
||||
if (Number.isFinite(statusValue)) next.label_status = [statusValue]
|
||||
} else {
|
||||
delete next.label_status
|
||||
}
|
||||
return next
|
||||
}, [form.search_id, form.search_status, params, projectId, user_id])
|
||||
|
||||
const load = useCallback(async () => {
|
||||
if (projectId === -1) return
|
||||
setLoading(true)
|
||||
try {
|
||||
const res = await getTaskList(appliedParams)
|
||||
setRecords(res?.task_list ?? [])
|
||||
setTotal(res?.total_items ?? 0)
|
||||
} catch (e) {
|
||||
setRecords([])
|
||||
setTotal(0)
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "加载失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [appliedParams, projectId, queryTrigger, setTotal])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
const handleAcquireTask = async (label_action: 1 | 2 | 3) => {
|
||||
const uid = typeof user_id === "number" ? user_id : Number(user_id ?? 0)
|
||||
if (!uid || projectId === -1) return
|
||||
try {
|
||||
await taskAcquire({
|
||||
uid,
|
||||
project_id: projectId,
|
||||
label_action,
|
||||
})
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: "领取成功",
|
||||
})
|
||||
setQueryTrigger((v) => v + 1)
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "领取失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const columns = useMemo(() => {
|
||||
const cols: DataTableColumn<Task.DataProps>[] = [
|
||||
{
|
||||
accessor: "id",
|
||||
title: "任务ID",
|
||||
width: 100,
|
||||
render: (record) => (
|
||||
<Button
|
||||
variant="subtle"
|
||||
size="xs"
|
||||
style={{ paddingLeft: 6, paddingRight: 6 }}
|
||||
onClick={async () => {
|
||||
const backUrl = type
|
||||
? `/management/person/collection/detail?id=${projectId}&type=${type}`
|
||||
: `/management/person/collection/detail?id=${projectId}`
|
||||
setBackProps(backUrl, "own")
|
||||
|
||||
if (info && [4, 5, 6].includes(info.label_type)) {
|
||||
router.push(
|
||||
`/label?project_id=${projectId}&task_id=${record.id}`
|
||||
)
|
||||
} else {
|
||||
await runCommand(
|
||||
String(record.id),
|
||||
user_name ?? "",
|
||||
user_password ?? ""
|
||||
)
|
||||
}
|
||||
}}>
|
||||
{record.id}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessor: "label_status",
|
||||
title: "状态",
|
||||
width: 120,
|
||||
render: (record) => (
|
||||
<TaskStatusTag
|
||||
status={record.label_status}
|
||||
rejected={record.rejected}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessor: "label_object_size.object_size",
|
||||
title: "对象总数",
|
||||
width: 110,
|
||||
render: (record) => record.label_object_size?.object_size ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "label_object_size.valid_size",
|
||||
title: "有效数",
|
||||
width: 100,
|
||||
render: (record) => record.label_object_size?.valid_size ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "label_object_size.new_size",
|
||||
title: "新增数",
|
||||
width: 100,
|
||||
render: (record) => record.label_object_size?.new_size ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "label_object_size.prelabel_size",
|
||||
title: "预标注总数",
|
||||
width: 120,
|
||||
render: (record) => record.label_object_size?.prelabel_size ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "label_object_size.prelabel_modify_size",
|
||||
title: "预标注修改数",
|
||||
width: 130,
|
||||
render: (record) =>
|
||||
record.label_object_size?.prelabel_modify_size ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "label_object_size.first_comment_size",
|
||||
title: "批注一轮",
|
||||
width: 110,
|
||||
render: (record) => record.label_object_size?.first_comment_size ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "label_object_size.second_comment_size",
|
||||
title: "批注二轮",
|
||||
width: 110,
|
||||
render: (record) =>
|
||||
record.label_object_size?.second_comment_size ?? "-",
|
||||
},
|
||||
]
|
||||
return cols
|
||||
}, [info, projectId, router, setBackProps, type, user_name, user_password])
|
||||
|
||||
return (
|
||||
<Stack gap="sm" style={{ flex: 1, minHeight: 0 }}>
|
||||
<Paper
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="md"
|
||||
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Group justify="space-between" wrap="wrap" gap="sm">
|
||||
<Group gap="sm" wrap="wrap">
|
||||
<TextInput
|
||||
size="xs"
|
||||
label="任务ID"
|
||||
value={form.search_id}
|
||||
onChange={(e) =>
|
||||
setForm((s) => ({ ...s, search_id: e.currentTarget.value }))
|
||||
}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
<Select
|
||||
size="xs"
|
||||
label="状态"
|
||||
data={Object.entries(OwnTaskStatusOpts).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))}
|
||||
value={form.search_status}
|
||||
onChange={(v) =>
|
||||
setForm((s) => ({ ...s, search_status: v ?? "0" }))
|
||||
}
|
||||
allowDeselect={false}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
<Button
|
||||
size="xs"
|
||||
leftSection={<IconRefresh size={16} />}
|
||||
loading={loading}
|
||||
onClick={() => {
|
||||
setPagination(1, params.page_size ?? 20)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}>
|
||||
刷新
|
||||
</Button>
|
||||
</Group>
|
||||
|
||||
<Group gap="xs" wrap="wrap">
|
||||
<Button
|
||||
size="xs"
|
||||
variant="default"
|
||||
disabled={!isLabel}
|
||||
onClick={() => handleAcquireTask(1)}>
|
||||
领取标注
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="default"
|
||||
disabled={!isReview1}
|
||||
onClick={() => handleAcquireTask(2)}>
|
||||
领取审核
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="default"
|
||||
disabled={!isReview2}
|
||||
onClick={() => handleAcquireTask(3)}>
|
||||
领取复审
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="default"
|
||||
onClick={() => {
|
||||
resetParams()
|
||||
setForm({ search_id: "", search_status: "0" })
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}>
|
||||
重置
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
onClick={() => {
|
||||
setPagination(1, params.page_size ?? 20)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}>
|
||||
查询
|
||||
</Button>
|
||||
</Group>
|
||||
</Group>
|
||||
</Paper>
|
||||
|
||||
<Group gap={0} align="stretch" style={{ flex: 1, minHeight: 0 }}>
|
||||
<DataTable<Task.DataProps>
|
||||
width="100%"
|
||||
style={{ width: "100%" }}
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
pinFirstColumn
|
||||
pinLastColumn
|
||||
scrollAreaProps={{ type: "auto" }}
|
||||
fetching={loading}
|
||||
records={records}
|
||||
columns={columns}
|
||||
totalRecords={total}
|
||||
recordsPerPage={params.page_size ?? 20}
|
||||
page={params.page_number ?? 1}
|
||||
onPageChange={(p) => {
|
||||
setPagination(p, params.page_size ?? 20)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
onRecordsPerPageChange={(s) => {
|
||||
setPagination(1, s)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
recordsPerPageOptions={[10, 20, 50, 100]}
|
||||
noRecordsText="暂无数据"
|
||||
/>
|
||||
</Group>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
"use client"
|
||||
|
||||
import { Paper, Stack, Text } from "@mantine/core"
|
||||
|
||||
export default function TaskBoardContainer() {
|
||||
return (
|
||||
<Paper
|
||||
withBorder
|
||||
p="md"
|
||||
radius="md"
|
||||
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Stack gap="xs">
|
||||
<Text fw={700}>统计信息</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
暂未迁移统计看板,可在后续按需补齐。
|
||||
</Text>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
324
app/management/person/collection/detail/TaskTableContainer.tsx
Normal file
324
app/management/person/collection/detail/TaskTableContainer.tsx
Normal file
@@ -0,0 +1,324 @@
|
||||
"use client"
|
||||
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import { getTaskList } from "@/components/label/api/task"
|
||||
import { Task } from "@/components/label/api/task/typing"
|
||||
import {
|
||||
useAllTaskStore,
|
||||
usePermissionStore,
|
||||
} from "@/components/label/store/auth"
|
||||
import { TaskStatusOpts } from "@/components/label/utils/constants"
|
||||
import {
|
||||
ActionIcon,
|
||||
Button,
|
||||
Group,
|
||||
Paper,
|
||||
Select,
|
||||
Stack,
|
||||
TextInput,
|
||||
} from "@mantine/core"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import {
|
||||
IconArrowsShuffle,
|
||||
IconRefresh,
|
||||
IconRoute,
|
||||
IconTrashX,
|
||||
} from "@tabler/icons-react"
|
||||
import { DataTable, DataTableColumn } from "mantine-datatable"
|
||||
import { useSearchParams } from "next/navigation"
|
||||
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||
import DispatchModal from "./components/DispatchModal"
|
||||
import ReleaseModal from "./components/ReleaseModal"
|
||||
import TaskStatusTag from "./components/TaskStatusTag"
|
||||
import WorkflowModal from "./components/WorkflowModal"
|
||||
|
||||
export default function TaskTableContainer(props: {
|
||||
info: ProjectDetail.DataProps | undefined
|
||||
userEnums: {
|
||||
allEnum: Map<any, any>
|
||||
labelEnum: Map<any, any>
|
||||
review1Enum: Map<any, any>
|
||||
review2Enum: Map<any, any>
|
||||
}
|
||||
}) {
|
||||
const { info, userEnums } = props
|
||||
const urlParams = useSearchParams()
|
||||
const id = urlParams.get("id")
|
||||
const projectId =
|
||||
typeof id === "string" && !isNaN(Number(id)) ? Number(id) : -1
|
||||
|
||||
const currentUid = usePermissionStore((s) => s.user_id)
|
||||
const { params, total, setPagination, resetParams, setTotal } =
|
||||
useAllTaskStore()
|
||||
|
||||
const [form, setForm] = useState<{
|
||||
search_id: string
|
||||
search_status: string
|
||||
}>({
|
||||
search_id: "",
|
||||
search_status: "0",
|
||||
})
|
||||
|
||||
const [records, setRecords] = useState<Task.DataProps[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [queryTrigger, setQueryTrigger] = useState(0)
|
||||
|
||||
const [workflowTaskId, setWorkflowTaskId] = useState<number | null>(null)
|
||||
const [dispatchRecord, setDispatchRecord] = useState<Task.DataProps | null>(
|
||||
null
|
||||
)
|
||||
const [releaseRecord, setReleaseRecord] = useState<Task.DataProps | null>(
|
||||
null
|
||||
)
|
||||
|
||||
const userOptions = useMemo(() => {
|
||||
const arr: Array<{ label: string; value: string }> = []
|
||||
userEnums.allEnum?.forEach((label, value) => {
|
||||
arr.push({ label: String(label), value: String(value) })
|
||||
})
|
||||
return arr
|
||||
}, [userEnums.allEnum])
|
||||
|
||||
const appliedParams = useMemo(() => {
|
||||
const obj: Task.ListRequest = {
|
||||
...params,
|
||||
page_number: params.page_number ?? 1,
|
||||
page_size: params.page_size ?? 20,
|
||||
project_id: projectId !== -1 ? [projectId] : undefined,
|
||||
get_data: false,
|
||||
}
|
||||
if (form.search_id) {
|
||||
const idValue = Number(form.search_id)
|
||||
if (Number.isFinite(idValue)) obj.id = [idValue]
|
||||
}
|
||||
if (form.search_status !== "0") {
|
||||
const statusValue = Number(form.search_status)
|
||||
if (Number.isFinite(statusValue)) obj.label_status = [statusValue]
|
||||
} else {
|
||||
delete obj.label_status
|
||||
}
|
||||
return obj
|
||||
}, [form.search_id, form.search_status, params, projectId])
|
||||
|
||||
const load = useCallback(async () => {
|
||||
if (projectId === -1) return
|
||||
setLoading(true)
|
||||
try {
|
||||
const res = await getTaskList(appliedParams)
|
||||
setRecords(res?.task_list ?? [])
|
||||
setTotal(res?.total_items ?? 0)
|
||||
} catch (e) {
|
||||
setRecords([])
|
||||
setTotal(0)
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "加载失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [appliedParams, projectId, queryTrigger, setTotal])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
const columns = useMemo(() => {
|
||||
const cols: DataTableColumn<Task.DataProps>[] = [
|
||||
{ accessor: "id", title: "任务ID", width: 90 },
|
||||
{
|
||||
accessor: "label_status",
|
||||
title: "状态",
|
||||
width: 130,
|
||||
render: (record) => (
|
||||
<TaskStatusTag
|
||||
status={record.label_status}
|
||||
rejected={record.rejected}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessor: "current_username",
|
||||
title: "当前处理人",
|
||||
width: 120,
|
||||
render: (record) => record.current_username ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "label_username",
|
||||
title: "标注员",
|
||||
width: 120,
|
||||
render: (record) => record.label_username ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "review1_username",
|
||||
title: "审核员",
|
||||
width: 120,
|
||||
render: (record) => record.review1_username ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "review2_username",
|
||||
title: "复审员",
|
||||
width: 120,
|
||||
render: (record) => record.review2_username ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "label_object_size.object_size",
|
||||
title: "对象总数",
|
||||
width: 110,
|
||||
render: (record) => record.label_object_size?.object_size ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "operation",
|
||||
title: "操作",
|
||||
width: 140,
|
||||
textAlign: "center",
|
||||
render: (record) => (
|
||||
<Group gap={6} justify="center" wrap="nowrap">
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="blue"
|
||||
onClick={() => setWorkflowTaskId(record.id)}
|
||||
title="工作流">
|
||||
<IconRoute size={16} />
|
||||
</ActionIcon>
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="violet"
|
||||
onClick={() => setDispatchRecord(record)}
|
||||
title="调度">
|
||||
<IconArrowsShuffle size={16} />
|
||||
</ActionIcon>
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="red"
|
||||
onClick={() => setReleaseRecord(record)}
|
||||
title="释放">
|
||||
<IconTrashX size={16} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
),
|
||||
},
|
||||
]
|
||||
return cols
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack gap="sm" style={{ flex: 1, minHeight: 0 }}>
|
||||
<Paper
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="md"
|
||||
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Group justify="space-between" wrap="wrap" gap="sm">
|
||||
<Group gap="sm" wrap="wrap">
|
||||
<TextInput
|
||||
size="xs"
|
||||
label="任务ID"
|
||||
value={form.search_id}
|
||||
onChange={(e) =>
|
||||
setForm((s) => ({ ...s, search_id: e.currentTarget.value }))
|
||||
}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
<Select
|
||||
size="xs"
|
||||
label="状态"
|
||||
data={Object.entries(TaskStatusOpts).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}))}
|
||||
value={form.search_status}
|
||||
onChange={(v) =>
|
||||
setForm((s) => ({ ...s, search_status: v ?? "0" }))
|
||||
}
|
||||
allowDeselect={false}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
<Button
|
||||
size="xs"
|
||||
leftSection={<IconRefresh size={16} />}
|
||||
loading={loading}
|
||||
onClick={() => setQueryTrigger((v) => v + 1)}>
|
||||
刷新
|
||||
</Button>
|
||||
</Group>
|
||||
|
||||
<Group gap="xs" wrap="wrap">
|
||||
<Button
|
||||
size="xs"
|
||||
variant="default"
|
||||
onClick={() => {
|
||||
resetParams()
|
||||
setForm({ search_id: "", search_status: "0" })
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}>
|
||||
重置
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
onClick={() => {
|
||||
setPagination(1, params.page_size ?? 20)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}>
|
||||
查询
|
||||
</Button>
|
||||
</Group>
|
||||
</Group>
|
||||
</Paper>
|
||||
|
||||
<Group gap={0} align="stretch" style={{ flex: 1, minHeight: 0 }}>
|
||||
<DataTable<Task.DataProps>
|
||||
width="100%"
|
||||
style={{ width: "100%" }}
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
pinFirstColumn
|
||||
pinLastColumn
|
||||
scrollAreaProps={{ type: "auto" }}
|
||||
fetching={loading}
|
||||
records={records}
|
||||
columns={columns}
|
||||
totalRecords={total}
|
||||
recordsPerPage={params.page_size ?? 20}
|
||||
page={params.page_number ?? 1}
|
||||
onPageChange={(p) => {
|
||||
setPagination(p, params.page_size ?? 20)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
onRecordsPerPageChange={(s) => {
|
||||
setPagination(1, s)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
recordsPerPageOptions={[10, 20, 50, 100]}
|
||||
noRecordsText="暂无数据"
|
||||
/>
|
||||
</Group>
|
||||
</Stack>
|
||||
|
||||
<WorkflowModal
|
||||
opened={workflowTaskId !== null}
|
||||
taskId={workflowTaskId}
|
||||
onClose={() => setWorkflowTaskId(null)}
|
||||
/>
|
||||
<DispatchModal
|
||||
opened={dispatchRecord !== null}
|
||||
record={dispatchRecord}
|
||||
userOptions={userOptions}
|
||||
onClose={(refresh) => {
|
||||
setDispatchRecord(null)
|
||||
if (refresh) setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
/>
|
||||
<ReleaseModal
|
||||
opened={releaseRecord !== null}
|
||||
record={releaseRecord}
|
||||
onClose={(refresh) => {
|
||||
setReleaseRecord(null)
|
||||
if (refresh) setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
"use client"
|
||||
|
||||
import { Button, Group, Modal, MultiSelect, Stack } from "@mantine/core"
|
||||
import { useEffect } from "react"
|
||||
import { useForm } from "@mantine/form"
|
||||
|
||||
export default function AdminUserModal(props: {
|
||||
opened: boolean
|
||||
value: number[]
|
||||
options: Array<{ label: string; value: string }>
|
||||
onClose: (next?: number[]) => void
|
||||
}) {
|
||||
const { opened, value, options, onClose } = props
|
||||
|
||||
const form = useForm({
|
||||
initialValues: { users: value.map(String) },
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!opened) return
|
||||
form.setValues({ users: value.map(String) })
|
||||
form.resetDirty()
|
||||
}, [opened, value, form])
|
||||
|
||||
return (
|
||||
<Modal opened={opened} onClose={() => onClose()} title="编辑项目管理员" centered size={560}>
|
||||
<form
|
||||
onSubmit={form.onSubmit((values) => {
|
||||
const next = values.users
|
||||
.map((v) => Number(v))
|
||||
.filter((v) => Number.isFinite(v))
|
||||
onClose(next)
|
||||
})}>
|
||||
<Stack gap="sm">
|
||||
<MultiSelect
|
||||
label="项目管理员"
|
||||
data={options}
|
||||
searchable
|
||||
clearable
|
||||
value={form.values.users}
|
||||
onChange={(v) => form.setFieldValue("users", v)}
|
||||
/>
|
||||
<Group justify="flex-end" gap="sm">
|
||||
<Button variant="default" onClick={() => onClose()}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit">保存</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
"use client"
|
||||
|
||||
import { taskDispatch } from "@/components/label/api/task"
|
||||
import { Task } from "@/components/label/api/task/typing"
|
||||
import { usePermissionStore } from "@/components/label/store/auth"
|
||||
import { Button, Group, Modal, Select, Stack, Switch, Text } from "@mantine/core"
|
||||
import { useForm } from "@mantine/form"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import { dispatchOpts } from "../../config"
|
||||
|
||||
export default function DispatchModal(props: {
|
||||
opened: boolean
|
||||
record: Task.DataProps | null
|
||||
userOptions: Array<{ label: string; value: string }>
|
||||
onClose: (refresh?: boolean) => void
|
||||
}) {
|
||||
const { opened, record, userOptions, onClose } = props
|
||||
const operation_uid = usePermissionStore((s) => s.user_id)
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
reject: false,
|
||||
task_status_dst: "",
|
||||
uid_dst: "",
|
||||
},
|
||||
})
|
||||
|
||||
const taskStatusSrc = record?.label_status ?? 0
|
||||
const dstOptions =
|
||||
dispatchOpts[taskStatusSrc]?.opts?.map((o) => ({
|
||||
label: o.label,
|
||||
value: String(o.value),
|
||||
})) ?? []
|
||||
|
||||
return (
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={() => onClose()}
|
||||
title="调度任务"
|
||||
centered
|
||||
size={520}>
|
||||
<form
|
||||
onSubmit={form.onSubmit(async (values) => {
|
||||
const opUid = typeof operation_uid === "number" ? operation_uid : Number(operation_uid ?? 0)
|
||||
if (!record?.id || !opUid) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: "缺少必要参数",
|
||||
})
|
||||
return
|
||||
}
|
||||
const taskStatusDst = Number(values.task_status_dst)
|
||||
if (!Number.isFinite(taskStatusDst)) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "校验失败",
|
||||
message: "请选择目标状态",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const uidDst = values.uid_dst ? Number(values.uid_dst) : null
|
||||
if (values.uid_dst && !Number.isFinite(uidDst)) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "校验失败",
|
||||
message: "请选择目标人员",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await taskDispatch({
|
||||
operation_uid: opUid,
|
||||
reject: values.reject,
|
||||
task_ids: [record.id],
|
||||
task_status_src: taskStatusSrc,
|
||||
task_status_dst: taskStatusDst,
|
||||
uid_src: record.current_uid ?? null,
|
||||
uid_dst: uidDst,
|
||||
})
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: "已调度任务",
|
||||
})
|
||||
onClose(true)
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
}
|
||||
})}>
|
||||
<Stack gap="sm">
|
||||
<Text size="sm" c="dimmed">
|
||||
当前任务:{record?.id ?? "-"}(源状态:{taskStatusSrc})
|
||||
</Text>
|
||||
|
||||
<Select
|
||||
label="目标状态"
|
||||
data={dstOptions}
|
||||
searchable
|
||||
clearable
|
||||
value={form.values.task_status_dst}
|
||||
onChange={(v) => form.setFieldValue("task_status_dst", v ?? "")}
|
||||
/>
|
||||
|
||||
<Select
|
||||
label="目标人员"
|
||||
data={userOptions}
|
||||
searchable
|
||||
clearable
|
||||
value={form.values.uid_dst}
|
||||
onChange={(v) => form.setFieldValue("uid_dst", v ?? "")}
|
||||
/>
|
||||
|
||||
<Switch
|
||||
label="是否返工"
|
||||
checked={form.values.reject}
|
||||
onChange={(e) => form.setFieldValue("reject", e.currentTarget.checked)}
|
||||
/>
|
||||
|
||||
<Group justify="flex-end" gap="sm">
|
||||
<Button variant="default" onClick={() => onClose()}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit">确定</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
"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<ProjectDetail.LabelSchemaList>[] = [
|
||||
{ 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 (
|
||||
<Group gap={8} wrap="nowrap">
|
||||
<div
|
||||
style={{
|
||||
width: 14,
|
||||
height: 14,
|
||||
borderRadius: 4,
|
||||
background: bg,
|
||||
border: "1px solid rgba(0,0,0,0.12)",
|
||||
}}
|
||||
/>
|
||||
<Text size="sm">
|
||||
{color.length >= 3 ? `${color[0]},${color[1]},${color[2]}` : "-"}
|
||||
</Text>
|
||||
</Group>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
accessor: "label_type",
|
||||
title: "类型",
|
||||
width: 90,
|
||||
render: (record) => <Badge variant="light">{record.label_type}</Badge>,
|
||||
},
|
||||
{
|
||||
accessor: "sub_attributes",
|
||||
title: "子属性",
|
||||
width: 240,
|
||||
render: (record) => (
|
||||
<Text
|
||||
size="sm"
|
||||
style={{
|
||||
maxWidth: 240,
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
whiteSpace: "nowrap",
|
||||
}}>
|
||||
{(record.sub_attributes ?? []).join("、") || "-"}
|
||||
</Text>
|
||||
),
|
||||
},
|
||||
]
|
||||
return cols
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<Paper withBorder p="sm" radius="md" style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Stack gap="sm">
|
||||
<Text fw={700}>标注方案</Text>
|
||||
<DataTable<ProjectDetail.LabelSchemaList>
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
records={schemas}
|
||||
columns={columns}
|
||||
minHeight={160}
|
||||
noRecordsText="暂无数据"
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
"use client"
|
||||
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import { List, Paper, Stack, Text } from "@mantine/core"
|
||||
|
||||
export default function NoteRulesTable(props: {
|
||||
info: ProjectDetail.DataProps | undefined
|
||||
}) {
|
||||
const rules = props.info?.comment_rule
|
||||
const textRules = rules?.text_rules ?? []
|
||||
const checkBoxRules = rules?.check_box_rules ?? []
|
||||
|
||||
return (
|
||||
<Paper withBorder p="sm" radius="md" style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Stack gap="xs">
|
||||
<Text fw={700}>批注规则</Text>
|
||||
|
||||
<Stack gap={4}>
|
||||
<Text size="sm" fw={600}>
|
||||
文本规则
|
||||
</Text>
|
||||
{textRules.length ? (
|
||||
<List size="sm" spacing={4}>
|
||||
{textRules.map((r, idx) => (
|
||||
<List.Item key={idx}>{r}</List.Item>
|
||||
))}
|
||||
</List>
|
||||
) : (
|
||||
<Text size="sm" c="dimmed">
|
||||
-
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
<Stack gap={4}>
|
||||
<Text size="sm" fw={600}>
|
||||
勾选规则
|
||||
</Text>
|
||||
{checkBoxRules.length ? (
|
||||
<List size="sm" spacing={4}>
|
||||
{checkBoxRules.map((r, idx) => (
|
||||
<List.Item key={idx}>{String(r)}</List.Item>
|
||||
))}
|
||||
</List>
|
||||
) : (
|
||||
<Text size="sm" c="dimmed">
|
||||
-
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"use client"
|
||||
|
||||
import { taskRelease } from "@/components/label/api/task"
|
||||
import { Task } from "@/components/label/api/task/typing"
|
||||
import { usePermissionStore } from "@/components/label/store/auth"
|
||||
import { Button, Group, Modal, Stack, Switch, Text } from "@mantine/core"
|
||||
import { useForm } from "@mantine/form"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
|
||||
export default function ReleaseModal(props: {
|
||||
opened: boolean
|
||||
record: Task.DataProps | null
|
||||
onClose: (refresh?: boolean) => void
|
||||
}) {
|
||||
const { opened, record, onClose } = props
|
||||
const operation_uid = usePermissionStore((s) => s.user_id)
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
reject: false,
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={() => onClose()}
|
||||
title="释放任务"
|
||||
centered
|
||||
size={520}>
|
||||
<form
|
||||
onSubmit={form.onSubmit(async (values) => {
|
||||
const opUid = typeof operation_uid === "number" ? operation_uid : Number(operation_uid ?? 0)
|
||||
if (!record?.id || !opUid || !record.current_uid) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: "缺少必要参数",
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
await taskRelease({
|
||||
operation_uid: opUid,
|
||||
reject: values.reject,
|
||||
task_ids: [record.id],
|
||||
task_status: record.label_status,
|
||||
uid: record.current_uid,
|
||||
})
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: "已释放任务",
|
||||
})
|
||||
onClose(true)
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
}
|
||||
})}>
|
||||
<Stack gap="sm">
|
||||
<Text size="sm" c="dimmed">
|
||||
当前任务:{record?.id ?? "-"}(状态:{record?.label_status ?? "-"})
|
||||
</Text>
|
||||
<Switch
|
||||
label="是否返工"
|
||||
checked={form.values.reject}
|
||||
onChange={(e) => form.setFieldValue("reject", e.currentTarget.checked)}
|
||||
/>
|
||||
<Group justify="flex-end" gap="sm">
|
||||
<Button variant="default" onClick={() => onClose()}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit" color="red">
|
||||
确定释放
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
"use client"
|
||||
|
||||
import { projectConfig } from "@/components/label/api/project"
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import { Button, Checkbox, Group, NumberInput, Paper, SimpleGrid, Stack, Text } from "@mantine/core"
|
||||
import { useForm } from "@mantine/form"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import { useEffect } from "react"
|
||||
|
||||
type GradeKey = "A" | "B" | "C"
|
||||
|
||||
export default function SamplingPlanContainer(props: {
|
||||
projectId: number
|
||||
info: ProjectDetail.DataProps | undefined
|
||||
onUpdated: () => void
|
||||
}) {
|
||||
const { projectId, info, onUpdated } = props
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
check_task: false,
|
||||
check_frame: false,
|
||||
A_task: 0,
|
||||
A_frame: 0,
|
||||
B_task: 0,
|
||||
B_frame: 0,
|
||||
C_task: 0,
|
||||
C_frame: 0,
|
||||
},
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!info) return
|
||||
const grade = info.user_grade ?? ({} as any)
|
||||
const toPercent = (v?: number) => Number(((v ?? 0) * 100).toFixed(2))
|
||||
form.setValues({
|
||||
check_task: !!info.check_task,
|
||||
check_frame: !!info.check_frame,
|
||||
A_task: toPercent(grade.A?.task),
|
||||
A_frame: toPercent(grade.A?.frame),
|
||||
B_task: toPercent(grade.B?.task),
|
||||
B_frame: toPercent(grade.B?.frame),
|
||||
C_task: toPercent(grade.C?.task),
|
||||
C_frame: toPercent(grade.C?.frame),
|
||||
})
|
||||
form.resetDirty()
|
||||
}, [info, form])
|
||||
|
||||
const save = async () => {
|
||||
try {
|
||||
const toRatio = (v: number) => Number((v / 100).toFixed(4))
|
||||
await projectConfig({
|
||||
project_id: projectId,
|
||||
check_task: form.values.check_task,
|
||||
check_frame: form.values.check_frame,
|
||||
user_grade: {
|
||||
A: { task: toRatio(form.values.A_task), frame: toRatio(form.values.A_frame) },
|
||||
B: { task: toRatio(form.values.B_task), frame: toRatio(form.values.B_frame) },
|
||||
C: { task: toRatio(form.values.C_task), frame: toRatio(form.values.C_frame) },
|
||||
},
|
||||
})
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: "已保存抽检配置",
|
||||
})
|
||||
onUpdated()
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Paper withBorder p="sm" radius="md" style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Stack gap="sm">
|
||||
<Group justify="space-between" wrap="wrap">
|
||||
<Text fw={700}>抽检方案</Text>
|
||||
<Button size="xs" onClick={save}>
|
||||
保存
|
||||
</Button>
|
||||
</Group>
|
||||
|
||||
<Group gap="md" wrap="wrap">
|
||||
<Checkbox
|
||||
label="抽检任务"
|
||||
checked={form.values.check_task}
|
||||
onChange={(e) => form.setFieldValue("check_task", e.currentTarget.checked)}
|
||||
/>
|
||||
<Checkbox
|
||||
label="抽检帧"
|
||||
checked={form.values.check_frame}
|
||||
onChange={(e) => form.setFieldValue("check_frame", e.currentTarget.checked)}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
<SimpleGrid cols={{ base: 1, sm: 3 }} spacing="sm">
|
||||
{(["A", "B", "C"] as GradeKey[]).map((g) => (
|
||||
<Paper
|
||||
key={g}
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="md"
|
||||
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Stack gap="xs">
|
||||
<Text fw={600}>等级 {g}</Text>
|
||||
<NumberInput
|
||||
label="任务抽检比例(%)"
|
||||
min={0}
|
||||
max={100}
|
||||
decimalScale={2}
|
||||
value={form.values[`${g}_task` as const]}
|
||||
onChange={(v) => form.setFieldValue(`${g}_task` as any, Number(v ?? 0))}
|
||||
hideControls
|
||||
/>
|
||||
<NumberInput
|
||||
label="帧抽检比例(%)"
|
||||
min={0}
|
||||
max={100}
|
||||
decimalScale={2}
|
||||
value={form.values[`${g}_frame` as const]}
|
||||
onChange={(v) => form.setFieldValue(`${g}_frame` as any, Number(v ?? 0))}
|
||||
hideControls
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
"use client"
|
||||
|
||||
import { Button, Group, Modal, MultiSelect, Stack } from "@mantine/core"
|
||||
import { useForm } from "@mantine/form"
|
||||
import { useEffect } from "react"
|
||||
|
||||
export default function StageUserModal(props: {
|
||||
opened: boolean
|
||||
title: string
|
||||
value: number[]
|
||||
options: Array<{ label: string; value: string }>
|
||||
onClose: (next?: number[]) => void
|
||||
}) {
|
||||
const { opened, title, value, options, onClose } = props
|
||||
|
||||
const form = useForm({
|
||||
initialValues: { users: value.map(String) },
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!opened) return
|
||||
form.setValues({ users: value.map(String) })
|
||||
form.resetDirty()
|
||||
}, [opened, value, form])
|
||||
|
||||
return (
|
||||
<Modal opened={opened} onClose={() => onClose()} title={title} centered size={560}>
|
||||
<form
|
||||
onSubmit={form.onSubmit((values) => {
|
||||
const next = values.users
|
||||
.map((v) => Number(v))
|
||||
.filter((v) => Number.isFinite(v))
|
||||
onClose(next)
|
||||
})}>
|
||||
<Stack gap="sm">
|
||||
<MultiSelect
|
||||
label="人员"
|
||||
data={options}
|
||||
searchable
|
||||
clearable
|
||||
value={form.values.users}
|
||||
onChange={(v) => form.setFieldValue("users", v)}
|
||||
/>
|
||||
<Group justify="flex-end" gap="sm">
|
||||
<Button variant="default" onClick={() => onClose()}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit">保存</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
"use client"
|
||||
|
||||
import { projectConfig } from "@/components/label/api/project"
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import { Button, Group, Paper, Stack, Text } from "@mantine/core"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import { useMemo, useState } from "react"
|
||||
import StageUserModal from "./StageUserModal"
|
||||
|
||||
type StageKey = "label" | "review1" | "review2"
|
||||
|
||||
function stageTitle(stage: StageKey) {
|
||||
if (stage === "label") return "标注阶段"
|
||||
if (stage === "review1") return "审核阶段"
|
||||
return "复审阶段"
|
||||
}
|
||||
|
||||
function stageAction(stage: StageKey) {
|
||||
if (stage === "label") return 1
|
||||
if (stage === "review1") return 2
|
||||
return 3
|
||||
}
|
||||
|
||||
export default function TaskStageTabsContainer(props: {
|
||||
projectId: number
|
||||
info: ProjectDetail.DataProps | undefined
|
||||
userOptions: Array<{ label: string; value: string }>
|
||||
userEnums: {
|
||||
allEnum: Map<any, any>
|
||||
labelEnum: Map<any, any>
|
||||
review1Enum: Map<any, any>
|
||||
review2Enum: Map<any, any>
|
||||
}
|
||||
onUpdated: () => void
|
||||
}) {
|
||||
const { projectId, info, userOptions, userEnums, onUpdated } = props
|
||||
|
||||
const stageUsers = useMemo(() => {
|
||||
const detail = info?.label_process?.step_detail ?? []
|
||||
const findUsers = (action: number) => {
|
||||
const item = detail.find((d) => d.action === action)
|
||||
return (item?.user_list ?? []) as number[]
|
||||
}
|
||||
return {
|
||||
label: findUsers(1),
|
||||
review1: findUsers(2),
|
||||
review2: findUsers(3),
|
||||
}
|
||||
}, [info])
|
||||
|
||||
const [editingStage, setEditingStage] = useState<StageKey | null>(null)
|
||||
|
||||
const currentStageValue = useMemo(() => {
|
||||
if (!editingStage) return []
|
||||
return stageUsers[editingStage] ?? []
|
||||
}, [editingStage, stageUsers])
|
||||
|
||||
const saveStageUsers = async (stage: StageKey, users: number[]) => {
|
||||
try {
|
||||
if (stage === "label") {
|
||||
await projectConfig({ project_id: projectId, label_users: users })
|
||||
} else if (stage === "review1") {
|
||||
await projectConfig({ project_id: projectId, review1_users: users })
|
||||
} else {
|
||||
await projectConfig({ project_id: projectId, review2_users: users })
|
||||
}
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: "已保存阶段人员",
|
||||
})
|
||||
onUpdated()
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const renderUsersText = (uids: number[]) => {
|
||||
const names = uids.map((uid) => {
|
||||
const name = userEnums.allEnum.get(uid)
|
||||
return name ? String(name) : String(uid)
|
||||
})
|
||||
return names.length ? names.join("、") : "-"
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Paper withBorder p="sm" radius="md" style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Stack gap="sm">
|
||||
<Text fw={700}>任务工序配置</Text>
|
||||
<Group gap="sm" align="stretch" wrap="wrap">
|
||||
{(["label", "review1", "review2"] as StageKey[]).map((stage) => (
|
||||
<Paper
|
||||
key={stage}
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="md"
|
||||
style={{
|
||||
borderColor: "rgba(0,0,0,0.06)",
|
||||
flex: "1 1 260px",
|
||||
minWidth: 260,
|
||||
}}>
|
||||
<Stack gap="xs">
|
||||
<Group justify="space-between" wrap="wrap">
|
||||
<Text fw={600}>{stageTitle(stage)}</Text>
|
||||
<Button size="xs" variant="default" onClick={() => setEditingStage(stage)}>
|
||||
编辑人员
|
||||
</Button>
|
||||
</Group>
|
||||
<Text size="sm" c="dimmed">
|
||||
{renderUsersText(stageUsers[stage] ?? [])}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Paper>
|
||||
))}
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
<StageUserModal
|
||||
opened={editingStage !== null}
|
||||
title={editingStage ? `${stageTitle(editingStage)}-人员配置` : "人员配置"}
|
||||
value={currentStageValue}
|
||||
options={userOptions}
|
||||
onClose={async (next) => {
|
||||
const stage = editingStage
|
||||
setEditingStage(null)
|
||||
if (!stage || !next) return
|
||||
await saveStageUsers(stage, next)
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
"use client"
|
||||
|
||||
import { TaskStatusEnum } from "@/components/label/utils/constants"
|
||||
import { Badge, Group } from "@mantine/core"
|
||||
import { useMemo } from "react"
|
||||
|
||||
function statusColor(status?: number | null) {
|
||||
switch (status) {
|
||||
case 1:
|
||||
return "yellow"
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
return "blue"
|
||||
case 3:
|
||||
case 5:
|
||||
case 7:
|
||||
return "green"
|
||||
case 8:
|
||||
return "red"
|
||||
default:
|
||||
return "gray"
|
||||
}
|
||||
}
|
||||
|
||||
export default function TaskStatusTag(props: {
|
||||
status: number
|
||||
rejected?: boolean
|
||||
center?: boolean
|
||||
}) {
|
||||
const text = useMemo(() => TaskStatusEnum.get(props.status) || "默认", [props.status])
|
||||
return (
|
||||
<Group gap={6} justify={props.center ? "center" : "flex-start"} wrap="nowrap">
|
||||
<Badge color={statusColor(props.status)} size="sm">
|
||||
{text}
|
||||
</Badge>
|
||||
{props.rejected ? (
|
||||
<Badge variant="outline" color="yellow" size="sm">
|
||||
返工
|
||||
</Badge>
|
||||
) : null}
|
||||
</Group>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
"use client"
|
||||
|
||||
import { getTaskWorkFlow } from "@/components/label/api/task"
|
||||
import { Button, Group, Modal, ScrollArea, Stack, Text } from "@mantine/core"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
export default function WorkflowModal(props: {
|
||||
opened: boolean
|
||||
taskId: number | null
|
||||
onClose: () => void
|
||||
}) {
|
||||
const { opened, taskId, onClose } = props
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [records, setRecords] = useState<any[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
if (!opened || !taskId) return
|
||||
const run = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
const res = await getTaskWorkFlow(taskId)
|
||||
setRecords(res ?? [])
|
||||
} catch (e) {
|
||||
setRecords([])
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "加载失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
run()
|
||||
}, [opened, taskId])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={onClose}
|
||||
title="工作流"
|
||||
centered
|
||||
size={720}>
|
||||
<Stack gap="sm">
|
||||
<ScrollArea h={360} type="auto">
|
||||
<Stack gap="xs">
|
||||
{records.length ? (
|
||||
records.map((r, idx) => (
|
||||
<Text
|
||||
key={idx}
|
||||
size="sm"
|
||||
style={{
|
||||
fontFamily:
|
||||
"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace",
|
||||
whiteSpace: "pre-wrap",
|
||||
wordBreak: "break-word",
|
||||
background: "rgba(0,0,0,0.03)",
|
||||
borderRadius: 6,
|
||||
padding: 10,
|
||||
}}>
|
||||
{JSON.stringify(r, null, 2)}
|
||||
</Text>
|
||||
))
|
||||
) : (
|
||||
<Text size="sm" c="dimmed">
|
||||
{loading ? "加载中..." : "暂无数据"}
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
</ScrollArea>
|
||||
<Group justify="flex-end">
|
||||
<Button variant="default" onClick={onClose}>
|
||||
关闭
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
72
app/management/person/collection/detail/components/config.ts
Normal file
72
app/management/person/collection/detail/components/config.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
type FormItemProps = {
|
||||
label: string
|
||||
name: string
|
||||
type: "input" | "select" | "radio"
|
||||
options?: Array<{ label: any; value: any }>
|
||||
}
|
||||
|
||||
const monthOpt = Array.from({ length: 12 }).map((_, idx) => {
|
||||
const n = idx + 1
|
||||
return { label: n, value: n }
|
||||
})
|
||||
|
||||
export const confirmOpt = [
|
||||
{ label: "否", value: false },
|
||||
{ label: "是", value: true },
|
||||
]
|
||||
|
||||
export const labelStageConfig: FormItemProps[] = [
|
||||
{ label: "可领取最多任务条数", name: "max_size", type: "input" },
|
||||
{ label: "单次可领取任务条数", name: "acquire_size", type: "input" },
|
||||
{ label: "标注配置更新月份", name: "label_update_month", type: "select", options: monthOpt },
|
||||
{ label: "动态标注倍速", name: "dynamic_label_speed", type: "input" },
|
||||
{ label: "静态标注倍速", name: "static_label_speed", type: "input" },
|
||||
{ label: "标注准确率", name: "label_accuracy_rate", type: "input" },
|
||||
{ label: "标注结果数量倍数", name: "avg_remind_threshold", type: "input" },
|
||||
{ label: "标注结果数量告警阈值", name: "fix_remind_threshold", type: "input" },
|
||||
{
|
||||
label: "领取顺序",
|
||||
name: "acquire_mode",
|
||||
type: "radio",
|
||||
options: [
|
||||
{ label: "顺序领取", value: 0 },
|
||||
{ label: "乱序领取", value: 1 },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
export const reviewStageConfig: FormItemProps[] = [
|
||||
{ label: "可领取最多任务条数", name: "max_size", type: "input" },
|
||||
{ label: "单次可领取任务条数", name: "acquire_size", type: "input" },
|
||||
{ label: "审核配置更新月份", name: "review1_update_month", type: "select", options: monthOpt },
|
||||
{ label: "动态审核倍速", name: "dynamic_review1_speed", type: "input" },
|
||||
{ label: "静态审核倍速", name: "static_review1_speed", type: "input" },
|
||||
{ label: "审核准确率", name: "review1_accuracy_rate", type: "input" },
|
||||
{
|
||||
label: "领取顺序",
|
||||
name: "acquire_mode",
|
||||
type: "radio",
|
||||
options: [
|
||||
{ label: "顺序领取", value: 0 },
|
||||
{ label: "乱序领取", value: 1 },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
export const recheckStageConfig: FormItemProps[] = [
|
||||
{ label: "可领取最多任务条数", name: "max_size", type: "input" },
|
||||
{ label: "单次可领取任务条数", name: "acquire_size", type: "input" },
|
||||
{ label: "复审配置更新月份", name: "review2_update_month", type: "select", options: monthOpt },
|
||||
{ label: "动态复审倍速", name: "dynamic_review2_speed", type: "input" },
|
||||
{ label: "静态复审倍速", name: "static_review2_speed", type: "input" },
|
||||
{
|
||||
label: "领取顺序",
|
||||
name: "acquire_mode",
|
||||
type: "radio",
|
||||
options: [
|
||||
{ label: "顺序领取", value: 0 },
|
||||
{ label: "乱序领取", value: 1 },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
206
app/management/person/collection/detail/page.tsx
Normal file
206
app/management/person/collection/detail/page.tsx
Normal file
@@ -0,0 +1,206 @@
|
||||
"use client"
|
||||
|
||||
import { getProjectDetailById } from "@/components/label/api/project"
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import { useAllUserStore, useBackUrlStore } from "@/components/label/store/auth"
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Group,
|
||||
Paper,
|
||||
SegmentedControl,
|
||||
Stack,
|
||||
Text,
|
||||
UnstyledButton,
|
||||
} from "@mantine/core"
|
||||
import { IconChevronLeft } from "@tabler/icons-react"
|
||||
import { useRouter, useSearchParams } from "next/navigation"
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import InfoSettingContainer from "./InfoSettingContainer"
|
||||
import OwnTaskTableContainer from "./OwnTaskTableContainer"
|
||||
import TaskBoardContainer from "./TaskBoardContainer"
|
||||
import TaskTableContainer from "./TaskTableContainer"
|
||||
|
||||
type TabKey = "own" | "all" | "setting" | "board"
|
||||
|
||||
export default function CollectionDetailPage() {
|
||||
const router = useRouter()
|
||||
const urlParams = useSearchParams()
|
||||
const type = urlParams.get("type")
|
||||
const id = urlParams.get("id")
|
||||
const projectId =
|
||||
typeof id === "string" && !isNaN(Number(id)) ? Number(id) : -1
|
||||
|
||||
const { backTitle, setBackProps } = useBackUrlStore()
|
||||
const { userOpts } = useAllUserStore()
|
||||
|
||||
const [selectKey, setSelectedKey] = useState<TabKey>(
|
||||
(backTitle as TabKey) || "own"
|
||||
)
|
||||
const [info, setInfo] = useState<ProjectDetail.DataProps>()
|
||||
const [userEnums, setUserEnums] = useState<{
|
||||
allEnum: Map<any, any>
|
||||
labelEnum: Map<any, any>
|
||||
review1Enum: Map<any, any>
|
||||
review2Enum: Map<any, any>
|
||||
}>({
|
||||
allEnum: new Map(),
|
||||
labelEnum: new Map(),
|
||||
review1Enum: new Map(),
|
||||
review2Enum: new Map(),
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (projectId === -1) return
|
||||
const getProjectInfo = async () => {
|
||||
const res = await getProjectDetailById(projectId)
|
||||
setInfo(res)
|
||||
}
|
||||
getProjectInfo()
|
||||
}, [projectId])
|
||||
|
||||
const updateProjectInfo = async () => {
|
||||
if (projectId === -1) return
|
||||
const res = await getProjectDetailById(projectId)
|
||||
setInfo(res)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!info?.label_process) return
|
||||
const { step_detail } = info.label_process
|
||||
let label: number[] = []
|
||||
let review1: number[] = []
|
||||
let review2: number[] = []
|
||||
step_detail.forEach(({ action, user_list }: any) => {
|
||||
if (action === 1) label = user_list
|
||||
else if (action === 2) review1 = user_list
|
||||
else if (action === 3) review2 = user_list
|
||||
})
|
||||
const all = Array.from(new Set([...label, ...review1, ...review2]))
|
||||
|
||||
const toLabelMap = (uids: number[]) =>
|
||||
new Map(
|
||||
uids.map((uid) => {
|
||||
const opt = userOpts.find((o) => o.value === uid)
|
||||
return [uid, opt?.label ?? String(uid)]
|
||||
})
|
||||
)
|
||||
|
||||
queueMicrotask(() => {
|
||||
setUserEnums({
|
||||
allEnum: toLabelMap(all),
|
||||
labelEnum: toLabelMap(label),
|
||||
review1Enum: toLabelMap(review1),
|
||||
review2Enum: toLabelMap(review2),
|
||||
})
|
||||
})
|
||||
}, [info, userOpts])
|
||||
|
||||
const breadcrumbsItems = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
title: type
|
||||
? type === "collect"
|
||||
? "我的收藏"
|
||||
: type === "dynamic"
|
||||
? "动态项目"
|
||||
: "全部项目"
|
||||
: "我的收藏",
|
||||
href: type
|
||||
? `/management/person/collection?type=${type}`
|
||||
: "/management/person/collection?type=collect",
|
||||
},
|
||||
{
|
||||
title: info?.name || "项目名称",
|
||||
href: "",
|
||||
},
|
||||
].map((item) => (
|
||||
<UnstyledButton
|
||||
key={item.title}
|
||||
onClick={() => {
|
||||
if (!item.href) return
|
||||
router.push(item.href)
|
||||
}}>
|
||||
<Text
|
||||
size="sm"
|
||||
c={item.href ? "dimmed" : "dark"}
|
||||
fw={item.href ? 400 : 700}>
|
||||
{item.title}
|
||||
</Text>
|
||||
</UnstyledButton>
|
||||
))
|
||||
}, [info?.name, router, type])
|
||||
|
||||
return (
|
||||
<Stack w="100%" h="calc(100vh - 56px)" p="md" gap="md">
|
||||
<Paper
|
||||
withBorder
|
||||
p="md"
|
||||
radius="md"
|
||||
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Group justify="space-between" wrap="wrap" gap="sm">
|
||||
<Group gap="sm">
|
||||
<Button
|
||||
variant="subtle"
|
||||
size="xs"
|
||||
leftSection={<IconChevronLeft size={16} />}
|
||||
onClick={() => {
|
||||
router.push(
|
||||
type
|
||||
? `/management/person/collection?type=${type}`
|
||||
: "/management/person/collection?type=collect"
|
||||
)
|
||||
}}>
|
||||
返回
|
||||
</Button>
|
||||
<Breadcrumbs separator=">">{breadcrumbsItems}</Breadcrumbs>
|
||||
</Group>
|
||||
<SegmentedControl
|
||||
value={selectKey}
|
||||
data={[
|
||||
{ label: "我的任务", value: "own" },
|
||||
{ label: "任务列表", value: "all" },
|
||||
{ label: "任务配置", value: "setting" },
|
||||
]}
|
||||
onChange={(v) => {
|
||||
const next = v as TabKey
|
||||
setSelectedKey(next)
|
||||
const backUrl = type
|
||||
? `/management/person/collection/detail?id=${projectId}&type=${type}`
|
||||
: `/management/person/collection/detail?id=${projectId}`
|
||||
setBackProps(backUrl, next)
|
||||
}}
|
||||
/>
|
||||
</Group>
|
||||
</Paper>
|
||||
|
||||
<Paper
|
||||
withBorder
|
||||
p="md"
|
||||
radius="md"
|
||||
style={{
|
||||
borderColor: "rgba(0,0,0,0.06)",
|
||||
flex: 1,
|
||||
minHeight: 0,
|
||||
display: "flex",
|
||||
}}>
|
||||
<Stack style={{ flex: 1, minHeight: 0 }} gap="md">
|
||||
{selectKey === "own" ? (
|
||||
<OwnTaskTableContainer info={info} userEnums={userEnums} />
|
||||
) : null}
|
||||
{selectKey === "all" ? (
|
||||
<TaskTableContainer info={info} userEnums={userEnums} />
|
||||
) : null}
|
||||
{selectKey === "board" ? <TaskBoardContainer /> : null}
|
||||
{selectKey === "setting" ? (
|
||||
<InfoSettingContainer
|
||||
info={info}
|
||||
userEnums={userEnums}
|
||||
update={updateProjectInfo}
|
||||
/>
|
||||
) : null}
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
1
app/management/person/collection/detail/util.ts
Normal file
1
app/management/person/collection/detail/util.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { runCommand } from "@/app/management/person/dashboard/components/util"
|
||||
536
app/management/person/collection/page.tsx
Normal file
536
app/management/person/collection/page.tsx
Normal file
@@ -0,0 +1,536 @@
|
||||
"use client"
|
||||
|
||||
import {
|
||||
getProjectList,
|
||||
getProjectTypeList,
|
||||
projectCollect,
|
||||
} from "@/components/label/api/project"
|
||||
import { Project } from "@/components/label/api/project/typing"
|
||||
import {
|
||||
initAllParams,
|
||||
initCollectParams,
|
||||
initDynamicParams,
|
||||
useAllUserStore,
|
||||
useProjectStore,
|
||||
} from "@/components/label/store/auth"
|
||||
import {
|
||||
projectLabelTypeOpts,
|
||||
projectStatusOpts,
|
||||
STATUS_CODE,
|
||||
} from "@/components/label/utils/constants"
|
||||
import {
|
||||
ActionIcon,
|
||||
Badge,
|
||||
Button,
|
||||
Collapse,
|
||||
Group,
|
||||
Paper,
|
||||
Select,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import {
|
||||
IconChevronDown,
|
||||
IconChevronUp,
|
||||
IconRefresh,
|
||||
IconSearch,
|
||||
IconStar,
|
||||
IconStarFilled,
|
||||
} from "@tabler/icons-react"
|
||||
import dayjs from "dayjs"
|
||||
import { DataTable, DataTableColumn } from "mantine-datatable"
|
||||
import { useRouter, useSearchParams } from "next/navigation"
|
||||
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||
|
||||
type PageType = "all" | "collect" | "dynamic"
|
||||
|
||||
function statusBadgeColor(status?: number | null) {
|
||||
if (!status) return "gray"
|
||||
if ([191, 199, 700].includes(status)) return "red"
|
||||
if ([580].includes(status)) return "yellow"
|
||||
if ([600].includes(status)) return "green"
|
||||
if ([201, 202, 203].includes(status)) return "cyan"
|
||||
return "blue"
|
||||
}
|
||||
|
||||
function parseStatusValue(value?: string) {
|
||||
if (!value) return undefined
|
||||
if (value.includes(",")) {
|
||||
return value
|
||||
.split(",")
|
||||
.map((v) => Number(v))
|
||||
.filter((n) => Number.isFinite(n))
|
||||
}
|
||||
const n = Number(value)
|
||||
return Number.isFinite(n) ? [n] : undefined
|
||||
}
|
||||
|
||||
export default function CollectionPage() {
|
||||
const router = useRouter()
|
||||
const urlParams = useSearchParams()
|
||||
const type = (urlParams.get("type") as PageType | null) ?? "collect"
|
||||
|
||||
const { userOpts } = useAllUserStore()
|
||||
const {
|
||||
allParams,
|
||||
allTotal,
|
||||
collectParams,
|
||||
collectTotal,
|
||||
dynamicParams,
|
||||
dynamicTotal,
|
||||
resetParams,
|
||||
setSearchParams,
|
||||
setTotal,
|
||||
}: any = useProjectStore()
|
||||
|
||||
const storeParams = useMemo(() => {
|
||||
return type === "collect"
|
||||
? collectParams
|
||||
: type === "dynamic"
|
||||
? dynamicParams
|
||||
: allParams
|
||||
}, [allParams, collectParams, dynamicParams, type])
|
||||
|
||||
const total = useMemo(() => {
|
||||
return type === "collect"
|
||||
? collectTotal
|
||||
: type === "dynamic"
|
||||
? dynamicTotal
|
||||
: allTotal
|
||||
}, [allTotal, collectTotal, dynamicTotal, type])
|
||||
|
||||
const [typeOpts, setTypeOpts] = useState<
|
||||
Array<{ label: string; value: string }>
|
||||
>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [records, setRecords] = useState<Project.DataProps[]>([])
|
||||
|
||||
const [searchExpanded, setSearchExpanded] = useState(false)
|
||||
const [filters, setFilters] = useState(() => {
|
||||
return {
|
||||
project_name: "",
|
||||
project_type: "",
|
||||
status: "",
|
||||
owner: "",
|
||||
label_type: "",
|
||||
admin_user: "",
|
||||
start_date: dayjs().subtract(6, "day").format("YYYY-MM-DD"),
|
||||
end_date: dayjs().format("YYYY-MM-DD"),
|
||||
}
|
||||
})
|
||||
|
||||
const [appliedFilters, setAppliedFilters] = useState(filters)
|
||||
const [queryTrigger, setQueryTrigger] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
const initFormOpts = async () => {
|
||||
const res = await getProjectTypeList()
|
||||
setTypeOpts((res ?? []).map((name) => ({ label: name, value: name })))
|
||||
}
|
||||
initFormOpts()
|
||||
}, [])
|
||||
|
||||
const queryParams = useMemo(() => {
|
||||
const base =
|
||||
type === "collect"
|
||||
? { ...initCollectParams }
|
||||
: type === "dynamic"
|
||||
? { ...initDynamicParams }
|
||||
: { ...initAllParams }
|
||||
|
||||
const params: Project.ListRequest & any = {
|
||||
...base,
|
||||
...storeParams,
|
||||
page_number: storeParams.page_number ?? 1,
|
||||
page_size: storeParams.page_size ?? 15,
|
||||
project_name: appliedFilters.project_name || undefined,
|
||||
project_type: appliedFilters.project_type || undefined,
|
||||
owner: appliedFilters.owner || undefined,
|
||||
admin_user: appliedFilters.admin_user || undefined,
|
||||
start_date: appliedFilters.start_date || undefined,
|
||||
end_date: appliedFilters.end_date || undefined,
|
||||
label_type: appliedFilters.label_type
|
||||
? Number(appliedFilters.label_type)
|
||||
: undefined,
|
||||
status: parseStatusValue(appliedFilters.status),
|
||||
}
|
||||
|
||||
return params
|
||||
}, [appliedFilters, storeParams, type])
|
||||
|
||||
const load = useCallback(async () => {
|
||||
if (!queryTrigger) return
|
||||
setLoading(true)
|
||||
try {
|
||||
const res = await getProjectList(queryParams)
|
||||
setRecords(res?.project_list ?? [])
|
||||
setTotal(res?.total_items ?? 0, type)
|
||||
} catch (e) {
|
||||
setRecords([])
|
||||
setTotal(0, type)
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "加载失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [queryParams, queryTrigger, setTotal, type])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
useEffect(() => {
|
||||
queueMicrotask(() => {
|
||||
setQueryTrigger((v) => v + 1)
|
||||
})
|
||||
}, [])
|
||||
|
||||
const columns = useMemo(() => {
|
||||
const cols: DataTableColumn<Project.DataProps>[] = [
|
||||
{
|
||||
accessor: "id",
|
||||
title: "项目ID",
|
||||
width: 90,
|
||||
},
|
||||
{
|
||||
accessor: "name",
|
||||
title: "项目名称",
|
||||
width: 220,
|
||||
render: (record) => (
|
||||
<Button
|
||||
variant="subtle"
|
||||
size="xs"
|
||||
style={{
|
||||
paddingLeft: 6,
|
||||
paddingRight: 6,
|
||||
maxWidth: 220,
|
||||
}}
|
||||
onClick={() => {
|
||||
const url = type
|
||||
? `/management/person/collection/detail?id=${record.id}&type=${type}`
|
||||
: `/management/person/collection/detail?id=${record.id}`
|
||||
router.push(url)
|
||||
}}>
|
||||
<Text
|
||||
size="sm"
|
||||
style={{
|
||||
maxWidth: 200,
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
whiteSpace: "nowrap",
|
||||
}}>
|
||||
{record.name}
|
||||
</Text>
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessor: "project_type",
|
||||
title: "所属业务",
|
||||
width: 140,
|
||||
render: (record) => record.project_type ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "status",
|
||||
title: "状态",
|
||||
width: 110,
|
||||
render: (record) => (
|
||||
<Badge color={statusBadgeColor(record.status)}>
|
||||
{STATUS_CODE.get(record.status) ?? record.status}
|
||||
</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessor: "owner",
|
||||
title: "负责人",
|
||||
width: 120,
|
||||
render: (record) => record.owner ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "label_schema_name",
|
||||
title: "标注方案",
|
||||
width: 160,
|
||||
render: (record) => record.label_schema_name ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "update_at",
|
||||
title: "更新时间",
|
||||
width: 160,
|
||||
render: (record) => record.update_at ?? record.create_at ?? "-",
|
||||
},
|
||||
{
|
||||
accessor: "operation",
|
||||
title: "操作",
|
||||
width: 80,
|
||||
textAlign: "center",
|
||||
render: (record) => (
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color={record.is_collect ? "yellow" : "gray"}
|
||||
onClick={async () => {
|
||||
try {
|
||||
await projectCollect({
|
||||
project_id: record.id,
|
||||
is_collect: !record.is_collect,
|
||||
})
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: record.is_collect ? "已取消收藏" : "已收藏",
|
||||
})
|
||||
load()
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
}
|
||||
}}>
|
||||
{record.is_collect ? (
|
||||
<IconStarFilled size={16} />
|
||||
) : (
|
||||
<IconStar size={16} />
|
||||
)}
|
||||
</ActionIcon>
|
||||
),
|
||||
},
|
||||
]
|
||||
return cols
|
||||
}, [load, router, type])
|
||||
|
||||
return (
|
||||
<Stack w="100%" h="calc(100vh - 56px)" p="md" gap="md">
|
||||
<Paper
|
||||
withBorder
|
||||
p="md"
|
||||
radius="md"
|
||||
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
|
||||
<Group justify="space-between" wrap="wrap" gap="sm">
|
||||
{/* <SegmentedControl
|
||||
value={type}
|
||||
data={[
|
||||
{ label: "全部项目", value: "all" },
|
||||
{ label: "我的收藏", value: "collect" },
|
||||
{ label: "动态项目", value: "dynamic" },
|
||||
]}
|
||||
onChange={(v) => {
|
||||
const next = v as PageType
|
||||
router.replace(`/management/person/collection?type=${next}`)
|
||||
}}
|
||||
/> */}
|
||||
<Group gap="xs">
|
||||
<Text fw={700}>我的收藏</Text>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="transparent"
|
||||
rightSection={
|
||||
searchExpanded ? (
|
||||
<IconChevronUp size={16} />
|
||||
) : (
|
||||
<IconChevronDown size={16} />
|
||||
)
|
||||
}
|
||||
onClick={() => setSearchExpanded((v) => !v)}>
|
||||
{searchExpanded ? "收起筛选" : "展开筛选"}
|
||||
</Button>
|
||||
</Group>
|
||||
<Group gap="xs">
|
||||
<Button
|
||||
size="xs"
|
||||
radius="xs"
|
||||
variant="default"
|
||||
leftSection={<IconRefresh size={16} />}
|
||||
onClick={() => {
|
||||
resetParams(type)
|
||||
const next = {
|
||||
project_name: "",
|
||||
project_type: "",
|
||||
status: "",
|
||||
owner: "",
|
||||
label_type: "",
|
||||
admin_user: "",
|
||||
start_date: dayjs().subtract(6, "day").format("YYYY-MM-DD"),
|
||||
end_date: dayjs().format("YYYY-MM-DD"),
|
||||
}
|
||||
setFilters(next)
|
||||
setAppliedFilters(next)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}>
|
||||
重置
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
radius="xs"
|
||||
leftSection={<IconSearch size={16} />}
|
||||
onClick={() => {
|
||||
setSearchParams({ ...storeParams, page_number: 1 }, type)
|
||||
setAppliedFilters(filters)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}>
|
||||
查询
|
||||
</Button>
|
||||
</Group>
|
||||
</Group>
|
||||
|
||||
<Collapse
|
||||
in={searchExpanded}
|
||||
transitionDuration={250}
|
||||
transitionTimingFunction="ease"
|
||||
animateOpacity>
|
||||
<Stack gap="sm" mt="sm">
|
||||
<SimpleGrid cols={{ base: 1, sm: 2, md: 3, lg: 4 }} spacing="sm">
|
||||
<TextInput
|
||||
label="项目名称"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
value={filters.project_name}
|
||||
onChange={(e) =>
|
||||
setFilters((s) => ({
|
||||
...s,
|
||||
project_name: e.currentTarget.value,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
<Select
|
||||
label="所属业务"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
searchable
|
||||
clearable
|
||||
data={typeOpts}
|
||||
value={filters.project_type || null}
|
||||
onChange={(v) =>
|
||||
setFilters((s) => ({ ...s, project_type: v ?? "" }))
|
||||
}
|
||||
/>
|
||||
<Select
|
||||
label="状态"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
searchable
|
||||
data={projectStatusOpts.map((o) => ({
|
||||
label: o.label,
|
||||
value: o.label,
|
||||
}))}
|
||||
value={filters.status}
|
||||
onChange={(v) => setFilters((s) => ({ ...s, status: v ?? "" }))}
|
||||
/>
|
||||
<TextInput
|
||||
label="负责人"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
value={filters.owner}
|
||||
onChange={(e) =>
|
||||
setFilters((s) => ({ ...s, owner: e.currentTarget.value }))
|
||||
}
|
||||
/>
|
||||
<Select
|
||||
label="标注类型"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
searchable
|
||||
clearable
|
||||
data={projectLabelTypeOpts.map((o) => ({
|
||||
label: o.label,
|
||||
value: String(o.value),
|
||||
}))}
|
||||
value={filters.label_type || null}
|
||||
onChange={(v) =>
|
||||
setFilters((s) => ({ ...s, label_type: v ?? "" }))
|
||||
}
|
||||
/>
|
||||
<Select
|
||||
label="标注管理员"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
searchable
|
||||
clearable
|
||||
data={userOpts.map((o) => ({
|
||||
label: o.label,
|
||||
value: String(o.value),
|
||||
}))}
|
||||
value={filters.admin_user || null}
|
||||
onChange={(v) =>
|
||||
setFilters((s) => ({ ...s, admin_user: v ?? "" }))
|
||||
}
|
||||
/>
|
||||
<TextInput
|
||||
label="开始日期"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
type="date"
|
||||
value={filters.start_date}
|
||||
onChange={(e) =>
|
||||
setFilters((s) => ({
|
||||
...s,
|
||||
start_date: e.currentTarget.value,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
<TextInput
|
||||
label="结束日期"
|
||||
size="xs"
|
||||
radius="xs"
|
||||
type="date"
|
||||
value={filters.end_date}
|
||||
onChange={(e) =>
|
||||
setFilters((s) => ({ ...s, end_date: e.currentTarget.value }))
|
||||
}
|
||||
/>
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
</Collapse>
|
||||
</Paper>
|
||||
|
||||
<Paper
|
||||
withBorder
|
||||
p="md"
|
||||
radius="md"
|
||||
style={{
|
||||
borderColor: "rgba(0,0,0,0.06)",
|
||||
flex: 1,
|
||||
minHeight: 0,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
}}>
|
||||
<Group gap={0} align="stretch" style={{ flex: 1, minHeight: 0 }}>
|
||||
<DataTable<Project.DataProps>
|
||||
width="100%"
|
||||
style={{ width: "100%" }}
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
pinFirstColumn
|
||||
pinLastColumn
|
||||
scrollAreaProps={{ type: "auto" }}
|
||||
fetching={loading}
|
||||
records={records}
|
||||
columns={columns}
|
||||
totalRecords={total}
|
||||
recordsPerPage={storeParams.page_size ?? 15}
|
||||
page={storeParams.page_number ?? 1}
|
||||
onPageChange={(p) => {
|
||||
setSearchParams({ ...storeParams, page_number: p }, type)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
onRecordsPerPageChange={(s) => {
|
||||
setSearchParams(
|
||||
{ ...storeParams, page_number: 1, page_size: s },
|
||||
type
|
||||
)
|
||||
setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
recordsPerPageOptions={[10, 15, 20, 50]}
|
||||
noRecordsText="暂无数据"
|
||||
/>
|
||||
</Group>
|
||||
</Paper>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user