feat(task): task detail
This commit is contained in:
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user