diff --git a/public/react/src/modules/modals/SendTopics.js b/public/react/src/modules/modals/SendTopics.js index 013988d93..6e53a716f 100644 --- a/public/react/src/modules/modals/SendTopics.js +++ b/public/react/src/modules/modals/SendTopics.js @@ -1,158 +1,100 @@ 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 Modals from './Modals'; const { Search } = Input; class SendTopics 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:'' + courses:[], + search:null, + Radiolist:undefined, + showcheck:false } } - //发送至 - SentToLesson =() =>{ - let id=this.props.detailInfoList.id; - let url="/paths/"+id+"/choose_course.json"; - axios.get(url).then((result)=>{ - if(result.status==200){ - if (result.data.status === 403||result.data.status === 402||result.data.status === 407||result.data.status === 408) { - }else{ - this.setState({ - sendToCourseList:result.data, - sentShixunPath:true - }) - } + componentDidMount(){ + let{search}=this.state; + this.onupdatalist(search) + } + onupdatalist=(search)=>{ + let url="/question_banks/my_courses.json"; + axios.get(url,{params:{ + search } + }).then((result)=>{ + this.setState({ + courses:result.data.courses + }) }).catch((error)=>{ console.log(error); }) - // this.setState({ - // sentShixunPath:true - // }) - } - //隐藏发送至弹框 - hideSenttothevalue =()=>{ - this.setState({ - sentShixunPath:false, - sendToShixunArray:[], - sendToCourseId:undefined, - }) - this.props.topicscancelmodel() - } - //打开课堂列表下拉框 - 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); - }) - } - } + onSearchChange=(e)=>{ + this.setState({ + search:e.target.value + }) + // this.onupdatalist(e.target.value) + } - 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); - // }) - } + onSearch=(search)=>{ + this.onupdatalist(search) + } - cardsModalcancel=()=>{ - this.setState({ - Modalstype:false, - }) - } - cardsModalsave=()=>{ - let {courseurl}=this.state; - window.location.href =courseurl; - } + onChange=(e)=>{ + this.setState({ + Radiolist:e.target.value + }) + } + submitInfo=()=>{ + let{Radiolist}=this.state; + let url=`/question_banks/send_to_course.json`; + let object_id=this.props.checkBoxValues; + let object_type=this.props.category; + if(Radiolist===undefined){ + this.setState({ + showcheck:true + }) + }else{ + axios.post(url,{ + object_id: object_id, + object_type:object_type, + course_id:Radiolist + } + ).then((result)=>{ + if(result.data.status===0){ + this.props.updataslist() + this.props.topicscancelmodel() + this.props.showNotification(result.data.message) + }else{ + this.props.showNotification(result.data.message) + } + }).catch((error)=>{ + console.log(error) + }) + } + + } render(){ - let{sentShixunPath,sendToCourseList,Modalstype,Modalstopval,Modalsbottomval,cardsModalcancel,cardsModalsave}= this.state; + let{courses,Radiolist,showcheck}= this.state; + + const radioStyle = { + display: 'block', + height: '30px', + lineHeight: '30px', + }; + return(