index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <div class="m-right-block fr mh576">
  3. <el-row class="p20">
  4. <el-col :span="6">
  5. <img :src="tpl.tb" width="200px" style="border-radius: 20px;" />
  6. </el-col>
  7. <el-col :span="6">
  8. <div>
  9. <p style="font-size: 24px;"> 课程信息 </p>
  10. <p class="mt10">岗位名称:{{tpl.name}} </p>
  11. <p class="mt10">课程学时:<strong style="color: red;">{{tpl.xs/10}} </strong>学时
  12. </p>
  13. <p class="mt10" v-if="tpl.examGroupId">课程年度:
  14. <strong style="color: red;">{{tpl.nd}} </strong>
  15. </p>
  16. </div>
  17. </el-col>
  18. <el-col :span="6">
  19. <div>
  20. <p style="font-size: 24px;"> 学习信息 </p>
  21. <p class="mt10">学习情况:
  22. 完成 <strong style="color: red;">{{info.getXs/10}} </strong>
  23. 共计 <strong style="color: red;">{{info.totalXs/10}}</strong>
  24. </p>
  25. <p class="mt10" v-if="tpl.examGroupId">最高分数:
  26. <strong style="color: red;">{{info.score}} </strong>
  27. </p>
  28. <p class="mt10" v-if="tpl.examGroupId">开始时间:
  29. <strong style="color: red;">{{info.startDate}} </strong>
  30. </p>
  31. </div>
  32. </el-col>
  33. <el-col :span="6">
  34. <p>
  35. <el-button type="primary" class="mt10" style="font-size: 14px;" @click="startExam" v-if="tpl.examGroupId>0">
  36. 模拟练习
  37. </el-button>
  38. </p><p>
  39. <el-button type="success" class="mt10" style="font-size: 14px;" @click="startExamTest" v-if="tpl.examGroupId>0">
  40. 在线练习
  41. </el-button>
  42. </p><p>
  43. <el-button type="warning" class="mt10" style="font-size: 14px;" @click="printCert">
  44. 学时证明
  45. </el-button>
  46. </p>
  47. </el-col>
  48. </el-row>
  49. <div class="right-block-bd ng-scope" ui-view="myStudyContent" style="position: relative;">
  50. <div class="m-account">
  51. <div class="account-tit" style="height:30px">
  52. <a :class="{'current':show===1}" @click="show=1" class="">正在学习</a>
  53. <a :class="{'current':show===2}" @click="show=2" class="">已经完成</a>
  54. <a :class="{'current':show===3}" @click="show=3" class="" v-if="tpl.examGroupId>0">考试记录</a>
  55. </div>
  56. <div v-if="show <3" class="lwh-ul-form mt20">
  57. <!-- 列表展示 -->
  58. <el-table :data="showList" border stripe style="width: 100%;">
  59. <el-table-column label="NO." prop="id" width="50" align="center">
  60. <template v-slot="{$index}">
  61. <span> {{$index+1}}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="课程名称" prop="name" min-width="200">
  65. </el-table-column>
  66. <el-table-column label="类型" prop="type" align="center" width="80">
  67. <span>必修</span>
  68. </el-table-column>
  69. <el-table-column label="学时" prop="xs" align="center" width="80">
  70. <template v-slot="{row}">
  71. <span> {{row.xs/10}}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="学习进度" prop="useTime" align="left" width="220">
  75. <template v-slot="{row}">
  76. <span style="display: flex;">
  77. <el-progress type="line" style="width: 120px;" :stroke-width="26" :text-inside="true" :show-text="false"
  78. :percentage="row.percent" :class="row.percent|showProgressColor">
  79. </el-progress>
  80. <span style="margin-left: 10px;"> {{row.percent}}% </span>
  81. </span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="操作" prop="xs" align="center" width="80">
  85. <template v-slot="{row, $index}">
  86. <el-button @click="loadMedia(row, $index)" type="text">播放</el-button>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. </div>
  91. <div v-if="show ==3" class="lwh-ul-form mt20">
  92. <exam-list :courseId="courseId"> </exam-list>
  93. </div>
  94. </div>
  95. </div>
  96. <el-dialog class="fc tc media-dialog" :visible.sync="mediaDialog" append-to-body top="50px" :title="media.name"
  97. :close-on-click-modal="false" width="640px">
  98. <Media :options="options" :dialog="mediaDialog" :media="media" :course="info" @close="mediaDialog=false"
  99. @update="update">
  100. </Media>
  101. <span slot="footer" class="dialog-footer mt5">
  102. <el-button type="warning" @click="mediaDialog=false">退出播放</el-button>
  103. <el-select placeholder="流畅" v-model="mediaType" style="width: 80px;">
  104. <el-option label="流畅" value="ld"></el-option>
  105. <el-option label="标清" value="hls"></el-option>
  106. </el-select>
  107. </span>
  108. </el-dialog>
  109. <el-dialog title="输入认证" center :visible.sync="editRzcode">
  110. <el-form label-width="120px" ref="elAdd">
  111. <el-form-item label="认证编号">
  112. <el-input v-model="info.rzCode" type="text" disabled></el-input>
  113. </el-form-item>
  114. </el-form>
  115. <div class="dialog-footer" slot="footer">
  116. <el-button @click="cancelRzCode">取 消</el-button>
  117. <el-button @click="doAddRzCode" type="primary">确定打印</el-button>
  118. </div>
  119. </el-dialog>
  120. <el-dialog class="previewDialog" :visible.sync="testExamDalog"
  121. :title="'在线练习-'+tpl.name"
  122. center
  123. style="color:red"
  124. top="50px" width="1024px"
  125. @close="testExamDalog=false">
  126. <ICourseAnswerTest :info="info" :tpl="tpl" :groupId="examGroupId" > </ICourseAnswerTest>
  127. </el-dialog>
  128. </div>
  129. </template>
  130. <script>
  131. import {
  132. httpServer
  133. } from "@/components/httpServer/httpServer.js";
  134. import Media from "./components/media.vue";
  135. import ExamList from "./components/ExamList.vue";
  136. import ICourseAnswerTest from "./components/iCourseAnswerTest.vue";
  137. import {
  138. getPercent
  139. } from '@/utils/index.js'
  140. import {
  141. delExam
  142. } from '../exam/components/util.js'
  143. import md5 from 'js-md5';
  144. export default {
  145. name: "Index",
  146. data() {
  147. return {
  148. courseId: 0,
  149. examGroupId:0,
  150. show: 1,
  151. mediaDialog: false,
  152. mediaType: 'hls',
  153. mediaUrl: '',
  154. editRzcode: false,
  155. testExamDalog: false,
  156. info: {
  157. score: 0,
  158. percent: 0
  159. },
  160. tpl: {},
  161. media: {},
  162. options: {
  163. autoplay: true, // 如果true,浏览器准备好时开始回放。
  164. muted: false, // 默认情况下将会消除任何音频。
  165. loop: false, // 导致视频一结束就重新开始。
  166. preload: "true", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  167. language: 'zh-CN',
  168. aspectRatio: '4:3', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  169. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  170. sources: [],
  171. poster: '', // 你的封面地址
  172. notSupportedMessage: '无法播放媒体源', // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
  173. playtimes: '',
  174. controlBar: {
  175. currentTimeDisplay: true, // 当前时间
  176. timeDivider: true, // 时间分割线
  177. durationDisplay: true, // 总时间
  178. progressControl: true, // 进度条
  179. remainingTimeDisplay: true, //
  180. customControlSpacer: true, //
  181. fullscreenToggle: true, // 全屏按钮
  182. volumePanel: true
  183. }
  184. },
  185. list: [],
  186. showList: [],
  187. };
  188. },
  189. components: {
  190. Media,
  191. ICourseAnswerTest,
  192. ExamList
  193. },
  194. beforeMount() {
  195. this.courseId = +this.$route.params.courseId
  196. this.getData()
  197. },
  198. watch: {
  199. show(val) {
  200. this.updateShowList()
  201. },
  202. mediaType(val) {
  203. let mediaUrl = this.mediaUrl;
  204. if (val == 'ld') {
  205. mediaUrl = mediaUrl.replace('/hls/', '/ld/');
  206. }
  207. this.options.sources = [{
  208. src: mediaUrl,
  209. type: "application/x-mpegURL"
  210. }];
  211. this.options.playtimes = this.media.position || 0;
  212. this.options.autoplay = this.options.playtimes > 0;
  213. this.mediaDialog = true;
  214. }
  215. },
  216. filters: {
  217. showProgressColor: function(val) {
  218. if (val == '进行中') {
  219. return val = 'el-bg-inner-running';
  220. } else if (val == '失败') {
  221. return val = 'el-bg-inner-error'
  222. } else if (val == '完成') {
  223. return val = 'el-bg-inner-done'
  224. }
  225. },
  226. useTime(val) {
  227. let timestr = ""
  228. timestr += val > 3600 ? parseInt(val / 3600) : "0";
  229. timestr += ":" + (val > 60 ? parseInt((val % 3600) / 60) : "00");
  230. timestr += ":" + (val % 60);
  231. return timestr
  232. }
  233. },
  234. methods: {
  235. startExam() {
  236. let courseId = this.courseId
  237. delExam()
  238. this.$router.push(`/center/exam/${courseId}`);
  239. },
  240. startExamTest( ){
  241. this.examGroupId = this.tpl.examGroupId;
  242. this.testExamDalog = true;
  243. },
  244. printCert() {
  245. if (this.info.getXs < this.info.totalXs) {
  246. this.$message.errorMsg("课程还未完成", 2)
  247. return;
  248. }
  249. if (this.tpl.examGroupId > 0 && this.info.score < 60) {
  250. this.$message.errorMsg("考试未通过", 2)
  251. return;
  252. }
  253. let {
  254. id,
  255. rzCode
  256. } = this.info
  257. // this.editRzcode = true
  258. httpServer('Cert.printCert', {
  259. rzCode,
  260. id
  261. }).then(res => {
  262. if (res.code == 200) {
  263. this.editRzcode = false;
  264. this.info.tmpRzCode = "";
  265. window.open(res.data.url)
  266. }
  267. })
  268. },
  269. cancelRzCode() {
  270. this.info.rzCode = this.info.tmpRzCode;
  271. this.editRzcode = false;
  272. },
  273. doAddRzCode() {
  274. let {
  275. type,
  276. rzCode,
  277. id
  278. } = this.info;
  279. if (!rzCode) rzCode = "sm" + id
  280. httpServer('Cert.printCert', {
  281. rzCode,
  282. id
  283. }).then(res => {
  284. if (res.code == 200) {
  285. this.editRzcode = false;
  286. this.info.tmpRzCode = "";
  287. window.open(res.data.url)
  288. }
  289. })
  290. },
  291. formatFinish() {
  292. let {
  293. gxs,
  294. axs
  295. } = this.info;
  296. if (!axs) axs = 1;
  297. return `获得${gxs}学时, 总共${axs}学时`;
  298. },
  299. formatExam() {
  300. let {
  301. score
  302. } = this.info
  303. if (score == -1) return `已答0次,未通过`;
  304. return `最高${score<1?0:score}分, ${score>=60?'通过':'未通过'}`;
  305. },
  306. formatPass() {
  307. let {
  308. score
  309. } = this.info
  310. if (score == -1) return `未参加`;
  311. return `${score||0}分,${score>=60?'通过':'未通过'}`;
  312. },
  313. formatString(val) {
  314. return () => val;
  315. },
  316. getData() {
  317. let param = {
  318. courseId: this.courseId
  319. }
  320. httpServer("course.getCourse", param).then(res => {
  321. if (res.code == 200) {
  322. this.info = res.data.info;
  323. let list = res.data.list;
  324. this.tpl = res.data.tpl || {};
  325. this.list = list.map((item) => {
  326. item.percent = getPercent(item) || 0;
  327. return item;
  328. })
  329. this.updateShowList()
  330. }
  331. })
  332. },
  333. updateShowList() {
  334. let show = this.show;
  335. this.showList = this.list.filter(item => {
  336. if (show == 1) return !item.isFinish
  337. if (show == 2) return !!item.isFinish
  338. return false
  339. })
  340. //
  341. this.info.gxs = 0
  342. this.info.axs = 0;
  343. this.info.tcount = this.list.length;
  344. this.info.fcount = 0;
  345. this.info.percent = 0;
  346. for (let i = 0; i < this.list.length; i++) {
  347. let item = this.list[i]
  348. this.info.axs += (item.xs / 10)
  349. if (item.isFinish) {
  350. this.info.gxs += (item.xs / 10)
  351. this.info.fcount++
  352. }
  353. }
  354. this.info.percent = (this.info.gxs * 10000 / this.info.axs) / 100;
  355. },
  356. //
  357. update(item) {
  358. let index = this.media.index
  359. if (item.position) this.media.position = item.position
  360. this.media.isFinish = item.isFinish
  361. this.media.id = item.id
  362. this.media.percent = getPercent(this.media);
  363. this.updateShowList()
  364. },
  365. // 加载媒体
  366. loadMedia(item, index) {
  367. this.media = item;
  368. this.media.index = index
  369. httpServer('course.GetMedia', {
  370. id: item.id
  371. }).then(({
  372. data,
  373. code
  374. }) => {
  375. this.mediaUrl = data
  376. this.mediaType = 'hls';
  377. this.options.sources = [{
  378. src: this.mediaUrl,
  379. type: "application/x-mpegURL"
  380. }];
  381. this.options.playtimes = item.position;
  382. this.options.autoplay = item.position > 0;
  383. this.mediaDialog = true;
  384. });
  385. }
  386. }
  387. };
  388. </script>
  389. <style>
  390. @import "../../../assets/css/content.css";
  391. @import "../../../assets/css/course.css";
  392. @import url("../../../assets/css/m-account.css");
  393. @import url("./index.css");
  394. .media-dialog .el-dialog__header {
  395. /* display: none !important; */
  396. }
  397. .media-dialog .el-dialog__body {
  398. padding: 0 !important;
  399. }
  400. .media-dialog .el-scrollbar__wrap {
  401. overflow-x: hidden !important;
  402. }
  403. .mprocess {
  404. margin: 0 auto;
  405. width: 150px !important;
  406. }
  407. .el-progress {
  408. width: 100%;
  409. }
  410. .el-progress__text {
  411. font-size: 16px;
  412. font-weight: 700;
  413. line-height: 1.5;
  414. color: #3290D4;
  415. }
  416. .el-progress-bar__outer {
  417. height: 20px !important;
  418. border: 1px solid #78335f;
  419. background-color: transparent;
  420. }
  421. /* 渐变进度条 */
  422. .el-bg-inner-running .el-progress-bar__inner {
  423. background-color: unset;
  424. background-image: linear-gradient(to right, #3587d8, #6855ff);
  425. }
  426. .el-bg-inner-error .el-progress-bar__inner {
  427. background-image: linear-gradient(to right, #3587d8, #fb3a7e);
  428. }
  429. .el-bg-inner-done .el-progress-bar__inner {
  430. background-image: linear-gradient(to right, #3587d8, #53ff54);
  431. }
  432. </style>