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