/** 历次考试成绩统计 */
import { DownloadOutlined, PlusOutlined } from '@ant-design/icons';
import { Button } from 'antd';
import React, { useState, useRef } from 'react';

import type { ProColumns, ActionType } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';


import { getExaminationPersonStatistics } from '../service';
//import type { TableListItem, TableListPagination } from '../data';


const TableList: React.FC = () => {
  /** 新建窗口的弹窗 */
  const [createModalVisible, handleModalVisible] = useState<boolean>(false);
  /** 分布更新窗口的弹窗 */

  // const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
  //const [showDetail, setShowDetail] = useState<boolean>(false);
  const actionRef = useRef<ActionType>();
  //const [currentRow, setCurrentRow] = useState<TableListItem>();
  //const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]);
  /** 国际化配置 */

  const columns: ProColumns<TableListItem>[] = [
    {
      title: '序号',
      key: 'index',
      valueType: 'indexBorder',
      width: 48,
    },
    {
      title: '考试名称',
      dataIndex: 'examination_name',
      valueType: 'textarea',
    },
    {
      title: '报名人数',
      dataIndex: 'apply_count',
      sorter: true,
      hideInForm: true,
      renderText: (val: string) => `${val}`,
    },
    {
      title: '通过人数',
      dataIndex: 'pass_count',
      sorter: true,
      hideInForm: true,
      renderText: (val: string) => `${val}`,
    },
    {
      title: '通过率',
      dataIndex: 'pass_rate',
      sorter: true,
      hideInForm: true,
      renderText: (val: string) => `${val}%`,
    },

  ];

  return (
    <div style={{ marginBottom: '20px' }}>
      <ProTable<TableListItem, TableListPagination>
        headerTitle="历次考试成绩统计"
        actionRef={actionRef}
        rowKey="key"
        search={false}
        options={false}
        toolBarRender={() => [
          <Button icon={<DownloadOutlined />} type="primary" key="subscribeAlert" href={`/dsideal_yy/zygh/training/statistics/exportExaminationData`}>
            导出名单
          </Button>,
        ]}

        request={async (params) => {
          const _data = await getExaminationPersonStatistics({ page_number:params.current, page_size:20,sort_type: 2, sort_colum: 1 });
          return {
            data: _data?.table_List,
          };
        }}
        columns={columns}
        rowSelection={false}
      />
    </div>
  );
};

export default TableList;
