From f93892f95cf6b327bea6d4c1785a1a3bfabb4add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 17 Mar 2020 21:11:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/signin/component/Teacherentry.js | 61 ++++++-- .../courses/signin/model/Createsignmodel.js | 131 ++++++++++++++---- 2 files changed, 154 insertions(+), 38 deletions(-) diff --git a/public/react/src/modules/courses/signin/component/Teacherentry.js b/public/react/src/modules/courses/signin/component/Teacherentry.js index ff08fe126..c07aea9a0 100644 --- a/public/react/src/modules/courses/signin/component/Teacherentry.js +++ b/public/react/src/modules/courses/signin/component/Teacherentry.js @@ -2,14 +2,17 @@ import React, {Component} from "react"; import '../css/signincdi.css'; import {Progress} from 'antd'; import axios from 'axios'; - +import Createsignmodel from '../model/Createsignmodel'; //条目 class Teacherentry extends Component { //条目组件 constructor(props) { super(props); - this.state = {} + this.state = { + editvisible:false, + attendancesid:null + } } componentDidMount() { @@ -21,7 +24,30 @@ class Teacherentry extends Component { } + getdatalist=(id)=>{ + let urls = `/attendances/${id}/edit.json`; + axios.get(urls).then((response) => { + //console.log(response); + if(response){ + if(response.data){ + this.setState({ + editvisible:true, + attendancesdata:response.data, + attendancesid:id + }) + } + } + + }).catch((error) => { + console.log(error); + }) + } + hideCreatesign=()=>{ + this.setState({ + editvisible:false + }) + } render() { let isAdmin = this.props.isAdmin(); let item = this.props.item; @@ -32,9 +58,18 @@ class Teacherentry extends Component { } catch (e) { jdt = 100; } + return (
+ {/*修改实训*/} + {this.state.editvisible===true?this.hideCreatesign()} + settabsdata={()=>this.props.getsetdatas()} + type={"edit"} + />:""}
{e.stopPropagation();this.props.qiandaoxiangq(true,item.id)}:""}>

{ @@ -97,17 +132,21 @@ class Teacherentry extends Component {

{e.stopPropagation();this.props.thisEnd(item.id)}}>截止
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
+
{e.stopPropagation();this.getdatalist(item.id)}}>编辑
: - item.edit_auth === true ? -
-
{e.stopPropagation();this.props.Signinnamestypes(item.id,true,item.name)}}>编辑
-
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
-
- : -
-
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
-
+ ( + //是否有编辑权限 + item.edit_auth === true ? +
+
{e.stopPropagation();this.getdatalist(item.id,true,item.name)}}>编辑
+
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
+
+ : +
+
{e.stopPropagation();this.props.thisdelete(item.id)}}>删除
+
+ ) : ( this.props.defaultActiveKey === "1" ? diff --git a/public/react/src/modules/courses/signin/model/Createsignmodel.js b/public/react/src/modules/courses/signin/model/Createsignmodel.js index 117531750..99f616204 100644 --- a/public/react/src/modules/courses/signin/model/Createsignmodel.js +++ b/public/react/src/modules/courses/signin/model/Createsignmodel.js @@ -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') { + + 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 ( {getFieldDecorator('group_ids')( - 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' })( 二维码签到 , )} - {Radiolist==="QUICK"?
学生点击签到按钮即可完成签到
:""} - {Radiolist==="NUMBER"?
学生需要输入签到码才能完成签到
:""} - {Radiolist==="QRCODE"?
{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: '请选择签到日期',}], })( trigger.parentNode} disabledTime={disabledDateTime} disabledDate={disabledDate} onChange={this.onChange} + // value={moment('2015-01-01', 'YYYY-MM-DD')} />)}