page.js 23 KB

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