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 './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:[] } } componentDidMount(){ let courseslist=[] this.props.courses.map((item,key)=>{ if(1===key+1){ return( courseslist.push(item) ) } }) this.setState({ courseslist:courseslist }) console.log(courseslist) } 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 }) } 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) ) } }) console.log(courseslist) this.setState({ MenuItemskey:keys, courseslist:courseslist }) } render(){ let{detailInfoList}=this.props; let{Modalstype,Modalstopval,cardsModalcancel,cardsModalsave,Modalsbottomval,cardsModalsavetype,loadtype}=this.state; const radioStyle = { display: 'block', height: '30px', lineHeight: '30px', }; //
let menu = ( {this.props.courses&&this.props.courses.map((item,key)=>{ return( this.MenuItems(key+1)}> 第{key+1}次开课 ) })} ); return(
{/*
*/} { detailInfoList &&
{detailInfoList.name} {this.props.courses===undefined?"": 开放课程 } {detailInfoList===undefined?"":detailInfoList.allow_statistics===true? :"" } {detailInfoList===undefined?"":detailInfoList.allow_statistics===true?this.props.courses===undefined? 学习统计 :"":"" } { detailInfoList.allow_send === true?this.props.courses===undefined? :"":"" }
{ 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}
  • : ""}
} {this.props.courses===undefined?
{detailInfoList===undefined?"":detailInfoList.allow_delete===true?删除路径:""} { detailInfoList.publish_status===0&&detailInfoList.allow_add_member===true? 申请发布:"" } { detailInfoList.publish_status===1 && detailInfoList.allow_statistics===true? 撤销申请:"" } { detailInfoList.publish_status===2 && detailInfoList.allow_statistics===true? 撤销发布:"" }
:""} {this.props.courses===undefined?"":detailInfoList.is_creator===true?
开课 学习统计
:""}
{/*{this.props.courses===undefined||this.props.courses.length===0?"":
*/} {this.props.courses===undefined?"":
  • {this.state.MenuItemskey}次开课
  • {this.state.courseslist.map((item,key)=>{ // course_id: 1309 // course_identity: 5 // course_status: {status: 1, time: "进行至第5周,共1642周"} // first_category_url: "/courses/1309/informs" return(
    开课时间:
    {item.start_date}
    结课时间:
    {item.end_date}
    报名人数:
    {item.student_count}人
    ) }) }
  • {this.state.courseslist.map((item,key)=>{ return(
    {item.course_status.status===0?即将开课:""} {item.course_status.status===1?{item.course_status.time}:""} {item.course_status.status===2? detailInfoList.is_creator===true?已结束:item.course_identity<6? 已结束:"":""} {item.course_status.status===0? detailInfoList.is_creator===true? 进入课堂 :item.course_identity<6?
    报名成功
    :立即报名:""} {item.course_status.status===1? detailInfoList.is_creator===true? 进入课堂 :item.course_identity<6? 立即学习 :立即加入:""} {item.course_status.status===2? detailInfoList.is_creator===true? 进入课堂 :item.course_identity<6? 进入课堂 :
    已结束
    :""}
    )})}
  • }
    }
    ) } } export default DetailTop;