page.js 24 KB

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