import React, { useState, useEffect } from 'react';
import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
import { FormattedMessage } from 'umi-plugin-react/locale';
import styles from '../style/GoodsList.less';
import router from 'umi/router';
import moment from 'moment';

import request from '../../utils/request'

const { Option } = Select;
const { MonthPicker, RangePicker, WeekPicker } = DatePicker;

/**
 *
 *
 * @param {*} props
 * @returns
 */

const columns = [
  {
    title: '用户姓名',
    dataIndex: 'name',
    key: 'name',
    align: 'center',
  },
  {
    title: '手机号',
    dataIndex: 'phone',
    key: 'phone',
    align: 'center',
  },
  {
    title: '报名时间',
    dataIndex: 'createDate',
    key: 'createDate',
    align: 'center',
    render: (x, row) => <><span>{`${moment(row.createDate).format('YYYY-MM-DD')}`}</span></>
  }
];



const header = (props) => {
  const [ data, setData ] = useState({list: {}})
//   const [page, changePage] = useState({})
  useEffect(() => {
    getSignList({pageNum: 1,pageSize: 10, dynamicId: props.location.query.dynamicId });
  },[])

  // 查询列表
  const getSignList = (params) => {
    request({
        url: '/api/admin/SignList',
        method: 'GET',
        params: { ...params },
    }).then((data) => {
        console.log(data)
        setData(data)
    })
  }

  const changePageNum = (pageNumber) => {
    getList({ pageNum: pageNumber, pageSize: 10, dynamicId: props.location.query.dynamicId })
  }

  const toActivityList = () => {
    router.push({
      pathname: '/activity/ActivityList',
    });
  }

  return (
    <>
      <Button type="primary" className={styles.addBtn} onClick={toActivityList}>返回</Button>
      <Table dataSource={data.list.data} columns={columns} pagination={false} />
      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} />
      </div>
    </>
  )
}
const WrappedHeader = Form.create({ name: 'header' })(header);

export default WrappedHeader
