feat(image): add page
This commit is contained in:
@@ -7,6 +7,7 @@ import "mantine-datatable/styles.css"
|
||||
import Script from "next/script"
|
||||
|
||||
import { InfoCheck } from "@/app/store/InfoCheck"
|
||||
import { OptStore } from "@/components/label/OptStore"
|
||||
import {
|
||||
ColorSchemeScript,
|
||||
MantineProvider,
|
||||
@@ -58,6 +59,7 @@ export default function RootLayout({
|
||||
<MantineProvider defaultColorScheme="light" theme={theme}>
|
||||
<Notifications zIndex={GLOBAL_NOTICE_Z_INDEX} withinPortal />
|
||||
<InfoCheck />
|
||||
<OptStore />
|
||||
<ModalsProvider>
|
||||
<Suspense fallback={<></>}>{children}</Suspense>
|
||||
</ModalsProvider>
|
||||
|
||||
369
app/project/detail/InfoSettingContainer.tsx
Normal file
369
app/project/detail/InfoSettingContainer.tsx
Normal file
@@ -0,0 +1,369 @@
|
||||
"use client"
|
||||
|
||||
import {
|
||||
getProjectAdminList,
|
||||
projectConfig,
|
||||
} from "@/components/label/api/project"
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import { useAllUserStore } from "@/components/label/store/auth"
|
||||
import {
|
||||
ActionIcon,
|
||||
Collapse,
|
||||
Group,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Switch,
|
||||
Text,
|
||||
} from "@mantine/core"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import {
|
||||
IconCheck,
|
||||
IconChevronDown,
|
||||
IconChevronRight,
|
||||
IconEdit,
|
||||
IconX,
|
||||
} from "@tabler/icons-react"
|
||||
import { useCallback, useEffect, 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>
|
||||
}
|
||||
updateAction: () => void
|
||||
}) {
|
||||
const { info, userEnums, updateAction } = props
|
||||
const projectId = info?.id ?? -1
|
||||
|
||||
const { userOpts } = useAllUserStore()
|
||||
const fallbackUserOptions = useMemo(() => {
|
||||
return userOpts.map((o) => ({ label: o.label, value: String(o.value) }))
|
||||
}, [userOpts])
|
||||
|
||||
const [adminOptions, setAdminOptions] = useState<
|
||||
Array<{ label: string; value: string }>
|
||||
>([])
|
||||
|
||||
const [adminModalOpen, setAdminModalOpen] = useState(false)
|
||||
const [lockingValue, setLockingValue] = useState<boolean>(
|
||||
!!info?.is_lock_object
|
||||
)
|
||||
const [lockingEditValue, setLockingEditValue] = useState<boolean>(
|
||||
!!info?.is_lock_object
|
||||
)
|
||||
const [isLockingEdit, setIsLockingEdit] = useState(false)
|
||||
const [savingLock, setSavingLock] = useState(false)
|
||||
|
||||
const [show, setShow] = useState({
|
||||
process: true,
|
||||
scheme: true,
|
||||
sampling: true,
|
||||
note: true,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const v = !!info?.is_lock_object
|
||||
setLockingValue(v)
|
||||
setLockingEditValue(v)
|
||||
setIsLockingEdit(false)
|
||||
}, [info?.is_lock_object])
|
||||
|
||||
const loadAdminOptions = useCallback(async () => {
|
||||
try {
|
||||
const res = await getProjectAdminList()
|
||||
const opts = (res ?? []).map((item) => ({
|
||||
label: item.label,
|
||||
value: String(item.value),
|
||||
}))
|
||||
setAdminOptions(opts)
|
||||
} catch {
|
||||
setAdminOptions([])
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
queueMicrotask(loadAdminOptions)
|
||||
}, [loadAdminOptions])
|
||||
|
||||
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: lockingEditValue,
|
||||
})
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: "已保存配置",
|
||||
})
|
||||
setLockingValue(lockingEditValue)
|
||||
setIsLockingEdit(false)
|
||||
updateAction()
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
} finally {
|
||||
setSavingLock(false)
|
||||
}
|
||||
}
|
||||
|
||||
const sectionTitle = (
|
||||
key: keyof typeof show,
|
||||
title: string,
|
||||
color: "blue" | "orange" | "teal" | "grape"
|
||||
) => {
|
||||
const opened = show[key]
|
||||
return (
|
||||
<Group justify="space-between" wrap="nowrap">
|
||||
<Group gap={8}>
|
||||
<div
|
||||
style={{
|
||||
width: 3,
|
||||
height: 14,
|
||||
borderRadius: 2,
|
||||
backgroundColor: `var(--mantine-color-${color}-6)`,
|
||||
}}
|
||||
/>
|
||||
<Text fw={700}>{title}</Text>
|
||||
</Group>
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="gray"
|
||||
onClick={() => setShow((s) => ({ ...s, [key]: !opened }))}>
|
||||
{opened ? (
|
||||
<IconChevronDown size={16} />
|
||||
) : (
|
||||
<IconChevronRight size={16} />
|
||||
)}
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
)
|
||||
}
|
||||
|
||||
const finalAdminOptions =
|
||||
adminOptions.length > 0 ? adminOptions : fallbackUserOptions
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack gap="md" style={{ flex: 1, minHeight: 0 }} w="100%">
|
||||
<Paper
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="md"
|
||||
style={{
|
||||
borderColor:
|
||||
"light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
}}>
|
||||
<Stack gap="sm">
|
||||
<Group justify="space-between" wrap="wrap">
|
||||
<Text fw={700}>项目配置</Text>
|
||||
<ActionIcon variant="subtle" onClick={updateAction}>
|
||||
<IconEdit size={16} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
|
||||
<SimpleGrid cols={{ base: 1, md: 2 }} spacing="sm">
|
||||
<Paper
|
||||
withBorder
|
||||
p="xs"
|
||||
radius="sm"
|
||||
style={{
|
||||
borderColor:
|
||||
"light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
}}>
|
||||
<Group justify="space-between" wrap="nowrap" align="center">
|
||||
<Stack gap={2} style={{ minWidth: 0 }}>
|
||||
<Text size="sm" fw={600}>
|
||||
项目管理员
|
||||
</Text>
|
||||
<Text
|
||||
size="sm"
|
||||
c="dimmed"
|
||||
style={{
|
||||
maxWidth: 420,
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
whiteSpace: "nowrap",
|
||||
}}>
|
||||
{adminText}
|
||||
</Text>
|
||||
</Stack>
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="blue"
|
||||
onClick={() => {
|
||||
setAdminModalOpen(true)
|
||||
if (adminOptions.length === 0) {
|
||||
queueMicrotask(loadAdminOptions)
|
||||
}
|
||||
}}>
|
||||
<IconEdit size={16} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
</Paper>
|
||||
|
||||
<Paper
|
||||
withBorder
|
||||
p="xs"
|
||||
radius="sm"
|
||||
style={{
|
||||
borderColor:
|
||||
"light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
}}>
|
||||
<Group justify="space-between" wrap="nowrap" align="center">
|
||||
<Stack gap={2}>
|
||||
<Text size="sm" fw={600}>
|
||||
图片对象锁定
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
开启后对象可被锁定,避免多人同时标注冲突
|
||||
</Text>
|
||||
</Stack>
|
||||
{isLockingEdit ? (
|
||||
<Group gap={4} wrap="nowrap">
|
||||
<Switch
|
||||
checked={lockingEditValue}
|
||||
onChange={(e) =>
|
||||
setLockingEditValue(e.currentTarget.checked)
|
||||
}
|
||||
/>
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="gray"
|
||||
onClick={() => {
|
||||
setLockingEditValue(lockingValue)
|
||||
setIsLockingEdit(false)
|
||||
}}>
|
||||
<IconX size={16} />
|
||||
</ActionIcon>
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="blue"
|
||||
loading={savingLock}
|
||||
onClick={saveLock}>
|
||||
<IconCheck size={16} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
) : (
|
||||
<Group gap={8} wrap="nowrap">
|
||||
<Switch checked={lockingValue} readOnly />
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="blue"
|
||||
onClick={() => setIsLockingEdit(true)}>
|
||||
<IconEdit size={16} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
)}
|
||||
</Group>
|
||||
</Paper>
|
||||
</SimpleGrid>
|
||||
|
||||
<Group justify="flex-end">
|
||||
<ActionIcon variant="subtle" onClick={updateAction}>
|
||||
<IconCheck size={16} />
|
||||
</ActionIcon>
|
||||
<Text size="xs" c="dimmed">
|
||||
刷新项目详情
|
||||
</Text>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
<Paper
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="md"
|
||||
style={{
|
||||
borderColor:
|
||||
"light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
flex: 1,
|
||||
minHeight: 0,
|
||||
}}>
|
||||
<ScrollArea h="100%" type="auto">
|
||||
<Stack gap="sm">
|
||||
{sectionTitle("process", "任务流程", "blue")}
|
||||
<Collapse in={show.process}>
|
||||
<TaskStageTabsContainer
|
||||
projectId={projectId}
|
||||
info={info}
|
||||
userOptions={fallbackUserOptions}
|
||||
userEnums={userEnums}
|
||||
onUpdatedAction={updateAction}
|
||||
/>
|
||||
</Collapse>
|
||||
|
||||
{sectionTitle("scheme", "标注方案", "orange")}
|
||||
<Collapse in={show.scheme}>
|
||||
<LabelSchemeContainer info={info} />
|
||||
</Collapse>
|
||||
|
||||
{sectionTitle("sampling", "抽检方案", "teal")}
|
||||
<Collapse in={show.sampling}>
|
||||
<SamplingPlanContainer
|
||||
projectId={projectId}
|
||||
info={info}
|
||||
onUpdated={updateAction}
|
||||
/>
|
||||
</Collapse>
|
||||
|
||||
{sectionTitle("note", "批注规则", "grape")}
|
||||
<Collapse in={show.note}>
|
||||
<NoteRulesTable info={info} onUpdated={updateAction} />
|
||||
</Collapse>
|
||||
</Stack>
|
||||
</ScrollArea>
|
||||
</Paper>
|
||||
</Stack>
|
||||
|
||||
<AdminUserModal
|
||||
opened={adminModalOpen}
|
||||
value={info?.admin_user ?? []}
|
||||
options={finalAdminOptions}
|
||||
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 : "请求失败",
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
427
app/project/detail/OwnTaskTableContainer.tsx
Normal file
427
app/project/detail/OwnTaskTableContainer.tsx
Normal file
@@ -0,0 +1,427 @@
|
||||
"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,
|
||||
usePermissionStore,
|
||||
} from "@/components/label/store/auth"
|
||||
import { OwnTaskStatusOpts } from "@/components/label/utils/constants"
|
||||
import {
|
||||
ActionIcon,
|
||||
Button,
|
||||
Collapse,
|
||||
Flex,
|
||||
Group,
|
||||
Paper,
|
||||
Select,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import {
|
||||
IconChevronDown,
|
||||
IconChevronUp,
|
||||
IconRefresh,
|
||||
IconSearch,
|
||||
} 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"
|
||||
|
||||
function createInitialFilters() {
|
||||
return {
|
||||
search_id: "",
|
||||
search_status: "0",
|
||||
}
|
||||
}
|
||||
|
||||
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 [total, setTotal] = useState(0)
|
||||
|
||||
const [pageNumber, setPageNumber] = useState(1)
|
||||
const [pageSize, setPageSize] = useState(15)
|
||||
|
||||
const [searchExpanded, setSearchExpanded] = useState(false)
|
||||
|
||||
const [filters, setFilters] = useState(() => createInitialFilters())
|
||||
const [form, setForm] = useState<{
|
||||
search_id: string
|
||||
search_status: string
|
||||
}>(createInitialFilters())
|
||||
|
||||
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 = {
|
||||
page_number: pageNumber ?? 1,
|
||||
page_size: pageSize ?? 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,
|
||||
pageNumber,
|
||||
pageSize,
|
||||
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])
|
||||
|
||||
useEffect(() => {
|
||||
queueMicrotask(() => {
|
||||
setQueryTrigger((v) => v + 1)
|
||||
})
|
||||
}, [])
|
||||
|
||||
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="transparent"
|
||||
size="xs"
|
||||
style={{ paddingLeft: 6, paddingRight: 6 }}
|
||||
onClick={async () => {
|
||||
const backUrl = type
|
||||
? `/project/detail?id=${projectId}&type=${type}`
|
||||
: `/project/detail?id=${projectId}`
|
||||
setBackProps(backUrl, "own")
|
||||
|
||||
if (info && [4, 5, 6, 7].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="sm">
|
||||
<Group justify="space-between" wrap="wrap" gap="sm">
|
||||
<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={() => {
|
||||
const next = createInitialFilters()
|
||||
setFilters(next)
|
||||
setForm(next)
|
||||
setPageNumber(1)
|
||||
}}>
|
||||
重置
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
radius={"xs"}
|
||||
leftSection={<IconSearch size={16} />}
|
||||
onClick={() => {
|
||||
setPageNumber(1)
|
||||
setForm({ ...filters })
|
||||
}}>
|
||||
查询
|
||||
</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
|
||||
size="xs"
|
||||
radius="xs"
|
||||
label="任务ID"
|
||||
value={filters.search_id}
|
||||
onChange={(e) =>
|
||||
setFilters((s) => ({
|
||||
...s,
|
||||
search_id: e.target.value,
|
||||
}))
|
||||
}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
<Select
|
||||
size="xs"
|
||||
radius="xs"
|
||||
label="状态"
|
||||
data={Object.entries(OwnTaskStatusOpts).map(
|
||||
([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
})
|
||||
)}
|
||||
value={filters.search_status}
|
||||
onChange={(v) =>
|
||||
setFilters((s) => ({ ...s, search_status: v ?? "0" }))
|
||||
}
|
||||
allowDeselect={false}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
</Collapse>
|
||||
</Paper>
|
||||
|
||||
<Paper
|
||||
withBorder
|
||||
p="md"
|
||||
radius="sm"
|
||||
style={{
|
||||
flex: 1,
|
||||
minHeight: 0,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
}}>
|
||||
<Stack gap={12} align="stretch" style={{ flex: 1, minHeight: 0 }}>
|
||||
<Flex justify={"space-between"} align="center" w="100%">
|
||||
<Flex gap={12}>
|
||||
<Button
|
||||
size="xs"
|
||||
radius="xs"
|
||||
variant="default"
|
||||
disabled={!isLabel}
|
||||
onClick={() => handleAcquireTask(1)}>
|
||||
领取标注
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
radius="xs"
|
||||
variant="default"
|
||||
disabled={!isReview1}
|
||||
onClick={() => handleAcquireTask(2)}>
|
||||
领取审核
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
radius="xs"
|
||||
variant="default"
|
||||
disabled={!isReview2}
|
||||
onClick={() => handleAcquireTask(3)}>
|
||||
领取复审
|
||||
</Button>
|
||||
</Flex>
|
||||
<ActionIcon onClick={load} variant="transparent">
|
||||
<IconRefresh size={16} />
|
||||
</ActionIcon>
|
||||
</Flex>
|
||||
<DataTable<Task.DataProps>
|
||||
width="100%"
|
||||
style={{ width: "100%" }}
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
pinFirstColumn
|
||||
pinLastColumn
|
||||
scrollAreaProps={{ type: "auto" }}
|
||||
fetching={loading}
|
||||
records={records}
|
||||
columns={columns}
|
||||
totalRecords={total}
|
||||
recordsPerPage={pageSize}
|
||||
page={pageNumber}
|
||||
onPageChange={(p) => setPageNumber(p)}
|
||||
onRecordsPerPageChange={(s) => {
|
||||
setPageSize(s)
|
||||
setPageNumber(1)
|
||||
}}
|
||||
recordsPerPageOptions={[10, 15, 20]}
|
||||
noRecordsText="暂无数据"
|
||||
recordsPerPageLabel="当前页数"
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
23
app/project/detail/TaskBoardContainer.tsx
Normal file
23
app/project/detail/TaskBoardContainer.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
"use client"
|
||||
|
||||
import { Paper, Stack, Text } from "@mantine/core"
|
||||
|
||||
export default function TaskBoardContainer() {
|
||||
return (
|
||||
<Paper
|
||||
withBorder
|
||||
p="md"
|
||||
radius="md"
|
||||
style={{
|
||||
borderColor:
|
||||
"light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
}}>
|
||||
<Stack gap="xs">
|
||||
<Text fw={700}>统计信息</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
暂未迁移统计看板,可在后续按需补齐。
|
||||
</Text>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
1005
app/project/detail/TaskTableContainer.tsx
Normal file
1005
app/project/detail/TaskTableContainer.tsx
Normal file
File diff suppressed because it is too large
Load Diff
59
app/project/detail/components/AdminUserModal.tsx
Normal file
59
app/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>
|
||||
)
|
||||
}
|
||||
157
app/project/detail/components/DispatchModal.tsx
Normal file
157
app/project/detail/components/DispatchModal.tsx
Normal file
@@ -0,0 +1,157 @@
|
||||
"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 { selectedDataProps } from "../TaskTableContainer"
|
||||
import { dispatchOpts } from "./config"
|
||||
|
||||
export default function DispatchModal(props: {
|
||||
opened: boolean
|
||||
dispatchData?: selectedDataProps
|
||||
task_ids: Task.DataProps[]
|
||||
userOptions: Array<{ label: string; value: string }>
|
||||
onCloseAction: (refresh?: boolean) => void
|
||||
}) {
|
||||
const { opened, dispatchData, task_ids, userOptions, onCloseAction } = props
|
||||
const operation_uid = usePermissionStore((s) => s.user_id)
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
reject: false,
|
||||
task_status_dst: "",
|
||||
uid_dst: "",
|
||||
},
|
||||
})
|
||||
|
||||
const taskStatusSrc = dispatchData?.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)
|
||||
console.log(dispatchData, operation_uid)
|
||||
|
||||
if (!values?.uid_dst || !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: task_ids.map((item) => item.id),
|
||||
task_status_src: taskStatusSrc,
|
||||
task_status_dst: taskStatusDst,
|
||||
uid_src: dispatchData?.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">
|
||||
当前任务:
|
||||
{task_ids.map((item) => item.project_name).join("、") ?? "-"}
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
(源状态:{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>
|
||||
)
|
||||
}
|
||||
224
app/project/detail/components/LabelSchemeContainer.tsx
Normal file
224
app/project/detail/components/LabelSchemeContainer.tsx
Normal file
@@ -0,0 +1,224 @@
|
||||
"use client"
|
||||
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import {
|
||||
labelTypeMap,
|
||||
selectModeMap,
|
||||
staticsColor,
|
||||
} from "@/components/label/utils/constants"
|
||||
import { Badge, Button, Group, Modal, Paper, Stack, Text } from "@mantine/core"
|
||||
import { DataTable, DataTableColumn } from "mantine-datatable"
|
||||
import { useState } from "react"
|
||||
|
||||
type DetailRow = ProjectDetail.SubAttributesDescribe
|
||||
|
||||
function getColorIndex(color: number[] | undefined) {
|
||||
if (!Array.isArray(color) || color.length < 3) return undefined
|
||||
const key = color.slice(0, 3).join("_")
|
||||
for (const item of staticsColor) {
|
||||
const [colorKey, colorIndex] = Object.entries(item)[0] ?? []
|
||||
if (colorKey === key && typeof colorIndex === "number") {
|
||||
return colorIndex
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
export default function LabelSchemeContainer(props: {
|
||||
info: ProjectDetail.DataProps | undefined
|
||||
}) {
|
||||
const schemas = props.info?.label_schema_list ?? []
|
||||
const [detailOpen, setDetailOpen] = useState(false)
|
||||
const [detailRows, setDetailRows] = useState<DetailRow[]>([])
|
||||
|
||||
const columns: DataTableColumn<ProjectDetail.LabelSchemaList>[] = [
|
||||
{
|
||||
accessor: "label_class",
|
||||
title: "类别",
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
accessor: "super_category",
|
||||
title: "属性",
|
||||
width: 120,
|
||||
render: (record) => record.super_category || "-",
|
||||
},
|
||||
{
|
||||
accessor: "category_id",
|
||||
title: "ID",
|
||||
width: 90,
|
||||
},
|
||||
{
|
||||
accessor: "label_type",
|
||||
title: "标注方式",
|
||||
width: 140,
|
||||
render: (record) => (
|
||||
<Badge variant="light">
|
||||
{labelTypeMap.get(record.label_type) ??
|
||||
String(record.label_type ?? "-")}
|
||||
</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessor: "color",
|
||||
title: "标签颜色",
|
||||
width: 130,
|
||||
render: (record) => {
|
||||
const color = Array.isArray(record.color) ? record.color : []
|
||||
const idx = getColorIndex(color)
|
||||
if (color.length < 3) {
|
||||
return (
|
||||
<Text size="sm" c="dimmed">
|
||||
-
|
||||
</Text>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Group gap={8} wrap="nowrap">
|
||||
<div
|
||||
style={{
|
||||
width: 10,
|
||||
height: 10,
|
||||
borderRadius: 999,
|
||||
backgroundColor: `rgb(${color.join(",")})`,
|
||||
border:
|
||||
"1px solid light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
}}
|
||||
/>
|
||||
<Text size="sm">{idx ?? "-"}</Text>
|
||||
</Group>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
accessor: "sub_attributes",
|
||||
title: "子属性",
|
||||
width: 180,
|
||||
render: (record) => {
|
||||
const attrs = Array.isArray(record.sub_attributes)
|
||||
? record.sub_attributes
|
||||
: []
|
||||
return (
|
||||
<Text
|
||||
size="sm"
|
||||
style={{
|
||||
maxWidth: 180,
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
whiteSpace: "nowrap",
|
||||
}}>
|
||||
{attrs.length ? attrs.join("、") : "-"}
|
||||
</Text>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
accessor: "sub_attributes_describe",
|
||||
title: "子属性描述",
|
||||
width: 120,
|
||||
textAlign: "center",
|
||||
render: (record) => {
|
||||
const details = Array.isArray(record.sub_attributes_describe)
|
||||
? record.sub_attributes_describe
|
||||
: []
|
||||
if (!details.length) {
|
||||
return (
|
||||
<Text size="sm" c="dimmed">
|
||||
-
|
||||
</Text>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Button
|
||||
variant="subtle"
|
||||
size="compact-xs"
|
||||
onClick={() => {
|
||||
setDetailRows(details)
|
||||
setDetailOpen(true)
|
||||
}}>
|
||||
查看
|
||||
</Button>
|
||||
)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
const detailColumns: DataTableColumn<DetailRow>[] = [
|
||||
{
|
||||
accessor: "chinese_name",
|
||||
title: "子属性",
|
||||
width: 140,
|
||||
render: (record) => record.chinese_name || "-",
|
||||
},
|
||||
{
|
||||
accessor: "select_mode",
|
||||
title: "输入方式",
|
||||
width: 100,
|
||||
render: (record) =>
|
||||
selectModeMap.get(record.select_mode) ??
|
||||
String(record.select_mode ?? "-"),
|
||||
},
|
||||
{
|
||||
accessor: "isrequired",
|
||||
title: "是否必填",
|
||||
width: 90,
|
||||
render: (record) => (record.isrequired === 1 ? "是" : "否"),
|
||||
},
|
||||
{
|
||||
accessor: "optional_item",
|
||||
title: "可选属性值",
|
||||
render: (record) => {
|
||||
const opts = Array.isArray(record.optional_item)
|
||||
? record.optional_item
|
||||
: []
|
||||
return opts.length ? opts.join(";") : "-"
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
<Paper
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="md"
|
||||
style={{
|
||||
borderColor:
|
||||
"light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
}}>
|
||||
<Stack gap="sm">
|
||||
<Text fw={700}>标注方案</Text>
|
||||
<DataTable<ProjectDetail.LabelSchemaList>
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
idAccessor="category_id"
|
||||
records={schemas}
|
||||
columns={columns}
|
||||
minHeight={160}
|
||||
noRecordsText="暂无数据"
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
<Modal
|
||||
opened={detailOpen}
|
||||
onClose={() => {
|
||||
setDetailOpen(false)
|
||||
setDetailRows([])
|
||||
}}
|
||||
title="子属性描述"
|
||||
centered
|
||||
size="70%">
|
||||
<DataTable<DetailRow>
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
records={detailRows}
|
||||
columns={detailColumns}
|
||||
noRecordsText="暂无数据"
|
||||
minHeight={220}
|
||||
idAccessor="chinese_name"
|
||||
/>
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
278
app/project/detail/components/NoteRulesTable.tsx
Normal file
278
app/project/detail/components/NoteRulesTable.tsx
Normal file
@@ -0,0 +1,278 @@
|
||||
"use client"
|
||||
|
||||
import { projectConfig } from "@/components/label/api/project"
|
||||
import { ProjectDetail } from "@/components/label/api/project/typing"
|
||||
import { usePermissionStore } from "@/components/label/store/auth"
|
||||
import {
|
||||
ActionIcon,
|
||||
Badge,
|
||||
Button,
|
||||
Group,
|
||||
Modal,
|
||||
Paper,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core"
|
||||
import { modals } from "@mantine/modals"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import { IconPlus, IconTrash } from "@tabler/icons-react"
|
||||
import dayjs from "dayjs"
|
||||
import { DataTable, DataTableColumn } from "mantine-datatable"
|
||||
import { useMemo, useState } from "react"
|
||||
|
||||
type RulePayload = {
|
||||
text: string
|
||||
create_user: string
|
||||
create_date: string
|
||||
}
|
||||
|
||||
type RuleRow = RulePayload & {
|
||||
index: number
|
||||
}
|
||||
|
||||
function normalizeRule(item: unknown): RulePayload {
|
||||
if (typeof item === "string") {
|
||||
return { text: item, create_user: "-", create_date: "-" }
|
||||
}
|
||||
if (item && typeof item === "object") {
|
||||
const rule = item as {
|
||||
text?: unknown
|
||||
create_user?: unknown
|
||||
create_date?: unknown
|
||||
}
|
||||
return {
|
||||
text: String(rule.text ?? ""),
|
||||
create_user: String(rule.create_user ?? "-"),
|
||||
create_date: String(rule.create_date ?? "-"),
|
||||
}
|
||||
}
|
||||
return { text: "", create_user: "-", create_date: "-" }
|
||||
}
|
||||
|
||||
export default function NoteRulesTable(props: {
|
||||
info: ProjectDetail.DataProps | undefined
|
||||
onUpdated: () => void
|
||||
}) {
|
||||
const { info, onUpdated } = props
|
||||
const projectId = info?.id ?? -1
|
||||
const userName = usePermissionStore((s) => s.user_name)
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
const [inputText, setInputText] = useState("")
|
||||
const [saving, setSaving] = useState(false)
|
||||
|
||||
const textRules = useMemo(() => {
|
||||
const rules = (info?.comment_rule as any)?.text_rules
|
||||
return Array.isArray(rules) ? rules.map((r) => String(r ?? "")) : []
|
||||
}, [info?.comment_rule])
|
||||
|
||||
const checkBoxRules = useMemo<RulePayload[]>(() => {
|
||||
const raw = (info?.comment_rule as any)?.check_box_rules
|
||||
const list = Array.isArray(raw) ? raw : []
|
||||
return list.map((item) => normalizeRule(item))
|
||||
}, [info?.comment_rule])
|
||||
|
||||
const rows = useMemo<RuleRow[]>(() => {
|
||||
return checkBoxRules.map((rule, index) => ({ ...rule, index }))
|
||||
}, [checkBoxRules])
|
||||
|
||||
const saveRules = async (nextRules: RulePayload[], successText: string) => {
|
||||
if (projectId === -1) return
|
||||
setSaving(true)
|
||||
try {
|
||||
await projectConfig({
|
||||
project_id: projectId,
|
||||
comment_rule: {
|
||||
check_box_rules: nextRules,
|
||||
text_rules: textRules,
|
||||
},
|
||||
})
|
||||
notifications.show({
|
||||
color: "green",
|
||||
title: "操作成功",
|
||||
message: successText,
|
||||
})
|
||||
setOpen(false)
|
||||
setInputText("")
|
||||
onUpdated()
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "操作失败",
|
||||
message: e instanceof Error ? e.message : "请求失败",
|
||||
})
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleAdd = async () => {
|
||||
const value = inputText.trim()
|
||||
if (!value) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "新增失败",
|
||||
message: "批注内容不能为空",
|
||||
})
|
||||
return
|
||||
}
|
||||
const exists = rows.some((row) => row.text.trim() === value)
|
||||
if (exists) {
|
||||
notifications.show({
|
||||
color: "red",
|
||||
title: "新增失败",
|
||||
message: "批注规则重复,请重新输入",
|
||||
})
|
||||
return
|
||||
}
|
||||
const next: RulePayload[] = [
|
||||
...checkBoxRules,
|
||||
{
|
||||
text: value,
|
||||
create_user: userName ? String(userName) : "-",
|
||||
create_date: dayjs().format("YYYY-MM-DD"),
|
||||
},
|
||||
]
|
||||
await saveRules(next, "已添加规则")
|
||||
}
|
||||
|
||||
const handleDelete = async (row: RuleRow) => {
|
||||
const next = checkBoxRules.filter((_, index) => index !== row.index)
|
||||
await saveRules(next, "已删除规则")
|
||||
}
|
||||
|
||||
const columns: DataTableColumn<RuleRow>[] = [
|
||||
{
|
||||
accessor: "method",
|
||||
title: "批注方式",
|
||||
width: 90,
|
||||
render: () => <Badge variant="light">勾选</Badge>,
|
||||
},
|
||||
{
|
||||
accessor: "text",
|
||||
title: "内容",
|
||||
},
|
||||
{
|
||||
accessor: "create_user",
|
||||
title: "添加者",
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
accessor: "create_date",
|
||||
title: "添加日期",
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
accessor: "operation",
|
||||
title: "操作",
|
||||
width: 90,
|
||||
textAlign: "center",
|
||||
render: (record) => (
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="red"
|
||||
onClick={() => {
|
||||
modals.openConfirmModal({
|
||||
title: "删除规则",
|
||||
centered: true,
|
||||
children: <Text size="sm">确定删除该批注规则吗?</Text>,
|
||||
labels: { confirm: "确定", cancel: "取消" },
|
||||
confirmProps: { color: "red" },
|
||||
onConfirm: () => handleDelete(record),
|
||||
})
|
||||
}}>
|
||||
<IconTrash size={16} />
|
||||
</ActionIcon>
|
||||
),
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
<Paper
|
||||
withBorder
|
||||
p="sm"
|
||||
radius="md"
|
||||
style={{
|
||||
borderColor:
|
||||
"light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
}}>
|
||||
<Stack gap="sm">
|
||||
<Group justify="space-between" wrap="wrap">
|
||||
<Text fw={700}>批注规则</Text>
|
||||
<Button
|
||||
size="xs"
|
||||
leftSection={<IconPlus size={14} />}
|
||||
onClick={() => {
|
||||
setInputText("")
|
||||
setOpen(true)
|
||||
}}>
|
||||
添加规则
|
||||
</Button>
|
||||
</Group>
|
||||
|
||||
<Stack gap={4}>
|
||||
<Text size="sm" fw={600}>
|
||||
文本规则
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
{textRules.length ? textRules.join(";") : "-"}
|
||||
</Text>
|
||||
</Stack>
|
||||
|
||||
<DataTable<RuleRow>
|
||||
withTableBorder
|
||||
withRowBorders
|
||||
records={rows}
|
||||
columns={columns}
|
||||
noRecordsText="暂无规则"
|
||||
minHeight={200}
|
||||
idAccessor={(record) =>
|
||||
`${record.index}_${record.text}_${record.create_user}_${record.create_date}`
|
||||
}
|
||||
/>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
<Modal
|
||||
opened={open}
|
||||
onClose={() => {
|
||||
if (saving) return
|
||||
setOpen(false)
|
||||
setInputText("")
|
||||
}}
|
||||
title="添加批注规则"
|
||||
centered>
|
||||
<Stack gap="sm">
|
||||
<Group gap="sm">
|
||||
<Text size="sm" c="dimmed">
|
||||
批注方式
|
||||
</Text>
|
||||
<Badge variant="light">勾选</Badge>
|
||||
</Group>
|
||||
<TextInput
|
||||
label="批注内容"
|
||||
placeholder="请输入批注内容"
|
||||
value={inputText}
|
||||
onChange={(e) => setInputText(e.currentTarget.value)}
|
||||
/>
|
||||
<Group justify="flex-end" gap="sm">
|
||||
<Button
|
||||
variant="default"
|
||||
onClick={() => {
|
||||
setOpen(false)
|
||||
setInputText("")
|
||||
}}
|
||||
disabled={saving}>
|
||||
取消
|
||||
</Button>
|
||||
<Button onClick={handleAdd} loading={saving}>
|
||||
保存
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
90
app/project/detail/components/ReleaseModal.tsx
Normal file
90
app/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>
|
||||
)
|
||||
}
|
||||
172
app/project/detail/components/SamplingPlanContainer.tsx
Normal file
172
app/project/detail/components/SamplingPlanContainer.tsx
Normal file
@@ -0,0 +1,172 @@
|
||||
"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:
|
||||
"light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
}}>
|
||||
<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:
|
||||
"light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4))",
|
||||
}}>
|
||||
<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/project/detail/components/StageUserModal.tsx
Normal file
60
app/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>
|
||||
)
|
||||
}
|
||||
1537
app/project/detail/components/TaskStageTabsContainer.tsx
Normal file
1537
app/project/detail/components/TaskStageTabsContainer.tsx
Normal file
File diff suppressed because it is too large
Load Diff
50
app/project/detail/components/TaskStatusTag.tsx
Normal file
50
app/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/project/detail/components/WorkflowModal.tsx
Normal file
80
app/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>
|
||||
)
|
||||
}
|
||||
151
app/project/detail/components/config.ts
Normal file
151
app/project/detail/components/config.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
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 },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
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 }],
|
||||
},
|
||||
}
|
||||
224
app/project/detail/page.tsx
Normal file
224
app/project/detail/page.tsx
Normal file
@@ -0,0 +1,224 @@
|
||||
"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,
|
||||
Flex,
|
||||
Group,
|
||||
Paper,
|
||||
Stack,
|
||||
Text,
|
||||
UnstyledButton,
|
||||
} from "@mantine/core"
|
||||
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) || "all"
|
||||
)
|
||||
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
|
||||
? type === "collect"
|
||||
? `/person/collection`
|
||||
: "/project/dynamic"
|
||||
: "/project/own",
|
||||
},
|
||||
{
|
||||
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
|
||||
}, [])
|
||||
|
||||
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
|
||||
? `/project/detail?id=${projectId}&type=${type}`
|
||||
: `/project/detail?id=${projectId}`
|
||||
setBackProps(backUrl, next)
|
||||
}}
|
||||
style={{
|
||||
paddingLeft: 14,
|
||||
paddingRight: 14,
|
||||
paddingTop: 6,
|
||||
paddingBottom: 6,
|
||||
borderTopLeftRadius: index === 0 ? 4 : 0,
|
||||
borderBottomLeftRadius: index === 0 ? 4 : 0,
|
||||
borderTopRightRadius: index === menuItems.length - 1 ? 4 : 0,
|
||||
borderBottomRightRadius: index === menuItems.length - 1 ? 4 : 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="sm">
|
||||
<Group justify="space-between" wrap="wrap" gap="sm">
|
||||
<Flex gap="sm" w="100%" justify="space-between">
|
||||
<Breadcrumbs separator=">">{breadcrumbsItems}</Breadcrumbs>
|
||||
{DetailMenuItems()}
|
||||
</Flex>
|
||||
</Group>
|
||||
</Paper>
|
||||
|
||||
<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}
|
||||
updateAction={updateProjectInfo}
|
||||
/>
|
||||
) : null}
|
||||
</Stack>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
"use client"
|
||||
|
||||
export default function ProjectOwnPage() {
|
||||
return <>Project Own</>
|
||||
import ProjectInfoPage from "@/components/project"
|
||||
|
||||
export default function ProjectAllPage() {
|
||||
return <ProjectInfoPage type={""} />
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
"use client"
|
||||
|
||||
export default function ProjectSettingPage() {
|
||||
return <>Project Setting</>
|
||||
}
|
||||
@@ -14,6 +14,7 @@ export namespace Project {
|
||||
rate_speed?: number // 额定倍速
|
||||
create_user: string // 创建人
|
||||
owner: string // 项目负责人
|
||||
members: number[] // 项目成员
|
||||
label_process?: string[] // 工序
|
||||
admin_user: number[] // 标注管理员id
|
||||
data_source?: string // 数据源
|
||||
|
||||
@@ -1070,8 +1070,8 @@ const TopTools = (
|
||||
} else {
|
||||
// 无id返回时跳转回任务列表页
|
||||
const url = backUrl || "/"
|
||||
// router.push(url)
|
||||
window.location.href = url
|
||||
router.push(url)
|
||||
// window.location.href = url
|
||||
// 重置图片比例及选中标注对象
|
||||
usePaperStore.getState().resetRasterScale()
|
||||
useObjectStore.getState().resetPathAndOperationStatus()
|
||||
@@ -1660,8 +1660,8 @@ const TopTools = (
|
||||
onClick={() => {
|
||||
if (isView) {
|
||||
const url = backUrl || "/"
|
||||
// router.push(url)
|
||||
window.location.href = url
|
||||
router.push(url)
|
||||
// window.location.href = url
|
||||
// handleBackup("auto_backup");
|
||||
// 重置图片比例及选中标注对象
|
||||
usePaperStore.getState().resetRasterScale()
|
||||
@@ -2248,8 +2248,8 @@ const TopTools = (
|
||||
}
|
||||
setConfirmOpen(false)
|
||||
const url = backUrl || "/"
|
||||
// router.push(url)
|
||||
window.location.href = url
|
||||
router.push(url)
|
||||
// window.location.href = url
|
||||
// 重置图片比例及选中标注对象
|
||||
usePaperStore.getState().resetRasterScale()
|
||||
useObjectStore.getState().resetPathAndOperationStatus()
|
||||
@@ -2259,8 +2259,8 @@ const TopTools = (
|
||||
setConfirmOpen(false)
|
||||
handleBackup("auto_backup")
|
||||
const url = backUrl || "/"
|
||||
// router.push(url)
|
||||
window.location.href = url
|
||||
router.push(url)
|
||||
// window.location.href = url
|
||||
// 重置图片比例及选中标注对象
|
||||
usePaperStore.getState().resetRasterScale()
|
||||
useObjectStore.getState().resetPathAndOperationStatus()
|
||||
|
||||
@@ -12,6 +12,7 @@ type PermissionMap = {
|
||||
}
|
||||
|
||||
const mappingList: { [x: string]: [string, string] } = {
|
||||
"/setting/project/all": ["project", "config"],
|
||||
"/management/team/employee": ["user", "view"],
|
||||
"/management/team/organization": ["user", "group_view"],
|
||||
"/management/team/dailypaper": ["daily_work", "team_view"],
|
||||
|
||||
@@ -144,6 +144,7 @@ export default function AppLayout({
|
||||
process.env.NEXT_PUBLIC_OUTPUT_TYPE === "standalone" &&
|
||||
(await deleteCookie())
|
||||
router.push("/login")
|
||||
window.location.reload()
|
||||
}
|
||||
const matches = useMediaQuery("(min-width: 48em)")
|
||||
|
||||
|
||||
@@ -15,15 +15,10 @@ const currentComponentList: MenuItem[] = [
|
||||
icon: "SystemIcon",
|
||||
items: [
|
||||
{
|
||||
title: "个人项目",
|
||||
title: "我的项目",
|
||||
url: "own",
|
||||
icon: "PersonalMenuIcon",
|
||||
},
|
||||
{
|
||||
title: "项目设置",
|
||||
url: "setting",
|
||||
icon: "PersonalMenuIcon",
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
@@ -187,12 +187,12 @@ export default function LoginPage({ useUserStore }: { useUserStore: any }) {
|
||||
setError(null)
|
||||
|
||||
try {
|
||||
let isAdmin = values.username === "admin"
|
||||
let phone = values.username.startsWith("+86")
|
||||
? values.username
|
||||
: `+86${values.username}`
|
||||
// let isAdmin = values.username === "admin"
|
||||
// let phone = values.username.startsWith("+86")
|
||||
// ? values.username
|
||||
// : `+86${values.username}`
|
||||
const params = {
|
||||
account: isAdmin ? values.username : phone,
|
||||
account: values.username,
|
||||
password: values.password,
|
||||
tenant: TENANT,
|
||||
platform: PLATFORM,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ResultData } from "@/api/typing"
|
||||
import { Login } from "@/components/login/api/types"
|
||||
import redis from "@/components/login/libs/redis"
|
||||
import { encrypt, generateKeyFromEnv } from "@/components/login/libs/session"
|
||||
@@ -55,7 +54,7 @@ export const handleLoginData = async (props: {
|
||||
}
|
||||
|
||||
export const handleRefreshToken = async (props: {
|
||||
data: ResultData<Login.ResRefreshKey>
|
||||
data: Login.ResLabelLogin
|
||||
userData: any
|
||||
}) => {
|
||||
const { userData, data } = props
|
||||
@@ -64,21 +63,18 @@ export const handleRefreshToken = async (props: {
|
||||
JSON.parse(redisKey),
|
||||
JSON.stringify({
|
||||
...rest,
|
||||
access_token: data?.message?.access,
|
||||
refresh_token: data?.message?.refresh,
|
||||
user_name: data?.name,
|
||||
access_token: data.token,
|
||||
refresh_token: data.refresh_token,
|
||||
}),
|
||||
"EX",
|
||||
172800
|
||||
)
|
||||
return {
|
||||
...data,
|
||||
message: {
|
||||
...data.message,
|
||||
// access_token: "",
|
||||
// refresh_token: "",
|
||||
access: "",
|
||||
refresh: "",
|
||||
},
|
||||
token: "",
|
||||
access_token: "",
|
||||
refresh_token: "",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
245
components/project/components/ProjectIcon.tsx
Normal file
245
components/project/components/ProjectIcon.tsx
Normal file
File diff suppressed because one or more lines are too long
1144
components/project/index.tsx
Normal file
1144
components/project/index.tsx
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user