import React,{ Component } from "react";
import { Modal,Checkbox,Upload,Button,Icon,message,Input} from "antd";
import { WordNumberTextarea } from 'educoder';

class ModulationModal extends Component{
  constructor(props){
    super(props);
    this.state={
      group_ids:[],
      fileList:[],
      textareaval:undefined,
      Inputsval:undefined
    }
  }


  Saves=()=>{
    let {textareaval,Inputsval}=this.state;
    if(textareaval===""||textareaval===undefined){
      this.setState({
        textareavaltype:true
      })
      return
    }
    this.setState({
      textareavaltype: false
    })

    if(Inputsval===undefined||Inputsval===""){
      this.setState({
        Inputsvaltype:true
      })
      return
    }
     this.props.Saves(textareaval,Inputsval)

  }

  settextarea=(e)=>{
   this.setState({
     textareaval:e.target.value
   })
  }

  setInputs=(e)=>{
    var value=parseInt(e.target.value)

    if(isNaN(value)){
      value=0
    }else{
      if(value<0||value>100){
        value=0
      }
    }
    this.setState({
      Inputsval:value
    })
  }
  render(){
     let {textareaval,Inputsval,textareavaltype,Inputsvaltype}=this.state;
    return(
      <div>
        <Modal
          keyboard={false}
          className={"HomeworkModal"}
          title={this.props.modalname || '调分'}
          visible={this.props.visible}
          closable={false}
          footer={null}
          destroyOnClose={true}
        >
          <div className="task-popup-content">
            <p className="task-popup-text-center font-16 mb20">

              <span className={"color-dark-21"}>该学生的最终成绩将不会按照评分规则进行计算</span>

            </p>


            <div className="clearfix">
              {/*<textarea*/}
              {/*className="winput-100-150"*/}
              {/*placeholder="请填写您对作品调分的原因"*/}
              {/*value={textareaval}*/}
              {/*onInput={this.settextarea}*/}
              {/*></textarea>*/}

							<WordNumberTextarea
								placeholder={"请填写您对作品调分的原因"}
								onInput={(e)=>this.settextarea(e)}
								value={textareaval}
								maxlength={100}
							/>

              <li style={{height:"20px",lineHeight:"20px"}}><span className={textareavaltype===true?"color-red":"none"}>原因不能为空</span></li>
            </div>
            <li>
              <Input style={{
                width: '20%',
              }}
              placeholder="请填写分数"
              value={Inputsval}
              onInput={this.setInputs}/> <span className="ml10">分</span>
            </li>
            <li style={{height:"20px",lineHeight:"20px"}}><span className={Inputsvaltype===true?"color-red":"none"}>分数不能为空</span></li>
            <div className="clearfix edu-txt-center">
              <a  className="task-btn color-white mr30" onClick={this.props.Cancel}>{this.props.Cancelname || '取消'}</a>
              <a className="task-btn task-btn-orange" onClick={this.Saves}>{this.props.Savesname || '保存'}</a>
            </div>
          </div>
        </Modal>
      </div>
    )
  }
}
export default ModulationModal;