import React, { Component } from 'react'; import './index.less'; import { Checkbox } from 'antd'; import Page from '@src/containers/Page'; import Modal from '../../../components/Modal'; import HardInput from '../../../components/HardInput'; import AnswerCheckbox from '../../../components/AnswerCheckbox'; import { formatDate, getMap, formatPercent, formatSeconds } from '../../../../../src/services/Tools'; import { My } from '../../../stores/my'; import { User } from '../../../stores/user'; import { SentenceOption } from '../../../../Constant'; const ExportType = [ { label: '收藏', value: 'question_collect' }, { label: '错题', value: 'question_error' }, { label: '笔记', value: 'note_question' }, { label: '笔记', value: 'note_course' }, ]; const ExportTypeMap = getMap(ExportType, 'value', 'label'); const AnswerIndex = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K']; const width = 595; const height = 1050; const top = 72; const left = 93; const size = 10; export default class extends Page { initState() { const { info } = this.props.user; return { showTip: !info.exportTips, nextTips: true, }; } initData() { const { id } = this.params; My.exportDetail(id) .then(result => { this.setState({ data: result }); setTimeout(() => { const { waters } = result; const waterList = []; const pageSize = Math.ceil(this.view.offsetHeight / height); console.log(pageSize, this.view.offsetHeight); for (let i = 0; i < pageSize; i += 1) { const a = [top, (height / 2 - top) / 2 - size / 2 + top, height / 2 - size / 2, (height / 2 + (height - top - height / 2) / 2) - size / 2, height - top - size]; for (let j = 0; j < 5; j += 1) { waterList.push({ style: { left, top: a[j] + height * i, textAlign: 'left' }, text: waters[0], }); waterList.push({ style: { left: width / 2, top: a[j] + height * i, textAlign: 'center' }, text: waters[1], }); waterList.push({ style: { left: width - left, top: a[j] + height * i, textAlign: 'right' }, text: waters[0], }); } } this.setState({ waterList }); }, 1000); }); } closeTips() { this.setState({ showTip: false }); const { nextTips } = this.state; if (!nextTips) return; My.exportTips() .then(() => { const { info } = this.props.user; info.exportTips = 1; User.infoHandle(info); }); } renderView() { const { data = {}, showTip, nextTips, waterList = [] } = this.state; return (
{ if (ref) this.view = ref; }}> {waterList.map(row => { return
{row.text}
; })} {this.renderHead()} {data.type !== 'note_course' && this.renderQuestion()} {data.type === 'note_course' && this.renderNote()} this.closeTips()} confirmText="好的,知道了" btnAlign="center" >
鼠标右键点击打印后,可直接保存为PDF或打印。
this.setState({ nextTips: !nextTips })} />下次进入时不再提醒。
); } renderHead() { const { data = {} } = this.state; const { content = {} } = data; const { info } = this.props.user; return (
千行GMAT
{info.nickname} ID {info.id}
* 请勿外传或商用!
第{data.no || 0}次导出{ExportTypeMap[data.type]}
本次导出 {(content.list || []).length} 道
{formatDate(data.createTime, 'YYYY-MM-DD HH:mm:ss')}
); } renderQuestion() { const { data } = this.state; const { content = {} } = data; const { list = [] } = content; return (
{list.map(item => { return [this.renderTotal(item), item.question.questionType === 'sentence' ? : ]; })}
); } renderTotal(item) { const { questionNo = {}, userTime, userPaper } = item; return (
{questionNo.title} {userPaper && {userPaper.title}} ID:{questionNo.title}
{userTime && 用时: $1$2', ), }} /> } 全站: $1$2', ), }} /> {formatPercent(item.questionNo.totalCorrect, item.questionNo.totalNumber)}%
); } renderNote() { const { data } = this.state; const { content = {} } = data; const { list = [] } = content; return (
{list.map(item => { return ; })}
); } } class BaseDetail extends Component { render() { return (
{this.renderQuestion()} {this.renderOfficial()} {this.renderQx()} {this.renderConnect()} {this.renderAsk()}
); } renderQuestion() { const { data = {} } = this.props; const { question = {} } = data; if (!question.stem) return null; return [
{question.content.questions.map(q => { return [q.description &&
, this.renderSelect(q.select)]; })}
, this.renderAnswer(), ]; } renderAnswer() { const { data = {} } = this.props; const { question = {}, note = {}, userAnswer } = data; const { answer } = question; let a = true; if (!answer.questions[0].single) a = false; return (
{a &&
答案
} {a &&
我的答案 {userAnswer && AnswerIndex[userAnswer.questions[0].single.indexOf(true)]} 正确答案 {AnswerIndex[answer.questions[0].single.indexOf(true)]}
} {this.renderNote('题目', note.questionContent)}
); } renderOfficial() { const { data = {} } = this.props; const { question = {}, note = {} } = data; if (!question.officialContent) return null; return (
官方解析
{this.renderNote('官方解析', note.officialContent)}
); } renderQx() { const { data = {} } = this.props; const { question = {}, note = {} } = data; if (!question.qxContent) return null; return (
千行解析
{this.renderNote('千行解析', note.qxContent)}
); } renderConnect() { const { data = {} } = this.props; const { associations = [], note = {} } = data; if (!associations || associations.length === 0) return null; return (
题源联想
{associations.filter(row => row).map((item, index) => { return (
例题 {index + 1}
{this.renderSelect(item.content.questions[0].select)}
); })} {this.renderNote('题源联想', note.associationContent)}
); } renderAsk() { const { data = {} } = this.props; const { asks = [], note = {} } = data; if (!asks || asks.length === 0) return null; return (
相关问答
{asks.map((item) => { return (
提问
回答
); })} {this.renderNote('相关问答', note.qaContent)}
); } renderSelect(list) { return (
{list.map((item) => { return (
{item}
); })}
); } renderNote(title, content) { if (!content) return null; return (
我的笔记-{title}
{content}
); } } class SentenceDetail extends Component { render() { return (
{this.renderQuestion()} {this.renderDetail()} {this.renderChinese()}
); } renderQuestion() { const { data = {} } = this.props; const { question = {}, userAnswer = {} } = data; const { answer = {} } = question; return (
主语
谓语
宾语
本句存在以下哪种逻辑关系?(可多选)
); } renderDetail() { const { data = {} } = this.props; const { question = {} } = data; return (
解析详情
); } renderChinese() { const { data = {} } = this.props; const { question = {} } = data; return (
中文语意
); } } class NoteDetail extends Component { render() { const { data } = this.props; return (
课时{data.courseNo.no} {data.courseNo.title}
{formatDate(data.updateTime, 'YYYY-MM-DD HH:mm:ss')}
{data.content}
); } }