import "../css/Signinstatistics.css" import React from 'react' import { Modal , Form, Input, Radio,DatePicker,Select,Button} from 'antd'; import moment from 'moment'; import axios from 'axios'; import TimePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; function range(start, end) { const result = []; for (let i = start; i < end; i++) { result.push(i); } return result; } function disabledDateTime() { return { disabledMinutes: () => range(1, 30).concat(range(31, 60)), // disabledSeconds: () => range(0,60) } } function disabledDate(current) { return current && current < moment().endOf('day').subtract(1, 'days'); } const CollectionCreateForm = Form.create({ name: 'form_in_modal' })( class extends React.Component { constructor(props){ super(props); this.state = { course_groups:[], type:false, dateString:null, start_time: "", end_time:"" } } handleChangestart_time = (date) => { console.log(moment(date).format('HH:mm')) this.setState({ start_time: date }); }; handleChangeend_time=(date)=>{ console.log(moment(date).format('HH:mm')) this.setState({ end_time: date }); } componentDidMount() { const coursesId=this.props.match.params.coursesId; let newurl=`/courses/${coursesId}/all_course_groups.json`; axios.get(newurl).then((response) => { this.setState({ course_groups:response.data.course_groups }) }) } hideCreatesign=(e)=>{ e.preventDefault(); const {settabsdata,hideCreatesign} = this.props; const coursesId=this.props.match.params.coursesId; this.setState({ type:true }) this.props.form.validateFields((err, values) => { if (!err) { if(moment(values.end_time).format('HH:mm') { if (response.data.status == 0) { this.props.showNotification(`创建签到成功`); this.setState({ type:false }) hideCreatesign() settabsdata() } }) .catch(function (error) { console.log(error); }); }else{ this.setState({ type:false }) } }); } // getDisabledHours=()=> { // let hours = [] // if(this.state.dateString===moment().format('YYYY-MM-DD')){ // let time = moment().format('HH:mm') // let timeArr = time.split(':') // for (var i = 0; i < parseInt(timeArr[0]); i++) { // hours.push(i) // } // } // // return hours // } // // getDisabledMinutes=(selectedHour)=>{ // let minutes = [] // if(this.state.dateString===moment().format('YYYY-MM-DD')){ // let time = moment().format('HH:mm') // let timeArr = time.split(':') // if (selectedHour == parseInt(timeArr[0])) { // for(var i = 0; i < parseInt(timeArr[1]); i++) { // minutes.push(i) // } // } // } // return minutes // } onChange=(date, dateString)=>{ this.setState({ dateString:dateString }) } render() { const { visible, form ,setRadio,Radiolist,hideCreatesign} = this.props; let {course_groups}=this.state; const { getFieldDecorator } = form; const { Option } = Select; const formItemLayout = { labelCol: { span: 4 }, wrapperCol: { span: 19}, }; const leftbuton={ "width":"130px", "height":"40px", "border":"1px solid rgba(76,172,255,1)", "borderRadius":"4px", } const rightbuton={ "width":"130px", "height":"40px", "background":"#4CACFF", "borderRadius":"4px", } const format = 'HH:mm'; return (
{getFieldDecorator('name', { rules: [{ required: true, message: '请输入签到名称' },{whitespace:true,message: '请勿输入空格'}], })()} {getFieldDecorator('group_ids')( , )} {getFieldDecorator('mode', { rules: [{ required: true, message: '请选择签到方式' }], })( trigger.parentNode}> 快捷签到 签到码签到 二维码签到 , )} {Radiolist==="QUICK"?
学生点击签到按钮即可完成签到
:""} {Radiolist==="NUMBER"?
学生需要输入签到码才能完成签到
:""} {Radiolist==="QRCODE"?
学生需从小程序进入课堂扫码才能完成签到
:""}
{getFieldDecorator('attendance_date', { rules: [{ type: 'object', required: true, message: '请选择签到日期',}], })( trigger.parentNode} disabledTime={disabledDateTime} disabledDate={disabledDate} onChange={this.onChange} />)} {getFieldDecorator('start_time', { rules: [{ type: 'object', required: true, message: '请选择开始时间' }], })( // trigger.parentNode}/> this.handleChangestart_time(date)} showTimeSelect showTimeSelectOnly timeIntervals={1} timeCaption="Time" timeFormat="HH:mm" getPopupContainer={trigger => trigger.parentNode} /> )} {getFieldDecorator('end_time', { rules: [{ type: 'object', required: true, message: '请选择结束时间' }], })( // trigger.parentNode} // disabledHours={this.getDisabledHours} // disabledMinutes={this.getDisabledMinutes} // // /> this.handleChangeend_time(date)} showTimeSelect showTimeSelectOnly timeIntervals={1} minTime={this.state.dateString===moment().format('YYYY-MM-DD')||this.state.dateString===null?new Date():false} maxTime={this.state.dateString===moment().format('YYYY-MM-DD')||this.state.dateString===null?moment().endOf('day').toDate():false} timeCaption="Time" timeFormat="HH:mm" getPopupContainer={trigger => trigger.parentNode} /> )}
); } }, ); class Createsignmodel extends React.Component { state = { Radiolist: "", }; setRadio=(e)=>{ this.setState({ Radiolist:e.target.value }) } render() { return ( this.setRadio(e)} /> ); } } export default Createsignmodel;