diff --git a/src/components/DetailForm/index.js b/src/components/DetailForm/index.js index ab401e7..b66e068 100644 --- a/src/components/DetailForm/index.js +++ b/src/components/DetailForm/index.js @@ -5,7 +5,7 @@ import { Button, Dialog, TextArea, - Space, Tag, Radio, Checkbox + Space, Tag, Radio } from 'antd-mobile' import ParentTask from "../ParentTask"; import "./index.css" @@ -143,9 +143,9 @@ const DetailForm = () => { values.pid = '0' } if (currentPath === "addTask") { - addTask(values).then(values => { + addTask(values).then(res => { Dialog.show({ - content: `添加任务${values}成功`, + content: `添加任务${res}成功`, closeOnAction: true, actions: [ [ @@ -161,11 +161,15 @@ const DetailForm = () => { text: '创建下一条', onClick: () => { // 清空值 + console.log("1",{pName}) form.resetFields(); + console.log("reset",values) form.setFieldValue("pidArray", values.pidArray); + form.setFieldValue("pid",values.pid) setPidArray(values.pidArray) window.scrollTo(0, 0); setRemovePid(values.pid); + console.log("2",{pName}) } }, ], diff --git a/src/components/ParentTask/index.js b/src/components/ParentTask/index.js index d3a5837..4e381f7 100644 --- a/src/components/ParentTask/index.js +++ b/src/components/ParentTask/index.js @@ -83,7 +83,7 @@ const ParentTask = (props) => { console.log({value}) if (value && value.length > 0) { changeSelectValue(value) - changeTaskId(value[value.length - 1]) + changeTaskId(value) } }} > diff --git a/src/components/TaskItemList/index.js b/src/components/TaskItemList/index.js new file mode 100644 index 0000000..16c234f --- /dev/null +++ b/src/components/TaskItemList/index.js @@ -0,0 +1,217 @@ +import React, {Fragment, useCallback, useEffect, useRef, useState} from "react"; +import {Dialog, InfiniteScroll, List, PullToRefresh, SwipeAction} from "antd-mobile"; +import {deleteTaskById, getTaskList, updateTaskStateById} from "../../utils"; +import dayjs from "dayjs"; +import {DATE_TIME_FORMAT_SIMPLE} from "../../utils/timeFormatUtil"; +import {useNavigate} from "react-router-dom"; +import {getDictionary} from "../../utils/dictUtil"; + +const TaskItemList = (prop)=>{ + let search = prop.search.value + console.log("TaskItemList",search) + const [taskList, setTaskList] = useState([]) + const [hasMore, setHasMore] = useState(true) + const [pageNumber, setPageNumber] = useState(1) + const [priorityMap, setPriorityMap] = useState([]); + const [stateMap, setStateMap] = useState([]) + const navigate = useNavigate(); + let loading = false; + + const loadMore = async () => { + console.log("loading:", pageNumber, loading) + if (loading || !search) { + return + } + loading = true; + console.log("loadMore", loading) + const taskRes = await getTaskList({...search, "pageNumber": pageNumber}); + console.log({taskRes}) + setTaskList([...taskList, ...taskRes.content]) + + if (taskRes.page.number < taskRes.page.totalPages) { + setHasMore(true) + setPageNumber(pageNumber + 1) + } else { + setHasMore(false) + setPageNumber(1) + } + loading = false; + } + + /** + * 根据查询条件筛选本地列表,不触发接口? + */ + const localRefresh = () => { + console.log("refresh",loading,!search) + if (loading||!search){ + return + } + const refreshSearch = {...search, "pageNumber": 1}; + if (pageNumber>1){ + refreshSearch.pageSize = 20*pageNumber; + } + loading = true; + getTaskList({...search, "pageNumber": 1}).then(result => { + setTaskList(result.content) + if (result.page.number < result.page.totalPages) { + setHasMore(true) + setPageNumber(pageNumber + 1) + } else { + setHasMore(false) + setPageNumber(1) + } + }) + loading = false; + } + + useEffect(() => { + getDictionary("2").then(res => { + setStateMap(res) + }) + getDictionary("1").then(res => { + setPriorityMap(res) + }) + }, []) + + useEffect(() => { + localRefresh() + }, [search]) + + // 创建一个用于存储当前激活的 SwipeAction ref 的变量 + const activeSwipeActionRef = useRef(null); + // 定义一个回调函数来更新当前激活的 SwipeAction ref + const setActiveSwipeAction = useCallback((ref) => { + if (activeSwipeActionRef.current && ref !== activeSwipeActionRef.current) { + activeSwipeActionRef.current.close(); + }else { + activeSwipeActionRef.current = ref; + } + }, []); + // 定义一个函数来关闭当前激活的 SwipeAction + const closeActiveSwipeAction = useCallback(() => { + console.log({activeSwipeActionRef}) + if (activeSwipeActionRef.current) { + activeSwipeActionRef.current.close(); + } + }, []); + + return ( + + {/* 下拉刷新 */} + + + {taskList.map((item) => ( + setActiveSwipeAction(ref)} + closeOnAction={true} + closeOnTouchOutside={false} + rightActions={[ + { + key: `delete${item.id}`, + text: '删除', + color: 'danger', + onClick: async () => { + const result = await Dialog.confirm({ + content: '确定要删除吗?', + }) + if (result){ + await deleteTaskById(item.id) + } + // 关闭当前激活的 SwipeAction + closeActiveSwipeAction(); + localRefresh() + }, + }, + { + key: `close${item.id}`, + text: '关闭', + color: 'warning', + onClick: () => { + Dialog.confirm({ + content: '确定要关闭吗?', + onConfirm: () => { + updateTaskStateById('6', item.id).then(res => { + // 关闭当前激活的 SwipeAction + closeActiveSwipeAction(); + localRefresh() + }) + }, + }) + }, + }, + { + key: `update${item.id}`, + text: '修改', + color: 'primary', + onClick: () => { + // 关闭当前激活的 SwipeAction + closeActiveSwipeAction(); + // 跳转 + navigate(`/detail/updateTask?id=${item.id}`) + }, + }, + { + key: `complete${item.id}`, + text: '完成', + color: 'success', + onClick: () => { + Dialog.confirm({ + content: '确定要完成吗?', + onConfirm: () => { + updateTaskStateById('7', item.id).then(res => { + // 关闭当前激活的 SwipeAction + closeActiveSwipeAction(); + localRefresh() + }) + }, + }) + }, + }, + ]} + > + { + console.log("click/detail") + navigate(`/detail/selectTask?id=${item.id}`) + } + } + title={ +
+ {(priorityMap.get(item.priority)?.jsonValue?.color) ? + ({item.name}) : ( + {item.name})} + + {item.expectedStartTime && (stateMap.get(item.state)?.jsonValue?.color ? + ( + {dayjs(item.expectedStartTime).format(DATE_TIME_FORMAT_SIMPLE)}) : + ( + {dayjs(item.expectedStartTime).format(DATE_TIME_FORMAT_SIMPLE)})) + } +
} + description={item.description} + > +
+
+ ))} +
+ {/*无限滚动*/} + +
+
+ ) +} +export default TaskItemList; \ No newline at end of file diff --git a/src/hooks/useChildList.js b/src/hooks/useChildList.js index ec4f3a1..aab541f 100644 --- a/src/hooks/useChildList.js +++ b/src/hooks/useChildList.js @@ -117,8 +117,12 @@ export function useChildList() { } function removeTaskId(taskId) { - childList.delete(taskId); - setChildList(...childList) + delete childList[taskId]; + setChildList({...childList}) + fetchOptionsForValue(taskId,undefined) + // console.log({taskId,childList}) + // const {[taskId]:deleteTaskId,...newChildList} = childList + // setChildList({...newChildList}) } return { diff --git a/src/pages/DetailLogTask/index.js b/src/pages/DetailLogTask/index.js index 5e7a552..fb4c4be 100644 --- a/src/pages/DetailLogTask/index.js +++ b/src/pages/DetailLogTask/index.js @@ -1,4 +1,4 @@ -import {ActionSheet, Button, Dialog, Divider, Tabs, TextArea, Toast} from "antd-mobile"; +import {ActionSheet, Button, Dialog, Divider, Tabs, TextArea} from "antd-mobile"; import React, {Fragment, useEffect, useMemo, useRef, useState} from "react"; import "./index.css" import {useNavigate, useOutletContext, useSearchParams} from "react-router-dom"; @@ -27,10 +27,8 @@ export function DetailLogTask() { const [sendValue, setSendValue] = useState(''); const [hasMore, setHasMore] = useState(true); - const [pageTime, setPageTime] = useState(new Date()); - - // 记录上一次的滚动高度 - const previousScrollHeight = useRef(0); + const loading = useRef(false) + const [pageNumber, setPageNumber] = useState(1); // 点击操作面板 const [actionSheetVisible, setActionSheetVisible] = useState(false) @@ -55,7 +53,13 @@ export function DetailLogTask() { 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); + if (currentShow === 'all' && taskLog.enableFlag === '0') { + map.get(dayjs(taskLog.createdDate).format("YYYY-MM-DD"))?.push({ + ...taskLog, description: {taskLog.description} + }); + } else { + map.get(dayjs(taskLog.createdDate).format("YYYY-MM-DD"))?.push(taskLog); + } return map; }, new Map()); }, [taskLogList, currentShow]) @@ -66,15 +70,20 @@ export function DetailLogTask() { "enableFlag": '1' }).then(res => { // 加入当前集合中 - setTaskLogList([...taskLogList, res]); + setTaskLogList([res, ...taskLogList]); }) setSendValue('') textAreaRef.current.focus(); }; async function fetchMessages() { + if (loading.current) { + return + } + loading.current = true; // 获取之前的日志信息,根据日期分组排序,遍历map const res = await listTaskLog(JSON.stringify({ + "pageNumber": pageNumber, "pageSize": 20, "sortList": [{"direction": "DESC", "property": "createdDate"}], "data": { @@ -82,24 +91,21 @@ export function DetailLogTask() { "name": "taskId", "operateType": "=", "value": params.get('id') - }, { - "name": "createdDate", - "operateType": "<", - "value": pageTime }] } })) console.log({res}) if (res.content.length > 0) { - setPageTime(res.content[res.content.length - 1].createdDate) setTaskLogList([...taskLogList, ...res.content]); - } else if (res.page.totalElements === 0) { + } + if (pageNumber >= res.page.totalPages) { setHasMore(false); } + setPageNumber(pageNumber + 1) + loading.current = false; } useEffect(() => { - setPageTime(new Date()) textAreaRef.current.focus(); fetchMessages() }, []) diff --git a/src/pages/PersonalCenter/index.js b/src/pages/PersonalCenter/index.js index 77f4cba..dbc03cb 100644 --- a/src/pages/PersonalCenter/index.js +++ b/src/pages/PersonalCenter/index.js @@ -1,5 +1,5 @@ import React, {Fragment, useContext, useEffect, useState} from "react"; -import {Button, Form, List, Picker, Space, Switch} from "antd-mobile"; +import {Button, List, Picker, Switch,} from "antd-mobile"; import Cookies from "js-cookie"; import {columnSortConstant} from "./columnSortConstant"; import {MyRootContext, UPDATE_SEARCH} from "../../components/MyRootContext"; @@ -57,6 +57,20 @@ export function PersonalCenter() { {/* localStorage.setItem('huayu-todo-setting', setting);*/} {/* }*/} {/*}/>}>新建任务时父任务只展示未完成任务*/} + { + let setting = localStorage.getItem('huayu-todo-setting'); + if (setting) { + let parseObj = JSON.parse(setting); + parseObj.calDetail = checked + setting = JSON.stringify(parseObj) + setParentCheck(checked); + } else { + setting = JSON.stringify({calDetail: checked}) + } + localStorage.setItem('huayu-todo-setting', setting); + } + }/>}>日历页面默认展示详情 { return (

TODO日{currentDay && dayjs(currentDay).format(DATE_FORMAT)}代办: - {currentDay && 详情} + {/*{currentDay && 详情}*/} {!dayjs(currentMonth).isSame(today, 'months') && backToToday()}>回到当月}

diff --git a/src/pages/ToDoCal/index.jsx b/src/pages/ToDoCal/index.jsx index 9a1e15b..9c868b7 100644 --- a/src/pages/ToDoCal/index.jsx +++ b/src/pages/ToDoCal/index.jsx @@ -2,14 +2,14 @@ import {Calendar, Cascader, SwipeAction, Tag} from "antd-mobile"; import dayjs from "dayjs"; import {TaskCount} from "../TaskCount"; import React, {Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState} from "react"; -import {getTaskByPid, getTaskCount} from "../../utils"; -import {FrownFill, SmileFill} from "antd-mobile-icons"; +import {getTaskCount} from "../../utils"; import {NEW, OVERDUE, UNDER_WAY} from "../../utils/commonConstant"; -import {dateStartUtcFormat} from "../../utils/timeFormatUtil"; +import {dateStartUtcFormat, dayStartUtcFormat, nextDayStartUtcFormat} from "../../utils/timeFormatUtil"; import './index.css' +import TaskItemList from "../../components/TaskItemList"; -const ToDoCal = (props) => { +const ToDoCal = () => { const today = new Date() const calRef = useRef(null); const refSwip = useRef(null); @@ -22,8 +22,10 @@ const ToDoCal = (props) => { console.log("getCurrentShowDay", getCurrentShowDay()) const {startDay, endDay} = getCurrentShowDay(); listTaskCount(startDay, endDay); + todoDayDetail(new Date()) }, [currentMonth]) let loading = false + const currentDaySearch =useRef() async function listTaskCount(start, end) { if (loading) { @@ -55,6 +57,54 @@ const ToDoCal = (props) => { setCurrentDay(today) } + const todoDayDetail = (searchDay) => { + let andSearchModel = {} + let orSearchModel = {andSearchModel} + if (searchDay) { + andSearchModel.andList = [{ + "name": "expectedStartTime", + "value": nextDayStartUtcFormat(searchDay), + "operateType": "<" + }, { + "name": "expectedEndTime", + "value": dayStartUtcFormat(searchDay), + "operateType": ">" + }] + andSearchModel.orSearchModel = { + "andList": [ + { + "name": "expectedStartTime", + "value": nextDayStartUtcFormat(searchDay), + "operateType": "<" + }, { + "name": "expectedStartTime", + "value": dayStartUtcFormat(searchDay), + "operateType": ">" + }, { + "name": "expectedEndTime", + "operateType": "NULL" + } + ], orSearchModel: { + "andList": [ + { + "name": "expectedEndTime", + "value": nextDayStartUtcFormat(searchDay), + "operateType": "<" + }, { + "name": "expectedEndTime", + "value": dayStartUtcFormat(searchDay), + "operateType": ">" + }, { + "name": "expectedStartTime", + "operateType": "NULL" + } + ] + } + } + } + currentDaySearch.value = {data:orSearchModel} + } + return ( @@ -145,6 +195,7 @@ const ToDoCal = (props) => { defaultValue={currentDay} onChange={val => { setCurrentDay(val) + todoDayDetail(val) }} onPageChange={(year, month) => { console.log(year, month) @@ -156,6 +207,8 @@ const ToDoCal = (props) => { + + ) }