import React, { Component } from 'react';
import { InputNumber,Radio } from 'antd'
import './numberSelection.less';

const RadioGroup = Radio.Group


export default class numberSelection extends Component {
  state = {
    radioValue: 1, // 类型选择 1-全时 2-自定义
    value:this.props.value || []
  }

  componentDidMount(){
    this.state.radioValue === 1 && this.onOk(1000);
  }

  onChangeRadioValue = (e) => {
    this.props.ChangeExportType(e.target.value);
     this.onOk(e.target.value === 1 ? 1000 : '')
     this.setState({
        radioValue: e.target.value,
      })
  }
  onOk = (e) =>{
    const { onChange } = this.props;
    onChange && onChange(e)
  }
  onChange =(e)=>{
    this.onOk(e)
  }
  render(){
    const { radioValue } = this.state
    return (
      <div className='form-group-item-content capture_time'>
        <RadioGroup onChange={this.onChangeRadioValue} value={radioValue}>
          <Radio value={1}>全部</Radio>
          <Radio value={2} style={{marginLeft: '16px'}}>自定义</Radio>
        </RadioGroup>
        <br/>
        {radioValue === 2&&
          <>
          导出前 <InputNumber placeholder="请输入导出数量" className="export-number" step={1} min={1} max={this.props.maxValue} onChange={this.onChange} /> 条数据
         </>
         }
      </div>
    )
  }
}
