|
|
|
@ -33,8 +33,10 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
course_groups:[],
|
|
|
|
|
type:false,
|
|
|
|
|
dateString:null,
|
|
|
|
|
start_time: "",
|
|
|
|
|
end_time:""
|
|
|
|
|
start_time:"",
|
|
|
|
|
end_time:"",
|
|
|
|
|
attendance_date:"",
|
|
|
|
|
newmode:null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -53,6 +55,43 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
if(this.props.type==="edit"){
|
|
|
|
|
let newlist=[]
|
|
|
|
|
if(this.props.attendancesdata.groups.length>0){
|
|
|
|
|
this.props.attendancesdata.groups.map((item,key)=>{
|
|
|
|
|
newlist.push(item.id)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(this.props.attendancesdata.start_time)
|
|
|
|
|
// console.log()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
attendance_date: this.props.attendancesdata.attendance_date,
|
|
|
|
|
start_time:new Date(this.props.attendancesdata.start_time),
|
|
|
|
|
end_time:new Date(this.props.attendancesdata.end_time),
|
|
|
|
|
newmode:this.props.attendancesdata.mode,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.props.form.setFieldsValue({
|
|
|
|
|
name: this.props.attendancesdata.name,
|
|
|
|
|
group_ids:newlist,
|
|
|
|
|
mode:this.props.attendancesdata.mode,
|
|
|
|
|
start_time:new Date(this.props.attendancesdata.start_time),
|
|
|
|
|
end_time:new Date(this.props.attendancesdata.end_time),
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({
|
|
|
|
|
start_time: new Date("2000-01-01T09:00:00.000+08:00"),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.props.form.setFieldsValue({
|
|
|
|
|
start_time:new Date("2000-01-01T09:00:00.000+08:00"),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const coursesId=this.props.match.params.coursesId;
|
|
|
|
|
let newurl=`/courses/${coursesId}/all_course_groups.json`;
|
|
|
|
|
axios.get(newurl).then((response) => {
|
|
|
|
@ -73,6 +112,7 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
type:true
|
|
|
|
|
})
|
|
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
|
|
|
|
|
|
|
if (!err) {
|
|
|
|
|
if(moment(values.end_time).format('HH:mm')<moment(values.start_time).format('HH:mm')){
|
|
|
|
|
this.props.showNotification(`结束时间不能小于起始时间`);
|
|
|
|
@ -88,17 +128,21 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
})
|
|
|
|
|
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(this.props.type==="edit"){
|
|
|
|
|
|
|
|
|
|
const attendancesid=this.props.attendancesid;
|
|
|
|
|
|
|
|
|
|
let url=`/attendances/${attendancesid}.json`
|
|
|
|
|
axios.put(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({
|
|
|
|
@ -107,10 +151,38 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
hideCreatesign()
|
|
|
|
|
settabsdata()
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
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'),
|
|
|
|
|
})
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
.then((response) => {
|
|
|
|
|
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
|
|
|
|
@ -153,8 +225,8 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
const { visible, form ,setRadio,Radiolist,hideCreatesign} = this.props;
|
|
|
|
|
let {course_groups}=this.state;
|
|
|
|
|
const { visible,form ,setRadio,Radiolist,hideCreatesign,editvisible} = this.props;
|
|
|
|
|
let {course_groups,newmode}=this.state;
|
|
|
|
|
const { getFieldDecorator } = form;
|
|
|
|
|
const { Option } = Select;
|
|
|
|
|
const formItemLayout = {
|
|
|
|
@ -175,12 +247,12 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
"background":"#4CACFF",
|
|
|
|
|
"borderRadius":"4px",
|
|
|
|
|
}
|
|
|
|
|
const format = 'HH:mm';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
visible={visible}
|
|
|
|
|
title="创建签到"
|
|
|
|
|
visible={editvisible?editvisible:visible}
|
|
|
|
|
title={this.props&&this.props.type==="edit"?"编辑签到":"创建签到"}
|
|
|
|
|
closable={false}
|
|
|
|
|
footer={null}
|
|
|
|
|
width={600}
|
|
|
|
@ -196,7 +268,9 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
|
|
|
|
|
<Form.Item label="签到班级:">
|
|
|
|
|
{getFieldDecorator('group_ids')(
|
|
|
|
|
<Select mode="multiple" placeholder={course_groups.length>0?"不选择分班时默认选择全部学生":'暂无分班,将默认选择课堂全部学生'} getPopupContainer={trigger => trigger.parentNode}>
|
|
|
|
|
<Select mode="multiple" placeholder={course_groups.length>0?"不选择分班时默认选择全部学生":'暂无分班,将默认选择课堂全部学生'} getPopupContainer={trigger => trigger.parentNode}
|
|
|
|
|
disabled={this.props&&this.props.type==="edit"?true:false}
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
{course_groups.map((item,key)=>{
|
|
|
|
|
return(
|
|
|
|
@ -218,18 +292,18 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
<Radio value="QRCODE">二维码签到</Radio>
|
|
|
|
|
</Radio.Group>,
|
|
|
|
|
)}
|
|
|
|
|
{Radiolist==="QUICK"?<div
|
|
|
|
|
{Radiolist==="QUICK"||!Radiolist&&newmode==="QUICK"?<div
|
|
|
|
|
style={{color:"#E6A23C",
|
|
|
|
|
height:"15px",
|
|
|
|
|
lineHeight: "15px"}}>学生点击签到按钮即可完成签到</div>:""}
|
|
|
|
|
|
|
|
|
|
{Radiolist==="NUMBER"?<div
|
|
|
|
|
{Radiolist==="NUMBER"||!Radiolist&&newmode==="NUMBER"?<div
|
|
|
|
|
style={{color:"#E6A23C",
|
|
|
|
|
height:"15px",
|
|
|
|
|
lineHeight: "15px"}}
|
|
|
|
|
>学生需要输入签到码才能完成签到</div>:""}
|
|
|
|
|
|
|
|
|
|
{Radiolist==="QRCODE"?<div
|
|
|
|
|
{Radiolist==="QRCODE"||!Radiolist&&newmode==="QRCODE"?<div
|
|
|
|
|
style={{color:"#E6A23C",
|
|
|
|
|
height:"15px",
|
|
|
|
|
lineHeight: "15px"}}
|
|
|
|
@ -238,11 +312,13 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
|
|
|
|
|
<Form.Item label="签到日期:">
|
|
|
|
|
{getFieldDecorator('attendance_date', {
|
|
|
|
|
rules: [{ type: 'object', required: true, message: '请选择签到日期',}],
|
|
|
|
|
initialValue:this.props.type==="edit"?moment(this.state.attendance_date,'YYYY-MM-DD'):"",
|
|
|
|
|
rules: [{required: true, message: '请选择签到日期',}],
|
|
|
|
|
})(<DatePicker style={{width:"413px"}} getPopupContainer={trigger => trigger.parentNode}
|
|
|
|
|
disabledTime={disabledDateTime}
|
|
|
|
|
disabledDate={disabledDate}
|
|
|
|
|
onChange={this.onChange}
|
|
|
|
|
// value={moment('2015-01-01', 'YYYY-MM-DD')}
|
|
|
|
|
/>)}
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<style>
|
|
|
|
@ -332,7 +408,7 @@ const CollectionCreateForm = Form.create({ name: 'form_in_modal' })(
|
|
|
|
|
|
|
|
|
|
class Createsignmodel extends React.Component {
|
|
|
|
|
state = {
|
|
|
|
|
Radiolist: "",
|
|
|
|
|
Radiolist: null,
|
|
|
|
|
};
|
|
|
|
|
setRadio=(e)=>{
|
|
|
|
|
|
|
|
|
@ -341,6 +417,7 @@ class Createsignmodel extends React.Component {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<CollectionCreateForm
|
|
|
|
|