import React,{ Component } from "react"; import { Modal,Radio,Input,Tooltip,Checkbox,Select, Row,Col } from "antd"; import axios from 'axios'; import { SnackbarHOC } from 'educoder'; import moment from 'moment'; import Modals from '../../modals/Modals'; const Option = Select.Option; const CheckboxGroup = Checkbox.Group; class sendPanel extends Component{ constructor(props){ super(props); this.state={ sentShixunPath:false, sendToCourseList:undefined, openSearch:false, sendToCourseId:undefined, sendToShixunArray:[], Modalstype:false, cardsModalcancel:this.cardsModalcancel, cardsModalsave:this.cardsModalsave, modalsTopval:'', Modalsbottomval:'', courseurl:'' } } //发送至 SentToLesson =() =>{ this.setState({ sentShixunPath:true }) } //隐藏发送至弹框 hideSenttothevalue =()=>{ this.setState({ sentShixunPath:false, sendToShixunArray:[], sendToCourseId:undefined, }) } //打开课堂列表下拉框 openList=()=>{ this.setState({ openSearch:true }) } //关闭课堂列表下拉框 closeList=()=>{ this.setState({ openSearch:false }) } // 选择课堂获取选中的Id selectCloseList=(e)=>{ this.setState({ openSearch:false, sendToCourseId:e }) } //选择checkbox changeCheckBoxs=(list)=>{ this.setState({ sendToShixunArray:list, // shixunNum:list.length }) } //确认提交 submitInfo=()=>{ let {sendToCourseId,sendToShixunArray}=this.state; if(sendToCourseId===undefined){ this.props.showSnackbar("您还未选择发送的课堂"); }else if(parseInt(sendToShixunArray.length)==0){ this.props.showSnackbar("您还未选择实训"); }else{ let id=this.props.detailInfoList.id; let url="/paths/"+id+"/send_to_course.json"; axios.post(url,{ shixun_ids:sendToShixunArray, course_id:sendToCourseId }).then((result)=>{ if(result.data.status===1){ this.setState({ Modalstype:true, sentShixunPath:false, Modalstopval:result.data.message, courseurl:result.data.url, sendToShixunArray:[], sendToCourseId:undefined, }) } }).catch((error)=>{ console.log(error); }) } } componentDidMount(){ let id=this.props.detailInfoList.id; let url="/paths/"+id+"/choose_course.json"; axios.get(url).then((result)=>{ if(result.status==200){ this.setState({ sendToCourseList:result.data }) } }).catch((error)=>{ console.log(error); }) } cardsModalcancel=()=>{ this.setState({ Modalstype:false, }) } cardsModalsave=()=>{ let {courseurl}=this.state; window.location.href =courseurl; } allChange = (e) => { if(e.target.checked===false){ this.setState({ sendToShixunArray: [], }) }else{ let { sendToCourseList} = this.state; let newlist = []; sendToCourseList.stages.map((item,key)=>{ item.shixuns.map((items,keys)=>{ newlist.push(items.shixun_id) }) }) this.setState({ sendToShixunArray: newlist, }) } } render(){ let{sentShixunPath,sendToCourseList,Modalstype,Modalstopval,Modalsbottomval,cardsModalcancel,cardsModalsave}= this.state; return(
{ this.props.detailInfoList===undefined?"":this.props.detailInfoList.allow_send===true? 发送至 :'' }
{ sendToCourseList && sendToCourseList.stages.map((item,key)=>{ return( item.shixuns.map((items,keys)=>{ return(
{items.shixun_name}
) }) ) }) }
this.allChange(e)} >全选

已选择 {this.state.sendToShixunArray.length} 个实训

取消 确定
) } } export default SnackbarHOC()(sendPanel);