封装题库发送弹窗

调整个人题库
dev_aliyun_beta
杨树明 6 years ago
parent 24b77c17f6
commit 1773e9dda4

@ -0,0 +1,223 @@
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:''
}
}
//发送至
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
})
}
}
}).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);
})
}
}
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{sentShixunPath,sendToCourseList,Modalstype,Modalstopval,Modalsbottomval,cardsModalcancel,cardsModalsave}= this.state;
return(
<div>
<Modals
modalsType={Modalstype}
modalsTopval={Modalstopval}
modalsBottomval={Modalsbottomval}
modalCancel={cardsModalcancel}
modalSave={cardsModalsave}
>
</Modals>
<style>
{
`
.ant-modal-body{
padding:20px 40px;
}
.onSearchtopics input{
height:40px;
}
.over221{
height:221px;
}
`
}
</style>
<Modal
keyboard={false}
title="发送至课堂"
visible={this.props.visible}
closable={false}
footer={null}
destroyOnClose={true}
width={600}
>
<div className="newupload_conbox">
<div className="mb15 font-14 edu-txt-center color-orange-tip">
温馨提示选择的题将会发送到指定课堂
</div>
<div className="mb5"
// onMouseLeave={this.closeList}
>
<Search
className="mb14 onSearchtopics"
placeholder="请输入课堂名称进行搜索"
onChange={this.onSearchChange}
onSearch={this.onSearch}
></Search>
</div>
<div className="edu-back-skyblue pl15 pr15 clearfix over221 pt5">
{
sendToCourseList && sendToCourseList.stages.map((item,key)=>{
return(
item.shixuns.map((items,keys)=>{
return(
<div className="mt5" key={keys}>
<Checkbox name={key} value={items.shixun_id} key={items.shixun_id}>{items.shixun_name}</Checkbox>
</div>
)
})
)
})
}
</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>
</div>
</div>
</Modal>
</div>
)
}
}
export default SnackbarHOC()(SendTopics);

@ -6,6 +6,7 @@ import axios from 'axios';
import {getImageUrl,WordsBtn} from 'educoder';
import moment from 'moment';
import Modals from '../../modals/Modals';
import SendTopics from '../../modals/SendTopics'
import NoneData from '../../courses/coursesPublic/NoneData';
import "./usersInfo.css";
@ -52,7 +53,7 @@ class InfosTopics extends Component{
data:response.data
})
}).catch((error) => {
});
}
@ -125,6 +126,78 @@ class InfosTopics extends Component{
})
}
deletecheckBoxValues=()=>{
this.setState({
Modalstype:true,
Modalstopval:"是否确认删除?",
ModalCancel:this.topicscancelmodel,
ModalSave:this.topicssavedelete,
})
}
topicssavedelete=()=>{
let {checkBoxValues}=this.state;
const url = `/homework_commons/${workId}/student_works/delete_work.json`;
axios.delete(url, { data: {
user_id: id
}})
.then((response) => {
})
.catch(function (error) {
console.log(error);
});
this.topicscancelmodel()
}
topicscancelmodel=()=>{
this.setState({
Modalstype:false,
Loadtype:false,
visible:false,
Modalstopval:"",
ModalCancel:"",
ModalSave:"",
checkBoxValues:[],
checkedtype:false
})
}
openTopics=()=>{
this.setState({
Modalstype:true,
Modalstopval:"公开后不能重设为私有",
ModalsBottomval:"是否确认设为公开?",
ModalCancel:this.topicscancelmodel,
ModalSave:this.topicssaveonOpen,
})
}
topicssaveonOpen=()=>{
let {checkBoxValues}=this.state;
const url = `/homework_commons/${workId}/student_works/delete_work.json`;
axios.delete(url, { data: {
user_id: id
}})
.then((response) => {
})
.catch(function (error) {
console.log(error);
});
this.topicscancelmodel()
}
sendTopics=()=>{
this.setState({
visible:true
})
}
render(){
let{
category,
@ -134,7 +207,9 @@ class InfosTopics extends Component{
page,
sort_direction,
sort_by,
checkBoxValues
checkBoxValues,
Modalstype,
visible
} = this.state;
let categorylist=[
@ -148,7 +223,7 @@ class InfosTopics extends Component{
let types=this.props.match.params.topicstype;
console.log(checkBoxValues)
console.log(Modalstype)
//types===publicly 公共
//types===personal 私有
@ -169,6 +244,23 @@ class InfosTopics extends Component{
return(
<div className="educontent mb50">
{/*提示*/}
{Modalstype&&Modalstype===true?<Modals
modalsType={this.state.Modalstype}
modalsTopval={this.state.Modalstopval}
modalCancel={this.state.ModalCancel}
modalSave={this.state.ModalSave}
modalsBottomval={this.state.ModalsBottomval}
loadtype={this.state.Loadtype}
/>:""}
{
visible&&visible===true?
<SendTopics
visible={visible}
topicscancelmodel={()=>this.topicscancelmodel()}
/>:""
}
<style>
{
@ -206,12 +298,7 @@ class InfosTopics extends Component{
`
}
</style>
<Modals
modalsType={this.state.Modalstype}
modalsTopval={this.state.Modalstopval}
modalCancel={this.state.ModalCancel}
modalSave={this.state.ModalSave}
/>
<Spin size="large" spinning={isSpin}>
<div className="clearfix topicsbox">
<div className={"topcschild"}>
@ -262,8 +349,8 @@ class InfosTopics extends Component{
</sapn>
</span>
</Dropdown>
<span className="fr mr30 topcsactive pointer">发送</span>
{types==="personal"?<span className="fr mr30 topcsactive pointer">删除</span>:""}
<span className="fr mr30 topcsactive pointer" onClick={()=>this.sendTopics()}>发送</span>
{types==="personal"?<span className="fr mr30 topcsactive pointer" onClick={()=>this.deletecheckBoxValues()}>删除</span>:""}
</p>
</div>
@ -284,7 +371,7 @@ class InfosTopics extends Component{
{item.is_public===false?<span className="edu-filter-btn ml15 fl typestyle mt3 topiscfilterbtn">公开</span>:""}
{types==="personal"&&item.is_public===false?<a className="btn colorblue mr25 fr font-16">设为公开</a>:""}
{types==="personal"&&item.is_public===false?<a className="btn colorblue mr25 fr font-16" onClick={()=>this.openTopics()}>设为公开</a>:""}
<div className="cl"></div>

Loading…
Cancel
Save