'use client' import React, {CSSProperties} from "react"; import {Draggable, Droppable} from "react-beautiful-dnd"; import {ConfigProvider, Tooltip} from "antd"; import {DataType} from "@/lib/definitions"; import './index.modules.css' import dayjs from "dayjs"; import {getTaskState, taskPriorityList} from "@/lib/task/project/data"; import {List as VirtualizedList, AutoSizer} from "react-virtualized"; import 'react-virtualized/styles.css'; import OperationButton from "@/ui/task/OperationButton"; interface DroppableTableProps { tableCode: string, taskList: DataType[] } export const DroppableTable = React.memo((props: DroppableTableProps) => { const stateName = React.useMemo(() => { switch (props.tableCode) { case '0': return '不紧急不重要'; case '1': return '紧急不重要'; case '2': return '不紧急重要'; case '3': return '紧急重要'; default: return ''; } }, [props.tableCode]); const getItemStyle = React.useCallback((isDragging: boolean, draggableStyle: any): CSSProperties => ({ userSelect: "none", background: isDragging ? "lightgreen" : "white", position: 'relative', // 确保 zIndex 生效 zIndex: isDragging ? 2147483647 : 'auto', // 使用 'auto' 代替 0 可能更好 ...draggableStyle, borderBottom: '1px solid #f0f0f0', boxSizing: 'border-box', // verticalAlign: 'middle', // textAlign: 'center', }), []); const getListStyle = React.useCallback((isDraggingOver: boolean) => ({ background: isDraggingOver ? "lightblue" : "white", height: 'calc((100vh - 42px)/2)', width: '50vw' }), []); const rowRenderer = React.useCallback(({index, key, style}: { index: number; key: string; style: React.CSSProperties }) => { const record = props.taskList[index]; if (!record) return null; return ( {(provided, snapshot) => (
{record.name}
{record.description}
{getTaskState(record.state) ? getTaskState(record.state).name : ""}
起: {record.expectedStartTime ? dayjs(record.expectedStartTime).format("YYYY-MM-DD HH:mm") : ""}
止: {record.expectedStartTime ? dayjs(record.expectedStartTime).format("YYYY-MM-DD HH:mm") : ""}
)}
); }, [props.taskList, getItemStyle]); const headerStyle = React.useMemo(() => ({ backgroundColor: taskPriorityList.find((item) => item.code === props.tableCode)?.color, height: '55px', borderBottom: '1px solid #f0f0f0', fontWeight: 'bold' }), [props.tableCode]); return ( {(provided, snapshot) => (
{/* 表头 */}
{stateName}
任务描述
任务状态
期望时间
操作
{/* 虚拟列表主体 */}
{({height, width}) => ( )}
{provided.placeholder}
)}
) });