feat(task): task detail

This commit is contained in:
2026-02-09 18:20:33 +08:00
parent f0298b91e3
commit 3f284d057c
19 changed files with 435 additions and 279 deletions

View File

@@ -8,9 +8,9 @@ export default function AdminUserModal(props: {
opened: boolean
value: number[]
options: Array<{ label: string; value: string }>
onClose: (next?: number[]) => void
onCloseAction: (next?: number[]) => void
}) {
const { opened, value, options, onClose } = props
const { opened, value, options, onCloseAction } = props
const form = useForm({
initialValues: { users: value.map(String) },
@@ -25,7 +25,7 @@ export default function AdminUserModal(props: {
return (
<Modal
opened={opened}
onClose={() => onClose()}
onClose={() => onCloseAction()}
title="编辑项目管理员"
centered
size={560}>
@@ -34,7 +34,7 @@ export default function AdminUserModal(props: {
const next = values.users
.map((v) => Number(v))
.filter((v) => Number.isFinite(v))
onClose(next)
onCloseAction(next)
})}>
<Stack gap="sm">
<MultiSelect
@@ -46,7 +46,7 @@ export default function AdminUserModal(props: {
onChange={(v) => form.setFieldValue("users", v)}
/>
<Group justify="flex-end" gap="sm">
<Button variant="default" onClick={() => onClose()}>
<Button variant="default" onClick={() => onCloseAction()}>
</Button>
<Button type="submit"></Button>

View File

@@ -3,7 +3,15 @@
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 {
Button,
Group,
Modal,
Select,
Stack,
Switch,
Text,
} from "@mantine/core"
import { useForm } from "@mantine/form"
import { notifications } from "@mantine/notifications"
import { dispatchOpts } from "../../config"
@@ -12,9 +20,9 @@ export default function DispatchModal(props: {
opened: boolean
record: Task.DataProps | null
userOptions: Array<{ label: string; value: string }>
onClose: (refresh?: boolean) => void
onCloseAction: (refresh?: boolean) => void
}) {
const { opened, record, userOptions, onClose } = props
const { opened, record, userOptions, onCloseAction } = props
const operation_uid = usePermissionStore((s) => s.user_id)
const form = useForm({
@@ -35,13 +43,16 @@ export default function DispatchModal(props: {
return (
<Modal
opened={opened}
onClose={() => onClose()}
onClose={() => onCloseAction()}
title="调度任务"
centered
size={520}>
<form
onSubmit={form.onSubmit(async (values) => {
const opUid = typeof operation_uid === "number" ? operation_uid : Number(operation_uid ?? 0)
const opUid =
typeof operation_uid === "number"
? operation_uid
: Number(operation_uid ?? 0)
if (!record?.id || !opUid) {
notifications.show({
color: "red",
@@ -85,7 +96,7 @@ export default function DispatchModal(props: {
title: "操作成功",
message: "已调度任务",
})
onClose(true)
onCloseAction(true)
} catch (e) {
notifications.show({
color: "red",
@@ -120,11 +131,13 @@ export default function DispatchModal(props: {
<Switch
label="是否返工"
checked={form.values.reject}
onChange={(e) => form.setFieldValue("reject", e.currentTarget.checked)}
onChange={(e) =>
form.setFieldValue("reject", e.currentTarget.checked)
}
/>
<Group justify="flex-end" gap="sm">
<Button variant="default" onClick={() => onClose()}>
<Button variant="default" onClick={() => onCloseAction()}>
</Button>
<Button type="submit"></Button>
@@ -134,4 +147,3 @@ export default function DispatchModal(props: {
</Modal>
)
}

View File

@@ -36,7 +36,9 @@ export default function LabelSchemeContainer(props: {
}}
/>
<Text size="sm">
{color.length >= 3 ? `${color[0]},${color[1]},${color[2]}` : "-"}
{color.length >= 3
? `${color[0]},${color[1]},${color[2]}`
: "-"}
</Text>
</Group>
)
@@ -70,7 +72,11 @@ export default function LabelSchemeContainer(props: {
}, [])
return (
<Paper withBorder p="sm" radius="md" style={{ borderColor: "rgba(0,0,0,0.06)" }}>
<Paper
withBorder
p="sm"
radius="md"
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
<Stack gap="sm">
<Text fw={700}></Text>
<DataTable<ProjectDetail.LabelSchemaList>
@@ -85,4 +91,3 @@ export default function LabelSchemeContainer(props: {
</Paper>
)
}

View File

@@ -11,7 +11,11 @@ export default function NoteRulesTable(props: {
const checkBoxRules = rules?.check_box_rules ?? []
return (
<Paper withBorder p="sm" radius="md" style={{ borderColor: "rgba(0,0,0,0.06)" }}>
<Paper
withBorder
p="sm"
radius="md"
style={{ borderColor: "rgba(0,0,0,0.06)" }}>
<Stack gap="xs">
<Text fw={700}></Text>
@@ -52,4 +56,3 @@ export default function NoteRulesTable(props: {
</Paper>
)
}

View File

@@ -10,9 +10,9 @@ import { notifications } from "@mantine/notifications"
export default function ReleaseModal(props: {
opened: boolean
record: Task.DataProps | null
onClose: (refresh?: boolean) => void
onCloseAction: (refresh?: boolean) => void
}) {
const { opened, record, onClose } = props
const { opened, record, onCloseAction } = props
const operation_uid = usePermissionStore((s) => s.user_id)
const form = useForm({
@@ -24,13 +24,16 @@ export default function ReleaseModal(props: {
return (
<Modal
opened={opened}
onClose={() => onClose()}
onClose={() => onCloseAction()}
title="释放任务"
centered
size={520}>
<form
onSubmit={form.onSubmit(async (values) => {
const opUid = typeof operation_uid === "number" ? operation_uid : Number(operation_uid ?? 0)
const opUid =
typeof operation_uid === "number"
? operation_uid
: Number(operation_uid ?? 0)
if (!record?.id || !opUid || !record.current_uid) {
notifications.show({
color: "red",
@@ -52,7 +55,7 @@ export default function ReleaseModal(props: {
title: "操作成功",
message: "已释放任务",
})
onClose(true)
onCloseAction(true)
} catch (e) {
notifications.show({
color: "red",
@@ -68,10 +71,12 @@ export default function ReleaseModal(props: {
<Switch
label="是否返工"
checked={form.values.reject}
onChange={(e) => form.setFieldValue("reject", e.currentTarget.checked)}
onChange={(e) =>
form.setFieldValue("reject", e.currentTarget.checked)
}
/>
<Group justify="flex-end" gap="sm">
<Button variant="default" onClick={() => onClose()}>
<Button variant="default" onClick={() => onCloseAction()}>
</Button>
<Button type="submit" color="red">
@@ -83,4 +88,3 @@ export default function ReleaseModal(props: {
</Modal>
)
}

View File

@@ -2,7 +2,16 @@
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 {
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"
@@ -54,9 +63,18 @@ export default function SamplingPlanContainer(props: {
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) },
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({
@@ -75,7 +93,11 @@ export default function SamplingPlanContainer(props: {
}
return (
<Paper withBorder p="sm" radius="md" style={{ borderColor: "rgba(0,0,0,0.06)" }}>
<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>
@@ -88,12 +110,16 @@ export default function SamplingPlanContainer(props: {
<Checkbox
label="抽检任务"
checked={form.values.check_task}
onChange={(e) => form.setFieldValue("check_task", e.currentTarget.checked)}
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)}
onChange={(e) =>
form.setFieldValue("check_frame", e.currentTarget.checked)
}
/>
</Group>
@@ -113,7 +139,9 @@ export default function SamplingPlanContainer(props: {
max={100}
decimalScale={2}
value={form.values[`${g}_task` as const]}
onChange={(v) => form.setFieldValue(`${g}_task` as any, Number(v ?? 0))}
onChange={(v) =>
form.setFieldValue(`${g}_task` as any, Number(v ?? 0))
}
hideControls
/>
<NumberInput
@@ -122,7 +150,9 @@ export default function SamplingPlanContainer(props: {
max={100}
decimalScale={2}
value={form.values[`${g}_frame` as const]}
onChange={(v) => form.setFieldValue(`${g}_frame` as any, Number(v ?? 0))}
onChange={(v) =>
form.setFieldValue(`${g}_frame` as any, Number(v ?? 0))
}
hideControls
/>
</Stack>
@@ -133,4 +163,3 @@ export default function SamplingPlanContainer(props: {
</Paper>
)
}

View File

@@ -9,9 +9,9 @@ export default function StageUserModal(props: {
title: string
value: number[]
options: Array<{ label: string; value: string }>
onClose: (next?: number[]) => void
onCloseAction: (next?: number[]) => void
}) {
const { opened, title, value, options, onClose } = props
const { opened, title, value, options, onCloseAction } = props
const form = useForm({
initialValues: { users: value.map(String) },
@@ -24,13 +24,18 @@ export default function StageUserModal(props: {
}, [opened, value, form])
return (
<Modal opened={opened} onClose={() => onClose()} title={title} centered size={560}>
<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))
onClose(next)
onCloseAction(next)
})}>
<Stack gap="sm">
<MultiSelect
@@ -42,7 +47,7 @@ export default function StageUserModal(props: {
onChange={(v) => form.setFieldValue("users", v)}
/>
<Group justify="flex-end" gap="sm">
<Button variant="default" onClick={() => onClose()}>
<Button variant="default" onClick={() => onCloseAction()}>
</Button>
<Button type="submit"></Button>
@@ -52,4 +57,3 @@ export default function StageUserModal(props: {
</Modal>
)
}

View File

@@ -15,11 +15,11 @@ function stageTitle(stage: StageKey) {
return "复审阶段"
}
function stageAction(stage: StageKey) {
if (stage === "label") return 1
if (stage === "review1") return 2
return 3
}
// function stageAction(stage: StageKey) {
// if (stage === "label") return 1
// if (stage === "review1") return 2
// return 3
// }
export default function TaskStageTabsContainer(props: {
projectId: number
@@ -31,9 +31,9 @@ export default function TaskStageTabsContainer(props: {
review1Enum: Map<any, any>
review2Enum: Map<any, any>
}
onUpdated: () => void
onUpdatedAction: () => void
}) {
const { projectId, info, userOptions, userEnums, onUpdated } = props
const { projectId, info, userOptions, userEnums, onUpdatedAction } = props
const stageUsers = useMemo(() => {
const detail = info?.label_process?.step_detail ?? []
@@ -69,7 +69,7 @@ export default function TaskStageTabsContainer(props: {
title: "操作成功",
message: "已保存阶段人员",
})
onUpdated()
onUpdatedAction()
} catch (e) {
notifications.show({
color: "red",
@@ -89,7 +89,11 @@ export default function TaskStageTabsContainer(props: {
return (
<>
<Paper withBorder p="sm" radius="md" style={{ borderColor: "rgba(0,0,0,0.06)" }}>
<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">
@@ -107,7 +111,10 @@ export default function TaskStageTabsContainer(props: {
<Stack gap="xs">
<Group justify="space-between" wrap="wrap">
<Text fw={600}>{stageTitle(stage)}</Text>
<Button size="xs" variant="default" onClick={() => setEditingStage(stage)}>
<Button
size="xs"
variant="default"
onClick={() => setEditingStage(stage)}>
</Button>
</Group>
@@ -123,10 +130,12 @@ export default function TaskStageTabsContainer(props: {
<StageUserModal
opened={editingStage !== null}
title={editingStage ? `${stageTitle(editingStage)}-人员配置` : "人员配置"}
title={
editingStage ? `${stageTitle(editingStage)}-人员配置` : "人员配置"
}
value={currentStageValue}
options={userOptions}
onClose={async (next) => {
onCloseAction={async (next) => {
const stage = editingStage
setEditingStage(null)
if (!stage || !next) return
@@ -136,4 +145,3 @@ export default function TaskStageTabsContainer(props: {
</>
)
}

View File

@@ -28,9 +28,15 @@ export default function TaskStatusTag(props: {
rejected?: boolean
center?: boolean
}) {
const text = useMemo(() => TaskStatusEnum.get(props.status) || "默认", [props.status])
const text = useMemo(
() => TaskStatusEnum.get(props.status) || "默认",
[props.status]
)
return (
<Group gap={6} justify={props.center ? "center" : "flex-start"} wrap="nowrap">
<Group
gap={6}
justify={props.center ? "center" : "flex-start"}
wrap="nowrap">
<Badge color={statusColor(props.status)} size="sm">
{text}
</Badge>
@@ -42,4 +48,3 @@ export default function TaskStatusTag(props: {
</Group>
)
}

View File

@@ -8,9 +8,9 @@ import { useEffect, useState } from "react"
export default function WorkflowModal(props: {
opened: boolean
taskId: number | null
onClose: () => void
onCloseAction: () => void
}) {
const { opened, taskId, onClose } = props
const { opened, taskId, onCloseAction } = props
const [loading, setLoading] = useState(false)
const [records, setRecords] = useState<any[]>([])
@@ -38,7 +38,7 @@ export default function WorkflowModal(props: {
return (
<Modal
opened={opened}
onClose={onClose}
onClose={onCloseAction}
title="工作流"
centered
size={720}>
@@ -52,7 +52,7 @@ export default function WorkflowModal(props: {
size="sm"
style={{
fontFamily:
"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace",
'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)",
@@ -70,7 +70,7 @@ export default function WorkflowModal(props: {
</Stack>
</ScrollArea>
<Group justify="flex-end">
<Button variant="default" onClick={onClose}>
<Button variant="default" onClick={onCloseAction}>
</Button>
</Group>
@@ -78,4 +78,3 @@ export default function WorkflowModal(props: {
</Modal>
)
}

View File

@@ -18,12 +18,21 @@ export const confirmOpt = [
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: "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: "fix_remind_threshold",
type: "input",
},
{
label: "领取顺序",
name: "acquire_mode",
@@ -38,7 +47,12 @@ export const labelStageConfig: FormItemProps[] = [
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: "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" },
@@ -56,7 +70,12 @@ export const reviewStageConfig: FormItemProps[] = [
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: "review2_update_month",
type: "select",
options: monthOpt,
},
{ label: "动态复审倍速", name: "dynamic_review2_speed", type: "input" },
{ label: "静态复审倍速", name: "static_review2_speed", type: "input" },
{
@@ -69,4 +88,3 @@ export const recheckStageConfig: FormItemProps[] = [
],
},
]