+ setCurrentShow(key)}>
+
+
+ />
+
{
Array.from(taskLogMapMemory.keys()).map(key => {
return (
@@ -72,7 +109,13 @@ export function DetailLogTask() {
}
{taskLogMapMemory.get(key).map(taskLog => {
return
- {taskLog.description}
+ {
+ actions[1]={ text: '失效', key: 'edit' }
+ // setActions([...actions])
+ setCurrentTask(taskLog)
+ setActionSheetVisible(true)
+ }}>
+ {taskLog.description}
})})
})
@@ -96,6 +139,19 @@ export function DetailLogTask() {
onClick={handleSend}
>发送
+
setActionSheetVisible(false)}
+ onAction={action => {
+ if (action.key === 'copy') {
+ copyTextToClipboard(currentTask.description)
+ }
+ setActionSheetVisible(false)
+ }}
+ />
diff --git a/src/pages/TaskCount/index.js b/src/pages/TaskCount/index.js
index ffbaa8e..5bf2523 100644
--- a/src/pages/TaskCount/index.js
+++ b/src/pages/TaskCount/index.js
@@ -3,40 +3,19 @@ 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 {Divider, 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 {currentDay, taskCount, today, backToToday} = props;
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([])
- }
+ const {dispatch} = useContext(MyRootContext);
- }, [currentDay])
-
- const todoDayDetail = ()=>{
+ const todoDayDetail = () => {
let andSearchModel = {}
let orSearchModel = {andSearchModel}
if (currentDay) {
@@ -82,49 +61,56 @@ const TaskCount = (props) => {
}
}
console.log({orSearchModel})
- dispatch({type:UPDATE_SEARCH,search:{
+ dispatch({
+ type: UPDATE_SEARCH, search: {
"pageSize": 12,
"pageNumber": 1,
"data": {
orSearchModel
}
- }})
+ }
+ })
navigate("/home/listTask")
}
+ useEffect(() => {
+ console.log("useEffect");
+ getDictionary("2").then(state => {
+ setStateMap(state)
+ })
+ getDictionary("1").then(priority => {
+ console.log(priority)
+ setPriorityMap(priority)
+ })
+ }, [])
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]} 项代办;
;
- })
+ {currentDay &&
详情}
+ {!dayjs(currentDay).isSame(today, 'date') &&
+
backToToday()}>回到今天}
+
+ {taskCount.filter(taskC => dayjs(taskC.todoDay).isSame(dayjs(currentDay), 'date'))?.map(taskC => {
+ return
+ 任务状态
+ {
+ Object.keys(taskC.state).map(ob => {
+ return {stateMap.get(ob).itemName} 共
+ {taskC.state[ob]} 项代办;
;
+ })}
+ 优先级
+ {
+ Object.keys(taskC.priority).map(ob => {
+ console.log("stateMap.get(ob).jsonValue?.color", priorityMap.get(ob))
+ return {priorityMap.get(ob).itemName} 共
+ {taskC.priority[ob]} 项代办;
;
+ })
+ }
+
+ })
}
)
diff --git a/src/pages/ToDoCal/index.jsx b/src/pages/ToDoCal/index.jsx
index 62e2f12..f69e0b9 100644
--- a/src/pages/ToDoCal/index.jsx
+++ b/src/pages/ToDoCal/index.jsx
@@ -1,26 +1,82 @@
-import {Calendar} from "antd-mobile";
+import {Calendar, Tag} from "antd-mobile";
import dayjs from "dayjs";
import {TaskCount} from "../TaskCount";
-import React,{Fragment} from "react";
+import React, {Fragment, useEffect, useLayoutEffect, useRef} from "react";
+
+import {
+ dateStartUtcFormat,
+ nextDateStartUtcFormat,
+} from "../../utils/timeFormatUtil";
+import {getTaskCount} from "../../utils";
+import {FrownFill, SmileFill} from "antd-mobile-icons";
+import {NEW, OVERDUE, UNDER_WAY} from "../../utils/commonConstant";
const ToDoCal = (props) => {
+ const calRef = useRef(null);
const [currentDay, setCurrentDay] = React.useState(new Date())
- const today = dayjs()
+ const today = new Date()
+ const [allDay,setAllDay] = React.useState([])
+ const [taskCount,setTaskCount] = React.useState([])
+ function listTaskCount(){
+ if (allDay.length === 0){
+ return
+ }
+ getTaskCount(dateStartUtcFormat(allDay[0]),
+ nextDateStartUtcFormat(allDay[allDay.length-1]))
+ .then(res => {
+ setTaskCount(res)
+ })
+ }
+ useLayoutEffect(()=>{
+ console.log("useLayoutEffect",allDay)
+
+ listTaskCount();
+ },[])
+ function backToToday(){
+ calRef.current.jumpToToday();
+ setCurrentDay(today)
+ }
return (
{
- if (dayjs(date).isSame(today, 'day')) return '今天'
- if (date.getDay() === 0 || date.getDay() === 6) {
- return '周末'
- }
+ allDay.push(date)
+
+ // 没有任务不显示
+ return taskCount.filter(taskC => dayjs(taskC.todoDay).isSame(dayjs(date), 'date'))?.map(taskC => {
+ // 如果有逾期的 红色
+ // Object.keys() 返回一个包含对象自身所有可枚举属性的数组
+ // Object.entries() 返回一个包含对象所有可枚举属性的键值对数组。
+ if (Object.keys(taskC.state).length>0){
+ console.log("taskC.state",taskC.state)
+ if (taskC.state[OVERDUE]){
+ return ;
+ }
+ // 如果有未完成的任务 warn
+ if (taskC.state[NEW]||taskC.state[UNDER_WAY]){
+ return ;
+ }
+ // 任务全部完成 绿色
+ return ;
+ }
+ })
+
+ // if (dayjs(date).isSame(today, 'day')) return '今天'
+ // if (date.getDay() === 0 || date.getDay() === 6) {
+ // return '周末'
+ // }
}}
+ // renderDate={date=>{
+ // return {dayjs(date).date()}
+ // }}
defaultValue={currentDay}
onChange={val => {
setCurrentDay(val)
}}
+
/>
-
+
)
}
diff --git a/src/pages/ToDoTree/index.js b/src/pages/ToDoTree/index.js
index f6d15c8..b6cec44 100644
--- a/src/pages/ToDoTree/index.js
+++ b/src/pages/ToDoTree/index.js
@@ -1,79 +1,24 @@
-import {Fragment, useEffect, useMemo, useState} from "react";
-import {Card, Cascader, CascaderView} from "antd-mobile";
-import {getTaskByPid} from "../../utils";
-import dayjs from "dayjs";
-import {DATE_TIME_FORMAT} from "../../utils/timeFormatUtil";
+import {Fragment} from "react";
+import {Card, CascaderView, Dialog, Toast} from "antd-mobile";
+
import {useChildList} from "../../hooks/useChildList";
+import {useNavigate} from "react-router-dom";
export default () => {
- // const [valueToOptions, setValueToOptions] = useState([])
- // const [currentTask, setCurrentTask] = useState({
- // name:"想做的事情",
- // description:"想做的事情描述",
- // expectedStartTime:dayjs().format(DATE_TIME_FORMAT),
- // expectedEndTime:"",
- // state:"",
- // priority:"",
- // })
- // const options = useMemo(() => {
- // function generate(v) {
- // const options = valueToOptions[v]
- // if (options === null || options === undefined) {
- // return undefined
- // }
- // // if (options === undefined) {
- // // return Cascader.optionSkeleton
- // // }
- // return options.map(option => ({
- // ...option,
- // children: generate(option.value),
- // }))
- // }
- //
- // return generate('0') ?? []
- // }, [valueToOptions])
- //
- // async function fetchOptionsForValue(v, level) {
- // if (v in valueToOptions) return
- // // if (level >= 3) {
- // // setValueToOptions(prev => ({
- // // ...prev,
- // // [v]: null,
- // // }))
- // // return
- // // }
- // const data = await getTaskByPid(v)
- // console.log("await getTaskByPid(v)", data.content)
- // const options =
- // data.content.length === 0
- // ? null
- // : data.content.map(task => ({
- // value: task.id,
- // label: task.name,
- // }))
- // console.log("await getTaskByPid(v) options", options)
- // if (options){
- // setValueToOptions(prev => ({
- // ...prev,
- // [v]: options,
- // }))
- // }else {
- // setValueToOptions(prev => ({
- // ...prev,
- // [v]: undefined,
- // }))
- // }
- // }
-
- // useEffect(() => {
- // fetchOptionsForValue('0', 0)
- // }, [])
-
const {task, options, changeTaskId,} = useChildList();
+ const navigate = useNavigate();
return
-
+ {
+ if (task&&task.id) {
+ const result = await Dialog.confirm({ content: '确定要进入详情页吗?' })
+ if (result) {
+ navigate(`/detail/selectTask?id=${task.id}`)
+ }
+ }
+ }}
+ >
{task?.description}
-
预计开始时间:{task?.expectedStartTime}
预计结束时间:{task?.expectedEndTime}
diff --git a/src/utils/commonConstant.js b/src/utils/commonConstant.js
new file mode 100644
index 0000000..251a0b3
--- /dev/null
+++ b/src/utils/commonConstant.js
@@ -0,0 +1,5 @@
+const OVERDUE= '10';
+const COMPLETE = '7';
+const NEW = '8';
+const UNDER_WAY = '9';
+export { OVERDUE, COMPLETE, NEW, UNDER_WAY };
\ No newline at end of file
diff --git a/src/utils/copyToClipBoard.js b/src/utils/copyToClipBoard.js
new file mode 100644
index 0000000..273f13b
--- /dev/null
+++ b/src/utils/copyToClipBoard.js
@@ -0,0 +1,39 @@
+export function copyTextToClipboard(text) {
+ return new Promise((resolve, reject) => {
+ if (navigator.clipboard && window.isSecureContext) {
+ // 尝试使用现代剪贴板 API
+ navigator.clipboard.writeText(text)
+ .then(() => resolve('文本已成功复制到剪贴板'))
+ .catch((err) => reject(`无法复制文本:${err.message}`));
+ } else {
+ // 回退到旧方法
+ fallbackCopyTextToClipboard(text)
+ .then(message => resolve(message))
+ .catch(err => reject(err));
+ }
+ });
+}
+
+function fallbackCopyTextToClipboard(text) {
+ return new Promise((resolve, reject) => {
+ const textArea = document.createElement("textarea");
+ textArea.value = text;
+
+ // 避免 CSS 样式影响滚动条
+ textArea.style.position = 'fixed';
+ textArea.style.left = '-9999px';
+ document.body.appendChild(textArea);
+ textArea.focus();
+ textArea.select();
+
+ try {
+ const successful = document.execCommand('copy');
+ const msg = successful ? '文本已成功复制到剪贴板' : '无法复制文本';
+ resolve(msg);
+ } catch (err) {
+ reject(`无法复制文本:${err.message}`);
+ }
+
+ document.body.removeChild(textArea);
+ });
+}
\ No newline at end of file
diff --git a/src/utils/timeFormatUtil.js b/src/utils/timeFormatUtil.js
index 6470191..2884992 100644
--- a/src/utils/timeFormatUtil.js
+++ b/src/utils/timeFormatUtil.js
@@ -21,6 +21,22 @@ function dayStartUtcFormat(dayjsString) {
return dayJsObj.set('h', 0).set('m', 0).set('s', 0).set('ms', 0).utc().format()
}
+function dateStartUtcFormat(dateObject) {
+ if (!dateObject) {
+ return
+ }
+ let dayJsObj= dayjs(dateObject);
+ return dayJsObj.set('h', 0).set('m', 0).set('s', 0).set('ms', 0).utc().format()
+}
+
+function nextDateStartUtcFormat(dateObject) {
+ if (!dateObject) {
+ return
+ }
+ let dayJsObj= dayjs(dateObject);
+ return dayJsObj.add(1, "d").set('h', 0).set('m', 0).set('s', 0).set('ms', 0).utc().format()
+}
+
function nextDayStartUtcFormat(dayjsString) {
if (!dayjsString) {
return
@@ -34,4 +50,7 @@ function nextDayStartUtcFormat(dayjsString) {
return dayJsObj.add(1, "d").set('h', 0).set('m', 0).set('s', 0).set('ms', 0).utc().format()
}
-export {DATE_TIME_FORMAT, DATE_FORMAT,DATE_TIME_FORMAT_SIMPLE,dayStartUtcFormat,nextDayStartUtcFormat}
\ No newline at end of file
+export {DATE_TIME_FORMAT, DATE_FORMAT,DATE_TIME_FORMAT_SIMPLE,
+ dayStartUtcFormat,nextDayStartUtcFormat,
+ dateStartUtcFormat,nextDateStartUtcFormat,
+}
\ No newline at end of file