page.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. import React, { Component } from 'react';
  2. import { Link } from 'react-router-dom';
  3. import './index.less';
  4. import { Icon, Checkbox } from 'antd';
  5. import Page from '@src/containers/Page';
  6. import Assets from '@src/components/Assets';
  7. import { timeRange, getMap, formatPercent, formatMonth, formatDate, formatSeconds } from '@src/services/Tools';
  8. import UserLayout from '../../../layouts/User';
  9. import UserTable from '../../../components/UserTable';
  10. import UserAction from '../../../components/UserAction';
  11. import { RealAuth, QuestionNoteModal } from '../../../components/OtherModal';
  12. import Examination from '../../../components/Examination';
  13. import VipRenew from '../../../components/VipRenew';
  14. import menu, { refreshQuestionType } from '../index';
  15. import Tabs from '../../../components/Tabs';
  16. import Modal from '../../../components/Modal';
  17. import Select from '../../../components/Select';
  18. import GIcon from '../../../components/Icon';
  19. import { TimeRange, QuestionType, PrepareStatus, ExperiencePercent } from '../../../../Constant';
  20. import { My } from '../../../stores/my';
  21. import { Question } from '../../../stores/question';
  22. const QuestionTypeMap = getMap(QuestionType, 'value', 'label');
  23. const PrepareStatusMap = getMap(PrepareStatus, 'value', 'short');
  24. const ExperiencePercentMap = getMap(ExperiencePercent, 'value', 'label');
  25. const exportType = [
  26. { key: 'question', title: '题目' },
  27. { key: 'official', title: '官方解析' },
  28. { key: 'note', title: '我的笔记' },
  29. { key: 'qx', title: '千行解析', auth: true },
  30. { key: 'association', title: '题源联想', auth: true },
  31. { key: 'qa', title: '相关问答', auth: true },
  32. ];
  33. export default class extends Page {
  34. constructor(props) {
  35. props.size = 10;
  36. super(props);
  37. }
  38. initState() {
  39. return {
  40. tab: 'question',
  41. module: 'exercise',
  42. timerange: 'today',
  43. filterMap: {},
  44. sortMap: {},
  45. list: [],
  46. selectList: [],
  47. allChecked: false,
  48. showDetail: false,
  49. };
  50. }
  51. init() {
  52. this.columns = [
  53. {
  54. key: 'question_type',
  55. title: '题型',
  56. width: 115,
  57. render: (text, record) => {
  58. return QuestionTypeMap[record.questionType];
  59. },
  60. fixSort: true,
  61. },
  62. {
  63. key: 'title',
  64. title: '题目ID',
  65. width: 100,
  66. fixSort: true,
  67. render: (text, record) => {
  68. return <Link to={`/question/detail/${record.questionNoId}`}>{text}</Link>;
  69. },
  70. },
  71. {
  72. key: 'description',
  73. title: '内容',
  74. width: 220,
  75. render: (text) => {
  76. return <div style={{ maxHeight: '80px', overflow: 'hidden' }}>{text}</div>;
  77. },
  78. },
  79. {
  80. key: 'time',
  81. title: '耗时',
  82. width: 80,
  83. sort: true,
  84. render: (text, record) => {
  85. const user = record.stat ? record.stat.userTime / record.stat.userNumber : 0;
  86. const all = record.questionNo.totalNumber ? record.questionNo.totalTime / record.questionNo.totalNumber : 0;
  87. return <div className="sub">
  88. <div className="t-2 t-s-12">{user > 0 ? formatSeconds(user) : '-'}{user > 0 && <Assets height={10} width={10} name={user > all ? 'up' : 'down'} />}</div>
  89. <div className="t-6 t-s-12">全站{all > 0 ? formatSeconds(all) : '-'}</div>
  90. </div>;
  91. },
  92. },
  93. {
  94. key: 'correct',
  95. title: '错误率',
  96. width: 95,
  97. sort: true,
  98. render: (text, record) => {
  99. return <div className="sub">
  100. <div className="t-2 t-s-12">{record.stat ? formatPercent(record.stat.userNumber - record.stat.userCorrect, record.stat.userNumber, false) : '-'}</div>
  101. <div className="t-6 t-s-12">{record.stat ? `${record.stat.userNumber - record.stat.userCorrect}/${record.stat.userNumber}` : '-'}</div>
  102. </div>;
  103. },
  104. },
  105. {
  106. key: 'latest_time',
  107. title: '最近做题',
  108. width: 95,
  109. render: (text) => {
  110. return <div className="sub">
  111. <div className="t-2 t-s-12">{text.split(' ')[0]}</div>
  112. <div className="t-6 t-s-12">{text.split(' ')[1]}</div>
  113. </div>;
  114. },
  115. },
  116. {
  117. key: '',
  118. title: '',
  119. render: (text, record, index) => {
  120. return <div><GIcon name="note" active={record.note} onClick={() => this.note(index)} /></div>;
  121. },
  122. },
  123. ];
  124. }
  125. initData() {
  126. const data = Object.assign(this.state, this.state.search);
  127. data.filterMap = this.state.search;
  128. if (data.order) {
  129. data.sortMap = { [data.order]: data.direction };
  130. }
  131. if (data.timerange) {
  132. data.filterMap.timerange = data.timerange;
  133. }
  134. switch (data.tab) {
  135. case 'question':
  136. return this.refreshQuestion(data);
  137. case 'article':
  138. return this.refreshArticle(data);
  139. default:
  140. return null;
  141. }
  142. }
  143. refreshQuestion(data) {
  144. const [startTime, endTime] = timeRange(data.timerange);
  145. refreshQuestionType(this, data.subject, data.questionType, {
  146. all: true,
  147. needSentence: true,
  148. allSubject: true,
  149. }).then(({ questionTypes }) => {
  150. this.setState({ moduleSelect: [{ title: '练习', key: 'exercise' }, { title: '模考', key: 'examination' }] });
  151. My.listQuestionCollect(
  152. Object.assign(
  153. { module: data.module, questionTypes, startTime, endTime },
  154. this.state.search,
  155. {
  156. order: Object.keys(data.sortMap)
  157. .map(key => {
  158. if (key === 'title') return 'pid desc, no desc';
  159. return `${key} ${data.sortMap[key]}`;
  160. })
  161. .join(','),
  162. },
  163. ),
  164. ).then(result => {
  165. result.list = result.list.map(row => {
  166. row.questionNo = row.questionNo || {};
  167. row.key = row.questionNoId;
  168. row.questionType = row.question.questionType;
  169. row.title = row.questionNo.title;
  170. row.description = row.question.description;
  171. row.latest_time = row.latestTime ? formatDate(row.latestTime, 'YYYY-MM-DD HH:mm:ss') : '';
  172. return row;
  173. });
  174. this.setState({ list: result.list, total: result.total });
  175. });
  176. });
  177. }
  178. refreshArticle(data) {
  179. const [startTime, endTime] = timeRange(data.timerange);
  180. My.listExperienceCollect(Object.assign({ startTime, endTime }, this.state.search)).then(result => {
  181. this.setState({ list: result.list, total: result.total });
  182. });
  183. }
  184. note(index) {
  185. const { list } = this.props;
  186. const userQuestion = list[index];
  187. const { questionNo } = userQuestion;
  188. My.getQuestionNote(questionNo.id)
  189. .then(result => {
  190. this.setState({ questionNo, note: result || {}, showNote: true, index });
  191. });
  192. }
  193. onTabChange(tab) {
  194. const data = { tab };
  195. this.refreshQuery(data);
  196. }
  197. onFilter(value) {
  198. this.search(value, false);
  199. this.initData();
  200. }
  201. onSearch(value) {
  202. this.search({ keyword: value }, false);
  203. this.initData();
  204. }
  205. onSort(value) {
  206. const keys = Object.keys(value);
  207. // this.search({ order: keys.length ? keys.join('|') : null, direction: keys.length ? Object.values(value).join('|') : null });
  208. const { sortMap } = this.state;
  209. const index = keys.length > 1 && sortMap[keys[0]] ? 1 : 0;
  210. this.search({ order: keys.length && value[keys[index]] ? keys[index] : null, direction: keys.length ? value[keys[index]] : null }, false);
  211. this.initData();
  212. }
  213. onChangePage(page) {
  214. this.search({ page }, false);
  215. this.initData();
  216. }
  217. onAll(checked) {
  218. const { selectList } = this.state;
  219. const { list = [] } = this.state;
  220. if (checked) {
  221. list.forEach(item => {
  222. if (selectList.indexOf(item.key) >= 0) return;
  223. selectList.push(item.key);
  224. });
  225. } else {
  226. list.forEach(item => {
  227. const index = selectList.indexOf(item.key);
  228. if (index < 0) return;
  229. selectList.splice(index, 1);
  230. });
  231. }
  232. this.setState({ selectList, allChecked: checked });
  233. }
  234. onSelect(selectList) {
  235. this.setState({ selectList, allCheckbox: false });
  236. }
  237. onAction(key) {
  238. const { info } = this.props.user;
  239. const { selectList } = this.state;
  240. switch (key) {
  241. case 'help':
  242. this.setState({ showTips: true });
  243. return;
  244. case 'clear':
  245. if (selectList.length === 0) {
  246. this.setState({ showWarn: true, warn: { title: '移除', content: '不可少于1题,请重新选择' } });
  247. return;
  248. }
  249. this.setState({ showClearConfirm: true, clearInfo: { questionNoIds: selectList } });
  250. break;
  251. case 'group':
  252. if (!info.vip) {
  253. this.setState({ showVip: true });
  254. return;
  255. }
  256. if (selectList.length < 10) {
  257. this.setState({ showWarn: true, warn: { title: '组卷练习', content: '不可小于10题,请重新选择' } });
  258. return;
  259. }
  260. if (selectList.length > 50) {
  261. this.setState({ showWarn: true, warn: { title: '组卷练习', content: '不可多余50题,请重新选择' } });
  262. return;
  263. }
  264. if (selectList.length === 0) {
  265. this.setState({ showWarn: true, warn: { title: '组卷练习', content: '不可同时选中语文题和数学题,请重新选择。' } });
  266. return;
  267. }
  268. this.setState({ showGroupConfirm: true, groupInfo: { questionNoIds: selectList, filterTimes: 2 } });
  269. break;
  270. case 'export':
  271. if (!info.vip) {
  272. this.setState({ showVip: true });
  273. return;
  274. }
  275. if (selectList.length < 1) {
  276. this.setState({ showWarn: true, warn: { title: '导出', content: '不可小于1题,请重新选择' } });
  277. return;
  278. }
  279. if (selectList.length > 100) {
  280. this.setState({ showWarn: true, warn: { title: '导出', content: '不可多余100题,请重新选择' } });
  281. return;
  282. }
  283. if (info.bindReal) {
  284. this.setState({ showExportConfirm: true, exportInfo: { include: exportType.map(row => row.key), questionNoIds: selectList } });
  285. } else {
  286. this.setState({ showExportAuthConfirm: true, exportInfo: { include: exportType.filter(row => !row.auth).map(row => row.key), questionNoIds: selectList } });
  287. }
  288. break;
  289. default:
  290. }
  291. }
  292. clearCollectQuestion() {
  293. const { exportInfo } = this.state;
  294. My.clearQuestionCollect(exportInfo.questionNoIds)
  295. .then(() => {
  296. this.refresh();
  297. })
  298. .then(e => {
  299. this.setState({ showWarn: true, warn: { title: '移除', content: e.message }, showClearConfirm: false });
  300. });
  301. }
  302. group() {
  303. const { groupInfo } = this.state;
  304. My.groupQuestionCollect(groupInfo)
  305. .then((result) => {
  306. Question.startLink('collect', result);
  307. this.setState({ showGroupConfirm: false });
  308. })
  309. .catch(e => {
  310. this.setState({ showWarn: true, warn: { title: '组卷练习', content: e.message }, showGroupConfirm: false });
  311. });
  312. }
  313. export() {
  314. const { exportInfo } = this.state;
  315. this.setState({ showExportWait: true, showExportConfirm: false, showExportAuthConfirm: false });
  316. My.exportQuestionCollect(exportInfo)
  317. .then((result) => {
  318. openLink(`/export/${result}`);
  319. this.setState({ showExportWait: false });
  320. })
  321. .catch(e => {
  322. this.setState({ showWarn: true, warn: { title: '导出', content: e.message }, showExportWait: false });
  323. });
  324. }
  325. collectArticle(row, checked) {
  326. if (checked) {
  327. My.addExperienceCollect(row.id).then(() => {
  328. this.refresh();
  329. });
  330. } else {
  331. My.delExperienceCollect(row.id).then(() => {
  332. this.refresh();
  333. });
  334. }
  335. }
  336. prevArticle() {
  337. const { list, article } = this.state;
  338. let index = -1;
  339. list.forEach((row, i) => {
  340. if (row.id === article.id) {
  341. index = i;
  342. }
  343. });
  344. if (index === 0) return;
  345. this.setState({ article: list[index - 1] });
  346. }
  347. nextArticle() {
  348. const { list, article } = this.state;
  349. let index = -1;
  350. list.forEach((row, i) => {
  351. if (row.id === article.id) {
  352. index = i;
  353. }
  354. });
  355. if (index === list.length - 1) return;
  356. this.setState({ article: list[index + 1] });
  357. }
  358. renderView() {
  359. const { config } = this.props;
  360. return <UserLayout active={config.key} menu={menu} center={this.renderTable()} />;
  361. }
  362. renderTable() {
  363. const { tab } = this.state;
  364. return (
  365. <div className="table-layout">
  366. <Tabs
  367. border
  368. type="division"
  369. theme="theme"
  370. size="small"
  371. space={2.5}
  372. width={100}
  373. active={tab}
  374. tabs={[{ key: 'question', title: '题目' }, { key: 'article', title: '文章' }]}
  375. onChange={key => this.onTabChange(key)}
  376. />
  377. {this[`renderTab${tab}`]()}
  378. {this.renderModal()}
  379. </div>
  380. );
  381. }
  382. renderTabquestion() {
  383. const { info } = this.props.user;
  384. const {
  385. questionSubjectSelect,
  386. questionSubjectMap = {},
  387. moduleSelect,
  388. filterMap = {},
  389. sortMap = {},
  390. list = [],
  391. } = this.state;
  392. const { selectList = [], allChecked, page, total } = this.state;
  393. return (
  394. <div className="tab-1-layout">
  395. <UserAction
  396. search
  397. defaultSearch={filterMap.keyword}
  398. selectList={[
  399. {
  400. children: [
  401. {
  402. key: 'subject',
  403. placeholder: '学科',
  404. select: questionSubjectSelect,
  405. },
  406. {
  407. placeholder: '题型',
  408. key: 'questionType',
  409. be: 'subject',
  410. selectMap: questionSubjectMap,
  411. },
  412. ],
  413. },
  414. {
  415. label: '范围',
  416. key: 'module',
  417. select: moduleSelect,
  418. },
  419. {
  420. right: true,
  421. key: 'timerange',
  422. select: TimeRange,
  423. },
  424. ]}
  425. filterMap={filterMap}
  426. onFilter={value => this.onFilter(value)}
  427. onSearch={value => this.onSearch(value)}
  428. />
  429. <UserAction
  430. allCheckbox
  431. allChecked={allChecked}
  432. help
  433. btnList={[
  434. { title: '移除', key: 'clear' },
  435. { title: '组卷', key: 'group', tag: 'vip', disabled: !info.vip },
  436. { title: '导出', key: 'export', tag: 'vip', disabled: !info.vip },
  437. ]}
  438. onAll={checked => this.onAll(checked)}
  439. onAction={key => this.onAction(key)}
  440. />
  441. <UserTable
  442. select
  443. columns={this.columns}
  444. sortMap={sortMap}
  445. data={list}
  446. current={page}
  447. pageSize={this.state.search.size}
  448. total={total}
  449. selectList={selectList}
  450. onSelect={l => this.onSelect(l)}
  451. onSort={v => this.onSort(v)}
  452. onChange={p => this.onChangePage(p)}
  453. />
  454. </div>
  455. );
  456. }
  457. renderTabarticle() {
  458. const { filterMap = {}, sortMap = {}, list = [] } = this.state;
  459. return (
  460. <div className="tab-1-layout">
  461. <UserAction
  462. sortList={[
  463. {
  464. key: 'create_time',
  465. label: '收藏时间',
  466. },
  467. {
  468. key: 'update_time',
  469. label: '更新时间',
  470. },
  471. ]}
  472. sortMap={sortMap}
  473. filterMap={filterMap}
  474. onFilter={value => this.onFilter(value)}
  475. onSort={value => this.onSort(value)}
  476. />
  477. {list.map(item => {
  478. return <Article data={item} onClick={() => this.setState({ showDetail: true, article: item })} onUnCollect={() => this.collectArticle(item, false)} />;
  479. })}
  480. </div>
  481. );
  482. }
  483. renderModal() {
  484. const { article = {}, showTips, showWarn, warn = {}, showClearConfirm, clearInfo = {}, showGroupConfirm, groupInfo = {}, showExportConfirm, showExportAuthConfirm, exportInfo = {}, showExportWait, showExamination, showVip, showReal, showNote, note = {}, questionNo = {}, list } = this.state;
  485. const { info } = this.props.user;
  486. return [
  487. <ArticleDetail show={this.state.showDetail} data={article} onClose={() => this.setState({ showDetail: false })} onPrev={() => this.prevArticle()} onNext={() => this.nextArticle()} />,
  488. <Modal show={showTips} title="操作提示" confirmText="好的,知道了" btnAlign="center" onConfirm={() => this.setState({ showTips: false })}>
  489. <div className="flex-layout m-b-2">
  490. <div className="flex-block">
  491. <div className="t-1 t-s-18">组卷功能</div>
  492. <div className="t-2">操作数量:10-50;</div>
  493. <div className="t-2">注意事项:可跨题型、不可跨学科。</div>
  494. </div>
  495. <div className="flex-block">
  496. <div className="t-1 t-s-18">导出功能</div>
  497. <div className="t-2">操作数量:1-100;</div>
  498. <div className="t-2">注意事项:“综合推理IR”暂时无法导出。</div>
  499. </div>
  500. </div>
  501. <div className="t-3">
  502. *您可点击
  503. <Icon type="question-circle" theme="filled" />
  504. 查阅以上信息。
  505. </div>
  506. </Modal>,
  507. <Modal show={showWarn} title={warn.title} confirmText="好的,知道了" btnAlign="center" onConfirm={() => this.setState({ showWarn: false })}>
  508. <div className="t-2 t-s-18">{warn.content}</div>
  509. </Modal>,
  510. <Modal show={showGroupConfirm} title="组卷练习" confirmText="开始练习" onConfirm={() => this.group()} onCancel={() => this.setState({ showGroupConfirm: false })}>
  511. <div className="t-2 t-s-18">
  512. 您共选择了 <span className="t-4">{groupInfo.questionNoIds ? groupInfo.questionNoIds.length : 0}</span> 道题目,是否开始练习?
  513. </div>
  514. <div className="t-2 t-s-16">
  515. <Checkbox checked className="m-r-5" />
  516. 剔除已组卷练习 <Select
  517. theme="white"
  518. value={groupInfo.filterTimes}
  519. list={[{ key: 2, title: '2' }, { key: 3, title: '3' }]}
  520. onChange={({ key }) => {
  521. groupInfo.filterTimes = key;
  522. this.setState({ groupInfo });
  523. }}
  524. />{' '}
  525. 次以上的题
  526. </div>
  527. </Modal>,
  528. <Modal show={showClearConfirm} title="移出" onConfirm={() => this.clearCollectQuestion()} onCancel={() => this.setState({ showClearConfirm: false })}>
  529. <div className="t-2 t-s-18">
  530. 当前选中的 <span className="t-4">{clearInfo.questionNoIds ? clearInfo.questionNoIds.length : 0}</span> 道题即将被移出收藏,移出后无法恢复,是否继续?
  531. </div>
  532. </Modal>,
  533. <Modal show={showExportWait} title="导出" confirmText="好的,知道了" btnAlign="center" onConfirm={() => this.setState({ showExportWait: false })}>
  534. <div className="t-2 t-s-18">正在下载中,请不要关闭当前页面!</div>
  535. </Modal>,
  536. <Modal show={showExportConfirm} title="导出" confirmText="导出" onConfirm={() => this.export()} onCancel={() => this.setState({ showExportConfirm: false })}>
  537. <div className="t-2 t-s-18 m-b-5">
  538. 当前共选中 <span className="t-4">{exportInfo.questionNoIds ? exportInfo.questionNoIds.length : 0}</span> 道题,请确认需要导出的内容:
  539. </div>
  540. <div className="t-2 t-s-16">
  541. {exportType.map(item => {
  542. return (
  543. <div className="d-i-b m-b-5" style={{ width: 135 }}>
  544. <Checkbox checked={exportInfo.include ? exportInfo.include.indexOf(item.key) >= 0 : false} className="m-r-5" onChange={() => {
  545. const index = exportInfo.include.indexOf(item.key);
  546. if (index >= 0) {
  547. exportInfo.include.splice(index, 1);
  548. } else {
  549. exportInfo.include.push(item.key);
  550. }
  551. this.setState({ exportInfo });
  552. }} />
  553. {item.title}
  554. </div>
  555. );
  556. })}
  557. </div>
  558. </Modal>,
  559. <Modal show={showExportAuthConfirm} title="导出" confirmText="导出" onConfirm={() => this.export()} onCancel={() => this.setState({ showExportAuthConfirm: false })}>
  560. <div className="t-2 t-s-18 m-b-5">
  561. 当前共选中 <span className="t-4">{exportInfo.questionNoIds ? exportInfo.questionNoIds.length : 0}</span> 道题,请确认需要导出的内容:
  562. </div>
  563. <div className="t-2 t-s-16 m-b-2">
  564. {exportType
  565. .filter(item => !item.auth)
  566. .map(item => {
  567. return (
  568. <div className="d-i-b m-b-2" style={{ width: 135 }}>
  569. <Checkbox checked={exportInfo.include ? exportInfo.include.indexOf(item.key) >= 0 : false} className="m-r-5" onChange={() => {
  570. const index = exportInfo.include.indexOf(item.key);
  571. if (index >= 0) {
  572. exportInfo.include.splice(index, 1);
  573. } else {
  574. exportInfo.include.push(item.key);
  575. }
  576. this.setState({ exportInfo });
  577. }} />
  578. {item.title}
  579. </div>
  580. );
  581. })}
  582. </div>
  583. <div className="b-b m-b-2 m-t-2" />
  584. <div className="t-3 m-b-1">
  585. 以下内容需实名认证后才可导出: <a className="f-r" onClick={() => this.setState({ showExportAuthConfirm: false, showReal: true })}>去认证 ></a>
  586. </div>
  587. <div className="t-2 t-s-16 m-b-2">
  588. {exportType
  589. .filter(item => item.auth)
  590. .map(item => {
  591. return (
  592. <div className="d-i-b" style={{ width: 135 }}>
  593. <Checkbox disabled className="m-r-5" />
  594. {item.title}
  595. </div>
  596. );
  597. })}
  598. </div>
  599. </Modal>,
  600. <Examination
  601. show={showExamination}
  602. data={info}
  603. onConfirm={() => this.setState({ showExamination: false })}
  604. onCancel={() => this.setState({ showExamination: false })}
  605. onClose={() => this.setState({ showExamination: false })}
  606. />,
  607. <RealAuth show={showReal} data={info} onConfirm={() => this.setState({ showReal: false })} />,
  608. <VipRenew
  609. show={showVip}
  610. data={info}
  611. onReal={() => this.setState({ showVip: false, showReal: true })}
  612. onPrepare={() => this.setState({ showVip: false, showExamination: true })}
  613. onClose={(result) => {
  614. if (result) {
  615. this.refresh();
  616. } else {
  617. this.setState({ showVip: false });
  618. }
  619. }}
  620. />,
  621. <QuestionNoteModal show={showNote} defaultData={note} questionNo={questionNo} onConfirm={() => {
  622. list[this.state.index].note = true;
  623. this.setState({ showNote: false, list });
  624. }} onCancel={() => this.setState({ showNote: false })} />,
  625. ];
  626. }
  627. }
  628. class ArticleDetail extends Component {
  629. render() {
  630. const { show, data, onClose, onPrev, onNext } = this.props;
  631. return (
  632. <Modal
  633. className="article-detail-modal"
  634. body={false}
  635. show={show}
  636. width={720}
  637. maskClosable
  638. close={false}
  639. onClose={onClose}
  640. center
  641. >
  642. <Icon type="left" className="prev" onClick={() => onPrev && onPrev()} />
  643. <Icon type="right" className="next" onClick={() => onNext && onNext()} />
  644. <div className="t-1 t-s-20 m-b-5">{data.title}</div>
  645. <div className="t-1 t-s-12 m-b-2">
  646. <span className="m-r-2">{data.user ? data.user.nickname : data.nickname}</span>
  647. <span className="m-r-2">{PrepareStatusMap[data.prepareStatus]}</span>
  648. <span className="m-r-2">备考:{!!data.experienceDay && formatMonth(data.experienceDay, false)}</span>
  649. <span className="m-r-2">{data.experienceScore}分 /提分 {ExperiencePercentMap[data.experiencePercent]}</span>
  650. {data.link && <a className="t-4" href={data.link} target="_blank">更多信息</a>}
  651. </div>
  652. <div className="t-2 t-s-18 detail" dangerouslySetInnerHTML={{ __html: data.content }} />
  653. </Modal>
  654. );
  655. }
  656. }
  657. class Article extends Component {
  658. render() {
  659. const { data, onClick, onUnCollect } = this.props;
  660. return (
  661. <div className="article-item p-t-2 b-b" onClick={() => onClick && onClick()}>
  662. <div className="t-1 t-s-14 f-w-b">
  663. {data.title}
  664. <div className="f-r t-3 t-s-12 f-w-d">
  665. <span>{formatDate(data.updateTime, 'YYYY-MM-DD HH:mm:ss')}</span>
  666. <span className="m-l-2">阅读 {data.viewNumber}</span>
  667. <span className="m-l-2" onClick={(e) => {
  668. e.stopPropagation();
  669. onUnCollect();
  670. }}>取消收藏</span>
  671. </div>
  672. </div>
  673. <div className="t-1 t-s-12 m-b-2">
  674. <span className="m-r-2">{data.user ? data.user.nickname : data.nickname}</span>
  675. <span className="m-r-2">{PrepareStatusMap[data.prepareStatus]}</span>
  676. <span className="m-r-2">备考:{formatMonth(data.experienceDay, false)}</span>
  677. <span className="m-r-2">{data.experienceScore}分 /提分 {ExperiencePercentMap[data.experiencePercent]}</span>
  678. </div>
  679. <div className="t-2 m-b-2 detail" dangerouslySetInnerHTML={{ __html: data.content }} />
  680. </div>
  681. );
  682. }
  683. }