"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 ( onCloseAction()} title="释放任务" centered size={520}>
{ 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 : "请求失败", }) } })}> 当前任务:{record?.id ?? "-"}(状态:{record?.label_status ?? "-"}) form.setFieldValue("reject", e.currentTarget.checked) } />
) }