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 AccountProfile from"../../user/AccountProfile"; 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 } } 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 } } }) console.log(courseslist) } 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=()=>{ this.setState({ Modalstype:true, Modalstopval:"发布申请已提交,请等待管理员的审核", Modalsbottomval:"• 我们将在1-2个工作日内完成审核", loadtype:true }) } cancelissuePath=()=>{ let pathId=this.props.match.params.pathId; let url ="/paths/"+pathId+"/cancel_publish.json"; axios.get(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ }else if(result.data.status===1){ window.location.href = "/paths/" + result.data.subject_id } } }).catch((error)=>{ console.log(error); }) } reovkissuePath=()=>{ this.setState({ Modalstype:true, Modalstopval:"是否确认撤销发布", Modalsbottomval:"确认后,回退到编辑状态", cardsModalsavetype:true, }) } reovkissuePaths=()=>{ let pathId=this.props.match.params.pathId; let url ="/paths/"+pathId+"/cancel_has_publish.json"; axios.get(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ }else if(result.data.status===1){ this.setState({ cardsModalsavetype:false, loadtype:false, deletepathtype:false }) window.location.href = "/paths/" + result.data.subject_id } } }).catch((error)=>{ console.log(error); }) } cardsModalcancel=()=>{ this.setState({ Modalstype:false, Modalsbottomval:'', loadtype:false, deletepathtype:false, putappointmenttype:false }) } 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.current_user&&this.props.current_user.profile_completed===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.current_user&&this.props.current_user.profile_completed===false){ this.setState({ AccountProfiletype:true }) 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.props.showNotification(response.data.message) } } }).catch((error) => { console.log(error) this.cardsModalcancel() }) } hideAccountProfile=()=>{ this.setState({ AccountProfiletype:false }) } render(){ let{detailInfoList}=this.props; let{Modalstype,Modalstopval,cardsModalcancel,putappointmenttype,Modalsbottomval,cardsModalsavetype,loadtype,getappointmenttype,AccountProfiletype}=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(