import React,{ Component } from "react"; import { Pagination , Spin } from "antd"; import NoneData from "../coursesPublic/NoneData" import '../css/members.css' import '../css/busyWork.css' import './pollStyle.css' import update from 'immutability-helper' import axios from 'axios' const map={1:"单选题",2:"多选题",3:"主观题",4:"主观题"} class PollDetailTabSecond extends Component{ constructor(props){ super(props); this.state={ page:1, limit:10, questions:undefined, questionsInfo:undefined, isSpin:false } } getInfo=(page)=>{ this.setState({ isSpin:true }) let pollId=this.props.match.params.pollId; let url=`/polls/${pollId}/commit_result.json?page=${page}`; axios.get(url).then((result)=>{ if(result){ this.setState({ page: page, questions:result.data.questions, questionsInfo:result.data.question_types, isSpin:false }) } }).catch((error)=>{ console.log(error); }) } componentDidMount=()=>{ let{page}=this.state; this.getInfo(page); } //翻页 changePage=(pageNumber)=>{ this.getInfo(pageNumber); } changeTxtStatus=(index,flag)=>{ console.log(index+" "+flag) this.setState( (prevState) => ({ questions:update(prevState.questions, {[index]:{question:{ txt_status: {$set: !flag} }}}) }) ) console.log(this.state.questions[index].question) } render(){ let {page, limit, questions, questionsInfo , isSpin} = this.state; return( { questions && questions.length>0 && questions.map((item,key)=>{ return(
{parseInt(page-1)*parseInt(limit)+(key+1)}、{map[item.question.question_type]} { item.question.is_necessary==1 ? 必答:"" } { item.question.question_type == 2 && item.question.min_choices && item.question.max_choices ? { item.question.min_choices == item.question.max_choices ? "可选"+item.question.max_choices+"项" : "可选"+item.question.min_choices+"-"+item.question.max_choices+"项" } :"" }

{item.question.question_title}

{ item.question.question_type==3?

    编号 文本答案
:
    选项 小计 百分比
}

{/* 主观题 */} { item.question.question_type == 3 && item.question.vote_text && { item.question.vote_text.map((txt,t)=>{ return(
    {t+1}
  • {txt}
) }) }
} {/* 单选和多选 */} { item.question.question_type != 3 && item.question.answers && item.question.answers.map((options,k)=>{ return(
{ options.answer_text=="其他" && (!item.question.txt_status || !item.question.txt_status ==true) && item.question.vote_text && item.question.vote_text.length>0 &&
{ item.question.vote_text.map((i,j)=>{ return(

{j+1}.{i}

) }) }
}
) }) }
    有效填写量 {item.question.commit_users_count}
) }) } { questions && questions.length == 0 &&
} { questionsInfo && questionsInfo.q_counts > limit &&
}
) } } export default PollDetailTabSecond;