import {Card, Dialog, Image, InfiniteScroll, List, PullToRefresh, SwipeAction} from 'antd-mobile' import React, {Fragment, useEffect, useRef, useState} from 'react' import { DragDropContext, Draggable, Droppable, // DropResult, } from 'react-beautiful-dnd' import {getTaskList} from "../../utils"; import "./index.css" import {useLocation} from "react-router-dom"; const reorder = ( list, startIndex, endIndex ) => { const result = Array.from(list) const [removed] = result.splice(startIndex, 1) result.splice(endIndex, 0, removed) return result } const ToDoList = () => { const [taskList, setTaskList] = useState([]) const [hasMore, setHasMore] = useState(true) const [pageNumber, setPageNumber] = useState(1) const location = useLocation(); const search = location.state?.search; console.log("ToDoList.search",search) async function loadMore() { getTaskList(pageNumber+1).then(result => { setTaskList(val => [...val, ...result.data.data.content]) setHasMore(result.data.data.content.length > 0) }) setPageNumber(pageNumber + 1) } useEffect(() => { getTaskList(pageNumber).then(result => { setTaskList(result.data.data.content) }) }, []) const onDragEnd = (result) => { if (!result.destination) return const newList = reorder(taskList, result.source.index, result.destination.index) setTaskList([...newList]) } const ref = useRef(null) return ( { getTaskList(1).then(result => { console.log("getTaskList()", result) setTaskList(result.data.data.content) setPageNumber(1) setHasMore(true) }) }} > {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 && 结束时间:{item.expectedEndTime}}
} description={item.description} > {/**/} {/* {item.name}*/} {/* {item.expectedEndTime && */} {/* 结束时间:{item.expectedEndTime}}*/} {/*
}*/} {/*>*/} {/* {item.description}*/} {/**/}
)} ))} {droppableProvided.placeholder} )}
) } export default ToDoList;