import React,{ Component } from "react"; import {Menu} from "antd"; import CoursesListType from '../coursesPublic/CoursesListType'; import { WordsBtn,getRandomcode } from 'educoder' import PollTabFirst from './PollDetailTabFirst' import PollTabSecond from './PollDetailTabSecond' import PollTabThird from './PollDetailTabThird' import PollTabForth from './PollDetailTabForth' import DownloadMessageysl from "../../modals/DownloadMessageysl"; import ImmediatelyPublish from './pollPublicBtn/ImmediatelyPublish' import ImmediatelyEnd from './pollPublicBtn/ImmediatelyEnd' import CancelPublish from './pollPublicBtn/CancelPublish' import '../css/members.css' import '../css/busyWork.css' import axios from 'axios' const map={1:"未发布",2:"提交中",3:"已截止",4:"已结束"} class PollDetailIndex extends Component{ constructor(props){ super(props); this.state={ tab:["0"], pollDetail:undefined, user_permission:undefined, DownloadType:false, DownloadMessageval:undefined, polls_status:3, } } getPollInfo=()=>{ // console.log(this.props); let pollId=this.props.match.params.pollId; let url=`/polls/${pollId}/common_header.json` axios.get(url).then((result)=>{ if(result.status==200){ this.setState({ pollDetail:result.data, user_permission:result.data.user_permission, polls_status:result.data.polls_status, }) } }).catch((error)=>{ console.log(error); }) let{tab}=this.state; try { if(tab[0]==="0"){ this.child.Teacherliststudentlist(); } if(tab[0]==="1"){ this.child.Teacherliststudentlist(); } if(tab[0]==="2"){ this.child.Teacherliststudentlist(); } if(tab[0]==="3"){ this.child.getSettingInfo(); } }catch (e) { } } newgetPollInfo=()=>{ // console.log(this.props); let pollId=this.props.match.params.pollId; let url=`/polls/${pollId}/common_header.json` axios.get(url).then((result)=>{ if(result.status==200){ this.setState({ pollDetail:result.data, user_permission:result.data.user_permission, polls_status:result.data.polls_status, }) } }).catch((error)=>{ console.log(error); }) } componentDidMount(){ const query =this.props.location.search; if(query.indexOf("?")!=-1){ const type = query.split('?'); let name = type[1].split("tab="); name = String(name).split(","); name = decodeURI(name[1]); if(name!=undefined && name!="" && name!="undefined"){ this.setState({ tab:[name] }) } } this.getPollInfo(); } //切换tab changeTab=(e)=>{ this.setState({ tab:e.key }) } /// 确认是否下载 confirmysl(url){ axios.get(url + '&export=true' ).then((response) => { if(response.data.status&&response.data.status===-1){ }else if(response.data.status&&response.data.status===-2){ if(response.data.message === "100"){ // 已超出文件导出的上限数量(100 ),建议: this.setState({ DownloadType:true, DownloadMessageval:100 }) }else { //因附件资料超过500M this.setState({ DownloadType:true, DownloadMessageval:500 }) } }else { this.props.slowDownload(getRandomcode(url)) // this.props.showNotification(`正在下载中`); // window.open("/api"+url, '_blank'); } }).catch((error) => { console.log(error) }); } Downloadcal=()=>{ this.setState({ DownloadType:false, DownloadMessageval:undefined }) } bindRef = ref => { this.child = ref }; render(){ let {tab,pollDetail,user_permission,polls_status}=this.state; const { current_user } = this.props; const isAdmin =this.props.isAdmin(); const isStudent = this.props.isStudent(); document.title=this.props.coursedata&&this.props.coursedata.name; return(
{pollDetail && pollDetail.polls_name}