PCqiandao
杨树明 5 years ago
parent 8acb6b1af4
commit 051ba0c5b7

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

@ -28,7 +28,9 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
constructor(props){
super(props);
this.state = {
course_groups:[]
course_groups:[],
type:false,
dateString:null
}
}
componentDidMount() {
@ -46,13 +48,88 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
hideCreatesign=(e)=>{
e.preventDefault();
const { visible, form ,setRadio,Radiolist,hideCreatesign} = this.props;
const coursesId=this.props.match.params.coursesId;
this.setState({
type:true
})
this.props.form.validateFields((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
if(moment(values.end_time).format('HH:mm')<moment(values.start_time).format('HH:mm')){
this.props.showNotification(`结束时间不能小于起始时间`);
this.setState({
type:false
})
return
}
if( moment(values.start_time).format('HH:mm')===moment(values.end_time).format('HH:mm')){
this.props.showNotification(`结束时间不能与起始时间相同`);
this.setState({
type:false
})
return
}
let url=`/weapps/courses/${coursesId}/attendances.json`;
axios.post(url, {
attendance_date:moment(values.attendance_date).format('YYYY-MM-DD'),
end_time: moment(values.end_time).format('HH:mm'),
group_ids:values.group_ids,
mode: values.mode,
name: values.name,
start_time:moment(values.start_time).format('HH:mm'),
})
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification(`创建签到成功`);
this.setState({
type:true
})
hideCreatesign()
}
})
.catch(function (error) {
console.log(error);
});
}
});
}
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;
@ -142,6 +219,7 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
})(<DatePicker style={{width:"413px"}} getPopupContainer={trigger => trigger.parentNode}
disabledTime={disabledDateTime}
disabledDate={disabledDate}
onChange={this.onChange}
/>)}
</Form.Item>
@ -154,7 +232,11 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
<Form.Item label="结束时间:">
{getFieldDecorator('end_time', {
rules: [{ type: 'object', required: true, message: '请选择结束时间' }],
})(<TimePicker style={{width:"413px"}} format={format} getPopupContainer={trigger => trigger.parentNode}/>)}
})(<TimePicker style={{width:"413px"}} format={format} getPopupContainer={trigger => trigger.parentNode}
disabledHours={this.getDisabledHours}
disabledMinutes={this.getDisabledMinutes}
/>)}
</Form.Item>
@ -166,7 +248,7 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
</a>
<a>
<Button type="primary" className={"ml20"} style={rightbuton} onClick={(e)=>this.hideCreatesign(e)}>
<Button type="primary" className={"ml20"} style={rightbuton} onClick={(e)=>this.hideCreatesign(e)} loading={this.state.type}>
确定
</Button>
</a>

Loading…
Cancel
Save