fix(detail): change detail
This commit is contained in:
175
app/management/project/detail/InfoSettingContainer.tsx
Normal file
175
app/management/project/detail/InfoSettingContainer.tsx
Normal file
@@ -0,0 +1,175 @@
|
||||
"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 { JSX, 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
|
||||
menuAction?: () => JSX.Element
|
||||
userEnums: {
|
||||
allEnum: Map<any, any>
|
||||
labelEnum: Map<any, any>
|
||||
review1Enum: Map<any, any>
|
||||
review2Enum: Map<any, any>
|
||||
}
|
||||
updateAction: () => void
|
||||
}) {
|
||||
const { info, menuAction, userEnums, updateAction } = 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: "已保存配置",
|
||||
})
|
||||
updateAction()
|
||||
} 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">
|
||||
{menuAction ? <div>{menuAction()}</div> : null}
|
||||
<Group justify="space-between" wrap="wrap">
|
||||
<Text fw={700}>基础配置</Text>
|
||||
<Button size="xs" variant="default" onClick={updateAction}>
|
||||
刷新项目详情
|
||||
</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}
|
||||
onUpdatedAction={updateAction}
|
||||
/>
|
||||
|
||||
<SamplingPlanContainer
|
||||
projectId={projectId}
|
||||
info={info}
|
||||
onUpdated={updateAction}
|
||||
/>
|
||||
|
||||
<LabelSchemeContainer info={info} />
|
||||
|
||||
<NoteRulesTable info={info} />
|
||||
</Stack>
|
||||
|
||||
<AdminUserModal
|
||||
opened={adminModalOpen}
|
||||
value={info?.admin_user ?? []}
|
||||
options={userOptions}
|
||||
onCloseAction={async (next) => {
|
||||
setAdminModalOpen(false)
|
||||
if (!next || projectId === -1) return
|
||||
try {
|
||||
await projectConfig({ project_id: projectId, admin_user: next })
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: "已保存项目管理员",
|
||||
})
|
||||
updateAction()
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
355
app/management/project/detail/OwnTaskTableContainer.tsx
Normal file
355
app/management/project/detail/OwnTaskTableContainer.tsx
Normal file
@@ -0,0 +1,355 @@
|
||||
"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 { JSX, useCallback, useEffect, useMemo, useState } from "react"
|
||||
import TaskStatusTag from "./components/TaskStatusTag"
|
||||
import { runCommand } from "./util"
|
||||
|
||||
export default function OwnTaskTableContainer(props: {
|
||||
info: ProjectDetail.DataProps | undefined
|
||||
menuAction?: () => JSX.Element
|
||||
userEnums: {
|
||||
allEnum: Map<any, any>
|
||||
labelEnum: Map<any, any>
|
||||
review1Enum: Map<any, any>
|
||||
review2Enum: Map<any, any>
|
||||
}
|
||||
}) {
|
||||
const { info, menuAction, 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, 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 (!queryTrigger) return
|
||||
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/project/detail?id=${projectId}&type=${type}`
|
||||
: `/management/project/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)" }}>
|
||||
<Stack gap="sm">
|
||||
{menuAction ? <div>{menuAction()}</div> : null}
|
||||
<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>
|
||||
</Stack>
|
||||
</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>
|
||||
)
|
||||
}
|
||||
20
app/management/project/detail/TaskBoardContainer.tsx
Normal file
20
app/management/project/detail/TaskBoardContainer.tsx
Normal file
@@ -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>
|
||||
)
|
||||
}
|
||||
335
app/management/project/detail/TaskTableContainer.tsx
Normal file
335
app/management/project/detail/TaskTableContainer.tsx
Normal file
@@ -0,0 +1,335 @@
|
||||
"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 { JSX, 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
|
||||
menuAction?: () => JSX.Element
|
||||
userEnums: {
|
||||
allEnum: Map<any, any>
|
||||
labelEnum: Map<any, any>
|
||||
review1Enum: Map<any, any>
|
||||
review2Enum: Map<any, any>
|
||||
}
|
||||
}) {
|
||||
const { info, menuAction, userEnums } = props
|
||||
false && console.log(info)
|
||||
|
||||
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)
|
||||
false && console.log(currentUid)
|
||||
|
||||
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 (!queryTrigger) return
|
||||
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)" }}>
|
||||
<Stack gap="sm">
|
||||
{menuAction ? <div>{menuAction()}</div> : null}
|
||||
<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>
|
||||
</Stack>
|
||||
</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}
|
||||
onCloseAction={() => setWorkflowTaskId(null)}
|
||||
/>
|
||||
<DispatchModal
|
||||
opened={dispatchRecord !== null}
|
||||
record={dispatchRecord}
|
||||
userOptions={userOptions}
|
||||
onCloseAction={(refresh) => {
|
||||
setDispatchRecord(null)
|
||||
if (refresh) setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
/>
|
||||
<ReleaseModal
|
||||
opened={releaseRecord !== null}
|
||||
record={releaseRecord}
|
||||
onCloseAction={(refresh) => {
|
||||
setReleaseRecord(null)
|
||||
if (refresh) setQueryTrigger((v) => v + 1)
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
59
app/management/project/detail/components/AdminUserModal.tsx
Normal file
59
app/management/project/detail/components/AdminUserModal.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
"use client"
|
||||
|
||||
import { Button, Group, Modal, MultiSelect, Stack } from "@mantine/core"
|
||||
import { useForm } from "@mantine/form"
|
||||
import { useEffect } from "react"
|
||||
|
||||
export default function AdminUserModal(props: {
|
||||
opened: boolean
|
||||
value: number[]
|
||||
options: Array<{ label: string; value: string }>
|
||||
onCloseAction: (next?: number[]) => void
|
||||
}) {
|
||||
const { opened, value, options, onCloseAction } = props
|
||||
|
||||
const form = useForm({
|
||||
initialValues: { users: value.map(String) },
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!opened) return
|
||||
form.setValues({ users: value.map(String) })
|
||||
form.resetDirty()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [opened, value])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={() => onCloseAction()}
|
||||
title="编辑项目管理员"
|
||||
centered
|
||||
size={560}>
|
||||
<form
|
||||
onSubmit={form.onSubmit((values) => {
|
||||
const next = values.users
|
||||
.map((v) => Number(v))
|
||||
.filter((v) => Number.isFinite(v))
|
||||
onCloseAction(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={() => onCloseAction()}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit">保存</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
149
app/management/project/detail/components/DispatchModal.tsx
Normal file
149
app/management/project/detail/components/DispatchModal.tsx
Normal file
@@ -0,0 +1,149 @@
|
||||
"use client"
|
||||
|
||||
import { dispatchOpts } from "@/app/management/person/collection/config"
|
||||
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"
|
||||
|
||||
export default function DispatchModal(props: {
|
||||
opened: boolean
|
||||
record: Task.DataProps | null
|
||||
userOptions: Array<{ label: string; value: string }>
|
||||
onCloseAction: (refresh?: boolean) => void
|
||||
}) {
|
||||
const { opened, record, userOptions, onCloseAction } = 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={() => onCloseAction()}
|
||||
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: "已调度任务",
|
||||
})
|
||||
onCloseAction(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={() => onCloseAction()}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit">确定</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
"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
|
||||
idAccessor="category_id"
|
||||
records={schemas}
|
||||
columns={columns}
|
||||
minHeight={160}
|
||||
noRecordsText="暂无数据"
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
58
app/management/project/detail/components/NoteRulesTable.tsx
Normal file
58
app/management/project/detail/components/NoteRulesTable.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
"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>
|
||||
)
|
||||
}
|
||||
90
app/management/project/detail/components/ReleaseModal.tsx
Normal file
90
app/management/project/detail/components/ReleaseModal.tsx
Normal file
@@ -0,0 +1,90 @@
|
||||
"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
|
||||
onCloseAction: (refresh?: boolean) => void
|
||||
}) {
|
||||
const { opened, record, onCloseAction } = props
|
||||
const operation_uid = usePermissionStore((s) => s.user_id)
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
reject: false,
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={() => onCloseAction()}
|
||||
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: "已释放任务",
|
||||
})
|
||||
onCloseAction(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={() => onCloseAction()}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit" color="red">
|
||||
确定释放
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
"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()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [info])
|
||||
|
||||
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>
|
||||
)
|
||||
}
|
||||
60
app/management/project/detail/components/StageUserModal.tsx
Normal file
60
app/management/project/detail/components/StageUserModal.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
"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 }>
|
||||
onCloseAction: (next?: number[]) => void
|
||||
}) {
|
||||
const { opened, title, value, options, onCloseAction } = props
|
||||
|
||||
const form = useForm({
|
||||
initialValues: { users: value.map(String) },
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!opened) return
|
||||
form.setValues({ users: value.map(String) })
|
||||
form.resetDirty()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [opened, value])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={() => onCloseAction()}
|
||||
title={title}
|
||||
centered
|
||||
size={560}>
|
||||
<form
|
||||
onSubmit={form.onSubmit((values) => {
|
||||
const next = values.users
|
||||
.map((v) => Number(v))
|
||||
.filter((v) => Number.isFinite(v))
|
||||
onCloseAction(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={() => onCloseAction()}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit">保存</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
"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>
|
||||
}
|
||||
onUpdatedAction: () => void
|
||||
}) {
|
||||
const { projectId, info, userOptions, userEnums, onUpdatedAction } = 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: "已保存阶段人员",
|
||||
})
|
||||
onUpdatedAction()
|
||||
} 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}
|
||||
onCloseAction={async (next) => {
|
||||
const stage = editingStage
|
||||
setEditingStage(null)
|
||||
if (!stage || !next) return
|
||||
await saveStageUsers(stage, next)
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
50
app/management/project/detail/components/TaskStatusTag.tsx
Normal file
50
app/management/project/detail/components/TaskStatusTag.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
"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>
|
||||
)
|
||||
}
|
||||
80
app/management/project/detail/components/WorkflowModal.tsx
Normal file
80
app/management/project/detail/components/WorkflowModal.tsx
Normal file
@@ -0,0 +1,80 @@
|
||||
"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
|
||||
onCloseAction: () => void
|
||||
}) {
|
||||
const { opened, taskId, onCloseAction } = 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={onCloseAction}
|
||||
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={onCloseAction}>
|
||||
关闭
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
90
app/management/project/detail/components/config.ts
Normal file
90
app/management/project/detail/components/config.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
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 },
|
||||
],
|
||||
},
|
||||
]
|
||||
253
app/management/project/detail/page.tsx
Normal file
253
app/management/project/detail/page.tsx
Normal file
@@ -0,0 +1,253 @@
|
||||
"use client"
|
||||
|
||||
import { getProjectDetailById } from "@/components/label/api/project"
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import {
|
||||
useAllUserStore,
|
||||
useBackUrlStore,
|
||||
usePermissionStore,
|
||||
} from "@/components/label/store/auth"
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Group,
|
||||
Paper,
|
||||
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 permissions = usePermissionStore((s) => s.detailInfo?.permissions)
|
||||
|
||||
const canConfig = useMemo(() => {
|
||||
const v = permissions?.project?.config?.[0]
|
||||
return typeof v === "boolean" ? v : true
|
||||
}, [permissions])
|
||||
|
||||
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/project?type=${type}`
|
||||
: "/management/project?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])
|
||||
|
||||
const menuItems = useMemo(() => {
|
||||
const arr: Array<{ label: string; key: TabKey }> = [
|
||||
{ label: "我的任务", key: "own" },
|
||||
{ label: "任务列表", key: "all" },
|
||||
]
|
||||
if (canConfig) arr.push({ label: "任务配置", key: "setting" })
|
||||
return arr
|
||||
}, [canConfig])
|
||||
|
||||
useEffect(() => {
|
||||
if (menuItems.some((i) => i.key === selectKey)) return
|
||||
queueMicrotask(() => {
|
||||
setSelectedKey(menuItems[0]?.key ?? "own")
|
||||
})
|
||||
}, [menuItems, selectKey])
|
||||
|
||||
const DetailMenuItems = () => {
|
||||
return (
|
||||
<Group gap={0} wrap="nowrap">
|
||||
{menuItems.map((item, index) => {
|
||||
const active = item.key === selectKey
|
||||
return (
|
||||
<UnstyledButton
|
||||
key={item.key}
|
||||
onClick={() => {
|
||||
const next = item.key
|
||||
setSelectedKey(next)
|
||||
const backUrl = type
|
||||
? `/management/project/detail?id=${projectId}&type=${type}`
|
||||
: `/management/project/detail?id=${projectId}`
|
||||
setBackProps(backUrl, next)
|
||||
}}
|
||||
style={{
|
||||
paddingLeft: 14,
|
||||
paddingRight: 14,
|
||||
paddingTop: 6,
|
||||
paddingBottom: 6,
|
||||
borderTopLeftRadius: index === 0 ? 10 : 0,
|
||||
borderBottomLeftRadius: index === 0 ? 10 : 0,
|
||||
borderTopRightRadius: index === menuItems.length - 1 ? 10 : 0,
|
||||
borderBottomRightRadius:
|
||||
index === menuItems.length - 1 ? 10 : 0,
|
||||
background: active
|
||||
? "var(--mantine-color-brand-filled)"
|
||||
: "rgba(0,0,0,0.04)",
|
||||
}}>
|
||||
<Text size="sm" fw={600} c={active ? "white" : "dimmed"}>
|
||||
{item.label}
|
||||
</Text>
|
||||
</UnstyledButton>
|
||||
)
|
||||
})}
|
||||
</Group>
|
||||
)
|
||||
}
|
||||
|
||||
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/project?type=${type}`
|
||||
: "/management/project?type=collect"
|
||||
)
|
||||
}}>
|
||||
返回
|
||||
</Button>
|
||||
<Breadcrumbs separator=">">{breadcrumbsItems}</Breadcrumbs>
|
||||
</Group>
|
||||
</Group>
|
||||
</Paper>
|
||||
|
||||
<Stack style={{ flex: 1, minHeight: 0 }} gap="md">
|
||||
{selectKey === "own" ? (
|
||||
<OwnTaskTableContainer
|
||||
info={info}
|
||||
userEnums={userEnums}
|
||||
menuAction={DetailMenuItems}
|
||||
/>
|
||||
) : null}
|
||||
{selectKey === "all" ? (
|
||||
<TaskTableContainer
|
||||
info={info}
|
||||
userEnums={userEnums}
|
||||
menuAction={DetailMenuItems}
|
||||
/>
|
||||
) : null}
|
||||
{selectKey === "board" ? <TaskBoardContainer /> : null}
|
||||
{selectKey === "setting" ? (
|
||||
<InfoSettingContainer
|
||||
info={info}
|
||||
userEnums={userEnums}
|
||||
updateAction={updateProjectInfo}
|
||||
menuAction={DetailMenuItems}
|
||||
/>
|
||||
) : null}
|
||||
</Stack>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
1
app/management/project/detail/util.ts
Normal file
1
app/management/project/detail/util.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { runCommand } from "@/app/management/person/dashboard/components/util"
|
||||
Reference in New Issue
Block a user