index.vue 15 KB

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