From b90b63853f3fcc3d95ed66024fe437771332b647 Mon Sep 17 00:00:00 2001 From: 1708-huayu <57060237+1708-huayu@users.noreply.github.com> Date: Thu, 31 Jul 2025 19:18:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=8E=92=E5=BA=8F=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=AE=A1=E5=88=92=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=89=8D=E7=BC=80=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/StepSort.tsx | 92 +++++++++++++++++------ src/components/TaskNameAndIcon.module.css | 0 src/components/TaskNameAndIcon.tsx | 24 ++++++ src/components/service/StepSort.tsx | 9 +++ src/components/type/TaskSort.d.tsx | 5 +- src/lib/definitions.ts | 3 + src/lib/task/project/data.tsx | 2 +- src/ui/globals.css | 2 +- src/ui/task/calendar/CalShow.tsx | 8 +- src/ui/task/project/DetailModelForm.tsx | 10 ++- src/ui/task/project/TreeTablePro.tsx | 8 +- 11 files changed, 125 insertions(+), 38 deletions(-) create mode 100644 src/components/TaskNameAndIcon.module.css create mode 100644 src/components/TaskNameAndIcon.tsx create mode 100644 src/components/service/StepSort.tsx diff --git a/src/components/StepSort.tsx b/src/components/StepSort.tsx index 91c3424..889fad2 100644 --- a/src/components/StepSort.tsx +++ b/src/components/StepSort.tsx @@ -1,16 +1,9 @@ -import React, {CSSProperties, Fragment, useState} from "react"; +import React, {CSSProperties, Fragment, useEffect, useState} from "react"; import {DragDropContext, Droppable, Draggable, DropResult, DraggingStyle, NotDraggingStyle} from "react-beautiful-dnd"; import {TaskStepSortVO} from "@/components/type/TaskSort.d"; -import {Button, Drawer, Modal} from "antd"; +import {Button, Drawer, message, Modal} from "antd"; import TextArea from "antd/es/input/TextArea"; - -// fake data generator -const getItems = (count: number, offset = 0) => - Array.from({length: count}, (v, k) => k).map(k => ({ - id: `item-${k + offset}-${new Date().getTime()}`, - stepDesc: `item ${k + offset}`, - sortIndex: k + offset, - })); +import {addStepItemAPI} from "@/components/service/StepSort"; const reorder = (list: TaskStepSortVO[], startIndex: number, endIndex: number) => { const result = Array.from(list); @@ -34,11 +27,23 @@ const getListStyle = (isDraggingOver: boolean) => ({ width: "100%" }); -const StepSort = (props: { taskId: string }) => { - const [state, setState] = useState(getItems(5, 10)); +const StepSort = (props: { taskId: string, stepList: TaskStepSortVO[] }) => { + const [state, setState] = useState(props.stepList); // 抽屉 start const [open, setOpen] = useState(false); const [dialogueOpen, setDialogueOpen] = useState(false); + const [sortItemList, setSortItemList] = useState([]); + const [modalText, setModalText] = useState({ + id: "", + stepDesc: undefined, + sortIndex: undefined, + taskId: props.taskId, + }); + + useEffect(() => { + // 根据任务id查找步骤 + + }, []); function onDragEnd(result: DropResult) { const {source, destination} = result; @@ -50,16 +55,64 @@ const StepSort = (props: { taskId: string }) => { let newState = [...state]; newState = items; setState(newState); + props.stepList.length=0 + props.stepList.push(...newState) + } + + const [confirmButtonLoading, setConfirmButtonLoading] = useState(false); + const confirmModalTextArea = () => { + setConfirmButtonLoading(true) + addStepItemAPI(modalText).then(res => { + if (res.data.status.success) { + message.info("添加步骤成功") + setModalText( + {...modalText, stepDesc: undefined}) + setState([...state, res.data.data]) + props.stepList.length=0 + props.stepList.push(...state, res.data.data) + setDialogueOpen(false); + } else { + message.error(res.data.status.message) + } + }).finally(()=>{ + setConfirmButtonLoading(false) + }) } return ( - { + setDialogueOpen(false); + } + } + destroyOnClose={true} + onOk={confirmModalTextArea} > -