feat:日志修改

This commit is contained in:
1708-huayu 2025-07-22 18:47:00 +08:00
parent 967da82d9d
commit db19c5e12c
2 changed files with 101 additions and 46 deletions

View File

@ -1,8 +1,3 @@
.reverseScrollList {
display: flex;
flex-direction: column; /* 垂直反转 */
/*overflow-y: auto;*/
}
/* 容器样式 */ /* 容器样式 */
.container { .container {
display: flex; display: flex;
@ -55,7 +50,7 @@
display: inline-block; display: inline-block;
padding: 4rpx 20rpx; padding: 4rpx 20rpx;
border: solid; border: solid;
border-radius: 20rpx; border-radius: 0.5rem;
border-color: #1677FF; border-color: #1677FF;
white-space: normal; white-space: normal;
word-break: break-all; word-break: break-all;

View File

@ -1,5 +1,5 @@
import React, {useEffect, useState} from 'react'; import React, {useEffect, useRef, useState} from 'react';
import {Avatar, Input, List, message} from 'antd'; import {Avatar, Dropdown, Input, List, MenuProps, message} from 'antd';
import VirtualList from 'rc-virtual-list'; import VirtualList from 'rc-virtual-list';
import {Button, Drawer} from 'antd'; import {Button, Drawer} from 'antd';
import {ListDiary, SelectDiary} from "@/components/type/Diary"; import {ListDiary, SelectDiary} from "@/components/type/Diary";
@ -7,6 +7,8 @@ import TextArea from "antd/es/input/TextArea";
import style from "@/components/DiaryOption.module.css" import style from "@/components/DiaryOption.module.css"
import dayjs from "dayjs"; import dayjs from "dayjs";
import {addTaskLogAPI} from "@/components/service/Diary"; import {addTaskLogAPI} from "@/components/service/Diary";
import {ListBodyRef} from "antd/es/transfer/ListBody";
import {ListRef} from "rc-virtual-list/lib/List";
const CONTAINER_HEIGHT = 400; const CONTAINER_HEIGHT = 400;
const PAGE_SIZE = 20; const PAGE_SIZE = 20;
@ -29,12 +31,19 @@ const DiaryOption = (props: SelectDiary) => {
const [diaryList, setDiaryList] = useState<ListDiary[]>([]); const [diaryList, setDiaryList] = useState<ListDiary[]>([]);
const [diaryReduceList, setDiaryReduceList] = useState<ListDiary[]>([]) const [diaryReduceList, setDiaryReduceList] = useState<ListDiary[]>([])
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
const noMore = {id: '0', keyId: 'o0',createdDate:new Date(), description: '没有更多了',taskId:props.taskId, enableFlag: 'day-separate'}; const noMore = {
id: '0',
keyId: 'o0',
createdDate: new Date(),
description: '没有更多了',
taskId: props.taskId,
enableFlag: 'day-separate'
};
const [noMoreFlag, setNoMoreFlag] = useState(false) const [noMoreFlag, setNoMoreFlag] = useState(false)
const [sendValue,setSendValue] = useState<string>(); const [sendValue, setSendValue] = useState<string>();
const [sendValueFlag,setSendValueFlag] =useState(false); const [sendValueFlag, setSendValueFlag] = useState(false);
const handleSend = ()=>{ const handleSend = () => {
if(sendValueFlag){ if (sendValueFlag) {
return return
} }
setSendValueFlag(true); setSendValueFlag(true);
@ -72,21 +81,31 @@ const DiaryOption = (props: SelectDiary) => {
setDiaryList(diaryList.concat(results)); setDiaryList(diaryList.concat(results));
setPage(page + 1); setPage(page + 1);
showMessage && message.success(`${results.length} more items loaded!`); showMessage && message.success(`${results.length} more items loaded!`);
if (!showMessage) {
if (listRef && listRef.current && typeof listRef.current.scrollTo == 'function') {
listRef.current.scrollTo({top: 9999999 });
}
}
}); });
}; };
useEffect(() => { useEffect(() => {
appendData(false); appendData(false);
// 视口高度
window.innerHeight
}, []); }, []);
useEffect(() => { useEffect(() => {
console.log("处理日志集合",diaryList) console.log("处理日志集合", diaryList)
const returnResult: ListDiary[] = [] const returnResult: ListDiary[] = []
diaryList.filter(taskLog => { diaryList.filter(taskLog => {
if (currentIndex === 0) { return true } if (currentIndex === 0) {
else if (currentIndex === 1 && taskLog.enableFlag === "1") { return true } return true
else if (currentIndex === 2 && taskLog.enableFlag === "0") { return true } } else if (currentIndex === 1 && taskLog.enableFlag === "1") {
else return false; return true
} else if (currentIndex === 2 && taskLog.enableFlag === "0") {
return true
} else return false;
}).reduce((map, taskLog) => { }).reduce((map, taskLog) => {
if (!map.has(dayjs(taskLog.createdDate).format("YYYY-MM-DD"))) { if (!map.has(dayjs(taskLog.createdDate).format("YYYY-MM-DD"))) {
map.set(dayjs(taskLog.createdDate).format("YYYY-MM-DD"), []); map.set(dayjs(taskLog.createdDate).format("YYYY-MM-DD"), []);
@ -103,9 +122,10 @@ const DiaryOption = (props: SelectDiary) => {
createdDate: new Date() createdDate: new Date()
}) })
}) })
setDiaryReduceList(returnResult); setDiaryReduceList(returnResult.reverse());
}, [diaryList]); }, [diaryList, currentIndex]);
const listRef = useRef<ListRef>(null);
const onScroll = (e: React.UIEvent<HTMLElement, UIEvent>) => { const onScroll = (e: React.UIEvent<HTMLElement, UIEvent>) => {
// Refer to: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#problems_and_solutions // Refer to: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#problems_and_solutions
if ( if (
@ -120,6 +140,37 @@ const DiaryOption = (props: SelectDiary) => {
// 点击操作 start // 点击操作 start
const [clickTaskDiary, setClickTaskDiary] = useState<ListDiary>() const [clickTaskDiary, setClickTaskDiary] = useState<ListDiary>()
const onClickTAskDiary = (item: ListDiary, operate: string) => {
if (clickTaskDiary == item && operate == 'L') {
setClickTaskDiary(undefined)
} else {
setClickTaskDiary(item)
}
}
const items: MenuProps['items'] = [
{
label: '复制',
key: '1',
onClick: () => {
}
},
{
label: '失效',
key: '2',
},
{
label: '创建计划',
key: '3',
},
{
label: '删除',
key: '4',
},
{
label: '取消',
key: '5',
},
];
// 点击操作 end // 点击操作 end
return ( return (
@ -128,7 +179,10 @@ const DiaryOption = (props: SelectDiary) => {
</Button> </Button>
<Drawer <Drawer
style={{boxSizing:"border-box"}} style={{boxSizing: "border-box"}}
styles={{
body: {padding: "0 24px"}
}}
mask={false} mask={false}
title={props.taskName} title={props.taskName}
closable={{'aria-label': 'Close Button'}} closable={{'aria-label': 'Close Button'}}
@ -187,7 +241,8 @@ const DiaryOption = (props: SelectDiary) => {
</div> </div>
} }
> >
<div className="displayFlexRow"> <div className="displayFlexRow"
style={{position: "sticky", top: "0", background: "white", zIndex: "100"}}>
<Button style={{flexGrow: 1}} onClick={() => setCurrentIndex(0)} <Button style={{flexGrow: 1}} onClick={() => setCurrentIndex(0)}
type={currentIndex == 0 ? "primary" : "default"}></Button> type={currentIndex == 0 ? "primary" : "default"}></Button>
<Button style={{flexGrow: 1}} onClick={() => setCurrentIndex(1)} <Button style={{flexGrow: 1}} onClick={() => setCurrentIndex(1)}
@ -195,15 +250,15 @@ const DiaryOption = (props: SelectDiary) => {
<Button style={{flexGrow: 1}} onClick={() => setCurrentIndex(2)} <Button style={{flexGrow: 1}} onClick={() => setCurrentIndex(2)}
type={currentIndex == 2 ? "primary" : "default"}></Button> type={currentIndex == 2 ? "primary" : "default"}></Button>
</div> </div>
<div> <List style={{height: "auto"}}>
<List>
<VirtualList <VirtualList
data={diaryReduceList} data={diaryReduceList}
height={CONTAINER_HEIGHT} // height={CONTAINER_HEIGHT}
itemHeight={47} // itemHeight={47}
itemKey="email" itemKey="email"
onScroll={onScroll} onScroll={onScroll}
className={style.reverseScrollList} style={{height: "auto"}}
ref={listRef}
> >
{item => ( {item => (
item.enableFlag === 'day-separate' ? item.enableFlag === 'day-separate' ?
@ -213,19 +268,24 @@ const DiaryOption = (props: SelectDiary) => {
</div> </div>
</div> </div>
: <div className={style.logTaskContent} key={item.id}> : <div className={style.logTaskContent} key={item.id}>
<Dropdown menu={{items}} trigger={['contextMenu']}>
<div <div
className={`${style.detailLine} ${item.id === clickTaskDiary?.id ? style.detailLineClick : ''}`} className={`${style.detailLine} ${item.id === clickTaskDiary?.id ? style.detailLineClick : ''}`}
onClick={() => setClickTaskDiary(item)}> onClick={() => onClickTAskDiary(item, "L")}
onContextMenu={() => onClickTAskDiary(item, "R")}>
<text <text
style={{textDecoration: item.enableFlag === '0' && currentIndex === 0 ? 'line-through' : ''}}> style={{
textDecoration: item.enableFlag === '0' && currentIndex === 0 ? 'line-through' : '',
whiteSpace: 'pre-line'
}}>
{item.description} {item.description}
</text> </text>
</div> </div>
</Dropdown>
</div> </div>
)} )}
</VirtualList> </VirtualList>
</List> </List>
</div>
</Drawer> </Drawer>
</> </>
); );