123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712 |
- 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 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 [
- <div className="table-row" style={{ paddingRight: 40 }}>
- <div className="night f-s-16">
- {record.title}
- {record.paper && record.paper.paperNo > 0 ? String.fromCharCode(64 + record.paper.paperNo) : ''}
- </div>
- <div>
- <ProgressText progress={progress} size="small" />
- </div>
- {this.state.showPrev && (
- <div className="prev">
- <div className="night f-s-16">
- {record.title}
- {record.prevPaper && record.prevPaper.paperNo > 0
- ? String.fromCharCode(64 + record.prevPaper.paperNo)
- : ''}
- </div>
- </div>
- )}
- </div>,
- <div className="table-row" style={{ paddingRight: 40 }}>
- <div className="night f-s-16">
- {record.title}
- {record.paper && record.paper.paperNo > 0 ? String.fromCharCode(64 + record.paper.paperNo) : ''}
- </div>
- <div>
- <ProgressText progress={progress} size="small" />
- </div>
- {this.state.showPrev && (
- <div className="prev">
- <div className="night f-s-16">
- {record.title}
- {record.prevPaper && record.prevPaper.paperNo > 0
- ? String.fromCharCode(64 + record.prevPaper.paperNo)
- : ''}
- </div>
- </div>
- )}
- </div>,
- ];
- },
- },
- {
- title: 'Total',
- width: 110,
- align: 'left',
- render: record => {
- return [
- <div className="table-row">
- <div className="night f-s-16 f-w-b">
- {record.report ? `${record.report.score.totalScore}分${record.report.score.totalRank}th` : '-分-th'}
- </div>
- <div className="f-s-12">全站: {Math.round(record.totalScore / record.totalTimes)}分</div>
- {this.state.showPrev && record.prevReport && (
- <div className="prev">
- <div className="night f-s-16 f-w-b">
- {record.prevReport.score.totalScore}分{record.prevReport.score.totalRank}th
- </div>
- <div className="f-s-12">全站: {Math.round(record.secondTotalScore / record.secondTotalTimes)}分</div>
- </div>
- )}
- </div>,
- <div className="table-row">
- <div className="night f-s-16 f-w-b">
- {record.report ? `${record.report.score.totalScore}分${record.report.score.totalRank}th` : '-分-th'}
- </div>
- <div className="f-s-12">全站: {Math.round(record.totalScore / record.totalTimes)}分</div>
- {this.state.showPrev && record.prevReport && (
- <div className="prev">
- <div className="night f-s-16 f-w-b">
- {record.prevReport.score.totalScore}分{record.prevReport.score.totalRank}th
- </div>
- <div className="f-s-12">全站: {Math.round(record.secondTotalScore / record.secondTotalTimes)}分</div>
- </div>
- )}
- </div>,
- ];
- },
- },
- {
- title: 'Verbal',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="night f-s-16 f-w-b">
- {record.report ? `${record.report.score.verbalScore}分${record.report.score.verbalRank}th` : '-分-th'}
- </div>
- <div className="f-s-12">全站: {Math.round(record.verbalScore / record.totalTimes)}分</div>
- {this.state.showPrev && record.prevReport && (
- <div className="prev">
- <div className="night f-s-16 f-w-b">
- {record.prevReport.score.verbalScore}分{record.prevReport.score.verbalRank}th
- </div>
- <div className="f-s-12">全站: {Math.round(record.secondVerbalScore / record.secondTotalTimes)}分</div>
- </div>
- )}
- </div>
- );
- },
- },
- {
- title: 'Quant',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="night f-s-16 f-w-b">
- {record.report ? `${record.report.score.quantScore}分${record.report.score.quantRank}th` : '-分-th'}
- </div>
- <div className="f-s-12">全站: {Math.round(record.quantScore / record.totalTimes)}分</div>
- {this.state.showPrev && record.prevReport && (
- <div className="prev">
- <div className="night f-s-16 f-w-b">
- {record.prevReport.score.quantScore}分{record.prevReport.score.quantRank}th
- </div>
- <div className="f-s-12">全站: {Math.round(record.secondQuantScore / record.secondTotalTimes)}分</div>
- </div>
- )}
- </div>
- );
- },
- },
- {
- title: 'IR',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="night f-s-16 f-w-b">
- {record.report ? `${record.report.score.irScore}分${record.report.score.irRank}th` : '-分-th'}
- </div>
- <div className="f-s-12">全站: {Math.round(record.irScore / record.totalTimes)}分</div>
- {this.state.showPrev && record.prevReport && (
- <div className="prev">
- <div className="night f-s-16 f-w-b">
- {record.prevReport.score.irScore}分{record.prevReport.score.irRank}th
- </div>
- <div className="f-s-12">全站: {Math.round(record.secondIrScore / record.secondTotalTimes)}分</div>
- </div>
- )}
- </div>
- );
- },
- },
- {
- title: '做题时间',
- width: 100,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div>{record.report && formatDate(record.report.updateTime, 'YYYY-MM-DD')}</div>
- <div>{record.report && formatDate(record.report.updateTime, 'HH:mm')}</div>
- {this.state.showPrev && record.prevReport && (
- <div className="prev">
- <div>{formatDate(record.prevReport.updateTime, 'YYYY-MM-DD')}</div>
- <div>{formatDate(record.prevReport.updateTime, 'HH:mm')}</div>
- </div>
- )}
- </div>
- );
- },
- },
- {
- title: '操作',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row p-t-1">
- {!record.report && (
- <IconButton
- className="m-r-5"
- type="start"
- tip="Start"
- onClick={() => {
- Question.startLink('examination', record);
- }}
- />
- )}
- {record.report && !record.report.isFinish && (
- <IconButton
- type="continue"
- tip="Continue"
- onClick={() => {
- Question.continueLink('examination', record);
- }}
- />
- )}
- </div>
- );
- },
- },
- {
- title: '报告',
- width: 50,
- align: 'right',
- render: record => {
- return (
- <div className="table-row p-t-1">
- {record.report && record.report.isFinish && (
- <IconButton
- className="m-r-5"
- type="report"
- tip="Report"
- onClick={() => {
- Question.reportLink(record);
- }}
- />
- )}
- {this.state.showPrev && (
- <div className="prev">
- {record.prevReport && (
- <IconButton
- type="report"
- tip="Report"
- onClick={() => {
- Question.reportPrevLink(record);
- }}
- />
- )}
- </div>
- )}
- </div>
- );
- },
- },
- ];
- this.catColumns = [
- {
- title: '模考',
- width: 210,
- align: 'left',
- render: record => {
- let progress = 0;
- if (record.report) {
- progress = formatPercent(record.report.userNumber, record.report.questionNumber);
- }
- return (
- <div className="table-row">
- <div className="night f-s-16">
- {record.title}
- {record.paper && record.paper.paperNo > 0 ? String.fromCharCode(64 + record.paper.paperNo) : ''}
- </div>
- <div>
- <ProgressText progress={progress} size="small" />
- </div>
- </div>
- );
- },
- },
- {
- title: 'Total',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="night f-s-16 f-w-b">
- {record.report ? `${record.report.score.totalScore}分${record.report.score.totalRank}th` : '-分-th'}
- </div>
- <div className="f-s-12">全站: {Math.round(record.totalScore / record.totalTimes)}分</div>
- </div>
- );
- },
- },
- {
- title: 'Verbal',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="night f-s-16 f-w-b">
- {record.report ? `${record.report.score.verbalScore}分${record.report.score.verbalRank}th` : '-分-th'}
- </div>
- <div className="f-s-12">全站: {Math.round(record.verbalScore / record.totalTimes)}分</div>
- </div>
- );
- },
- },
- {
- title: 'Quant',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="night f-s-16 f-w-b">
- {record.report ? `${record.report.score.quantScore}分${record.report.score.quantRank}th` : '-分-th'}
- </div>
- <div className="f-s-12">全站: {Math.round(record.quantScore / record.totalTimes)}分</div>
- </div>
- );
- },
- },
- {
- title: 'IR',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="night f-s-16 f-w-b">
- {record.report ? `${record.report.score.irScore}分${record.report.score.irRank}th` : '-分-th'}
- </div>
- <div className="f-s-12">全站: {Math.round(record.irScore / record.totalTimes)}分</div>
- </div>
- );
- },
- },
- {
- title: '做题时间',
- width: 100,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div>{record.report && formatDate(record.report.updateTime, 'YYYY-MM-DD')}</div>
- <div>{record.report && formatDate(record.report.updateTime, 'HH:mm')}</div>
- </div>
- );
- },
- },
- {
- title: '操作',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row p-t-1">
- {!record.report && (
- <IconButton
- type="start"
- tip="Start"
- onClick={() => {
- Question.startLink('examination', record);
- }}
- />
- )}
- {record.report && !record.report.isFinish && (
- <IconButton
- className="m-r-2"
- type="continue"
- tip="Continue"
- onClick={() => {
- Question.continueLink('examination', record);
- }}
- />
- )}
- <IconButton
- type="restart"
- tip="Restart"
- onClick={() => {
- this.restart(record);
- }}
- />
- </div>
- );
- },
- },
- {
- title: '报告',
- width: 50,
- align: 'right',
- render: record => {
- return (
- <div className="table-row p-t-1">
- {record.report && record.report.isFinish && (
- <IconButton
- type="report"
- tip="Report"
- onClick={() => {
- Question.reportLink(record);
- }}
- />
- )}
- {this.state.showPrev && (
- <div className="prev">
- {record.prevReport && (
- <IconButton
- type="report"
- tip="Report"
- onClick={() => {
- Question.reportPrevLink(record);
- }}
- />
- )}
- </div>
- )}
- </div>
- );
- },
- },
- ];
- this.columns = [
- {
- title: '模考',
- width: 210,
- align: 'left',
- render: record => {
- let progress = 0;
- if (record.report) {
- progress = formatPercent(record.report.userNumber, record.report.questionNumber);
- }
- return (
- <div className="table-row">
- <div className="night f-s-16">{record.title}</div>
- <div>
- <ProgressText progress={progress} times={record.paper ? record.paper.times : 0} size="small" />
- </div>
- </div>
- );
- },
- },
- {
- title: 'Total',
- width: 110,
- align: 'left',
- render: () => {
- return (
- <div className="table-row">
- <div className="f-s-12">仅CAT模考</div>
- </div>
- );
- },
- },
- {
- title: 'Verbal',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="f-s-12">
- {record.report
- ? formatPercent(record.report.setting.number.verbal, this.nums.verbal.number, false)
- : '0%'}
- </div>
- </div>
- );
- },
- },
- {
- title: 'Quant',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="f-s-12">
- {record.report
- ? formatPercent(record.report.setting.number.quant, this.nums.quant.number, false)
- : '0%'}
- </div>
- </div>
- );
- },
- },
- {
- title: 'IR',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row">
- <div className="f-s-12">
- {record.report ? formatPercent(record.report.setting.number.ir, this.nums.ir.number, false) : '0%'}
- </div>
- </div>
- );
- },
- },
- {
- title: '做题时间',
- width: 100,
- align: 'left',
- render: record => {
- if (!record.report) return null;
- return (
- <div className="table-row">
- <div>{formatDate(record.report.updateTime, 'YYYY-MM-DD')}</div>
- <div>{formatDate(record.report.updateTime, 'HH:mm')}</div>
- </div>
- );
- },
- },
- {
- title: '操作',
- width: 110,
- align: 'left',
- render: record => {
- return (
- <div className="table-row p-t-1">
- {!record.report && (
- <IconButton
- type="start"
- tip="Start"
- onClick={() => {
- Question.startLink('examination', record);
- }}
- />
- )}
- {record.report && !record.report.isFinish && (
- <IconButton
- className="m-r-2"
- type="continue"
- tip="Continue"
- onClick={() => {
- Question.continueLink('examination', record);
- }}
- />
- )}
- <IconButton
- type="restart"
- tip="Restart"
- onClick={() => {
- this.restart(record);
- }}
- />
- </div>
- );
- },
- },
- {
- title: '报告',
- width: 50,
- align: 'right',
- render: record => {
- if (!record.report || !record.report.isFinish) return null;
- return (
- <div className="table-row p-t-1">
- <IconButton
- type="report"
- tip="Report"
- onClick={() => {
- Question.reportLink(record);
- }}
- />
- </div>
- );
- },
- },
- ];
- 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() {
- asyncConfirm('提示', '是否重置', () => {
- Question.resetCat().then(() => {
- this.refresh();
- });
- });
- }
- renderView() {
- const { list, navs, search, examination = {} } = this.state;
- const { finish } = search;
- return (
- <div>
- <div className="content">
- <Breadcrumb separator=">">
- <Breadcrumb.Item href="/examination">模考</Breadcrumb.Item>
- {(navs || []).map(row => {
- return <Breadcrumb.Item>{row.title}</Breadcrumb.Item>;
- })}
- </Breadcrumb>
- <ListTable
- rightAction={
- <div hidden={!this.qxCat}>
- <span>有效期至:{examination.expireTime && formatDate(examination.expireTime, 'YYYY-MM-DD')}</span>
- {examination.reset && (
- <span>
- 第一遍模考成绩
- <Switch
- checked={this.state.showPrev}
- onChange={() => {
- this.setState({ showPrev: !this.state.showPrev });
- }}
- />
- </span>
- )}
- {!examination.reset && examination.canReset && (
- <Button
- size="small"
- radius
- onClick={() => {
- this.resetExamination();
- }}
- >
- Reset
- </Button>
- )}
- {!examination.reset && !examination.canReset && (
- <Tooltip overlayClassName="gray" placement="top" title="全部模考做完才可重置">
- <a>
- <Button size="small" disabled radius>
- Reset
- </Button>
- </a>
- </Tooltip>
- )}
- </div>
- }
- 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}
- />
- </div>
- </div>
- );
- }
- }
|