import {Dialog, Image, List, SwipeAction} from 'antd-mobile' import React, {useEffect, useRef, useState} from 'react' import { DragDropContext, Draggable, Droppable, // DropResult, } from 'react-beautiful-dnd' import {getTaskList} from "../../utils"; import "./index.css" 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([]) useEffect(() => { getTaskList().then(result => { console.log("getTaskList()", 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 ( {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") } } />
)}
))} {droppableProvided.placeholder}
)}
) } export default ToDoList;