import React,{ Component } from "react"; import { Modal,Radio,Input,Tooltip, Menu, Dropdown, Icon,Breadcrumb } from "antd"; import { BrowserRouter as Router, Route, Link } from "react-router-dom"; import SendPanel from "./sendPanel.js"; import { getImageUrl } from 'educoder'; import axios from 'axios'; import Modals from '../../modals/Modals'; import OpenCourse from './OpenCourse'; import Jointheclass from '../../modals/Jointheclass'; import './DetailTop.css'; const Search = Input.Search; const RadioGroup = Radio.Group; class DetailTop extends Component{ constructor(props){ super(props) this.state={ cardsModalcancel:this.cardsModalcancel, cardsModalsave:this.cardsModalsave, Modalstype:false, Modalstopval:"", Modalsbottomval:'', loadtype:false, deletepathtype:false, cardsModalsavetype:false, MenuItemskey:1, courseslist:[], Pathcourseid:undefined, OpenCourseTypes:false, putappointmenttype:false, getappointmenttype:false, openpathss:false, cancel_publics:false, cancel_has_publics:false } } componentDidMount(){ this.getdatalist(); } getdatalist=()=>{ let courseslist=[]; let keys=1; let listtype=false; if(this.props.courses!=undefined&&this.props.courses.length!=0){ if(this.props.detailInfoList.has_start===true){ this.props.courses.map((item,key)=>{ if(item.course_status.status===1){ keys=key+1 return( courseslist.push(item) ) } }) }else{ let type=undefined; this.props.courses.map((item,key)=>{ let arr=[] keys=key+1 if(item.course_status.status===2) { type=key+1 arr.push(item) } courseslist=arr; }) this.props.courses.map((item,key)=>{ let arr=[] if(listtype===false){ keys=key+1 if(item.course_status.status===0) { listtype=true // courseslist.push(item) arr.push(item) courseslist=arr } } }) } if(courseslist.length!=0){ this.props.getMenuItemsindex(keys,courseslist[0].course_status.status) } } this.setState({ courseslist:courseslist, MenuItemskey:keys, }) } componentDidUpdate=(prevProps)=> { if(prevProps.courses!=this.props.courses){ this.getdatalist(); } } allow_deletepath=()=>{ this.setState({ Modalstype:true, Modalstopval:"是否删除路径?", deletepathtype:true }) } applyissuePath=()=>{ let pathid=this.props.match.params.pathId; let url ="/paths/"+pathid+"/publish.json"; axios.post(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ this.setState({ loadtype:true, Modalstype: true, Modalstopval: ` 课程需经过平台审核方可公开使用,公开的课程将对平台所`, modalsMidval:"有人公开可见。若仅本人教学使用则无需申请公开, 直接发", Modalsbottomval:"送到课堂即可.", cardsModalsavetype: true, }) this.props.showNotification(result.data.message) this.props.getlistdatas(); }else if(result.data.status===1){ // window.location.reload(); } } }).catch((error)=>{ console.log(error); }) } postcancelissuePath=()=>{ let pathId=this.props.match.params.pathId; let url ="/paths/"+pathId+"/cancel_publish.json"; axios.post(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ }else if(result.data.status===1){ this.cardsModalcancel() this.props.showNotification("撤销发布成功") this.props.getlistdatas() // window.location.href = "/paths/" + result.data.subject_id } } }).catch((error)=>{ console.log(error); }) } cancelissuePath=()=>{ this.setState({ Modalstype: true, Modalstopval: "是否确认撤销发布?", // modalsMidval:"撤销发布后,学员将无法进行练习,若您新增关", // Modalsbottomval:"卡,学员需要重新体验实训", cardsModalsavetype: true, modalstyles:"848282" }) } cardsModalcancel=()=>{ this.setState({ Modalstype:false, Modalsbottomval:'', loadtype:false, deletepathtype:false, putappointmenttype:false, modalsMidval:'', modalstyles:'', cardsModalsavetype:false, applyissuePath:false, openpathss:false, cancel_publics:false, cancel_has_publics:false, Modalstopval:``, }) } cardsModalsave=()=>{ let {loadtype,deletepathtype}=this.state; //删除路径 if(deletepathtype===true){ let pathid=this.props.match.params.pathId; const deleteUrl = `/paths/`+pathid+`.json`; axios.delete(deleteUrl).then((response) => { const status = response.data.status if (status === 1) { window.location.href = "/paths"; } }).catch((error) => { console.log(error) }) } // //申请发布 // if(loadtype===true){ // // let pathid=this.props.match.params.pathId; // let url ="/paths/"+pathid+"/publish.json"; // axios.get(url).then((result)=>{ // if(result.status===200){ // if(result.data.status===0){ // this.setState({ // Modalstype:true, // Modalstopval: result.data.message, // }) // }else if(result.data.status===1){ // window.location.reload(); // } // } // }).catch((error)=>{ // console.log(error); // }) // // } this.setState({ Modalstype:false, Modalsbottomval:'' }) } onVisibleChanges=(type)=>{ this.setState({ onVisibleChangestype:type }) } MenuItems=(keys)=>{ let courseslist=[] this.props.courses.map((item,key)=>{ if(keys===key+1){ return( courseslist.push(item) ) } }) this.props.getMenuItemsindex(keys,courseslist[0].course_status.status) this.setState({ MenuItemskey:keys, courseslist:courseslist, onVisibleChangestype:!this.state.onVisibleChangestype }) } JoinnowCourse=(id,typeid)=>{ if(this.props.checkIfLogin()===false){ this.props.showLoginDialog() return } if(this.props.checkIfProfileCompleted()===false){ this.props.showProfileCompleteDialog() return } this.setState({ yslJointhe:true, Pathcourseid:id, pathcousestypeid:typeid }) } putappointment=()=>{ if(this.props.checkIfLogin()===false){ this.props.showLoginDialog() return } if(this.props.checkIfProfileCompleted()===false){ this.props.showProfileCompleteDialog() return } this.setState({ Modalstype:true, Modalstopval:"是否确认立即预约?", Modalsbottomval:"", cardsModalcancel:()=>this.cardsModalcancel(), putappointmenttype:true, loadtype:false }) } ysljoinmodalCancel=()=>{ this.setState({ yslJointhe:false }) }; ysljoinmodalCanceltwo=(key)=>{ this.setState({ yslJointhe:false }) this.props.getdatasindex(key) }; OpenCoursefun=()=>{ this.setState({ OpenCourseTypes:true }) } OpenCourseCancel=()=>{ this.setState({ OpenCourseTypes:false }) } getappointment=()=>{ let pathid=this.props.match.params.pathId; let url=`/paths/${pathid}/appointment.json` axios.post(url).then((response) => { if (response.status === 200) { if(response.data.status===0){ this.setState({ getappointmenttype:true }) this.cardsModalcancel() // this.props.getlistdatas() this.props.showNotification(response.data.message) }else{ this.cardsModalcancel() this.props.showNotification(response.data.message) } } }).catch((error) => { console.log(error) this.cardsModalcancel() }) } postopenpaths=()=>{ let pathid=this.props.match.params.pathId; let url ="/paths/"+pathid+"/apply_public.json"; axios.post(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ this.props.showNotification(result.data.message) this.props.getlistdatas(); this.cardsModalcancel() }else if(result.data.status===1){ this.props.showNotification(result.data.message) this.props.getlistdatas(); this.cardsModalcancel() } } }).catch((error)=>{ console.log(error); }) } openpaths=()=>{ this.setState({ loadtype:true, Modalstype: true, openpathss:true, Modalstopval: "公开申请已提交,请等待管理员的审核", modalsMidval:"• 我们将在1-2个工作日内完成审核", Loadtype:true, modalstyles:"848282" }) } postcancel_public=()=>{ let pathid=this.props.match.params.pathId; let url ="/paths/"+pathid+"/cancel_public.json"; axios.post(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ this.cardsModalcancel() this.props.showNotification("撤销申请公开成功") this.props.getlistdatas(); } } }).catch((error)=>{ console.log(error); }) } cancel_public=()=>{ this.setState({ cancel_publics:true, Modalstype: true, Modalstopval: "是否确认撤销申请公开?", modalsMidval:" ", ModalsBottomval:" ", }) } postcancel_has_public=()=>{ let pathid=this.props.match.params.pathId; let url ="/paths/"+pathid+"/cancel_has_public.json"; axios.post(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ this.cardsModalcancel() this.props.showNotification("撤消公开成功") this.props.getlistdatas(); } } }).catch((error)=>{ console.log(error); }) } cancel_has_public=()=>{ this.setState({ cancel_has_publics:true, Modalstype: true, Modalstopval: "是否确认撤销公开?", modalsMidval:" ", ModalsBottomval:" ", }) } render(){ let{detailInfoList}=this.props; let{Modalstype,Modalstopval,cardsModalcancel,putappointmenttype,Modalsbottomval,cardsModalsavetype,loadtype,getappointmenttype,openpathss,cancel_publics,cancel_has_publics}=this.state; const radioStyle = { display: 'block', height: '30px', lineHeight: '30px', }; let menu = ( {this.props.courses===undefined||this.props.courses.length===0?"":this.props.courses.map((item,key)=>{ return( this.MenuItems(key+1)}> 第{key+1}次开课 ) })} ); let applypath=this.props.detailInfoList&&this.props.detailInfoList.participant_count!=undefined&&this.props.detailInfoList&&this.props.detailInfoList.allow_statistics===false; let coursestypes=this.props.courses!=undefined&&this.props.courses.length===0; let isadminallow_statistics=this.props.courses&&this.props.courses.length===0&&this.props.detailInfoList&&this.props.detailInfoList.allow_statistics===true; return(
40?"subhead mb100":"subhead mb70":this.state.MenuItemskey===this.props.courses.length?"subhead mb120":detailInfoList.name.length>40?"subhead mb100":"subhead mb80"}> this.cardsModalcancel():cardsModalsavetype===true?()=>this.postcancelissuePath():openpathss===true?()=>this.postopenpaths():cancel_publics===true?()=>this.postcancel_public():cancel_has_publics===true?()=>this.postcancel_has_public():putappointmenttype===true?()=>this.getappointment():()=>this.cardsModalsave()} loadtype={loadtype} modalsMidval={this.state.modalsMidval} modalstyles={this.state.modalstyles} > {this.state.yslJointhe===true?this.ysljoinmodalCancel()} ysljoinmodalCanceltwo={()=>this.ysljoinmodalCanceltwo(this.state.MenuItemskey)}>:""} {this.state.OpenCourseTypes===true?this.OpenCourseCancel()}/>:""} { detailInfoList &&
{/*27?detailInfoList.name:""}>*/} {/**/} {detailInfoList.name} {detailInfoList===undefined?"":detailInfoList.excellent === false ? "" :
开放课程
}
{ detailInfoList &&
    { detailInfoList.stages_count!=0 ?
  • 章节{detailInfoList.stages_count}
  • : ""} { detailInfoList.shixuns_count!=0 ?
  • 实训{ detailInfoList.shixuns_count}
  • : ""} { detailInfoList.challenge_choose_count!=0 ?
  • 选择题任务{detailInfoList.challenge_choose_count}
  • : ""} { detailInfoList.challenges_count!=0 ?
  • 实践任务{detailInfoList.challenges_count}
  • : ""} { detailInfoList.subject_score!=0 ?
  • 经验值{detailInfoList.subject_score}
  • : ""} { detailInfoList.member_count!=0 ?
  • 学习人数{detailInfoList.member_count}
  • : ""}
}
{detailInfoList===undefined?"":detailInfoList.allow_statistics===true? 学习统计 :"" } { detailInfoList.allow_send === true? :"" } {this.props.courses===undefined?"":detailInfoList.is_creator===true?this.OpenCoursefun()}>开课:""} { detailInfoList.allow_statistics===true&& detailInfoList.public_status===2? 撤销公开:"" } {detailInfoList.allow_statistics===true&& detailInfoList.public_status===1? 撤销申请公开:"" } { detailInfoList.publish_status===2&& detailInfoList.allow_statistics===true&& detailInfoList.public_status===0? 申请公开:"" } { detailInfoList.publish_status===2 && detailInfoList.allow_statistics===true&&detailInfoList.public_status===0? 撤销发布:"" } { detailInfoList.publish_status===0&&detailInfoList.allow_add_member===true? 发布:"" } {detailInfoList===undefined?"":detailInfoList.allow_delete===true?删除:""} {detailInfoList===undefined?"":detailInfoList.allow_statistics===true? 编辑 :"" }
{this.props.courses===undefined||isadminallow_statistics===true?"":
{this.props.courses===undefined||this.props.courses.length===0?"":
  • {this.state.courseslist.map((item,key)=>{ if(item.course_identity<4){ return( )}}) } {this.state.MenuItemskey} 次开课
  • } {this.props.courses===undefined||this.props.courses.length===0?"":
  • {this.state.courseslist.map((item,key)=>{ return(
    开课时间:
    {item.start_date}
    结课时间:
    {item.end_date}
    报名人数:
    {item.student_count} 人
    ) }) }
  • } {this.props.courses===undefined||this.props.courses.length===0?"":
  • {/* height: 158px; }*/} {this.state.courseslist.map((item,key)=>{ return(
    {applypath===false?"":this.state.MenuItemskey===this.props.courses.length||coursestypes===true? this.props.detailInfoList&&this.props.detailInfoList.has_participate===false? getappointmenttype===true?预约报名成功:this.putappointment()}>期待开课并预约报名: 预约报名成功:""} {/*{item.course_status.status===0?
    即将开课
    :""}*/} {item.course_status.status===1?
    {item.course_status.time}
    :""} {item.course_status.status===2&&item.course_identity<6?
    已结束
    :""} {/*
    已结束
    */} {item.course_status.status===0? item.course_identity<5? 进入课堂 :item.course_identity<6?
    报名成功
    :this.JoinnowCourse(item.course_id)}>立即报名:""} {item.course_status.status===1? item.course_identity<5? 进入课堂 :item.course_identity<6? 立即学习 :this.JoinnowCourse(item.course_id,item.course_status.status)}>立即加入:""} {item.course_status.status===2? item.course_identity<6? 进入课堂 :
    已结束
    :""}
    )})}
  • } {applypath===false?"":this.state.MenuItemskey===this.props.courses.length?
    :""} {applypath===false?"":this.props.courses.length===0?"":this.state.MenuItemskey===this.props.courses.length||coursestypes===true? 当前预约报名人数:{getappointmenttype===true?this.props.detailInfoList&&this.props.detailInfoList.participant_count+1:this.props.detailInfoList&&this.props.detailInfoList.participant_count} 当预约报名人数达到 {this.props.detailInfoList&&this.props.detailInfoList.student_count} 人时即将开课 {/*{this.props.detailInfoList&&this.props.detailInfoList.has_participate===false?*/} {/*getappointmenttype===true?预约报名成功:this.putappointment()}>期待开课并预约报名:*/} {/*预约报名成功}*/} :""} {applypath===true&&this.props.courses.length===0?this.state.MenuItemskey===this.props.courses.length||coursestypes===true? 当前预约报名人数:{getappointmenttype===true?this.props.detailInfoList&&this.props.detailInfoList.participant_count+1:this.props.detailInfoList&&this.props.detailInfoList.participant_count} 当预约报名人数达到 {this.props.detailInfoList&&this.props.detailInfoList.student_count} 人时即将开课 {this.props.detailInfoList&&this.props.detailInfoList.has_participate===false? getappointmenttype===true?预约报名成功:this.putappointment()}>期待开课并预约报名: 预约报名成功} :"":""}
    }
    }
    ) } } export default DetailTop;