page.js 60 KB

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