import React,{ Component } from "react"; import { Pagination} 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 } } getInfo=(page)=>{ 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 }) } }).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} = this.state; return(
{item.question.question_title}
{ item.question.question_type==3?
{(options.answer_percent * 100).toFixed(1)}%
{j+1}.{i}
) }) }