import React from 'react'; import { Breadcrumb, Tooltip, Switch } from 'antd'; import './index.less'; import Page from '@src/containers/Page'; import { asyncConfirm, asyncSMessage } from '@src/services/AsyncTools'; import { formatPercent, formatDate } from '@src/services/Tools'; import { RestartConfirmModal } from '../../../components/OtherModal'; import ListTable from '../../../components/ListTable'; import ProgressText from '../../../components/ProgressText'; import IconButton from '../../../components/IconButton'; import Button from '../../../components/Button'; import { Main } from '../../../stores/main'; import { Question } from '../../../stores/question'; export default class extends Page { initState() { this.qxCatColumns = [ { title: '模考', width: 210, align: 'left', render: record => { let progress = 0; if (record.report) { progress = formatPercent(record.report.userNumber, record.report.questionNumber); } return [
{record.title} {record.paper && record.paper.paperNo > 0 ? String.fromCharCode(64 + record.paper.paperNo) : ''}
, this.state.showPrev && record.prevReport && (
{record.title} {record.prevPaper && record.prevPaper.paperNo > 0 ? String.fromCharCode(64 + record.prevPaper.paperNo) : ''}
), ]; }, }, { title: 'Total', width: 110, align: 'left', render: record => { return [
{record.report ? `${record.report.score.totalScore}分${record.report.score.totalRank}th` : '-分-th'}
全站: {Math.round(record.totalScore / record.totalTimes)}分
, this.state.showPrev && record.prevReport && (
{record.prevReport.score.totalScore}分{record.prevReport.score.totalRank}th
全站: {Math.round(record.secondTotalScore / record.secondTotalTimes)}分
), ]; }, }, { title: 'Verbal', width: 110, align: 'left', render: record => { return [
{record.report ? `${record.report.score.verbalScore}分${record.report.score.verbalRank}th` : '-分-th'}
全站: {Math.round(record.verbalScore / record.totalTimes)}分
, this.state.showPrev && record.prevReport && (
{record.prevReport.score.verbalScore}分{record.prevReport.score.verbalRank}th
全站: {Math.round(record.secondVerbalScore / record.secondTotalTimes)}分
), ]; }, }, { title: 'Quant', width: 110, align: 'left', render: record => { return [
{record.report ? `${record.report.score.quantScore}分${record.report.score.quantRank}th` : '-分-th'}
全站: {Math.round(record.quantScore / record.totalTimes)}分
, this.state.showPrev && record.prevReport && (
{record.prevReport.score.quantScore}分{record.prevReport.score.quantRank}th
全站: {Math.round(record.secondQuantScore / record.secondTotalTimes)}分
), ]; }, }, { title: 'IR', width: 110, align: 'left', render: record => { return [
{record.report ? `${record.report.score.irScore}分${record.report.score.irRank}th` : '-分-th'}
全站: {Math.round(record.irScore / record.totalTimes)}分
, this.state.showPrev && record.prevReport && (
{record.prevReport.score.irScore}分{record.prevReport.score.irRank}th
全站: {Math.round(record.secondIrScore / record.secondTotalTimes)}分
), ]; }, }, { title: '做题时间', width: 100, align: 'left', render: record => { return [
{record.report && formatDate(record.report.updateTime, 'YYYY-MM-DD')}
{record.report && formatDate(record.report.updateTime, 'HH:mm')}
, this.state.showPrev && record.prevReport && (
{formatDate(record.prevReport.updateTime, 'YYYY-MM-DD')}
{formatDate(record.prevReport.updateTime, 'HH:mm')}
), ]; }, }, { title: '操作', width: 110, align: 'left', render: record => { return [
{!record.report && ( { Question.startLink('examination', record); }} /> )} {record.report && !record.report.isFinish && ( { Question.continueLink('examination', record); }} /> )}
, this.state.showPrev && record.prevReport && (
), ]; }, }, { title: '报告', width: 50, align: 'right', render: record => { return [
{record.report && !!record.report.isFinish && ( { Question.reportLink(record); }} /> )}
, this.state.showPrev && (
{record.prevReport && ( { Question.reportPrevLink(record); }} /> )}
), ]; }, }, ]; this.catColumns = [ { title: '模考', width: 210, align: 'left', render: record => { let progress = 0; if (record.report) { progress = formatPercent(record.report.userNumber, record.report.questionNumber); } return (
{record.title} {record.paper && record.paper.paperNo > 0 ? String.fromCharCode(64 + record.paper.paperNo) : ''}
); }, }, { title: 'Total', width: 110, align: 'left', render: record => { return (
{record.report ? `${record.report.score.totalScore}分${record.report.score.totalRank}th` : '-分-th'}
全站: {Math.round(record.totalScore / record.totalTimes)}分
); }, }, { title: 'Verbal', width: 110, align: 'left', render: record => { return (
{record.report ? `${record.report.score.verbalScore}分${record.report.score.verbalRank}th` : '-分-th'}
全站: {Math.round(record.verbalScore / record.totalTimes)}分
); }, }, { title: 'Quant', width: 110, align: 'left', render: record => { return (
{record.report ? `${record.report.score.quantScore}分${record.report.score.quantRank}th` : '-分-th'}
全站: {Math.round(record.quantScore / record.totalTimes)}分
); }, }, { title: 'IR', width: 110, align: 'left', render: record => { return (
{record.report ? `${record.report.score.irScore}分${record.report.score.irRank}th` : '-分-th'}
全站: {Math.round(record.irScore / record.totalTimes)}分
); }, }, { title: '做题时间', width: 100, align: 'left', render: record => { return (
{record.report && formatDate(record.report.updateTime, 'YYYY-MM-DD')}
{record.report && formatDate(record.report.updateTime, 'HH:mm')}
); }, }, { title: '操作', width: 110, align: 'left', render: record => { return (
{!record.report && ( { Question.startLink('examination', record); }} /> )} {record.report && !record.report.isFinish && ( { Question.continueLink('examination', record); }} /> )} {record.report && { this.restart(record); }} />}
); }, }, { title: '报告', width: 50, align: 'right', render: record => { return (
{record.report && !!record.report.isFinish && ( { Question.reportLink(record); }} /> )} {this.state.showPrev && (
{record.prevReport && ( { Question.reportPrevLink(record); }} /> )}
)}
); }, }, ]; this.columns = [ { title: '模考', width: 210, align: 'left', render: record => { let progress = 0; if (record.report) { progress = formatPercent(record.report.userNumber, record.report.questionNumber); } return (
{record.title}
); }, }, { title: 'Total', width: 110, align: 'left', render: () => { return (
仅CAT模考
提供分数
); }, }, { title: 'Verbal', width: 110, align: 'left', render: record => { return (
{record.report ? formatPercent(record.report.setting.number.verbal, this.nums.verbal.number, false) : '0%'}
); }, }, { title: 'Quant', width: 110, align: 'left', render: record => { return (
{record.report ? formatPercent(record.report.setting.number.quant, this.nums.quant.number, false) : '0%'}
); }, }, { title: 'IR', width: 110, align: 'left', render: record => { return (
{record.report ? formatPercent(record.report.setting.number.ir, this.nums.ir.number, false) : '0%'}
); }, }, { title: '做题时间', width: 100, align: 'left', render: record => { if (!record.report) return null; return (
{formatDate(record.report.updateTime, 'YYYY-MM-DD')}
{formatDate(record.report.updateTime, 'HH:mm')}
); }, }, { title: '操作', width: 110, align: 'left', render: record => { return (
{!record.report && ( { Question.startLink('examination', record); }} /> )} {record.report && !record.report.isFinish && ( { Question.continueLink('examination', record); }} /> )} {record.report && { this.restart(record); }} />}
); }, }, { title: '报告', width: 50, align: 'right', render: record => { if (!record.report || !record.report.isFinish) return null; return (
{ Question.reportLink(record); }} />
); }, }, ]; this.inited = false; return {}; } init() { const { id } = this.params; Main.getExaminationParent(id).then(result => { const navs = result.map(row => { row.title = `${row.titleZh}${row.titleEn}`; return row; }); this.cat = navs.filter(row => row.isAdapt > 0).length > 0; this.qxCat = navs.filter(row => row.isAdapt > 1).length > 0; Main.getExaminationNumber().then(nums => { this.nums = nums; this.inited = true; this.setState({ navs }); this.refreshData(); }); }); } initData() { const data = Object.assign(this.state, this.state.search); this.setState(data); if (this.inited) this.refreshData(); } refreshData() { if (this.cat) { Question.getExaminationInfo().then(result => { this.setState({ examination: result }); }); } this.refreshExamination(); } refreshExamination() { Question.getExaminationList(Object.assign({ structId: this.params.id }, this.state.search)) .then(result => { this.setState({ list: result.list, total: result.total }); }) .catch(err => { asyncSMessage(err.message, 'warn'); // linkTo('/examination'); }); } restart(item) { asyncConfirm('提示', '你打算重做本套练习,过往做题记录可至「个人中心-报告」查看。', () => { Question.restart(item.paper.id).then(() => { this.refresh(); }); }); } resetCat() { Question.resetCat().then(() => { this.refresh(); }); } renderView() { const { list, navs, search, examination = {}, reset } = this.state; const { finish } = search; return (
模考 {(navs || []).map(row => { return {row.title}; })}
} filters={[ { type: 'radio', checked: finish, list: [{ key: '0', title: '未完成' }, { key: '1', title: '已完成' }], onChange: item => { if (item.key === finish) { this.search({ finish: null }); } else if (item.key === '0') { this.search({ finish: 0 }); } else if (item.key === '1') { this.search({ finish: 1 }); } else { this.search({ finish: null }); } }, }, ]} data={list} columns={this.qxCatColumns} />
this.resetCat()} onCancel={() => this.setState({ reset: false })} />
); } }