Merge branch 'zh' into 'main'
Zh See merge request prism/lable/labelimage!11
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>
|
||||
|
||||
@@ -6,6 +6,7 @@ import React, {
|
||||
useImperativeHandle,
|
||||
useRef,
|
||||
} from "react"
|
||||
import { useTopToolsStore } from "../useTopToolsStore"
|
||||
|
||||
interface AssistShapeComponentProps {
|
||||
size: number
|
||||
@@ -16,7 +17,9 @@ const AssistShapeComponent = (
|
||||
ref: React.Ref<unknown> | undefined
|
||||
) => {
|
||||
const { size } = props
|
||||
const scale = useTopToolsStore((state) => state.scale)
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null)
|
||||
const lastPointerRef = useRef<{ x: number; y: number } | null>(null)
|
||||
|
||||
const drawAssistShape = useCallback(
|
||||
(centerX: number, centerY: number) => {
|
||||
@@ -24,7 +27,7 @@ const AssistShapeComponent = (
|
||||
const ctx = canvas?.getContext("2d")
|
||||
if (!canvas || !ctx) return
|
||||
|
||||
const radius = Math.max(1, size)
|
||||
const radius = Math.max(1, size * scale)
|
||||
const side = radius * 2
|
||||
const left = centerX - radius
|
||||
const top = centerY - radius
|
||||
@@ -38,7 +41,7 @@ const AssistShapeComponent = (
|
||||
ctx.arc(centerX, centerY, radius, 0, Math.PI * 2)
|
||||
ctx.stroke()
|
||||
},
|
||||
[size]
|
||||
[scale, size]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -47,7 +50,11 @@ const AssistShapeComponent = (
|
||||
canvas.width = window.innerWidth
|
||||
canvas.height = window.innerHeight
|
||||
const rect = canvas.getBoundingClientRect()
|
||||
drawAssistShape(rect.width / 2, rect.height / 2)
|
||||
const center = lastPointerRef.current || {
|
||||
x: rect.width / 2,
|
||||
y: rect.height / 2,
|
||||
}
|
||||
drawAssistShape(center.x, center.y)
|
||||
}, [drawAssistShape])
|
||||
|
||||
const updateAssistShape = (event: { clientX: number; clientY: number }) => {
|
||||
@@ -56,6 +63,7 @@ const AssistShapeComponent = (
|
||||
const rect = canvas.getBoundingClientRect()
|
||||
const centerX = event.clientX - rect.left
|
||||
const centerY = event.clientY - rect.top
|
||||
lastPointerRef.current = { x: centerX, y: centerY }
|
||||
drawAssistShape(centerX, centerY)
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
Paintbrush,
|
||||
Pen,
|
||||
SquarePen,
|
||||
SquareDashedMousePointer,
|
||||
Tag,
|
||||
Timer,
|
||||
} from "lucide-react"
|
||||
@@ -2082,7 +2083,7 @@ const TopTools = (
|
||||
onClick={() => {
|
||||
setAssistToolEnabled(!assistToolEnabled)
|
||||
}}>
|
||||
<Eclipse size={16} />
|
||||
<SquareDashedMousePointer size={16} />
|
||||
</ActionIcon>
|
||||
<NumberInput
|
||||
value={assistToolSize}
|
||||
|
||||
@@ -24,6 +24,15 @@ import {
|
||||
projectStatusOpts,
|
||||
STATUS_CODE,
|
||||
} from "@/components/label/utils/constants"
|
||||
import {
|
||||
SettingContentPanel,
|
||||
SettingFilterActions,
|
||||
SettingFilterPanel,
|
||||
SettingHeaderActions,
|
||||
SettingListHeader,
|
||||
SettingPage,
|
||||
SettingPanel,
|
||||
} from "@/components/setting/PageSurface"
|
||||
import {
|
||||
ActionIcon,
|
||||
Badge,
|
||||
@@ -46,15 +55,6 @@ import {
|
||||
Tooltip,
|
||||
UnstyledButton,
|
||||
} from "@mantine/core"
|
||||
import {
|
||||
SettingContentPanel,
|
||||
SettingFilterActions,
|
||||
SettingFilterPanel,
|
||||
SettingHeaderActions,
|
||||
SettingListHeader,
|
||||
SettingPage,
|
||||
SettingPanel,
|
||||
} from "@/components/setting/PageSurface"
|
||||
import { useForm } from "@mantine/form"
|
||||
import { notifications } from "@mantine/notifications"
|
||||
import {
|
||||
@@ -71,7 +71,6 @@ import {
|
||||
IconStar,
|
||||
IconStarFilled,
|
||||
} from "@tabler/icons-react"
|
||||
import dayjs from "dayjs"
|
||||
import { User2 } from "lucide-react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import {
|
||||
@@ -190,8 +189,8 @@ export default function ProjectInfoPage({
|
||||
owner: "",
|
||||
label_type: "",
|
||||
admin_user: [] as string[],
|
||||
start_date: dayjs().subtract(6, "day").format("YYYY-MM-DD"),
|
||||
end_date: dayjs().format("YYYY-MM-DD"),
|
||||
start_date: "",
|
||||
end_date: "",
|
||||
}
|
||||
})
|
||||
|
||||
@@ -395,8 +394,9 @@ export default function ProjectInfoPage({
|
||||
<Text
|
||||
fw={700}
|
||||
c={"brand"}
|
||||
title={record.name}
|
||||
style={{
|
||||
maxWidth: "100%",
|
||||
maxWidth: "100px",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
whiteSpace: "nowrap",
|
||||
@@ -649,8 +649,8 @@ export default function ProjectInfoPage({
|
||||
owner: "",
|
||||
label_type: "",
|
||||
admin_user: [],
|
||||
start_date: dayjs().subtract(6, "day").format("YYYY-MM-DD"),
|
||||
end_date: dayjs().format("YYYY-MM-DD"),
|
||||
start_date: "",
|
||||
end_date: "",
|
||||
}
|
||||
setFilters(next)
|
||||
setAppliedFilters(next)
|
||||
|
||||
Reference in New Issue
Block a user