index.vue 15 KB

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