import React, {Fragment, useContext, useEffect, useMemo} from "react"; import {getTaskCount} from "../../utils"; import dayjs from "dayjs"; import {DATE_FORMAT, dayStartUtcFormat, nextDayStartUtcFormat} from "../../utils/timeFormatUtil"; import {getDictionary} from "../../utils/dictUtil"; import {Tag} from "antd-mobile"; import {useNavigate} from "react-router-dom"; import {MyRootContext, UPDATE_SEARCH} from "../../components/MyRootContext"; const TaskCount = (props) => { let currentDay = props.currentDay; const navigate = useNavigate(); const [taskCount, setTaskCount] = React.useState([]); const [stateMap, setStateMap] = React.useState(new Map); const [priorityMap, setPriorityMap] = React.useState(new Map); const {dispatch } = useContext(MyRootContext); useEffect(() => { console.log("useEffect"); if (currentDay) { getTaskCount(dayStartUtcFormat(currentDay), nextDayStartUtcFormat(currentDay)) .then(taskCount => { setTaskCount(taskCount) }) getDictionary("2").then(state => { setStateMap(state) }) getDictionary("1").then(priority => { console.log(priority) setPriorityMap(priority) }) }else { setTaskCount([]) } }, [currentDay]) const todoDayDetail = ()=>{ let andSearchModel = {} let orSearchModel = {andSearchModel} if (currentDay) { andSearchModel.andList = [{ "name": "expectedStartTime", "value": nextDayStartUtcFormat(currentDay), "operateType": "<" }, { "name": "expectedEndTime", "value": dayStartUtcFormat(currentDay), "operateType": ">" }] andSearchModel.orSearchModel = { "andList": [ { "name": "expectedStartTime", "value": nextDayStartUtcFormat(currentDay), "operateType": "<" }, { "name": "expectedStartTime", "value": dayStartUtcFormat(currentDay), "operateType": ">" }, { "name": "expectedEndTime", "operateType": "NULL" } ], orSearchModel: { "andList": [ { "name": "expectedEndTime", "value": nextDayStartUtcFormat(currentDay), "operateType": "<" }, { "name": "expectedEndTime", "value": dayStartUtcFormat(currentDay), "operateType": ">" }, { "name": "expectedStartTime", "operateType": "NULL" } ] } } } console.log({orSearchModel}) dispatch({type:UPDATE_SEARCH,search:{ "pageSize": 12, "pageNumber": 1, "data": { orSearchModel } }}) navigate("/home/listTask") } return (

TODO日{currentDay && dayjs(currentDay).format(DATE_FORMAT)}代办: {currentDay&&详情}

任务状态

{ // taskCount.map(task => { // // if (dayjs(task.todoDay).isSame(dayjs(currentDay))){ // // console.log(dict); // // return {task.todoDay} // return Array.from(stateMap.entries()).map(([item,value]) => { // console.log("key",item,"value",value,task.state) // return value.itemName + task.state[item] // }) // // // return task.priority.map((key,value)=>getDictionary(2).get(key)+value) // // } // }) taskCount[0] && Object.keys(taskCount[0].state).map(ob => { return
{stateMap.get(ob).itemName} 共 {taskCount[0].state[ob]} 项代办;
; }) }

优先级

{ taskCount[0] && Object.keys(taskCount[0].priority).map(ob => { console.log("stateMap.get(ob).jsonValue?.color", priorityMap.get(ob)) return
{priorityMap.get(ob).itemName} 共 {taskCount[0].priority[ob]} 项代办;
; }) }
) } export {TaskCount};