import dayjs from 'dayjs';
import React from 'react';
import {Radio, DatePicker,  Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, Breadcrumb } from 'antd';

import UserSource from './components/UserSource.jsx';
// import XForm, { FieldTypes } from '../../components/XForm';
import moment from 'moment';


const header = props => {
  const { RangePicker } = DatePicker;
  function onChange(dates, dateStrings) {
    console.log('From: ', dates[0], ', to: ', dates[1]);
    console.log('From: ', dateStrings[0], ', to: ', dateStrings[1]);
  }


  const handleSubmit = (e, props) => {
    e.preventDefault();
    // props.form.validateFields((err, values) => {
    //   if (!err) {
    //     getList({ pageNum: 1, pageSize: 10, ...values })
    //   }
    // });
  }


  function getDataOf(days){      
    // const endDate = new Date()
    // const startDate = dayjs().subtract(days, 'day').toDate()

    // this.$refs.chart.getData({ startDate, endDate })
  }

  function onChange(e) {
    console.log(`radio checked:${e.target.value}`);
  }

  return (<>
  {/* <el-button type="text" @click="() => getDataOf(7)">最近7天</el-button>
      <el-button type="text" @click="() => getDataOf(30)">最近1月</el-button>
      <el-date-picker
        v-model="dateRange"
        type="daterange"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        style="margin-left: 16px">
      </el-date-picker>
      <el-button type="primary" icon="el-icon-search" style="margin-left: 32px" @click="search">查询</el-button>
    </div>
    <user-source ref="chart" mode="all"></user-source> */}
  <Radio.Group onChange={onChange} defaultValue="a">
        <Radio.Button value="a" onClick={getDataOf(7)}>最近7天</Radio.Button>
        <Radio.Button value="b" onClick={getDataOf(30)}>最近1月</Radio.Button>
      </Radio.Group>
      <RangePicker
      ranges={{
        Today: [moment(), moment()],
        'This Month': [moment().startOf('month'), moment().endOf('month')],
      }}
      showTime
      format="YYYY/MM/DD HH:mm:ss"
      // onChange={onChange}
    />
     <Button type="primary" htmlType="submit" >
            查询
          </Button>
  <div>
    

    <UserSource ></UserSource>
  </div>
  </>
  )
}

export default header