From 8ca5bb4e31e1e88d4dc1768c019d032f1d9b8de6 Mon Sep 17 00:00:00 2001 From: 1708-huayu <57060237+1708-huayu@users.noreply.github.com> Date: Fri, 18 Jul 2025 19:02:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:import=E4=BD=BF=E7=94=A8module=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/{page.module.css => page.modules.css} | 0 src/components/DiaryOption.module.css | 69 +++++++ src/components/DiaryOption.tsx | 191 +++++++++++++++--- src/components/service/Diary.tsx | 9 + src/components/type/Diary.tsx | 44 ++++ src/lib/definitions.ts | 1 + src/lib/login/service.ts | 4 + src/lib/task/calendar/service.tsx | 9 + src/ui/login/XcxLoginPage.tsx | 88 ++++---- ...odule.css => CustomSearchForm.modules.css} | 0 src/ui/task/CustomSearchForm.tsx | 2 +- ....modules.css => TitleOperation.module.css} | 0 src/ui/task/TitleOperation.tsx | 4 +- src/ui/task/calendar/CalShow.tsx | 132 ++++++------ src/ui/task/project/DetailModelForm.tsx | 35 +++- src/utils/axiosReq.ts | 2 + 16 files changed, 438 insertions(+), 152 deletions(-) rename src/app/{page.module.css => page.modules.css} (100%) create mode 100644 src/components/DiaryOption.module.css create mode 100644 src/components/service/Diary.tsx create mode 100644 src/components/type/Diary.tsx create mode 100644 src/lib/task/calendar/service.tsx rename src/ui/task/{CustomSearchForm.module.css => CustomSearchForm.modules.css} (100%) rename src/ui/task/{TitleOperation.modules.css => TitleOperation.module.css} (100%) diff --git a/src/app/page.module.css b/src/app/page.modules.css similarity index 100% rename from src/app/page.module.css rename to src/app/page.modules.css diff --git a/src/components/DiaryOption.module.css b/src/components/DiaryOption.module.css new file mode 100644 index 0000000..ad7744c --- /dev/null +++ b/src/components/DiaryOption.module.css @@ -0,0 +1,69 @@ +.reverseScrollList { + display: flex; + flex-direction: column; /* 垂直反转 */ + /*overflow-y: auto;*/ +} +/* 容器样式 */ +.container { + display: flex; + justify-content: center; + /* 水平居中 */ + align-items: center; + /* 垂直居中 */ + width: 100%; +} +/* 线条与文本容器 */ +.lineWithText { + position: relative; + width: 80%; + /* 根据需要调整宽度 */ + text-align: center; +} +/* 使用伪元素创建线条 */ +.lineWithText::before { + content: ''; + position: absolute; + top: 50%; + left: 0; + width: 100%; + border-top: 1px solid #c8c7cc; + /* 线条颜色和粗细 */ + z-index: 0; + /* 在文本下面 */ +} + +/* 中间文本 */ +.centerText { + background-color: white; + /* 背景色,确保文本清晰可见 */ + padding: 0 10px; + /* 给文本一些内边距 */ + position: relative; + z-index: 1; + /* 确保文本在上面 */ + font-size: 16px; + /* 文本大小 */ + color: #c8c7cc; +} + +.logTaskContent { + width: 80%; + padding: 10rpx 40rpx; + + .detailLine { + margin-top: 0.5rem; + display: inline-block; + padding: 4rpx 20rpx; + border: solid; + border-radius: 20rpx; + border-color: #1677FF; + white-space: normal; + word-break: break-all; + word-wrap: break-word; + font-size: 1rem; + } + .detailLineClick { + background-color: #1677FF; + color: #fff; + } +} \ No newline at end of file diff --git a/src/components/DiaryOption.tsx b/src/components/DiaryOption.tsx index 916f561..f147afa 100644 --- a/src/components/DiaryOption.tsx +++ b/src/components/DiaryOption.tsx @@ -1,18 +1,17 @@ import React, {useEffect, useState} from 'react'; -import { Avatar, List, message } from 'antd'; +import {Avatar, Input, List, message} from 'antd'; import VirtualList from 'rc-virtual-list'; -import { Button, Drawer } from 'antd'; -interface UserItem { - email: string; - gender: string; - name: string; - avatar: string; -} +import {Button, Drawer} from 'antd'; +import {ListDiary, SelectDiary} from "@/components/type/Diary"; +import TextArea from "antd/es/input/TextArea"; +import style from "@/components/DiaryOption.module.css" +import dayjs from "dayjs"; +import {addTaskLogAPI} from "@/components/service/Diary"; const CONTAINER_HEIGHT = 400; const PAGE_SIZE = 20; -const DiaryOption = () => { +const DiaryOption = (props: SelectDiary) => { // 抽屉 start const [open, setOpen] = useState(false); const showDrawer = () => { @@ -23,17 +22,54 @@ const DiaryOption = () => { }; // 抽屉 end + // 头按钮设置 start + const [currentIndex, setCurrentIndex] = useState(1); + // 头按钮设置 end // 数据 start - const [data, setData] = useState([]); + const [diaryList, setDiaryList] = useState([]); + const [diaryReduceList, setDiaryReduceList] = useState([]) const [page, setPage] = useState(1); + const noMore = {id: '0', keyId: 'o0',createdDate:new Date(), description: '没有更多了',taskId:props.taskId, enableFlag: 'day-separate'}; + const [noMoreFlag, setNoMoreFlag] = useState(false) + const [sendValue,setSendValue] = useState(); + const [sendValueFlag,setSendValueFlag] =useState(false); + const handleSend = ()=>{ + if(sendValueFlag){ + return + } + setSendValueFlag(true); + if (!sendValue?.trim()) { + message.info("发送信息不能为空"); + return; + } + addTaskLogAPI({ + description: sendValue!, + taskId: props.taskId, + enableFlag: '1' + }).then(res => { + setDiaryList([res.data.data, ...diaryList]) + setSendValue(undefined) + }).finally(() => { + setSendValueFlag(false); + }) + } const appendData = (showMessage = true) => { - const fakeDataUrl = `https://660d2bd96ddfa2943b33731c.mockapi.io/api/users/?page=${page}&limit=${PAGE_SIZE}`; - fetch(fakeDataUrl) + const fakeDataUrl = process.env.NEXT_PUBLIC_TODO_REQUEST_URL + `/task/message/diary/select`; + fetch(fakeDataUrl, { + method: 'POST', headers: { + 'Content-Type': 'application/json', // 指定 JSON 格式 + 'Authorization': `Bearer ${localStorage.getItem('platform-security')}`, + }, body: JSON.stringify({pageNumber: page, pageSize: 100, data: {taskId: props.taskId}}) + }) .then((res) => res.json()) .then((body) => { - const results = Array.isArray(body) ? body : []; - setData(data.concat(results)); + const results = Array.isArray(body.data.content) ? body.data.content : []; + if (results.length === 0) { + diaryList.push(noMore); + setNoMoreFlag(true); + } + setDiaryList(diaryList.concat(results)); setPage(page + 1); showMessage && message.success(`${results.length} more items loaded!`); }); @@ -43,10 +79,38 @@ const DiaryOption = () => { appendData(false); }, []); + useEffect(() => { + console.log("处理日志集合",diaryList) + const returnResult: ListDiary[] = [] + diaryList.filter(taskLog => { + if (currentIndex === 0) { return true } + else if (currentIndex === 1 && taskLog.enableFlag === "1") { return true } + else if (currentIndex === 2 && taskLog.enableFlag === "0") { return true } + else return false; + }).reduce((map, taskLog) => { + if (!map.has(dayjs(taskLog.createdDate).format("YYYY-MM-DD"))) { + map.set(dayjs(taskLog.createdDate).format("YYYY-MM-DD"), []); + } + map.get(dayjs(taskLog.createdDate).format("YYYY-MM-DD"))?.push(taskLog); + return map; + }, new Map()).forEach((value, Key) => { + returnResult.push(...value) + returnResult.push({ + description: dayjs(Key).isSame(dayjs(), 'date') ? "今天" : dayjs(Key).format("YYYY-MM-DD"), + id: dayjs(Key).format("YYYY-MM-DD"), + enableFlag: "day-separate", + taskId: props.taskId, + createdDate: new Date() + }) + }) + setDiaryReduceList(returnResult); + }, [diaryList]); + const onScroll = (e: React.UIEvent) => { // Refer to: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#problems_and_solutions if ( - Math.abs(e.currentTarget.scrollHeight - e.currentTarget.scrollTop - CONTAINER_HEIGHT) <= 1 + Math.abs(e.currentTarget.scrollHeight - e.currentTarget.scrollTop - CONTAINER_HEIGHT) <= 1 && + !noMoreFlag ) { appendData(); } @@ -54,41 +118,110 @@ const DiaryOption = () => { // 数据 end + // 点击操作 start + const [clickTaskDiary, setClickTaskDiary] = useState() + // 点击操作 end + return ( <> +