import { batchDeletePredictions, deletePrediction, getPredictions } from '@/services/api'; // 假设这些API已经实现 import type { ActionType, ProColumns } from '@ant-design/pro-components'; import { FooterToolbar, PageContainer, ProTable } from '@ant-design/pro-components'; import { Button, message, Popconfirm } from 'antd'; import React, { useRef, useState } from 'react'; const PredictionList: React.FC = () => { const actionRef = useRef(); // const [currentRow, setCurrentRow] = useState(); const [selectedRows, setSelectedRows] = useState([]); const [pageSize, setPageSize] = useState(10); // const [updateModalOpen, handleUpdateModalOpen] = useState(false); // const formRef = useRef(null); const columns: ProColumns[] = [ { title: '用户', dataIndex: 'username', valueType: 'text', }, { title: '比赛', dataIndex: 'matchInfo', valueType: 'text', // ellipsis: true, }, { title: '比赛时间', dataIndex: 'matchTime', valueType: 'text', // ellipsis: true, }, { title: '胜负预测', dataIndex: 'whoWillWin', valueEnum: { home: { text: '主队胜' }, away: { text: '客队胜' }, draw: { text: '平局' }, }, }, { title: '首先得分', dataIndex: 'firstTeamToScore', valueEnum: { home: { text: '主队' }, away: { text: '客队' }, no_goal: { text: '无进球' }, }, }, { title: '总进球数', dataIndex: 'totalGoals', valueType: 'digit', }, { title: '胜负预测结果', dataIndex: 'whoWillWinResult', valueEnum: { correct: { text: '正确', status: 'Success' }, incorrect: { text: '错误', status: 'Error' }, pending: { text: '-' }, }, }, { title: '首先得分预测结果', dataIndex: 'firstTeamToScoreResult', valueEnum: { correct: { text: '正确', status: 'Success' }, incorrect: { text: '错误', status: 'Error' }, // pending: { text: '待定', status: 'Warning' }, pending: { text: '-' }, }, }, { title: '总进球数预测结果', dataIndex: 'totalGoalsResult', valueEnum: { correct: { text: '正确', status: 'Success' }, incorrect: { text: '错误', status: 'Error' }, // pending: { text: '待定', status: 'Warning' }, pending: { text: '-' }, }, }, { title: '获得积分', dataIndex: 'pointsEarned', valueType: 'digit', }, { title: '操作', dataIndex: 'option', valueType: 'option', render: (_, record) => [ // { // handleUpdateModalOpen(true); // setCurrentRow(record); // }} // > // 编辑 // , handleDelete(record)} okText="确定" cancelText="取消" > 删除 , ], }, ]; const handleDelete = async (record: API.PredictionItem) => { const res = await deletePrediction(record._id); if (res.success) { message.success('预测记录已成功删除'); actionRef.current?.reload(); } }; return ( actionRef={actionRef} rowKey="_id" search={{ labelWidth: 120, }} // toolBarRender={() => [ // , // ]} request={getPredictions} columns={columns} scroll={{ x: 1240 }} pagination={{ showSizeChanger: true, pageSize: pageSize, onChange: (page, pageSize) => { setPageSize(pageSize); }, }} rowSelection={{ onChange: (_, selectedRows) => { setSelectedRows(selectedRows); }, }} /> {selectedRows?.length > 0 && ( 已选择 {selectedRows.length} 项    } > )} {/* { const res = await updatePrediction(value._id, value as API.PredictionItem); if (res.success) { message.success('修改成功'); handleUpdateModalOpen(false); setCurrentRow(undefined); actionRef.current?.reload(); } }} onCancel={() => { handleUpdateModalOpen(false); }} updateModalOpen={updateModalOpen} values={currentRow || {}} /> */} {/* { const res = await updatePrediction(currentRow?._id, value as API.PredictionItem); if (res.success) { message.success('修改成功'); handleUpdateModalOpen(false); setCurrentRow(undefined); actionRef.current?.reload(); } }} initialValues={currentRow} > */} ); }; export default PredictionList;