|
|
|
@ -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
|
|
|
|
|
}
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
|
console.log(error);
|
|
|
|
|
})
|
|
|
|
|
// this.setState({
|
|
|
|
|
// sentShixunPath:true
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
//隐藏发送至弹框
|
|
|
|
|
hideSenttothevalue =()=>{
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
sentShixunPath:false,
|
|
|
|
|
sendToShixunArray:[],
|
|
|
|
|
sendToCourseId:undefined,
|
|
|
|
|
courses:result.data.courses
|
|
|
|
|
})
|
|
|
|
|
this.props.topicscancelmodel()
|
|
|
|
|
}
|
|
|
|
|
//打开课堂列表下拉框
|
|
|
|
|
openList=()=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
openSearch:true
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
|
console.log(error);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
//关闭课堂列表下拉框
|
|
|
|
|
closeList=()=>{
|
|
|
|
|
|
|
|
|
|
onSearchChange=(e)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
openSearch:false
|
|
|
|
|
search:e.target.value
|
|
|
|
|
})
|
|
|
|
|
// this.onupdatalist(e.target.value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 选择课堂获取选中的Id
|
|
|
|
|
selectCloseList=(e)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
openSearch:false,
|
|
|
|
|
sendToCourseId:e
|
|
|
|
|
})
|
|
|
|
|
onSearch=(search)=>{
|
|
|
|
|
this.onupdatalist(search)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//选择checkbox
|
|
|
|
|
changeCheckBoxs=(list)=>{
|
|
|
|
|
|
|
|
|
|
onChange=(e)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
sendToShixunArray:list,
|
|
|
|
|
// shixunNum:list.length
|
|
|
|
|
Radiolist:e.target.value
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//确认提交
|
|
|
|
|
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){
|
|
|
|
|
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({
|
|
|
|
|
Modalstype:true,
|
|
|
|
|
sentShixunPath:false,
|
|
|
|
|
Modalstopval:result.data.message,
|
|
|
|
|
courseurl:result.data.url,
|
|
|
|
|
sendToShixunArray:[],
|
|
|
|
|
sendToCourseId:undefined,
|
|
|
|
|
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);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
render(){
|
|
|
|
|
let{courses,Radiolist,showcheck}= this.state;
|
|
|
|
|
|
|
|
|
|
const radioStyle = {
|
|
|
|
|
display: 'block',
|
|
|
|
|
height: '30px',
|
|
|
|
|
lineHeight: '30px',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
let{sentShixunPath,sendToCourseList,Modalstype,Modalstopval,Modalsbottomval,cardsModalcancel,cardsModalsave}= this.state;
|
|
|
|
|
return(
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
|
|
<Modals
|
|
|
|
|
modalsType={Modalstype}
|
|
|
|
|
modalsTopval={Modalstopval}
|
|
|
|
|
modalsBottomval={Modalsbottomval}
|
|
|
|
|
modalCancel={cardsModalcancel}
|
|
|
|
|
modalSave={cardsModalsave}
|
|
|
|
|
>
|
|
|
|
|
</Modals>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
|
`
|
|
|
|
@ -164,6 +106,7 @@ class SendTopics extends Component{
|
|
|
|
|
}
|
|
|
|
|
.over221{
|
|
|
|
|
height:221px;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
@ -192,26 +135,25 @@ class SendTopics extends Component{
|
|
|
|
|
></Search>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="edu-back-skyblue pl15 pr15 clearfix over221 pt5">
|
|
|
|
|
|
|
|
|
|
<Radio.Group onChange={this.onChange} value={Radiolist}>
|
|
|
|
|
{
|
|
|
|
|
sendToCourseList && sendToCourseList.stages.map((item,key)=>{
|
|
|
|
|
return(
|
|
|
|
|
item.shixuns.map((items,keys)=>{
|
|
|
|
|
courses && courses.map((item,key)=>{
|
|
|
|
|
return(
|
|
|
|
|
<div className="mt5" key={keys}>
|
|
|
|
|
<Checkbox name={key} value={items.shixun_id} key={items.shixun_id}>{items.shixun_name}</Checkbox>
|
|
|
|
|
<div className="mt5" key={key}>
|
|
|
|
|
<Radio style={radioStyle} value={item.course_id} key={item.course_id}>
|
|
|
|
|
{item.course_name}
|
|
|
|
|
</Radio>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</Radio.Group>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
{showcheck===true?<div className={"color-red mt10"}>请先选择课堂</div>:""}
|
|
|
|
|
<div className="mt20 clearfix edu-txt-center">
|
|
|
|
|
<a onClick={this.hideSenttothevalue} className="pop_close task-btn mr30">取消</a>
|
|
|
|
|
<a className="task-btn task-btn-orange" onClick={this.submitInfo}>确定</a>
|
|
|
|
|
<a onClick={()=>this.props.topicscancelmodel()} className="pop_close task-btn mr30">取消</a>
|
|
|
|
|
<a className="task-btn task-btn-orange" onClick={()=>this.submitInfo()}>确定</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Modal>
|
|
|
|
@ -220,4 +162,4 @@ class SendTopics extends Component{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
export default SnackbarHOC()(SendTopics);
|
|
|
|
|
export default SendTopics;
|