index.vue 14 KB

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