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'];
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 });
});
}
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 } = this.state;
return (
{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 (
千行GMAR
{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 [
{this.renderSelect(question.content.question[0].select)}
,
this.renderAnswer(),
];
}
renderAnswer() {
const { data = {} } = this.props;
const { question = {}, note = {}, userAnswer = {} } = data;
const { answer } = question;
return (
答案
{userAnswer && 我的答案 {AnswerIndex[answer.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 (
{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 (
);
})}
);
}
renderNote(title, content) {
if (!content) return null;
return (
);
}
}
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}
);
}
}