fix(ones): bug
This commit is contained in:
@@ -8,6 +8,14 @@ import {
|
||||
usePermissionStore,
|
||||
} from "@/components/label/store/auth"
|
||||
import { OwnTaskStatusOpts } from "@/components/label/utils/constants"
|
||||
import {
|
||||
SettingContentPanel,
|
||||
SettingDataTable,
|
||||
SettingFilterActions,
|
||||
SettingFilterPanel,
|
||||
SettingHeaderActions,
|
||||
SettingListHeader,
|
||||
} from "@/components/setting/PageSurface"
|
||||
import {
|
||||
Button,
|
||||
Collapse,
|
||||
@@ -28,14 +36,6 @@ import {
|
||||
import { DataTableColumn } from "mantine-datatable"
|
||||
import { useRouter, useSearchParams } from "next/navigation"
|
||||
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||
import {
|
||||
SettingContentPanel,
|
||||
SettingDataTable,
|
||||
SettingFilterActions,
|
||||
SettingFilterPanel,
|
||||
SettingHeaderActions,
|
||||
SettingListHeader,
|
||||
} from "@/components/setting/PageSurface"
|
||||
import TaskStatusTag from "./components/TaskStatusTag"
|
||||
|
||||
function createInitialFilters() {
|
||||
@@ -231,7 +231,7 @@ export default function OwnTaskTableContainer(props: {
|
||||
{
|
||||
accessor: "label_status",
|
||||
title: "状态",
|
||||
width: 120,
|
||||
width: 150,
|
||||
render: (record) => (
|
||||
<TaskStatusTag
|
||||
status={record.label_status}
|
||||
|
||||
@@ -658,7 +658,7 @@ export default function TaskTableContainer(props: {
|
||||
{
|
||||
accessor: "label_status",
|
||||
title: "状态",
|
||||
width: 110,
|
||||
width: 150,
|
||||
render: (record) => (
|
||||
<TaskStatusTag
|
||||
status={record.label_status}
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
} from "@mantine/core"
|
||||
import { useForm } from "@mantine/form"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import { useEffect } from "react"
|
||||
import { selectedDataProps } from "../TaskTableContainer"
|
||||
import { dispatchOpts } from "./config"
|
||||
|
||||
@@ -33,9 +34,33 @@ export default function DispatchModal(props: {
|
||||
task_status_dst: "",
|
||||
uid_dst: "",
|
||||
},
|
||||
validate: {
|
||||
task_status_dst: (value) => (!value ? "必填" : null),
|
||||
},
|
||||
})
|
||||
|
||||
const resetFormState = () => {
|
||||
form.setValues({
|
||||
reject: false,
|
||||
task_status_dst: "",
|
||||
uid_dst: "",
|
||||
})
|
||||
form.clearErrors()
|
||||
form.resetDirty()
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (opened) {
|
||||
resetFormState()
|
||||
return
|
||||
}
|
||||
|
||||
resetFormState()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [opened])
|
||||
|
||||
const taskStatusSrc = dispatchData?.status ?? 0
|
||||
const taskStatusSrcLabel = dispatchOpts[taskStatusSrc]?.label ?? "-"
|
||||
const dstOptions =
|
||||
dispatchOpts[taskStatusSrc]?.opts?.map((o) => ({
|
||||
label: o.label,
|
||||
@@ -45,7 +70,10 @@ export default function DispatchModal(props: {
|
||||
return (
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={() => onCloseAction()}
|
||||
onClose={() => {
|
||||
resetFormState()
|
||||
onCloseAction()
|
||||
}}
|
||||
title="调度任务"
|
||||
centered
|
||||
size={520}>
|
||||
@@ -100,6 +128,7 @@ export default function DispatchModal(props: {
|
||||
title: "操作成功",
|
||||
message: "已调度任务",
|
||||
})
|
||||
resetFormState()
|
||||
onCloseAction(true)
|
||||
} catch (e) {
|
||||
notifications.show({
|
||||
@@ -115,16 +144,19 @@ export default function DispatchModal(props: {
|
||||
{task_ids.map((item) => item.project_name).join("、") ?? "-"}
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
(源状态:{taskStatusSrc})
|
||||
(源状态:{taskStatusSrcLabel})
|
||||
</Text>
|
||||
|
||||
<Select
|
||||
label="目标状态"
|
||||
placeholder="请选择目标状态"
|
||||
data={dstOptions}
|
||||
searchable
|
||||
clearable
|
||||
value={form.values.task_status_dst}
|
||||
withAsterisk
|
||||
value={form.values.task_status_dst || null}
|
||||
onChange={(v) => form.setFieldValue("task_status_dst", v ?? "")}
|
||||
error={form.errors.task_status_dst}
|
||||
/>
|
||||
|
||||
<Select
|
||||
@@ -132,7 +164,7 @@ export default function DispatchModal(props: {
|
||||
data={userOptions}
|
||||
searchable
|
||||
clearable
|
||||
value={form.values.uid_dst}
|
||||
value={form.values.uid_dst || null}
|
||||
onChange={(v) => form.setFieldValue("uid_dst", v ?? "")}
|
||||
/>
|
||||
|
||||
@@ -145,7 +177,12 @@ export default function DispatchModal(props: {
|
||||
/>
|
||||
|
||||
<Group justify="flex-end" gap="sm">
|
||||
<Button variant="default" onClick={() => onCloseAction()}>
|
||||
<Button
|
||||
variant="default"
|
||||
onClick={() => {
|
||||
resetFormState()
|
||||
onCloseAction()
|
||||
}}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit">确定</Button>
|
||||
|
||||
Reference in New Issue
Block a user