page.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. import React from 'react';
  2. import { Breadcrumb, Tooltip, Switch } from 'antd';
  3. import './index.less';
  4. import Page from '@src/containers/Page';
  5. import { asyncConfirm, asyncSMessage } from '@src/services/AsyncTools';
  6. import { formatPercent, formatDate } from '@src/services/Tools';
  7. import { RestartConfirmModal } from '../../../components/OtherModal';
  8. import ListTable from '../../../components/ListTable';
  9. import ProgressText from '../../../components/ProgressText';
  10. import IconButton from '../../../components/IconButton';
  11. import Button from '../../../components/Button';
  12. import { Main } from '../../../stores/main';
  13. import { Question } from '../../../stores/question';
  14. export default class extends Page {
  15. initState() {
  16. this.qxCatColumns = [
  17. {
  18. title: '模考',
  19. width: 250,
  20. align: 'left',
  21. render: record => {
  22. let progress = 0;
  23. if (record.report) {
  24. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  25. }
  26. return [
  27. <div hidden={this.state.finish === '1' && progress < 100} className="table-row" style={{ paddingRight: 40 }}>
  28. <div className="night f-s-16">
  29. {record.title}
  30. {record.prevReport ? String.fromCharCode(65) : ''}
  31. </div>
  32. <div>
  33. <ProgressText progress={progress} size="small" />
  34. </div>
  35. </div>,
  36. this.state.showPrev && record.prevReport && (
  37. <div hidden={Number(this.state.finish) === 0} className="table-row prev t-3">
  38. <div className="f-s-16">
  39. {record.title}
  40. </div>
  41. </div>
  42. ),
  43. ];
  44. },
  45. },
  46. {
  47. title: 'Total',
  48. width: 100,
  49. align: 'left',
  50. render: record => {
  51. let progress = 0;
  52. if (record.report) {
  53. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  54. }
  55. return [
  56. <div hidden={this.state.finish === '1' && progress < 100} className="table-row">
  57. <div className="night f-s-16 f-w-b">
  58. {record.report && record.report.score ? `${record.report.score.totalScore || 0}分${record.report.score.totalRank || 0}th` : '-分-th'}
  59. </div>
  60. <div className="f-s-12">全站: {record.totalTimes > 0 ? Math.round(record.totalScore / record.totalTimes) : '-'}分</div>
  61. </div>,
  62. this.state.showPrev && record.prevReport && (
  63. <div hidden={Number(this.state.finish) === 0} className="table-row prev t-3">
  64. <div className="f-s-16 f-w-b">
  65. {record.prevReport.score.totalScore}分{record.prevReport.score.totalRank}th
  66. </div>
  67. <div className="f-s-12">全站: {record.totalTimes > 0 ? Math.round(record.secondTotalScore / record.secondTotalTimes) : '-'}分</div>
  68. </div>
  69. ),
  70. ];
  71. },
  72. },
  73. {
  74. title: 'Verbal',
  75. width: 100,
  76. align: 'left',
  77. render: record => {
  78. let progress = 0;
  79. if (record.report) {
  80. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  81. }
  82. return [
  83. <div hidden={this.state.finish === '1' && progress < 100} className="table-row">
  84. <div className="night f-s-16 f-w-b">
  85. {record.report && record.report.score ? `${record.report.score.verbalScore || 0}分${record.report.score.verbalRank || 0}th` : '-分-th'}
  86. </div>
  87. <div className="f-s-12">全站: {record.totalTimes > 0 ? Math.round(record.verbalScore / record.totalTimes) : '-'}分</div>
  88. </div>,
  89. this.state.showPrev && record.prevReport && (
  90. <div hidden={Number(this.state.finish) === 0} className="table-row prev t-3">
  91. <div className="f-s-16 f-w-b">
  92. {record.prevReport.score.verbalScore}分{record.prevReport.score.verbalRank}th
  93. </div>
  94. <div className="f-s-12">全站: {record.totalTimes > 0 ? Math.round(record.secondVerbalScore / record.secondTotalTimes) : '-'}分</div>
  95. </div>
  96. ),
  97. ];
  98. },
  99. },
  100. {
  101. title: 'Quant',
  102. width: 100,
  103. align: 'left',
  104. render: record => {
  105. let progress = 0;
  106. if (record.report) {
  107. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  108. }
  109. return [<div hidden={this.state.finish === '1' && progress < 100} className="table-row">
  110. <div className="night f-s-16 f-w-b">
  111. {record.report && record.report.score ? `${record.report.score.quantScore || 0}分${record.report.score.quantRank || 0}th` : '-分-th'}
  112. </div>
  113. <div className="f-s-12">全站: {record.totalTimes > 0 ? Math.round(record.quantScore / record.totalTimes) : '-'}分</div>
  114. </div>,
  115. this.state.showPrev && record.prevReport && (
  116. <div hidden={Number(this.state.finish) === 0} className="table-row prev t-3">
  117. <div className="f-s-16 f-w-b">
  118. {record.prevReport.score.quantScore}分{record.prevReport.score.quantRank}th
  119. </div>
  120. <div className="f-s-12">全站: {record.totalTimes > 0 ? Math.round(record.secondQuantScore / record.secondTotalTimes) : '-'}分</div>
  121. </div>
  122. ),
  123. ];
  124. },
  125. },
  126. {
  127. title: 'IR',
  128. width: 100,
  129. align: 'left',
  130. render: record => {
  131. let progress = 0;
  132. if (record.report) {
  133. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  134. }
  135. return [<div hidden={this.state.finish === '1' && progress < 100} className="table-row">
  136. <div className="night f-s-16 f-w-b">
  137. {record.report && record.report.score ? `${record.report.score.irScore || 0}分${record.report.score.irRank || 0}th` : '-分-th'}
  138. </div>
  139. <div className="f-s-12">全站: {record.totalTimes > 0 ? Math.round(record.irScore / record.totalTimes) : '-'}分</div>
  140. </div>,
  141. this.state.showPrev && record.prevReport && (
  142. <div hidden={Number(this.state.finish) === 0} className="table-row prev t-3">
  143. <div className="f-s-16 f-w-b">
  144. {record.prevReport.score.irScore}分{record.prevReport.score.irRank}th
  145. </div>
  146. <div className="f-s-12">全站: {record.totalTimes > 0 ? Math.round(record.secondIrScore / record.secondTotalTimes) : '-'}分</div>
  147. </div>
  148. ),
  149. ];
  150. },
  151. },
  152. {
  153. title: '做题时间',
  154. width: 100,
  155. align: 'left',
  156. render: record => {
  157. let progress = 0;
  158. if (record.report) {
  159. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  160. }
  161. return [<div hidden={this.state.finish === '1' && progress < 100} className="table-row">
  162. <div>{record.report && formatDate(record.report.updateTime, 'YYYY-MM-DD')}</div>
  163. <div>{record.report && formatDate(record.report.updateTime, 'HH:mm')}</div>
  164. </div>,
  165. this.state.showPrev && record.prevReport && (
  166. <div hidden={Number(this.state.finish) === 0} className="table-row prev t-3">
  167. <div>{formatDate(record.prevReport.updateTime, 'YYYY-MM-DD')}</div>
  168. <div>{formatDate(record.prevReport.updateTime, 'HH:mm')}</div>
  169. </div>
  170. ),
  171. ];
  172. },
  173. },
  174. {
  175. title: '操作',
  176. width: 110,
  177. align: 'left',
  178. render: record => {
  179. let progress = 0;
  180. if (record.report) {
  181. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  182. }
  183. return [<div hidden={this.state.finish === '1' && progress < 100} className="table-row p-t-1">
  184. {!record.report && (
  185. <IconButton
  186. className="m-r-5"
  187. type="start"
  188. tip="Start"
  189. onClick={() => {
  190. Question.startLink('examination', record);
  191. }}
  192. />
  193. )}
  194. {record.report && !record.report.isFinish && (
  195. <IconButton
  196. type="continue"
  197. tip="Continue"
  198. onClick={() => {
  199. Question.continueLink('examination', record);
  200. }}
  201. />
  202. )}
  203. </div>,
  204. this.state.showPrev && record.prevReport && (
  205. <div hidden={Number(this.state.finish) === 0} className="table-row prev" />
  206. ),
  207. ];
  208. },
  209. },
  210. {
  211. title: '报告',
  212. width: 50,
  213. align: 'right',
  214. render: record => {
  215. let progress = 0;
  216. if (record.report) {
  217. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  218. }
  219. return [<div hidden={this.state.finish === '1' && progress < 100} className="table-row p-t-1">
  220. {record.report && !!record.report.isFinish && (
  221. <IconButton
  222. className="m-r-5"
  223. type="report"
  224. tip="Report"
  225. onClick={() => {
  226. Question.reportLink(record);
  227. }}
  228. />
  229. )}
  230. </div>,
  231. this.state.showPrev && (
  232. <div hidden={Number(this.state.finish) === 0} className="prev">
  233. {record.prevReport && (
  234. <IconButton
  235. type="report"
  236. tip="Report"
  237. onClick={() => {
  238. Question.reportPrevLink(record);
  239. }}
  240. />
  241. )}
  242. </div>
  243. ),
  244. ];
  245. },
  246. },
  247. ];
  248. this.catColumns = [
  249. {
  250. title: '模考',
  251. width: 250,
  252. align: 'left',
  253. render: record => {
  254. let progress = 0;
  255. if (record.report) {
  256. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  257. }
  258. return (
  259. <div className="table-row">
  260. <div className="night f-s-16">
  261. {record.title}
  262. {record.paper && record.paper.paperNo > 0 ? String.fromCharCode(64 + record.paper.paperNo) : ''}
  263. </div>
  264. <div>
  265. <ProgressText progress={progress} size="small" />
  266. </div>
  267. </div>
  268. );
  269. },
  270. },
  271. {
  272. title: 'Total',
  273. width: 100,
  274. align: 'left',
  275. render: record => {
  276. return (
  277. <div className="table-row">
  278. <div className="night f-s-16 f-w-b">
  279. {record.report && record.report.score ? `${record.report.score.totalScore}分${record.report.score.totalRank}th` : '-分-th'}
  280. </div>
  281. <div className="f-s-12">全站: {record.totalTimes ? Math.round(record.totalScore / record.totalTimes) : '-'}分</div>
  282. </div>
  283. );
  284. },
  285. },
  286. {
  287. title: 'Verbal',
  288. width: 100,
  289. align: 'left',
  290. render: record => {
  291. return (
  292. <div className="table-row">
  293. <div className="night f-s-16 f-w-b">
  294. {record.report && record.report.score ? `${record.report.score.verbalScore}分${record.report.score.verbalRank}th` : '-分-th'}
  295. </div>
  296. <div className="f-s-12">全站: {record.totalTimes ? Math.round(record.verbalScore / record.totalTimes) : '-'}分</div>
  297. </div>
  298. );
  299. },
  300. },
  301. {
  302. title: 'Quant',
  303. width: 100,
  304. align: 'left',
  305. render: record => {
  306. return (
  307. <div className="table-row">
  308. <div className="night f-s-16 f-w-b">
  309. {record.report && record.report.score ? `${record.report.score.quantScore}分${record.report.score.quantRank}th` : '-分-th'}
  310. </div>
  311. <div className="f-s-12">全站: {record.totalTimes ? Math.round(record.quantScore / record.totalTimes) : '-'}分</div>
  312. </div>
  313. );
  314. },
  315. },
  316. {
  317. title: 'IR',
  318. width: 100,
  319. align: 'left',
  320. render: record => {
  321. return (
  322. <div className="table-row">
  323. <div className="night f-s-16 f-w-b">
  324. {record.report && record.report.score ? `${record.report.score.irScore}分${record.report.score.irRank}th` : '-分-th'}
  325. </div>
  326. <div className="f-s-12">全站: {record.totalTimes ? Math.round(record.irScore / record.totalTimes) : '-'}分</div>
  327. </div>
  328. );
  329. },
  330. },
  331. {
  332. title: '做题时间',
  333. width: 100,
  334. align: 'left',
  335. render: record => {
  336. return (
  337. <div className="table-row">
  338. <div>{record.report && formatDate(record.report.updateTime, 'YYYY-MM-DD')}</div>
  339. <div>{record.report && formatDate(record.report.updateTime, 'HH:mm')}</div>
  340. </div>
  341. );
  342. },
  343. },
  344. {
  345. title: '操作',
  346. width: 110,
  347. align: 'left',
  348. render: record => {
  349. return (
  350. <div className="table-row p-t-1">
  351. {!record.report && (
  352. <IconButton
  353. type="start"
  354. tip="Start"
  355. onClick={() => {
  356. Question.startLink('examination', record);
  357. }}
  358. />
  359. )}
  360. {record.report && !record.report.isFinish && (
  361. <IconButton
  362. className="m-r-2"
  363. type="continue"
  364. tip="Continue"
  365. onClick={() => {
  366. Question.continueLink('examination', record);
  367. }}
  368. />
  369. )}
  370. {record.report && <IconButton
  371. type="restart"
  372. tip="Restart"
  373. onClick={() => {
  374. this.restart(record);
  375. }}
  376. />}
  377. </div>
  378. );
  379. },
  380. },
  381. {
  382. title: '报告',
  383. width: 50,
  384. align: 'right',
  385. render: record => {
  386. return (
  387. <div className="table-row p-t-1">
  388. {record.report && !!record.report.isFinish && (
  389. <IconButton
  390. type="report"
  391. tip="Report"
  392. onClick={() => {
  393. Question.reportLink(record);
  394. }}
  395. />
  396. )}
  397. {this.state.showPrev && (
  398. <div className="prev">
  399. {record.prevReport && (
  400. <IconButton
  401. type="report"
  402. tip="Report"
  403. onClick={() => {
  404. Question.reportPrevLink(record);
  405. }}
  406. />
  407. )}
  408. </div>
  409. )}
  410. </div>
  411. );
  412. },
  413. },
  414. ];
  415. this.columns = [
  416. {
  417. title: '模考',
  418. width: 250,
  419. align: 'left',
  420. render: record => {
  421. let progress = 0;
  422. if (record.report) {
  423. progress = formatPercent(record.report.userNumber, record.report.questionNumber);
  424. }
  425. return (
  426. <div className="table-row">
  427. <div className="night f-s-16">{record.title}</div>
  428. <div>
  429. <ProgressText progress={progress} times={record.paper ? record.paper.resetTimes : 0} size="small" />
  430. </div>
  431. </div>
  432. );
  433. },
  434. },
  435. {
  436. title: 'Total',
  437. width: 100,
  438. align: 'left',
  439. render: () => {
  440. return (
  441. <div className="table-row">
  442. <div className="f-s-12">仅CAT模考<br />提供分数</div>
  443. </div>
  444. );
  445. },
  446. },
  447. {
  448. title: 'Verbal',
  449. width: 100,
  450. align: 'left',
  451. render: record => {
  452. return (
  453. <div className="table-row">
  454. <div className="f-s-12">
  455. {record.report && record.report.setting
  456. ? formatPercent(record.report.setting.real ? record.report.setting.real.verbal : record.report.setting.number.verbal, this.nums.verbal.number, false)
  457. : '0%'}
  458. </div>
  459. </div>
  460. );
  461. },
  462. },
  463. {
  464. title: 'Quant',
  465. width: 100,
  466. align: 'left',
  467. render: record => {
  468. return (
  469. <div className="table-row">
  470. <div className="f-s-12">
  471. {record.report && record.report.setting
  472. ? formatPercent(record.report.setting.real ? record.report.setting.real.quant : record.report.setting.number.quant, this.nums.quant.number, false)
  473. : '0%'}
  474. </div>
  475. </div>
  476. );
  477. },
  478. },
  479. {
  480. title: 'IR',
  481. width: 100,
  482. align: 'left',
  483. render: record => {
  484. return (
  485. <div className="table-row">
  486. <div className="f-s-12">
  487. {record.report && record.report.setting ? formatPercent(record.report.setting.real ? record.report.setting.real.ir : record.report.setting.number.ir, this.nums.ir.number, false) : '0%'}
  488. </div>
  489. </div>
  490. );
  491. },
  492. },
  493. {
  494. title: '做题时间',
  495. width: 100,
  496. align: 'left',
  497. render: record => {
  498. if (!record.report) return null;
  499. return (
  500. <div className="table-row">
  501. <div>{formatDate(record.report.updateTime, 'YYYY-MM-DD')}</div>
  502. <div>{formatDate(record.report.updateTime, 'HH:mm')}</div>
  503. </div>
  504. );
  505. },
  506. },
  507. {
  508. title: '操作',
  509. width: 110,
  510. align: 'left',
  511. render: record => {
  512. return (
  513. <div className="table-row p-t-1">
  514. {!record.report && (
  515. <IconButton
  516. type="start"
  517. tip="Start"
  518. onClick={() => {
  519. Question.startLink('examination', record);
  520. }}
  521. />
  522. )}
  523. {record.report && !record.report.isFinish && (
  524. <IconButton
  525. className="m-r-2"
  526. type="continue"
  527. tip="Continue"
  528. onClick={() => {
  529. Question.continueLink('examination', record);
  530. }}
  531. />
  532. )}
  533. {record.report && <IconButton
  534. type="restart"
  535. tip="Restart"
  536. onClick={() => {
  537. this.restart(record);
  538. }}
  539. />}
  540. </div>
  541. );
  542. },
  543. },
  544. {
  545. title: '报告',
  546. width: 50,
  547. align: 'right',
  548. render: record => {
  549. if (!record.report || !record.report.isFinish) return null;
  550. return (
  551. <div className="table-row p-t-1">
  552. <IconButton
  553. type="report"
  554. tip="Report"
  555. onClick={() => {
  556. Question.reportLink(record);
  557. }}
  558. />
  559. </div>
  560. );
  561. },
  562. },
  563. ];
  564. this.inited = false;
  565. return {};
  566. }
  567. init() {
  568. const { id } = this.params;
  569. Main.getExaminationParent(id).then(result => {
  570. let tab1 = '';
  571. let tab2 = '';
  572. const navs = result.map(row => {
  573. row.title = `${row.titleZh}${row.titleEn}`;
  574. if (!tab1) {
  575. tab1 = row.extend;
  576. } else if (!tab2) {
  577. tab2 = row.extend;
  578. }
  579. row.tab1 = tab1;
  580. row.tab2 = tab2;
  581. return row;
  582. });
  583. this.cat = navs.filter(row => row.isAdapt > 0).length > 0;
  584. this.qxCat = navs.filter(row => row.isAdapt > 1).length > 0;
  585. Main.getExaminationNumber().then(nums => {
  586. this.nums = nums;
  587. this.inited = true;
  588. this.setState({ navs });
  589. this.refreshData();
  590. });
  591. });
  592. }
  593. initData() {
  594. const data = Object.assign(this.state, this.state.search);
  595. this.setState(data);
  596. if (this.inited) this.refreshData();
  597. }
  598. refreshData() {
  599. if (this.cat) {
  600. Question.getExaminationInfo().then(result => {
  601. this.setState({ examination: result });
  602. });
  603. }
  604. this.refreshExamination();
  605. }
  606. refreshExamination() {
  607. Question.getExaminationList(Object.assign({ structId: this.params.id }, this.state.search))
  608. .then(result => {
  609. this.setState({ list: result.list, total: result.total });
  610. })
  611. .catch(err => {
  612. asyncSMessage(err.message, 'warn');
  613. // linkTo('/examination');
  614. });
  615. }
  616. restart(item) {
  617. asyncConfirm('提示', '你打算重做本套练习,过往做题记录可至「个人中心-报告」查看。', () => {
  618. Question.restart(item.paper.id).then(() => {
  619. this.refresh();
  620. });
  621. });
  622. }
  623. resetCat() {
  624. Question.resetCat().then(() => {
  625. this.refresh();
  626. });
  627. }
  628. renderView() {
  629. const { list, navs, search, examination = {}, reset } = this.state;
  630. const { finish } = search;
  631. return (
  632. <div>
  633. <div className="content">
  634. <Breadcrumb separator=">">
  635. <Breadcrumb.Item href="/examination">模考</Breadcrumb.Item>
  636. {(navs || []).map(row => {
  637. return <Breadcrumb.Item href={`/examination?tab1=${row.tab1}&tab2=${row.tab2}`}>{row.title}</Breadcrumb.Item>;
  638. })}
  639. </Breadcrumb>
  640. <ListTable
  641. rightAction={
  642. <div hidden={!this.qxCat}>
  643. <span>有效期至:{examination.expireTime && formatDate(examination.expireTime, 'YYYY-MM-DD')}</span>
  644. {examination.reset && (
  645. <span>
  646. 第一遍模考成绩
  647. <Switch
  648. checked={this.state.showPrev}
  649. onChange={() => {
  650. this.setState({ showPrev: !this.state.showPrev });
  651. }}
  652. />
  653. </span>
  654. )}
  655. {!examination.reset && examination.canReset && (
  656. <Button
  657. size="small"
  658. radius
  659. onClick={() => {
  660. this.setState({ reset: true });
  661. }}
  662. >
  663. Reset
  664. </Button>
  665. )}
  666. {!examination.reset && !examination.canReset && (
  667. <Tooltip overlayClassName="gray" placement="top" title="全部模考做完才可重置">
  668. <a>
  669. <Button size="small" disabled radius>
  670. Reset
  671. </Button>
  672. </a>
  673. </Tooltip>
  674. )}
  675. </div>
  676. }
  677. filters={[
  678. {
  679. type: 'radio',
  680. checked: finish,
  681. list: [{ key: '0', title: '未完成' }, { key: '1', title: '已完成' }],
  682. onChange: item => {
  683. if (item.key === finish) {
  684. this.search({ finish: null }, false);
  685. } else if (item.key === '0') {
  686. this.search({ finish: '0' }, false);
  687. } else if (item.key === '1') {
  688. this.search({ finish: '1' }, false);
  689. } else {
  690. this.search({ finish: null }, false);
  691. }
  692. this.initData();
  693. },
  694. },
  695. ]}
  696. data={list}
  697. columns={this.qxCat ? this.qxCatColumns : (this.cat ? this.catColumns : this.columns)}
  698. />
  699. </div>
  700. <RestartConfirmModal show={reset} onConfirm={() => this.resetCat()} onCancel={() => this.setState({ reset: false })} />
  701. </div>
  702. );
  703. }
  704. }