-
TODO日{dayjs(currentDay).format(DATE_FORMAT)}代办:
+
TODO日{currentDay&&dayjs(currentDay).format(DATE_FORMAT)}代办:
任务状态
{
// taskCount.map(task => {
diff --git a/src/pages/ToDoList/index.css b/src/pages/ToDoList/index.css
index edc6222..ae3f100 100644
--- a/src/pages/ToDoList/index.css
+++ b/src/pages/ToDoList/index.css
@@ -3,4 +3,7 @@
}
.adm-card-header-title{
width:100%;
+}
+.adm-pull-to-refresh{
+ touch-action:none;
}
\ No newline at end of file
diff --git a/src/pages/ToDoList/index.js b/src/pages/ToDoList/index.js
index 6152a60..b4634ee 100644
--- a/src/pages/ToDoList/index.js
+++ b/src/pages/ToDoList/index.js
@@ -6,11 +6,12 @@ import {
Droppable,
// DropResult,
} from 'react-beautiful-dnd'
-import {getTaskList} from "../../utils";
+import {deleteTaskById, getTaskList, updateTaskStateById} from "../../utils";
import "./index.css"
-import {useLocation, useOutletContext} from "react-router-dom";
+import {useLocation, useNavigate, useOutletContext} from "react-router-dom";
import dayjs from "dayjs";
import {DATE_TIME_FORMAT} from "../../utils/timeFormatUtil";
+import {getDictionary} from "../../utils/dictUtil";
const reorder = (
list,
@@ -28,7 +29,10 @@ const ToDoList = () => {
const [taskList, setTaskList] = useState([])
const [hasMore, setHasMore] = useState(true)
const [pageNumber, setPageNumber] = useState(1)
- let loading = false;
+ const [priorityMap, setPriorityMap] = useState([]);
+ const [stateMap, setStateMap] = useState([])
+ const navigate = useNavigate();
+ let loading = true;
const location = useLocation();
const {search: outletSearch} = useOutletContext()
const search = location.state ? location.state.search : outletSearch;
@@ -49,9 +53,18 @@ const ToDoList = () => {
}
useEffect(() => {
+ getDictionary("2").then(res => {
+ setStateMap(res)
+ })
+ getDictionary("1").then(res => {
+ setPriorityMap(res)
+ })
getTaskList({...search, "pageNumber": pageNumber}).then(result => {
setTaskList(result.content)
+ setHasMore(result.page.number < result.page.totalPages)
+ loading=false;
})
+
}, [])
const onDragEnd = (result) => {
if (!result.destination) return
@@ -59,11 +72,13 @@ const ToDoList = () => {
setTaskList([...newList])
}
const ref = useRef(null)
+ const refSwip = useRef(null)
return (
{/* 下拉刷新 */}
{
+ onRefresh={() => {
+ console.log("refresh")
getTaskList({...search, "pageNumber": 1}).then(result => {
setTaskList(result.content)
setPageNumber(1)
@@ -72,135 +87,133 @@ const ToDoList = () => {
}}
>
-
-
- {droppableProvided => (
-
- {taskList.map((item, index) => (
-
- {(provided, snapshot) => (
-
-
{
- await Dialog.confirm({
- content: '确定要关闭吗?',
- })
- ref.current?.close()
- },
- },
- {
- key: 'close',
- text: '关闭',
- color: 'warning',
- onClick: async () => {
- await Dialog.confirm({
- content: '确定要关闭吗?',
- })
- ref.current?.close()
- },
- },
- {
- key: 'update',
- text: '修改',
- color: 'primary',
- onClick: async () => {
- await Dialog.confirm({
- content: '确定要修改吗?',
- })
- ref.current?.close()
- },
- },
- {
- key: 'complete',
- text: '完成',
- color: 'success',
- onClick: async () => {
- await Dialog.confirm({
- content: '确定要完成吗?',
- })
- ref.current?.close()
- },
- },
- ]}
- >
-
- // }
- // title={{item.name}}
- // children={item.description}
- // description={item.state}
- // onClick={
- // () => {
- // console.log("dianji")
- // }
- // }
- title={
-
- {item.name}
- {item.expectedEndTime &&
- 结束时间:{dayjs(item.expectedEndTime).format(DATE_TIME_FORMAT)}}
-
}
- description={item.description}
- >
- {/**/}
- {/* {item.name}*/}
- {/* {item.expectedEndTime && */}
- {/* 结束时间:{item.expectedEndTime}}*/}
+ {taskList.map((item, index) => (
+ {
+ Dialog.confirm({
+ content: '确定要删除吗?',
+ onConfirm: () => {
+ deleteTaskById(item.id).then(() => {
+ refSwip.current?.close()
+ })
+ },
+ onClose: () => {
+ console.log(refSwip)
+ refSwip.current?.close()
+ }
+ })
+ },
+ },
+ {
+ key: 'close',
+ text: '关闭',
+ color: 'warning',
+ onClick: async () => {
+ await Dialog.confirm({
+ content: '确定要关闭吗?',
+ onConfirm: () => {
+ updateTaskStateById('6', item.id)
+ },
+ })
+ refSwip.current?.close()
+ },
+ },
+ {
+ key: 'update',
+ text: '修改',
+ color: 'primary',
+ onClick: () => {
+ refSwip.current?.close()
+ // 跳转
+ navigate(`/detail/updateTask?id=${item.id}`)
+ },
+ },
+ {
+ key: 'complete',
+ text: '完成',
+ color: 'success',
+ onClick: async () => {
+ await Dialog.confirm({
+ content: '确定要完成吗?',
+ onConfirm: () => {
+ updateTaskStateById('7', item.id)
+ },
+ })
+ refSwip.current?.close()
+ },
+ },
+ ]}
+ >
+
+ // }
+ // title={{item.name}}
+ // children={item.description}
+ // description={item.state}
+ onClick={
+ () => {
+ console.log("click/detail")
+ navigate(`/detail/selectTask?id=${item.id}`)
+ }
+ }
+ title={
+
+ {(priorityMap.get(item.priority)?.jsonValue?.color) ?
+ ({item.name}) : (
+ {item.name})}
- {/*
}*/}
- {/*>*/}
- {/* {item.description}*/}
- {/**/}
-
-
-
- )}
-
- ))}
- {droppableProvided.placeholder}
-
- )}
-
-
+ {item.expectedEndTime && (stateMap.get(item.state)?.jsonValue?.color ?
+ (
+ 结束时间:{dayjs(item.expectedEndTime).format(DATE_TIME_FORMAT)}) :
+ (结束时间:{dayjs(item.expectedEndTime).format(DATE_TIME_FORMAT)}))
+ }
+
}
+ description={item.description}
+ >
+ {/*