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 = (
); 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(