page.js 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874
  1. import React, { Component } from 'react';
  2. import { Link } from 'react-router-dom';
  3. import './index.less';
  4. import { Icon, Popover } from 'antd';
  5. import FileUpload from '@src/components/FileUpload';
  6. import Page from '@src/containers/Page';
  7. import Assets from '@src/components/Assets';
  8. import { asyncSMessage } from '@src/services/AsyncTools';
  9. import { formatDate, formatSeconds, formatPercent } from '@src/services/Tools';
  10. import UserLayout from '../../../layouts/User';
  11. import Button from '../../../components/Button';
  12. import ProgressText from '../../../components/ProgressText';
  13. import IconButton from '../../../components/IconButton';
  14. import { Icon as GIcon } from '../../../components/Icon';
  15. import menu from '../index';
  16. import Tabs from '../../../components/Tabs';
  17. import UserTable from '../../../components/UserTable';
  18. import More from '../../../components/More';
  19. import Modal from '../../../components/Modal';
  20. import DatePlane from '../../../components/Date';
  21. import Note from '../../../components/Note';
  22. import { My } from '../../../stores/my';
  23. import { User } from '../../../stores/user';
  24. import { Question } from '../../../stores/question';
  25. import { Order } from '../../../stores/order';
  26. import { Common } from '../../../stores/common';
  27. export default class extends Page {
  28. initState() {
  29. return {
  30. tab: 'online',
  31. status: 'all',
  32. };
  33. }
  34. formatRecord(row) {
  35. if (row.useEndTime) {
  36. if (row.isSuspend && !row.restoreTime) {
  37. row.status = 'suspend';
  38. } else if (new Date(row.useEndTime).getTime() < new Date().getTime()) {
  39. row.status = 'end';
  40. } else {
  41. row.status = 'ing';
  42. }
  43. } else {
  44. row.status = 'not';
  45. }
  46. row.paperMap = {};
  47. row.appointmentPaperMap = {};
  48. if (row.papers) {
  49. row.papers.forEach(paper => {
  50. if (paper.courseNo) row.paperMap[paper.courseNo] = paper;
  51. if (paper.appointment) row.appointmentPaperMap[paper.appointment] = paper;
  52. });
  53. }
  54. row.progressMap = {};
  55. if (row.progress) {
  56. row.progress.forEach(progress => {
  57. row.progressMap[progress.courseNoId] = progress;
  58. });
  59. }
  60. row.courseNoMap = {};
  61. row.courseTime = 0;
  62. if (row.courseNos) {
  63. row.courseNos.forEach(no => {
  64. row.courseNoMap[no.id] = no;
  65. row.courseTime += no.time;
  66. no.paper = row.paperMap[no.id];
  67. no.progress = row.progressMap[no.id];
  68. });
  69. }
  70. if (row.currentNo) {
  71. row.currentCourseNo = row.courseNoMap[row.currentNo];
  72. } else {
  73. row.currentNo = 0;
  74. }
  75. // 如果已经最新预约结束,则添加一个空记录作为最新预约
  76. if (row.appointments) {
  77. row.appointments.forEach(r => {
  78. r.paper = row.appointmentPaperMap[r.id];
  79. r.noteList = (row.comments || []).filter(c => c.type === 'note' && c.appointmentId === r.id);
  80. r.supplyList = (row.comments || []).filter(c => c.type === 'supply' && c.appointmentId === r.id);
  81. });
  82. // 是否是最后一课时,是否过预约时间
  83. const last = row.appointments.length - 1;
  84. const appointment = row.appointments[last];
  85. if (new Date(appointment.endTime).getTime() < new Date().getTime()) {
  86. // row.status = 'end';
  87. if (row.number !== row.appointments.length) {
  88. row.appointments.push([{}]);
  89. }
  90. }
  91. }
  92. row.days = new Date(row.userEndTime);
  93. return row;
  94. }
  95. initData() {
  96. const data = Object.assign(this.state, this.state.search);
  97. data.filterMap = this.state.search;
  98. if (data.order) {
  99. data.sortMap = { [data.order]: data.direction };
  100. }
  101. this.setState(data);
  102. let isUsed = null;
  103. let isEnd = null;
  104. switch (data.status) {
  105. case 'learning':
  106. isUsed = true;
  107. isEnd = false;
  108. break;
  109. case 'end':
  110. isUsed = true;
  111. isEnd = true;
  112. break;
  113. case 'nouse':
  114. isUsed = false;
  115. isEnd = false;
  116. break;
  117. case 'all':
  118. default:
  119. }
  120. My.listCourse(Object.assign({ courseModule: data.tab }, this.state.search, { isUsed, isEnd })).then(result => {
  121. result.list = result.list.map(row => {
  122. return this.formatRecord(row);
  123. });
  124. this.setState({ list: result.list, total: result.total, page: data.page });
  125. });
  126. }
  127. onAction() { }
  128. onTabChange(tab) {
  129. const data = { tab };
  130. this.refreshQuery(data);
  131. }
  132. onStatusChange(status) {
  133. this.search({ status });
  134. }
  135. openTime(record) {
  136. if (record.courseTimeMap) {
  137. this.setState({ data: record, showTime: true });
  138. return;
  139. }
  140. My.timeCourse(record.id).then(result => {
  141. const courseMap = {};
  142. const previewMap = {};
  143. const stopMap = {};
  144. result.forEach(row => {
  145. const date = formatDate(row.day, 'YYYY-MM-DD');
  146. if (row.type === 'stop') {
  147. stopMap[date] = true;
  148. } else if (row.type === 'preview') {
  149. previewMap[date] = true;
  150. } else if (row.type === 'course') {
  151. courseMap[date] = true;
  152. }
  153. });
  154. record.courseTimeMap = courseMap;
  155. record.previewTimeMap = previewMap;
  156. record.stopTimeMap = stopMap;
  157. this.setState({ data: record, showTime: true });
  158. });
  159. }
  160. refreshDetail(recordId) {
  161. My.detailCourse(recordId).then(result => {
  162. let { list } = this.state;
  163. list = list.map(row => {
  164. if (row.id === recordId) return this.formatRecord(result);
  165. return row;
  166. });
  167. this.setState({ list });
  168. });
  169. }
  170. suspend() {
  171. const { suspend } = this.state;
  172. My.suspendCourse(suspend.id)
  173. .then(() => {
  174. asyncSMessage('停课成功');
  175. this.setState({ showSuspend: false });
  176. this.refreshDetail(suspend.id);
  177. })
  178. .catch(err => {
  179. asyncSMessage(err.message, 'error');
  180. });
  181. }
  182. restore() {
  183. const { restore } = this.state;
  184. My.restoreCourse(restore.id)
  185. .then(() => {
  186. asyncSMessage('恢复成功');
  187. this.setState({ showRestore: false });
  188. this.refreshDetail(restore.id);
  189. })
  190. .catch(err => {
  191. asyncSMessage(err.message, 'error');
  192. });
  193. }
  194. submitAppointmentComment(data, type) {
  195. data.type = type;
  196. if (data.id) {
  197. My.editAppointmentComment(data).then(() => {
  198. this.refreshDetail(data.recordId);
  199. });
  200. } else {
  201. My.addAppointmentComment(data).then(() => {
  202. this.refreshDetail(data.recordId);
  203. });
  204. }
  205. }
  206. deleteAppointmentComment(row) {
  207. My.delAppointmentComment(row.id).then(() => {
  208. this.refreshDetail(row.recordId);
  209. });
  210. }
  211. submitQuestionFile(data) {
  212. My.uploadAppointmentQuestion(data).then(() => {
  213. this.refreshDetail(data.recordId);
  214. });
  215. }
  216. setCCTalkName(recordId, cctalkname) {
  217. My.setCCTalkName(recordId, cctalkname).then(() => {
  218. this.refreshDetail(recordId);
  219. });
  220. }
  221. submitComment() {
  222. const { comment } = this.state;
  223. My.addComment(comment.channel, comment.position, comment.content).then(() => {
  224. this.setState({ showComment: false, showFinish: true, comment: {} });
  225. });
  226. }
  227. open(recordId) {
  228. Order.useRecord(recordId).then(() => {
  229. this.refreshDetail(recordId);
  230. });
  231. }
  232. closeCommentTips(recordId) {
  233. My.courseCommentTips(recordId);
  234. }
  235. uploadNote(file) {
  236. const { note = {} } = this.state;
  237. Common.uploadImage(file).then(result => {
  238. note.file = result.url;
  239. note.name = file.name;
  240. this.setState({ note });
  241. });
  242. }
  243. uploadSupply(file) {
  244. const { supply = {} } = this.state;
  245. Common.uploadImage(file).then(result => {
  246. supply.file = result.url;
  247. supply.name = file.name;
  248. this.setState({ supply });
  249. });
  250. }
  251. renderView() {
  252. const { config } = this.props;
  253. return <UserLayout active={config.key} menu={menu} center={this.renderDetail()} />;
  254. }
  255. renderDetail() {
  256. const {
  257. tab,
  258. status,
  259. showTips,
  260. showTime,
  261. showSuspend,
  262. showRestore,
  263. showUploadNote,
  264. showUploadSupply,
  265. showSupply,
  266. showNote,
  267. showComment,
  268. showFinish,
  269. comment = {},
  270. data = {},
  271. note = {},
  272. supply = {},
  273. appointment = {},
  274. } = this.state;
  275. return (
  276. <div className="detail-layout">
  277. <div hidden={!showTips} className="tip">
  278. <div className="text">理清备考思路,避开常见误区,让学习的每一分钟发光发热!</div>
  279. <a href="" target="_blank">
  280. 去填写 >
  281. </a>
  282. <Icon type="close-circle" theme="filled" onClick={() => this.setState({ showTips: false })} />
  283. </div>
  284. <Tabs
  285. type="division"
  286. theme="theme"
  287. size="small"
  288. space={2.5}
  289. width={100}
  290. active={tab}
  291. tabs={[{ key: 'online', title: '在线课程' }, { key: 'vs', title: '1V1私教' }]}
  292. onChange={key => this.onTabChange(key)}
  293. />
  294. <Tabs
  295. type="tag"
  296. theme="white"
  297. size="small"
  298. space={5}
  299. width={54}
  300. active={status}
  301. tabs={[
  302. { key: 'all', title: '全部' },
  303. { key: 'nouse', title: '未开通' },
  304. { key: 'learning', title: '学习中' },
  305. { key: 'end', title: '已结束' },
  306. ]}
  307. onChange={key => this.onStatusChange(key)}
  308. />
  309. {this[`renderTab${tab}`]()}
  310. <Modal
  311. show={showTime}
  312. className="clock-modal"
  313. title="打卡表"
  314. width={460}
  315. onClose={() => this.setState({ showTime: false })}
  316. >
  317. <div>
  318. <div className="d-i-b w-3">
  319. <div className="t-2 t-s-14">听课频率</div>
  320. <div className="t-4 t-s-18">{data.currentNo ? data.totalDays / data.currentNo : 0}天/课时</div>
  321. </div>
  322. <div className="d-i-b w-3">
  323. <div className="t-2 t-s-14">作业完成度</div>
  324. <div className="t-4 t-s-18">{data.previewProgress || 0}%</div>
  325. </div>
  326. </div>
  327. <div className="b-b m-t-1 m-b-1" />
  328. <div className="m-b-1">
  329. <div className="tag d-i-b t-s-16">
  330. <i style={{ background: '#6865FD' }} />
  331. 听课
  332. </div>
  333. <div className="tag d-i-b t-s-16">
  334. <i style={{ background: '#4299FF' }} />
  335. 预习
  336. </div>
  337. <div className="tag d-i-b t-s-16">
  338. <i style={{ background: '#E7E7E7' }} />
  339. 停课
  340. </div>
  341. </div>
  342. <DatePlane
  343. hideInput
  344. show={showTime}
  345. onChange={() => { }}
  346. disabledDate={current => {
  347. const date = current.format('YYYY-MM-DD');
  348. return data.stopTimeMap[date];
  349. }}
  350. dateRender={current => {
  351. const date = current.format('YYYY-MM-DD');
  352. return (
  353. <div className="ant-calendar-date">
  354. {current.get('date')}
  355. {data.courseTimeMap[date] && <i className="s1" style={{ background: '#6865FD' }} />}
  356. {data.previewTimeMap[date] && <i className="s2" style={{ background: '#4299FF' }} />}
  357. </div>
  358. );
  359. }}
  360. checkRefresh={(date, refresh) => {
  361. setTimeout(() => {
  362. refresh();
  363. }, 2000);
  364. return true;
  365. }}
  366. />
  367. <div className="t-2 t-s-12">*听课频率≤2天/课时,作业完成度≥90%,课程有效期可延长7-10天。</div>
  368. </Modal>
  369. <Modal
  370. show={showComment}
  371. title="评价"
  372. onConfirm={() => comment.content && this.submitComment()}
  373. onCancel={() => this.setState({ showComment: false, comment: {} })}
  374. >
  375. <textarea
  376. value={comment.content}
  377. className="b-c-1 w-10 p-10"
  378. rows={6}
  379. placeholder="您的看法对我们来说很重要!"
  380. onChange={e => {
  381. comment.content = e.target.value;
  382. this.setState({ comment });
  383. }}
  384. />
  385. <div className="b-b m-t-2" />
  386. </Modal>
  387. <Modal
  388. show={showFinish}
  389. title="提交成功"
  390. confirmText="好的,知道了"
  391. btnAlign="center"
  392. onConfirm={() => this.setState({ showFinish: false })}
  393. >
  394. <div className="t-2 t-s-18">
  395. <Icon type="check" className="t-5 m-r-5" />
  396. 您的每一次反馈都是千行进步的动力。
  397. </div>
  398. </Modal>
  399. <Modal
  400. show={showSuspend}
  401. title="申请停课"
  402. width={630}
  403. confirmText="立即停课"
  404. onConfirm={() => this.suspend()}
  405. onCancel={() => this.setState({ showSuspend: false })}
  406. >
  407. <div className="t-2 t-s-18">最长停课周期为1个月,到期后系统自动恢复至“学习中”状态。</div>
  408. <div className="t-2 t-s-18">每门课程只有一次申请机会,是否需要停课?</div>
  409. <div style={{ bottom: 20, left: 0 }} className="p-a t-3 t-s-14">
  410. *停课不影响听课频率的计算;
  411. </div>
  412. <div style={{ bottom: 0, left: 0 }} className="p-a t-3 t-s-14">
  413. {' '}
  414. 停课期间可随时恢复学习。
  415. </div>
  416. </Modal>
  417. <Modal
  418. show={showRestore}
  419. title="恢复学习"
  420. width={630}
  421. confirmText="立即恢复"
  422. onConfirm={() => this.restore()}
  423. onCancel={() => this.setState({ showRestore: false })}
  424. >
  425. <div className="t-2 t-s-18">恢复学习后,本课程的停课功能将无法使用。是否恢复学习?</div>
  426. </Modal>
  427. <Modal
  428. show={showUploadNote}
  429. title="上传笔记"
  430. width={630}
  431. confirmText="提交"
  432. onConfirm={() => this.submitAppointmentComment(note, 'note')}
  433. onCancel={() => this.setState({ showUploadNote: false, note: {} })}
  434. >
  435. <textarea
  436. className="b-c-1 w-10 p-10 m-b-1"
  437. rows={6}
  438. value={note.content}
  439. placeholder="请输入留言内容。"
  440. onChange={e => {
  441. note.content = e.target.value;
  442. this.setState({ note });
  443. }}
  444. />
  445. <div className={`t-c drag-upload ${this.state.draging ? 'draging' : ''}`}>
  446. <Button theme="file">上传文件</Button>
  447. <span className="m-l-1 t-3 t-s-14">
  448. {note.file ? `上传文件:${note.name} 成功` : '支持 docx, xls, PDF, rar, zip, PNG, JPG 等类型的文件'}
  449. </span>
  450. <div className="fixed">
  451. <span className="f-w-b t-s-18">放开文件立刻上传</span>
  452. </div>
  453. <FileUpload
  454. type="none"
  455. onDragEnter={() => this.setState({ draging: true })}
  456. onDragLeave={() => this.setState({ draging: false })}
  457. onUpload={({ file }) => {
  458. Common.upload(file).then(result => {
  459. note.file = result.url;
  460. note.name = file.name;
  461. this.setState({ note });
  462. });
  463. }}
  464. />
  465. </div>
  466. <div className="b-b m-t-2" />
  467. </Modal>
  468. <Modal
  469. show={showNote}
  470. title="课后笔记"
  471. width={500}
  472. height={500}
  473. onClose={() => this.setState({ showNote: false })}
  474. >
  475. {appointment.noteList &&
  476. appointment.noteList.map(row => {
  477. return <Note user={this.props.user} teacher={data.teacher} data={row} />;
  478. })}
  479. </Modal>
  480. <Modal
  481. show={showSupply}
  482. title="课后留言"
  483. width={500}
  484. height={500}
  485. onClose={() => this.setState({ showSupply: false })}
  486. >
  487. {appointment.supplyList &&
  488. appointment.supplyList.map(row => {
  489. return <Note user={this.props.user} teacher={data.teacher} data={row} />;
  490. })}
  491. </Modal>
  492. <Modal
  493. show={showUploadSupply}
  494. title="上传留言"
  495. width={630}
  496. confirmText="提交"
  497. onConfirm={() => this.submitAppointmentComment(supply, 'supply')}
  498. onCancel={() => this.setState({ showUploadSupply: false, supply: {} })}
  499. >
  500. <textarea
  501. className="b-c-1 w-10 p-10 m-b-1"
  502. rows={6}
  503. value={supply.content}
  504. placeholder="请输入留言内容。"
  505. onChange={e => {
  506. supply.content = e.target.value;
  507. this.setState({ supply });
  508. }}
  509. />
  510. <div className={`t-c drag-upload ${this.state.draging ? 'draging' : ''}`}>
  511. <Button theme="file">上传文件</Button>
  512. <span className="m-l-1 t-3 t-s-14">
  513. {supply.file ? `上传文件:${supply.name} 成功` : '支持 docx, xls, PDF, rar, zip, PNG, JPG 等类型的文件'}
  514. </span>
  515. <div className="fixed">
  516. <span className="f-w-b t-s-18">放开文件立刻上传</span>
  517. </div>
  518. <FileUpload
  519. type="none"
  520. onDragEnter={() => this.setState({ draging: true })}
  521. onDragLeave={() => this.setState({ draging: false })}
  522. onUpload={({ file }) => {
  523. Common.upload(file).then(result => {
  524. supply.file = result.url;
  525. supply.name = file.name;
  526. this.setState({ supply });
  527. });
  528. }}
  529. />
  530. </div>
  531. <div className="b-b m-t-2" />
  532. </Modal>
  533. </div>
  534. );
  535. }
  536. renderTabonline() {
  537. const { list = [] } = this.state;
  538. return list.map(item => {
  539. return (
  540. <CourseOnline
  541. data={item}
  542. user={this.props.user}
  543. refreshDetail={recordId => {
  544. this.refreshDetail(recordId);
  545. }}
  546. onRestore={() => {
  547. this.setState({ showRestore: true, restore: item });
  548. }}
  549. onSuspend={() => {
  550. this.setState({ showSuspend: true, suspend: item });
  551. }}
  552. onTime={() => {
  553. this.openTime(item);
  554. }}
  555. onComment={() => {
  556. this.setState({ showComment: true, comment: { channel: 'course-video', position: item.course.id } });
  557. }}
  558. closeCommentTips={() => this.closeCommentTips(item.id)}
  559. />
  560. );
  561. });
  562. }
  563. renderTabvs() {
  564. const { list = [] } = this.state;
  565. return list.map(item => {
  566. return (
  567. <CourseVs
  568. data={item}
  569. user={this.props.user}
  570. refreshDetail={recordId => {
  571. this.refreshDetail(recordId);
  572. }}
  573. onRestore={() => {
  574. this.setState({ showRestore: true, restore: item });
  575. }}
  576. onSuspend={() => {
  577. this.setState({ showSuspend: true, suspend: item });
  578. }}
  579. onComment={() => {
  580. this.setState({ showComment: true, comment: { channel: 'course-vs', position: item.course.id } });
  581. }}
  582. closeCommentTips={() => this.closeCommentTips(item.id)}
  583. onUploadNote={(appointment, row) => {
  584. this.setState({ showUploadNote: true, appointment, data: item, note: row || {} });
  585. }}
  586. onUploadSupply={(appointment, row) => {
  587. this.setState({ showUploadSupply: true, appointment, data: item, supply: row || {} });
  588. }}
  589. onDeleteNote={(appointment, row) => this.deleteAppointmentComment(row)}
  590. onDeleteSupply={(appointment, row) => this.deleteAppointmentComment(row)}
  591. onNote={appointment => this.setState({ showNote: true, appointment, data: item })}
  592. onSupply={appointment => this.setState({ showSupply: true, appointment, data: item })}
  593. onUploadQuestion={(appointment, file, name) => {
  594. this.submitQuestionFile({
  595. id: appointment.id,
  596. recordId: appointment.recordId,
  597. questionFile: file,
  598. questionFileName: name,
  599. });
  600. }}
  601. setCCTalkName={(appointment, cctalkName) => this.setCCTalkName(appointment.recordId, cctalkName)}
  602. />
  603. );
  604. });
  605. }
  606. }
  607. class CourseOnline extends Component {
  608. constructor(props) {
  609. super(props);
  610. this.columns = [
  611. {
  612. title: '学习内容',
  613. key: 'title',
  614. render: (text, record) => {
  615. return `课时 ${record.no}: ${text}`;
  616. },
  617. },
  618. {
  619. title: '预习作业',
  620. key: 'paper',
  621. render: text => {
  622. text = text || {};
  623. const progress = text.report ? formatPercent(text.report.userNumber, text.report.questionNumber) : 0;
  624. const times = text.paper ? text.paper.times : 0;
  625. return (
  626. <div>
  627. <div className="v-a-m d-i-b">
  628. <ProgressText width={50} size="small" times={times} progress={progress} unit="次" />
  629. </div>
  630. {!text.report && (
  631. <IconButton
  632. className="m-l-2"
  633. type="start"
  634. tip="Start"
  635. onClick={() => {
  636. User.needLogin().then(() => {
  637. Question.startLink('preview', text);
  638. });
  639. }}
  640. />
  641. )}
  642. {text.report && !text.report.isFinish && (
  643. <IconButton
  644. className="m-l-2"
  645. type="continue"
  646. tip="Continue"
  647. onClick={() => {
  648. User.needLogin().then(() => {
  649. Question.continueLink('preview', text);
  650. });
  651. }}
  652. />
  653. )}
  654. {text.report && !!text.report.isFinish && (
  655. <IconButton
  656. className="m-l-2"
  657. type="restart"
  658. tip="Restart"
  659. onClick={() => {
  660. User.needLogin().then(() => {
  661. Question.restart('preview', text);
  662. });
  663. }}
  664. />
  665. )}
  666. {text.report && !!text.report.isFinish && (
  667. <IconButton
  668. className="m-l-5"
  669. type="report"
  670. tip="Report"
  671. onClick={() => {
  672. User.needLogin().then(() => {
  673. Question.reportLink('preview', text);
  674. });
  675. }}
  676. />
  677. )}
  678. </div>
  679. );
  680. },
  681. },
  682. {
  683. title: '进度',
  684. key: 'progress',
  685. render: (text, record) => {
  686. const { paper = {} } = record;
  687. return `${paper.paper && paper.paper.times > 0 ? `${paper.paper.times}次+` : ''}${
  688. paper.report ? formatPercent(paper.report.userNumber, paper.report.questionNumber, false) : '0%'}`;
  689. },
  690. },
  691. {
  692. title: '最近学习',
  693. key: 'lastTime',
  694. render: (text, record) => {
  695. const { paper = {} } = record;
  696. return paper.report && formatDate(paper.report.updateTime, 'YYYY-MM-DD HH:mm:ss');
  697. },
  698. },
  699. {
  700. title: '笔记',
  701. key: 'note',
  702. render: (text, record) => {
  703. return <GIcon name="note" active={record.note} />;
  704. },
  705. },
  706. {
  707. title: '问答',
  708. key: 'ask',
  709. render: (text, record) => {
  710. return (
  711. <Link to={`/course/ask/${record.courseId}?no=${record.id}`}>{`${record.answerNumber ||
  712. 0}/${record.askNumber || 0}`}</Link>
  713. );
  714. },
  715. },
  716. ];
  717. this.state = { open: props.data.status === 'ing' };
  718. }
  719. render() {
  720. const { data = {} } = this.props;
  721. switch (data.status) {
  722. case 'ing':
  723. return this.renderIng();
  724. case 'not':
  725. return this.renderNot();
  726. case 'end':
  727. return this.renderEnd();
  728. case 'suspend':
  729. return this.renderSuspend();
  730. default:
  731. return <div />;
  732. }
  733. }
  734. renderIng() {
  735. const { data, onTime, onComment, onSuspend } = this.props;
  736. const { open } = this.state;
  737. return (
  738. <div className="course-item ing">
  739. <div className="title">
  740. <div className="tag">学习中</div>
  741. <div className="text">{data.course.title}</div>
  742. <div className="right">
  743. <More
  744. menu={[{ label: '评价', key: 'comment' }, { label: '停课', key: 'suspend' }]}
  745. onClick={value => {
  746. const { key } = value;
  747. if (key === 'comment') {
  748. onComment();
  749. } else if (key === 'suspend') {
  750. onSuspend();
  751. }
  752. }}
  753. />
  754. </div>
  755. </div>
  756. {data.currentCourseNo && (
  757. <div
  758. className="continue"
  759. onClick={() => {
  760. linkTo(`/course/detail/${data.course.id}`);
  761. }}
  762. >
  763. <Assets name="notice" />
  764. 继续学习:课时 {data.currentNo}:{data.currentCourseNo.title}
  765. </div>
  766. )}
  767. <div className="detail">
  768. <div className="left">
  769. <Assets name="sun_blue" src={data.course.cover} />
  770. <div className="info">
  771. <div className="t1">授课老师</div>
  772. <div className="t2">{data.course.teacher}</div>
  773. <div className="t1">有效期</div>
  774. <div className="t2">{data.useExpireDays}Days</div>
  775. </div>
  776. </div>
  777. <div className="right">
  778. <div className="item">
  779. <GIcon name="speed-block" active noHover />
  780. <div className="text">
  781. <span>{data.currentNo}</span>/{data.courseNos.length}
  782. </div>
  783. </div>
  784. <div className="item">
  785. <GIcon name="question-block" active noHover />
  786. <div className="text">
  787. <span>{data.answerNumber}</span>/{data.askNumber}
  788. </div>
  789. </div>
  790. <div className="item" onClick={() => onTime()}>
  791. <GIcon name="clockin-block" active noHover />
  792. <div className="text">
  793. <span>{formatSeconds(data.totalTime)}</span> {data.previewProgress || 0}%
  794. </div>
  795. </div>
  796. <div className="item">
  797. <GIcon name="note-block" active noHover />
  798. <div className="text">{data.noteNumber}</div>
  799. </div>
  800. </div>
  801. <div className="open">
  802. <GIcon name={open ? 'up' : 'down'} onClick={() => this.setState({ open: !open })} />
  803. </div>
  804. </div>
  805. {open && this.renderTable()}
  806. </div>
  807. );
  808. }
  809. renderNot() {
  810. const { data } = this.props;
  811. return (
  812. <div className="course-item not">
  813. <div className="title">
  814. <div className="tag">未开通</div>
  815. <div className="text">{data.course.title}</div>
  816. </div>
  817. <div className="detail">
  818. <div className="left">
  819. <Assets name="sun_blue" src={data.course.cover} />
  820. <div className="info">
  821. <div className="t1">授课老师</div>
  822. <div className="t2">{data.course.teacher}</div>
  823. <div>
  824. <div className="d-i-b m-r-2">
  825. <div className="t-2">课时</div>
  826. <div className="t-1 t-s-16">{data.courseNos.length}</div>
  827. </div>
  828. <div className="d-i-b">
  829. <div className="t-2">总时长</div>
  830. <div className="t-1 t-s-16">{formatSeconds(data.courseTime)}</div>
  831. </div>
  832. </div>
  833. </div>
  834. </div>
  835. <div className="right t-c">
  836. <div className="text">请于 {formatDate(data.endTime, 'YYYY-MM-DD')} 前开通</div>
  837. <Button
  838. size="lager"
  839. radius
  840. onClick={() => {
  841. this.open(data.id);
  842. }}
  843. >
  844. 立即开通
  845. </Button>
  846. </div>
  847. </div>
  848. </div>
  849. );
  850. }
  851. renderEnd() {
  852. const { data, onTime, onComment } = this.props;
  853. const { open } = this.state;
  854. return (
  855. <div className="course-item end">
  856. <div className="title">
  857. <div className="tag">已结束</div>
  858. <div className="text">{data.course.title}</div>
  859. <div className="right">
  860. <More
  861. menu={[{ label: '评价', key: 'comment' }]}
  862. onClick={value => {
  863. const { key } = value;
  864. if (key === 'comment') {
  865. onComment();
  866. }
  867. }}
  868. />
  869. </div>
  870. </div>
  871. <div className="detail">
  872. <div className="left">
  873. <Assets name="sun_blue" src={data.course.cover} />
  874. <div className="info">
  875. <div className="t1">授课老师</div>
  876. <div className="t2">{data.course.teacher}</div>
  877. <div className="t1">有效期</div>
  878. <div className="t-s-12">
  879. {formatDate(data.useStartTime, 'YYYY-MM-DD')}
  880. <br />至{formatDate(data.useEndTime, 'YYYY-MM-DD')}
  881. </div>
  882. </div>
  883. </div>
  884. <div className="right">
  885. <div className="item">
  886. <GIcon name="question-block" active noHover />
  887. <div className="text">
  888. <span>{data.answerNumber}</span>/{data.askNumber}
  889. </div>
  890. </div>
  891. <div className="item" onClick={() => onTime()}>
  892. <GIcon name="clockin-block" active noHover />
  893. <div className="text">
  894. <span>{formatSeconds(data.totalTime)}</span> {data.previewProgress || 0}%
  895. </div>
  896. </div>
  897. <div className="item">
  898. <GIcon name="note-block" active noHover />
  899. <div className="text">{data.noteNumber}</div>
  900. </div>
  901. {data.courseAward > 0 && (
  902. <div className="item">
  903. <GIcon name="gift-block" active />
  904. <div className="text">赠送{data.courseAward}天</div>
  905. </div>
  906. )}
  907. </div>
  908. <div className="open">
  909. <GIcon name={open ? 'up' : 'down'} onClick={() => this.setState({ open: !open })} />
  910. </div>
  911. </div>
  912. {open && this.renderTable()}
  913. </div>
  914. );
  915. }
  916. renderSuspend() {
  917. const { data, onTime, onRestore, onComment } = this.props;
  918. const { open } = this.state;
  919. return (
  920. <div className="course-item end">
  921. <div className="title">
  922. <div className="tag">已停课</div>
  923. <div className="text">
  924. {data.course.title}
  925. <Button size="small" radius onClick={() => onRestore()}>
  926. 恢复上课
  927. </Button>
  928. </div>
  929. <div className="t-s-12">
  930. <span className="t-3">申请时间:</span>
  931. <span className="t-2 m-r-1">{formatDate(data.suspendTime, 'YYYY-MM-DD HH:mm:ss')}</span>
  932. <span className="t-3">已停课:</span>
  933. <span>{parseInt((new Date().getTime() - new Date(data.suspendTime).getTime()) / 86400000, 10)}Days/30</span>
  934. </div>
  935. <div className="right">
  936. <More
  937. menu={[{ label: '评价', key: 'comment' }]}
  938. onClick={value => {
  939. const { key } = value;
  940. if (key === 'comment') {
  941. onComment();
  942. }
  943. }}
  944. />
  945. </div>
  946. </div>
  947. <div className="detail">
  948. <div className="left">
  949. <Assets name="sun_blue" src={data.course.cover} />
  950. <div className="info">
  951. <div className="t1">授课老师</div>
  952. <div className="t2">{data.course.teacher}</div>
  953. <div className="t1">有效期</div>
  954. <div className="t2">{data.useExpireDays}Days</div>
  955. </div>
  956. </div>
  957. <div className="right">
  958. <div className="item">
  959. <GIcon name="speed-block" noHover />
  960. <div className="text">
  961. <span>{data.currentNo}</span>/{data.courseNos.length}
  962. </div>
  963. </div>
  964. <div className="item">
  965. <GIcon name="question-block" active noHover />
  966. <div className="text">
  967. <span>{data.answerNumber}</span>/{data.askNumber}
  968. </div>
  969. </div>
  970. <div className="item" onClick={() => onTime()}>
  971. <GIcon name="clockin-block" active noHover />
  972. <div className="text">
  973. <span>{formatSeconds(data.totalTime)}</span> {data.previewProgress || 0}%
  974. </div>
  975. </div>
  976. <div className="item">
  977. <GIcon name="note-block" active noHover />
  978. <div className="text">{data.noteNumber}</div>
  979. </div>
  980. </div>
  981. <div className="open">
  982. <GIcon name={open ? 'up' : 'down'} onClick={() => this.setState({ open: !open })} />
  983. </div>
  984. </div>
  985. {open && this.renderTable()}
  986. </div>
  987. );
  988. }
  989. renderTable() {
  990. const { data = {} } = this.props;
  991. const { courseNos = [] } = data;
  992. return <UserTable size="small" columns={this.columns} data={courseNos} />;
  993. }
  994. }
  995. const titleMap = {
  996. 1: '预约时间',
  997. 2: '答疑文档',
  998. 3: '上课',
  999. 4: '课后笔记',
  1000. 5: '课后补充',
  1001. 6: '备考信息',
  1002. 7: '完成作业',
  1003. };
  1004. const iconMap = {
  1005. 1: 'time-icon',
  1006. 2: 'QA-icon',
  1007. 3: 'class-icon',
  1008. 4: 'note-icon',
  1009. 5: 'supplement-icon',
  1010. 6: 'information-icon',
  1011. 7: 'homework-icon',
  1012. };
  1013. const statusMap = {
  1014. 1: appointment => {
  1015. if (!appointment.id) return 'end';
  1016. return '';
  1017. },
  1018. 2: appointment => {
  1019. if (!appointment.questionFile) return 'not';
  1020. return '';
  1021. },
  1022. 3: (appointment, data) => {
  1023. if (!data.cctalkName) return 'not';
  1024. // if (new Date(appointment.endTime).getTime() > new Date()) return 'not';
  1025. return '';
  1026. },
  1027. 4: appointment => {
  1028. if (!appointment.noteList || appointment.noteList.length === 0) return 'not';
  1029. return '';
  1030. },
  1031. 5: appointment => {
  1032. if (!appointment.supplyList || appointment.supplyList.length === 0) return 'not';
  1033. return '';
  1034. },
  1035. 6: () => {
  1036. return '';
  1037. },
  1038. 7: appointment => {
  1039. const { paper = {} } = appointment;
  1040. if (!paper.report || formatPercent(paper.report.userNumber, paper.report.questionNumber) < 100) return 'not';
  1041. return '';
  1042. },
  1043. };
  1044. class CourseVs extends Component {
  1045. constructor(props) {
  1046. super(props);
  1047. this.columns = {
  1048. system: [
  1049. { title: '学习内容', key: 'title' },
  1050. {
  1051. title: '预习作业',
  1052. key: 'paper',
  1053. render: text => {
  1054. text = text || {};
  1055. const progress = text.report ? formatPercent(text.report.userNumber, text.report.questionNumber) : 0;
  1056. const times = text.paper ? text.paper.times : 0;
  1057. return (
  1058. <div>
  1059. <div className="v-a-m d-i-b">
  1060. <ProgressText width={50} size="small" times={times} progress={progress} unit="次" />
  1061. </div>
  1062. {!text.report && (
  1063. <IconButton
  1064. className="m-l-2"
  1065. type="start"
  1066. tip="Start"
  1067. onClick={() => {
  1068. User.needLogin().then(() => {
  1069. Question.startLink('preview', text);
  1070. });
  1071. }}
  1072. />
  1073. )}
  1074. {text.report && !text.report.isFinish && (
  1075. <IconButton
  1076. className="m-l-2"
  1077. type="continue"
  1078. tip="Continue"
  1079. onClick={() => {
  1080. User.needLogin().then(() => {
  1081. Question.continueLink('preview', text);
  1082. });
  1083. }}
  1084. />
  1085. )}
  1086. {text.report && !!text.report.isFinish && (
  1087. <IconButton
  1088. className="m-l-2"
  1089. type="restart"
  1090. tip="Restart"
  1091. onClick={() => {
  1092. User.needLogin().then(() => {
  1093. Question.restart('preview', text);
  1094. });
  1095. }}
  1096. />
  1097. )}
  1098. {text.report && !!text.report.isFinish && (
  1099. <IconButton
  1100. className="m-l-5"
  1101. type="report"
  1102. tip="Report"
  1103. onClick={() => {
  1104. User.needLogin().then(() => {
  1105. Question.reportLink('preview', text);
  1106. });
  1107. }}
  1108. />
  1109. )}
  1110. </div>
  1111. );
  1112. },
  1113. },
  1114. {
  1115. title: '授课时间',
  1116. key: 'time',
  1117. render: (text, record) => {
  1118. return (
  1119. <div className="sub">
  1120. <div className="t-2 t-s-12">{formatDate(record.startTime, 'YYYY-MM-DD')}</div>
  1121. <div className="t-6 t-s-12">
  1122. {formatDate(record.startTime, 'HH:mm:ss')} ~ {formatDate(record.endTime, 'HH:mm:ss')}
  1123. </div>
  1124. </div>
  1125. );
  1126. },
  1127. },
  1128. {
  1129. title: '课后笔记',
  1130. key: 'note',
  1131. render: (text, record) => {
  1132. return record.noteList && record.noteList.length > 0 ? (
  1133. <a onClick={() => this.props.onNote(record)}>查看</a>
  1134. ) : (
  1135. <span>查看</span>
  1136. );
  1137. },
  1138. },
  1139. {
  1140. title: '课后补充',
  1141. key: 'supply',
  1142. render: (text, record) => {
  1143. return record.supplyList && record.supplyList.length > 0 ? (
  1144. <a onClick={() => this.props.onSupply(record)}>查看</a>
  1145. ) : (
  1146. <span>查看</span>
  1147. );
  1148. },
  1149. },
  1150. ],
  1151. answer: [
  1152. { title: '学习内容', key: 'title' },
  1153. {
  1154. title: '答疑文档',
  1155. key: 'questionFile',
  1156. render: (text, record) => {
  1157. return (
  1158. <a href={text} target="_blank">
  1159. {record.questionFileName}
  1160. </a>
  1161. );
  1162. },
  1163. },
  1164. {
  1165. title: '授课时间',
  1166. key: 'time',
  1167. render: (text, record) => {
  1168. return `${formatDate(record.startTime, 'YYYY-MM-DD HH:mm:ss')} ~ ${formatDate(record.endTime, 'HH:mm:ss')}`;
  1169. },
  1170. },
  1171. {
  1172. title: '课后补充',
  1173. key: 'supply',
  1174. render: (text, record) => {
  1175. return record.supplyList ? <a onClick={() => this.props.onSupply(record)}>查看</a> : <span>查看</span>;
  1176. },
  1177. },
  1178. ],
  1179. };
  1180. this.listMap = {
  1181. novice: [1, 3],
  1182. coach: [1, 6, 3],
  1183. system: [1, 7, 3, 4],
  1184. answer: [1, 2, 3],
  1185. };
  1186. const index = props.data.appointments.length - 1;
  1187. this.state = {
  1188. open: props.data.status === 'ing',
  1189. tab: 'ing',
  1190. index,
  1191. list: this.listMap[this.props.data.course.vsType],
  1192. showTips:
  1193. props.data.commentTips === 0 &&
  1194. (props.data.appointments.length === Math.ceil(props.data.number / 2) ||
  1195. props.data.appointments.length === props.data.number),
  1196. };
  1197. }
  1198. closeCommentTips() {
  1199. My.courseCommentTips(this.props.data.id).then(() => {
  1200. this.setState({ showTips: false });
  1201. });
  1202. }
  1203. render() {
  1204. const { data = {} } = this.props;
  1205. switch (data.status) {
  1206. case 'ing':
  1207. return this.renderIng();
  1208. case 'not':
  1209. return this.renderNot();
  1210. case 'end':
  1211. return this.renderEnd();
  1212. case 'suspend':
  1213. return this.renderSuspend();
  1214. default:
  1215. return <div />;
  1216. }
  1217. }
  1218. renderIng() {
  1219. const { data, onComment, closeCommentTips } = this.props;
  1220. const { tab, showTips, open } = this.state;
  1221. return (
  1222. <div className="education-item ing">
  1223. <div className="title">
  1224. <div className="tag">学习中</div>
  1225. <div className="text">
  1226. {data.course.title}
  1227. {data.vsNo > 0 ? `V${data.vsNo}` : ''}
  1228. {data.number > 0 ? `(${data.number}课时)` : ''}
  1229. </div>
  1230. <div className="right">
  1231. <More
  1232. menu={[{ label: '评价', key: 'comment' }, { label: '停课', key: 'suspend' }]}
  1233. onClick={value => {
  1234. const { key } = value;
  1235. if (key === 'comment') {
  1236. onComment();
  1237. }
  1238. }}
  1239. />
  1240. </div>
  1241. </div>
  1242. {showTips && (
  1243. <div className="continue">
  1244. <Icon className="close m-r-5 t-3" type="close-circle" theme="filled" onClick={() => closeCommentTips()} />
  1245. 课程已过半,可以来写写评价啦<a onClick={() => onComment()}>去写评价 ></a>
  1246. </div>
  1247. )}
  1248. <div className="detail">
  1249. <div className="left">
  1250. <Assets name="sun_blue" src={data.course.cover} />
  1251. <div className="info">
  1252. <div className="t1">授课老师</div>
  1253. <div className="t2">{data.teacher.realname}</div>
  1254. <div className="t1">有效期</div>
  1255. <div className="t2">{data.useExpireDays}Days</div>
  1256. </div>
  1257. </div>
  1258. <div className="right">
  1259. <div className="item">
  1260. <GIcon name="speed-block" active noHover />
  1261. <div className="text">
  1262. <span>{data.appointments.length}</span>/{data.number}
  1263. </div>
  1264. </div>
  1265. <div className="item">
  1266. <GIcon name="time-block" active noHover />
  1267. <div className="text">
  1268. <span>{data.appointments.length > 0 ? data.totalDays / data.appointments.length : 0}</span>/课时
  1269. </div>
  1270. </div>
  1271. </div>
  1272. <div className="open">
  1273. <GIcon name={open ? 'up' : 'down'} onClick={() => this.setState({ open: !open })} />
  1274. </div>
  1275. </div>
  1276. {open && (data.course.vsType === 'system' || data.course.vsType === 'answer') && (
  1277. <Tabs
  1278. className="t-l"
  1279. type="line"
  1280. theme="theme"
  1281. size="small"
  1282. width={80}
  1283. active={tab}
  1284. tabs={[{ key: 'ing', title: '授课中' }, { key: 'end', title: '已结课' }]}
  1285. onChange={key => this.setState({ tab: key })}
  1286. />
  1287. )}
  1288. {open && (tab === 'ing' ? this.renderTimeLine() : this.renderTable())}
  1289. </div>
  1290. );
  1291. }
  1292. renderNot() {
  1293. const { data } = this.props;
  1294. return (
  1295. <div className="education-item not">
  1296. <div className="title">
  1297. <div className="tag">未开通</div>
  1298. <div className="text">
  1299. {data.course.title}
  1300. {data.vsNo > 0 ? `V${data.vsNo}` : ''}
  1301. {data.number > 0 ? `(${data.number}课时)` : ''}
  1302. </div>
  1303. </div>
  1304. <div className="detail">
  1305. <div className="left">
  1306. <Assets name="sun_blue" src={data.course.cover} />
  1307. <div className="info">
  1308. <div className="t1">授课老师</div>
  1309. <div className="t2">{data.teacher.realname}</div>
  1310. <div>
  1311. <div className="d-i-b m-r-2">
  1312. <div className="t-2">课时</div>
  1313. <div className="t-1 t-s-16">{data.number}</div>
  1314. </div>
  1315. <div className="d-i-b">
  1316. <div className="t-2">总时长</div>
  1317. <div className="t-1 t-s-16">{data.number}Hours</div>
  1318. </div>
  1319. </div>
  1320. </div>
  1321. </div>
  1322. <div className="right">
  1323. <div className="qr-code">
  1324. <Assets name="qrcode" src={data.teacher.qr} />
  1325. <div className="i">
  1326. <div className="t1">请尽快与老师预约上课时间</div>
  1327. <div className="t2">请于 {formatDate(data.endTime, 'YYYY-MM-DD')} 前开通课程</div>
  1328. </div>
  1329. </div>
  1330. </div>
  1331. </div>
  1332. {/* {this.renderTimeLine()} */}
  1333. </div>
  1334. );
  1335. }
  1336. renderEnd() {
  1337. const { data, onComment, closeCommentTips } = this.props;
  1338. const { open, tab, showTips } = this.state;
  1339. return (
  1340. <div className="education-item end">
  1341. <div className="title">
  1342. <div className="tag">已结课</div>
  1343. <div className="text">
  1344. {data.course.title}
  1345. {data.vsNo > 0 ? `V${data.vsNo}` : ''}
  1346. {data.number > 0 ? `(${data.number}课时)` : ''}
  1347. </div>
  1348. <div className="right">
  1349. <More
  1350. menu={[{ label: '评价', key: 'comment' }]}
  1351. onClick={value => {
  1352. const { key } = value;
  1353. if (key === 'comment') {
  1354. onComment();
  1355. }
  1356. }}
  1357. />
  1358. </div>
  1359. </div>
  1360. {showTips && (
  1361. <div className="continue">
  1362. <Icon className="close m-r-5 t-3" type="close-circle" theme="filled" onClick={() => closeCommentTips()} />
  1363. 课程已结束,可以来写写评价啦<a onClick={() => onComment()}>去写评价 ></a>
  1364. </div>
  1365. )}
  1366. <div className="detail">
  1367. <div className="left">
  1368. <Assets name="sun_blue" src={data.course.cover} />
  1369. <div className="info">
  1370. <div className="t1">授课老师</div>
  1371. <div className="t2">{data.teacher.realname}</div>
  1372. <div className="t1">有效期</div>
  1373. <div className="t2">{data.useExpireDays}Days</div>
  1374. </div>
  1375. </div>
  1376. <div className="right">
  1377. <div className="item">
  1378. <GIcon name="speed-block" active noHover />
  1379. <div className="text">
  1380. <span>{data.appointments.length}</span>/{data.number}
  1381. </div>
  1382. </div>
  1383. <div className="item">
  1384. <GIcon name="time-block" active noHover />
  1385. <div className="text">
  1386. <span>{data.appointments.length > 0 ? data.totalDays / data.appointments.length : 0}</span>/课时
  1387. </div>
  1388. </div>
  1389. </div>
  1390. <div className="open">
  1391. <GIcon name={open ? 'up' : 'down'} onClick={() => this.setState({ open: !open })} />
  1392. </div>
  1393. </div>
  1394. {open && (data.course.vsType === 'system' || data.course.vsType === 'answer') && (
  1395. <Tabs
  1396. className="t-l"
  1397. type="line"
  1398. theme="theme"
  1399. size="small"
  1400. width={80}
  1401. active={tab}
  1402. tabs={[{ key: 'ing', title: '授课中' }, { key: 'end', title: '已结课' }]}
  1403. onChange={key => this.setState({ tab: key })}
  1404. />
  1405. )}
  1406. {open && (tab === 'ing' ? this.renderTimeLine() : this.renderTable())}
  1407. </div>
  1408. );
  1409. }
  1410. renderSuspend() {
  1411. const { data, onRestore, onComment } = this.props;
  1412. return (
  1413. <div className="education-item end">
  1414. <div className="title">
  1415. <div className="tag">已停课</div>
  1416. <div className="text">
  1417. {data.course.title}
  1418. {data.vsNo > 0 ? `V${data.vsNo}` : ''}
  1419. {data.number > 0 ? `(${data.number}课时)` : ''}
  1420. <Button size="small" onClick={() => onRestore()}>
  1421. 恢复上课
  1422. </Button>
  1423. </div>
  1424. <div className="t-s-12">
  1425. <span className="t-3">申请时间:</span>
  1426. <span className="t-2 m-r-1">{formatDate(data.suspendTime, 'YYYY-MM-DD HH:mm:ss')}</span>
  1427. <span className="t-3">已停课:</span>
  1428. <span>{parseInt((new Date().getTime() - new Date(data.suspendTime).getTime()) / 86400000, 10)}Days/30</span>
  1429. </div>
  1430. <div className="right">
  1431. <More
  1432. menu={[{ label: '评价', key: 'comment' }]}
  1433. onClick={value => {
  1434. const { key } = value;
  1435. if (key === 'comment') {
  1436. onComment();
  1437. }
  1438. }}
  1439. />
  1440. </div>
  1441. </div>
  1442. <div className="detail">
  1443. <div className="left">
  1444. <Assets name="sun_blue" src={data.course.cover} />
  1445. <div className="info">
  1446. <div className="t1">授课老师</div>
  1447. <div className="t2">{data.teacher.realname}</div>
  1448. <div className="t1">有效期</div>
  1449. <div className="t2">{data.useExpireDays}Days</div>
  1450. </div>
  1451. </div>
  1452. <div className="right">
  1453. <div className="item">
  1454. <GIcon name="speed-block" active noHover />
  1455. <div className="text">
  1456. <span>{data.appointments.length}</span>/{data.number}
  1457. </div>
  1458. </div>
  1459. <div className="item">
  1460. <GIcon name="time-block" active noHover />
  1461. <div className="text">
  1462. <span>{data.appointments.length > 0 ? data.totalDays / data.appointments.length : 0}</span>/课时
  1463. </div>
  1464. </div>
  1465. </div>
  1466. </div>
  1467. </div>
  1468. );
  1469. }
  1470. renderTimeLine() {
  1471. const { data = {}, onUploadNote, onUploadSupply, onUploadQuestion, setCCTalkName } = this.props;
  1472. const { list = [], index } = this.state;
  1473. const appointment = data.appointments[index] || {};
  1474. let status = '';
  1475. return [
  1476. <div className="class-hour">
  1477. {data.number > 1 && (
  1478. <div className="text">
  1479. 课时 {appointment.no}:{appointment.title}
  1480. </div>
  1481. )}
  1482. {data.number > 1 && (
  1483. <div className="right">
  1484. <GIcon name="prev" onClick={() => this.setState({ index: index === 0 ? index : index - 1 })} />
  1485. <span>上一课时</span>
  1486. <span>下一课时</span>
  1487. <GIcon
  1488. name="next"
  1489. onClick={() => this.setState({ index: index >= data.appointments.length - 1 ? index : index + 1 })}
  1490. />
  1491. </div>
  1492. )}
  1493. </div>,
  1494. <div className="time-line">
  1495. {list.map(item => {
  1496. if (status === '') {
  1497. // 上一阶段完成
  1498. status = statusMap[item](appointment, data);
  1499. } else {
  1500. // 上一阶段未完成
  1501. status = 'end';
  1502. }
  1503. return (
  1504. <TimeLineItem
  1505. type={`${item}`}
  1506. user={this.props.user}
  1507. appointment={appointment}
  1508. data={data}
  1509. status={status}
  1510. onUploadNote={onUploadNote}
  1511. onUploadSupply={onUploadSupply}
  1512. onUploadQuestion={onUploadQuestion}
  1513. setCCTalkName={setCCTalkName}
  1514. />
  1515. );
  1516. })}
  1517. </div>,
  1518. ];
  1519. }
  1520. renderTable() {
  1521. const { data = {} } = this.props;
  1522. const { appointments = [] } = data;
  1523. return (
  1524. <UserTable size="small" columns={this.columns[data.course.vsType]} data={appointments.filter(row => row.id)} />
  1525. );
  1526. }
  1527. }
  1528. class TimeLineItem extends Component {
  1529. constructor(props) {
  1530. super(props);
  1531. this.state = {};
  1532. }
  1533. onClick(key) {
  1534. const { onClick } = this.props;
  1535. const { status } = this.props;
  1536. if (status === 'not') return;
  1537. if (onClick) onClick(key);
  1538. }
  1539. render() {
  1540. const { type } = this.props;
  1541. const { status } = this.props;
  1542. return (
  1543. <div className={`time-line-item ${status}`}>
  1544. <div className="icon-title">
  1545. <GIcon name={iconMap[type]} active={!status} noHover />
  1546. <div className="title">{titleMap[type]}</div>
  1547. </div>
  1548. <div className="time-line-detail">{this.renderDetail()}</div>
  1549. </div>
  1550. );
  1551. }
  1552. renderDetail() {
  1553. const {
  1554. data = {},
  1555. appointment = {},
  1556. type,
  1557. onUploadNote,
  1558. onUploadSupply,
  1559. onDeleteNote,
  1560. onDeleteSupply,
  1561. onUploadQuestion,
  1562. setCCTalkName,
  1563. } = this.props;
  1564. const { status } = this.props;
  1565. const { paper } = appointment;
  1566. switch (type) {
  1567. case '1':
  1568. switch (status) {
  1569. case 'end':
  1570. case 'not':
  1571. return (
  1572. <span>
  1573. 请尽快与老师预约上课时间,老师微信:{data.teacher.wechat}扫码加微信{' '}
  1574. <Popover content={<Assets name="qrcode" src={data.teacher.qr} />}>
  1575. <span>
  1576. <Assets className="m-l-1" name="erweima" />
  1577. </span>
  1578. </Popover>
  1579. </span>
  1580. );
  1581. default:
  1582. return (
  1583. <span>
  1584. {formatDate(appointment.startTime, 'YYYY-MM-DD HH:mm:ss')} ~{' '}
  1585. {formatDate(appointment.endTime, 'HH:mm:ss')}
  1586. </span>
  1587. );
  1588. }
  1589. case '2':
  1590. switch (status) {
  1591. case 'end':
  1592. return <span className="link">点此上传</span>;
  1593. case 'not':
  1594. return (
  1595. <FileUpload
  1596. onUpload={file => {
  1597. return Common.upload({ file }).then(result => onUploadQuestion(appointment, result.url, file.name));
  1598. }}
  1599. >
  1600. <span className="link">点此上传</span>
  1601. </FileUpload>
  1602. );
  1603. default:
  1604. return (
  1605. <a href={appointment.questionFile} target="_blank">
  1606. {appointment.questionFileName || '文件'}
  1607. </a>
  1608. );
  1609. }
  1610. case '3':
  1611. switch (status) {
  1612. case 'end':
  1613. return data.cctalkName ? (
  1614. <span>
  1615. CCtalk 频道号 :{appointment.cctalkChannel}{' '}
  1616. <a className="link" href="" target="_black">
  1617. CC talk使用手册
  1618. </a>
  1619. </span>
  1620. ) : (<div>
  1621. <input
  1622. style={{ width: 200 }}
  1623. className="b-c-1 p-l-1 p-r-1 t-s-12 m-r-1"
  1624. placeholder="请输入CCtalk用户名查看授课频道"
  1625. onChange={e => {
  1626. this.setState({ cctalkName: e.target.value });
  1627. }}
  1628. />
  1629. <Button size="small" radius disabled>
  1630. 提交
  1631. </Button>
  1632. </div>
  1633. );
  1634. case 'not':
  1635. return data.cctalkName ? (
  1636. <span>
  1637. CCtalk 频道号 :{appointment.cctalkChannel}{' '}
  1638. <a className="link" href="" target="_black">
  1639. CC talk使用手册
  1640. </a>
  1641. </span>
  1642. ) : (<div>
  1643. <input
  1644. style={{ width: 200 }}
  1645. className="b-c-1 p-l-1 p-r-1 t-s-12 m-r-1"
  1646. placeholder="请输入CCtalk用户名查看授课频道"
  1647. onChange={e => {
  1648. this.setState({ cctalkName: e.target.value });
  1649. }}
  1650. />
  1651. <Button
  1652. size="small"
  1653. radius
  1654. onClick={() => {
  1655. if (this.state.cctalkName) setCCTalkName(appointment, this.state.cctalkName);
  1656. }}
  1657. >
  1658. 提交
  1659. </Button>
  1660. </div>
  1661. );
  1662. default:
  1663. return (
  1664. <span>
  1665. CCtalk 频道号 :{appointment.cctalkChannel}{' '}
  1666. <a className="link" href="" target="_black">
  1667. CC talk使用手册
  1668. </a>
  1669. </span>
  1670. );
  1671. }
  1672. case '4':
  1673. switch (status) {
  1674. case 'end':
  1675. return <span className="link">点此上传</span>;
  1676. case 'not':
  1677. return (
  1678. <span
  1679. className="link"
  1680. onClick={() => {
  1681. onUploadNote(appointment, { appointmentId: appointment.id, recordId: appointment.recordId });
  1682. }}
  1683. >
  1684. 点此上传
  1685. </span>
  1686. );
  1687. default:
  1688. return (
  1689. <div>
  1690. <div>
  1691. <span
  1692. className="link"
  1693. onClick={() => {
  1694. onUploadNote(appointment, { appointmentId: appointment.id, recordId: appointment.recordId });
  1695. }}
  1696. >
  1697. 点此上传
  1698. </span>
  1699. </div>
  1700. <div className="note-list">
  1701. {appointment.noteList.map(row => {
  1702. return (
  1703. <Note
  1704. user={this.props.user}
  1705. teacher={data.teacher}
  1706. data={row}
  1707. reply={!row.userId}
  1708. actionList={
  1709. row.userId ? [{ key: 'edit', label: '编辑' }, { key: 'delete', label: '删除' }] : null
  1710. }
  1711. onAction={key => {
  1712. switch (key) {
  1713. case 'edit':
  1714. onUploadNote(appointment, row);
  1715. break;
  1716. case 'delete':
  1717. onDeleteNote(appointment, row);
  1718. break;
  1719. case 'reply':
  1720. onUploadNote(appointment, {
  1721. parentId: row.id,
  1722. appointmentId: appointment.id,
  1723. recordId: appointment.recordId,
  1724. });
  1725. break;
  1726. default:
  1727. }
  1728. }}
  1729. />
  1730. );
  1731. })}
  1732. </div>
  1733. </div>
  1734. );
  1735. }
  1736. case '5':
  1737. switch (status) {
  1738. case 'end':
  1739. return <span className="link">写留言</span>;
  1740. case 'not':
  1741. return (
  1742. <span
  1743. className="link"
  1744. onClick={() => {
  1745. onUploadSupply(appointment, { appointmentId: appointment.id, recordId: appointment.recordId });
  1746. }}
  1747. >
  1748. 写留言
  1749. </span>
  1750. );
  1751. default:
  1752. return (
  1753. <div>
  1754. <div>
  1755. <span
  1756. className="link"
  1757. onClick={() => {
  1758. onUploadSupply(appointment, { appointmentId: appointment.id, recordId: appointment.recordId });
  1759. }}
  1760. >
  1761. 写留言
  1762. </span>
  1763. </div>
  1764. <div className="note-list">
  1765. {appointment.supplyList.map(row => {
  1766. return (
  1767. <Note
  1768. user={this.props.user}
  1769. teacher={data.teacher}
  1770. data={row}
  1771. reply={!row.userId}
  1772. actionList={
  1773. row.userId ? [{ key: 'edit', label: '编辑' }, { key: 'delete', label: '删除' }] : null
  1774. }
  1775. onAction={key => {
  1776. switch (key) {
  1777. case 'edit':
  1778. onUploadSupply(appointment, row);
  1779. break;
  1780. case 'delete':
  1781. onDeleteSupply(appointment, row);
  1782. break;
  1783. case 'reply':
  1784. onUploadSupply(appointment, {
  1785. parentId: row.id,
  1786. appointmentId: appointment.id,
  1787. recordId: appointment.recordId,
  1788. });
  1789. break;
  1790. default:
  1791. }
  1792. }}
  1793. />
  1794. );
  1795. })}
  1796. </div>
  1797. </div>
  1798. );
  1799. }
  1800. case '6':
  1801. return [
  1802. <div>
  1803. <span>基本情况</span>
  1804. <a href={status !== 'end' ? '' : ''} className="link">
  1805. 填写
  1806. </a>
  1807. </div>,
  1808. <div>
  1809. <span>备考细节</span>
  1810. <a href={status !== 'end' ? '' : ''} className="link">
  1811. 填写
  1812. </a>
  1813. </div>,
  1814. ];
  1815. case '7':
  1816. return (
  1817. <ProgressText
  1818. progress={paper ? formatPercent(paper.report.userNumber, paper.report.questionNumber) : 0}
  1819. size="small"
  1820. />
  1821. );
  1822. default:
  1823. return <div />;
  1824. }
  1825. }
  1826. }