Merge branch 'master' of https://bdgit.educoder.net/Hjqreturn/educoder
commit
f2605ef12d
@ -1,204 +1,204 @@
|
||||
import React,{ Component } from "react";
|
||||
import {Menu} from "antd";
|
||||
|
||||
|
||||
import CoursesListType from '../coursesPublic/CoursesListType';
|
||||
import { WordsBtn } from 'educoder'
|
||||
import PollTabFirst from './PollDetailTabFirst'
|
||||
import PollTabSecond from './PollDetailTabSecond'
|
||||
import PollTabThird from './PollDetailTabThird'
|
||||
import PollTabForth from './PollDetailTabForth'
|
||||
|
||||
import DownloadMessage from '../../modals/DownloadMessage';
|
||||
|
||||
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:"已截止"}
|
||||
class PollDetailIndex extends Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
tab:["0"],
|
||||
pollDetail:undefined,
|
||||
user_permission:undefined
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
}
|
||||
}).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){
|
||||
this.refs.DownloadMessage.confirmysl(url);
|
||||
}
|
||||
|
||||
render(){
|
||||
let {tab,pollDetail,user_permission}=this.state;
|
||||
|
||||
const isAdmin =this.props.isAdmin();
|
||||
const isStudent = this.props.isStudent();
|
||||
return(
|
||||
<div className="newMain">
|
||||
<DownloadMessage {...this.props} ref="DownloadMessage" />
|
||||
<div className="educontent mt10 mb50">
|
||||
<p className="clearfix mb20">
|
||||
<WordsBtn style="grey" className="fl" to={`/courses/${this.props.match.params.coursesId}/students`}>{this.props.coursedata.name}</WordsBtn>
|
||||
<span className="color-grey-9 fl ml3 mr3">></span>
|
||||
<WordsBtn style="grey" className="fl" to={`/courses/${this.props.match.params.coursesId}/polls/${user_permission && user_permission.left_banner_id}`}>问卷</WordsBtn>
|
||||
<span className="color-grey-9 fl ml3 mr3">></span>
|
||||
<span>问卷详情</span>
|
||||
</p>
|
||||
<p className="clearfix mb20 lineh-25">
|
||||
<span className="color-grey-3 font-24 fl task-hide break-word" style={{maxWidth:"900px",lineHeight:"25px"}} title={`${pollDetail && pollDetail.polls_name}`}>{pollDetail && pollDetail.polls_name}</span>
|
||||
<span className="mt3 fl" style={{height:"25px"}}>
|
||||
<CoursesListType typelist={[`${map[pollDetail && pollDetail.polls_status]}`]} typesylename={""} />
|
||||
</span>
|
||||
<WordsBtn className="fr font-16 mt2" style="grey" onClick={()=>this.props.history.goBack()}>返回</WordsBtn>
|
||||
</p>
|
||||
<div>
|
||||
<div className="clearfix edu-back-white pl30 pr30 bor-bottom-greyE">
|
||||
<div className="fl task_menu_ul">
|
||||
<Menu mode="horizontal" selectedKeys={tab} onClick={this.changeTab}>
|
||||
<Menu.Item key="0">答题列表</Menu.Item>
|
||||
{
|
||||
(isAdmin || (isStudent && pollDetail && pollDetail.show_result == 1 && pollDetail.polls_status == 3 && user_permission && user_permission.current_status==1)) && <Menu.Item key="1">统计结果</Menu.Item>
|
||||
}
|
||||
{ isAdmin && <Menu.Item key="2">问卷预览</Menu.Item> }
|
||||
<Menu.Item key="3">设置</Menu.Item>
|
||||
</Menu>
|
||||
</div>
|
||||
{
|
||||
isAdmin &&
|
||||
<span className="fr mt22">
|
||||
<WordsBtn style="blue" to={`/courses/${this.props.match.params.coursesId}/polls/${this.props.match.params.pollId}/edit`} className="fl mr20 font-16">编辑问卷</WordsBtn>
|
||||
{/* 立即发布 */}
|
||||
{
|
||||
user_permission && user_permission.poll_unpublish_count > 0 ?
|
||||
<li className="fl mr20">
|
||||
<ImmediatelyPublish
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
style="blue"
|
||||
className={"font-16"}
|
||||
checkBoxValues={[this.props.match.params.pollId]}
|
||||
action={this.getPollInfo}
|
||||
single={true}
|
||||
></ImmediatelyPublish>
|
||||
</li>
|
||||
:""
|
||||
}
|
||||
{/* 立即截止、撤销发布 */}
|
||||
{
|
||||
user_permission && user_permission.poll_publish_count > 0 ?
|
||||
<li className="fl mr20">
|
||||
<ImmediatelyEnd
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
style="blue"
|
||||
className={"font-16"}
|
||||
checkBoxValues={[this.props.match.params.pollId]}
|
||||
action={this.getPollInfo}
|
||||
single={true}
|
||||
></ImmediatelyEnd>
|
||||
</li>
|
||||
:""
|
||||
}
|
||||
{/* {
|
||||
user_permission && user_permission.poll_publish_count>0 ?
|
||||
<li className="fl mr20">
|
||||
<CancelPublish
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
style="blue"
|
||||
checkBoxValues={[this.props.match.params.pollId]}
|
||||
action={this.getPollInfo}
|
||||
></CancelPublish>
|
||||
</li>
|
||||
:""
|
||||
} */}
|
||||
<a className="fl color-blue font-16" onClick={()=>this.confirmysl("/polls/"+this.props.match.params.pollId+"/commit_result.xlsx")} href="javascript:void(0);">导出统计</a>
|
||||
</span>
|
||||
}
|
||||
{
|
||||
isStudent &&
|
||||
<span className="fr mt22 font-16">
|
||||
{
|
||||
user_permission && user_permission.current_status!=3 ?
|
||||
<WordsBtn style="blue" to={`/courses/${this.props.match.params.coursesId}/polls/${this.props.match.params.pollId}/users/${this.props.current_user.login}`}>
|
||||
{ user_permission && user_permission.current_status ==0 ? "继续答题" : user_permission.current_status == 1 ? "查看答题" : "开始答题" }
|
||||
</WordsBtn>
|
||||
:""
|
||||
}
|
||||
</span>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
{
|
||||
// 答题列表
|
||||
parseInt(tab[0])==0 && <PollTabFirst {...this.props} {...this.state}></PollTabFirst>
|
||||
}
|
||||
{
|
||||
// 统计结果
|
||||
parseInt(tab[0])==1 && <PollTabSecond {...this.props} {...this.state}></PollTabSecond>
|
||||
}
|
||||
|
||||
{
|
||||
//问卷预览
|
||||
parseInt(tab[0])==2 && <PollTabThird {...this.props} {...this.state}></PollTabThird>
|
||||
}
|
||||
{
|
||||
//设置
|
||||
parseInt(tab[0])==3 && <PollTabForth {...this.props} {...this.state} user_permission={user_permission} getPollInfo={this.getPollInfo}></PollTabForth>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
import React,{ Component } from "react";
|
||||
import {Menu} from "antd";
|
||||
|
||||
|
||||
import CoursesListType from '../coursesPublic/CoursesListType';
|
||||
import { WordsBtn } from 'educoder'
|
||||
import PollTabFirst from './PollDetailTabFirst'
|
||||
import PollTabSecond from './PollDetailTabSecond'
|
||||
import PollTabThird from './PollDetailTabThird'
|
||||
import PollTabForth from './PollDetailTabForth'
|
||||
|
||||
import DownloadMessage from '../../modals/DownloadMessage';
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
}
|
||||
}).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){
|
||||
this.refs.DownloadMessage.confirmysl(url);
|
||||
}
|
||||
|
||||
render(){
|
||||
let {tab,pollDetail,user_permission}=this.state;
|
||||
|
||||
const isAdmin =this.props.isAdmin();
|
||||
const isStudent = this.props.isStudent();
|
||||
return(
|
||||
<div className="newMain">
|
||||
<DownloadMessage {...this.props} ref="DownloadMessage" />
|
||||
<div className="educontent mt10 mb50">
|
||||
<p className="clearfix mb20">
|
||||
<WordsBtn style="grey" className="fl" to={`/courses/${this.props.match.params.coursesId}/students`}>{this.props.coursedata.name}</WordsBtn>
|
||||
<span className="color-grey-9 fl ml3 mr3">></span>
|
||||
<WordsBtn style="grey" className="fl" to={`/courses/${this.props.match.params.coursesId}/polls/${user_permission && user_permission.left_banner_id}`}>问卷</WordsBtn>
|
||||
<span className="color-grey-9 fl ml3 mr3">></span>
|
||||
<span>问卷详情</span>
|
||||
</p>
|
||||
<p className="clearfix mb20 lineh-25">
|
||||
<span className="color-grey-3 font-24 fl task-hide break-word" style={{maxWidth:"900px",lineHeight:"25px"}} title={`${pollDetail && pollDetail.polls_name}`}>{pollDetail && pollDetail.polls_name}</span>
|
||||
<span className="mt3 fl" style={{height:"25px"}}>
|
||||
<CoursesListType typelist={[`${map[pollDetail && pollDetail.polls_status]}`]} typesylename={""} />
|
||||
</span>
|
||||
<WordsBtn className="fr font-16 mt2" style="grey" onClick={()=>this.props.history.goBack()}>返回</WordsBtn>
|
||||
</p>
|
||||
<div>
|
||||
<div className="clearfix edu-back-white pl30 pr30 bor-bottom-greyE">
|
||||
<div className="fl task_menu_ul">
|
||||
<Menu mode="horizontal" selectedKeys={tab} onClick={this.changeTab}>
|
||||
<Menu.Item key="0">答题列表</Menu.Item>
|
||||
{
|
||||
(isAdmin || (isStudent && pollDetail && pollDetail.show_result == 1 && pollDetail.polls_status == 3 && user_permission && user_permission.current_status==1)) && <Menu.Item key="1">统计结果</Menu.Item>
|
||||
}
|
||||
{ isAdmin && <Menu.Item key="2">问卷预览</Menu.Item> }
|
||||
<Menu.Item key="3">设置</Menu.Item>
|
||||
</Menu>
|
||||
</div>
|
||||
{
|
||||
isAdmin &&
|
||||
<span className="fr mt22">
|
||||
<WordsBtn style="blue" to={`/courses/${this.props.match.params.coursesId}/polls/${this.props.match.params.pollId}/edit`} className="fl mr20 font-16">编辑问卷</WordsBtn>
|
||||
{/* 立即发布 */}
|
||||
{
|
||||
user_permission && user_permission.poll_unpublish_count > 0 ?
|
||||
<li className="fl mr20">
|
||||
<ImmediatelyPublish
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
style="blue"
|
||||
className={"font-16"}
|
||||
checkBoxValues={[this.props.match.params.pollId]}
|
||||
action={this.getPollInfo}
|
||||
single={true}
|
||||
></ImmediatelyPublish>
|
||||
</li>
|
||||
:""
|
||||
}
|
||||
{/* 立即截止、撤销发布 */}
|
||||
{
|
||||
user_permission && user_permission.poll_publish_count > 0 ?
|
||||
<li className="fl mr20">
|
||||
<ImmediatelyEnd
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
style="blue"
|
||||
className={"font-16"}
|
||||
checkBoxValues={[this.props.match.params.pollId]}
|
||||
action={this.getPollInfo}
|
||||
single={true}
|
||||
></ImmediatelyEnd>
|
||||
</li>
|
||||
:""
|
||||
}
|
||||
{/* {
|
||||
user_permission && user_permission.poll_publish_count>0 ?
|
||||
<li className="fl mr20">
|
||||
<CancelPublish
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
style="blue"
|
||||
checkBoxValues={[this.props.match.params.pollId]}
|
||||
action={this.getPollInfo}
|
||||
></CancelPublish>
|
||||
</li>
|
||||
:""
|
||||
} */}
|
||||
<a className="fl color-blue font-16" onClick={()=>this.confirmysl("/polls/"+this.props.match.params.pollId+"/commit_result.xlsx")} href="javascript:void(0);">导出统计</a>
|
||||
</span>
|
||||
}
|
||||
{
|
||||
isStudent &&
|
||||
<span className="fr mt22 font-16">
|
||||
{
|
||||
user_permission && user_permission.current_status!=3 ?
|
||||
<WordsBtn style="blue" to={`/courses/${this.props.match.params.coursesId}/polls/${this.props.match.params.pollId}/users/${this.props.current_user.login}`}>
|
||||
{ user_permission && user_permission.current_status ==0 ? "继续答题" : user_permission.current_status == 1 ? "查看答题" : "开始答题" }
|
||||
</WordsBtn>
|
||||
:""
|
||||
}
|
||||
</span>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
{
|
||||
// 答题列表
|
||||
parseInt(tab[0])==0 && <PollTabFirst {...this.props} {...this.state}></PollTabFirst>
|
||||
}
|
||||
{
|
||||
// 统计结果
|
||||
parseInt(tab[0])==1 && <PollTabSecond {...this.props} {...this.state}></PollTabSecond>
|
||||
}
|
||||
|
||||
{
|
||||
//问卷预览
|
||||
parseInt(tab[0])==2 && <PollTabThird {...this.props} {...this.state}></PollTabThird>
|
||||
}
|
||||
{
|
||||
//设置
|
||||
parseInt(tab[0])==3 && <PollTabForth {...this.props} {...this.state} user_permission={user_permission} getPollInfo={this.getPollInfo}></PollTabForth>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default PollDetailIndex
|
Loading…
Reference in new issue