index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <!-- 在线考试 -->
  2. <template>
  3. <div class="app-container onlineExam">
  4. <div class="page-container onlineExamPage" v-if="pageType === 1">
  5. <p class="pageTitle">在线考试</p>
  6. <div class="top-max-button-box scrollbar-x-box">
  7. <p :class="examTypeId == item.examTypeId?'check-button':''"
  8. @click="topCheckButton(item.examTypeId)"
  9. v-for="(item,index) in topDataList" :key="index">{{item.examTypeName}} {{item.examTypeCount}}</p>
  10. </div>
  11. <div class="page-form-title-box">
  12. <el-form :model="queryParams" class="form-box" ref="queryForm"
  13. :inline="true" style="width:100%;">
  14. <div class="table-top-button-box">
  15. <div>
  16. <p :class="examStatus === ''?'check-table-button':''" @click="tableTypeButton('')">全部</p>
  17. <p :class="examStatus === 1?'check-table-button':''" @click="tableTypeButton(1)">未开始</p>
  18. <p :class="examStatus === 2?'check-table-button':''" @click="tableTypeButton(2)">进行中</p>
  19. <!--<p :class="examStatus === 3?'check-table-button':''" @click="tableTypeButton(3)">已完成</p>-->
  20. </div>
  21. </div>
  22. <el-form-item label="" prop="searchValue">
  23. <el-input
  24. maxLength="30"
  25. v-model="queryParams.searchValue"
  26. placeholder="搜索名称"
  27. style="width: 200px"
  28. />
  29. </el-form-item>
  30. <el-form-item label="" prop="state">
  31. <el-date-picker
  32. :clearable="false"
  33. v-model="dateRange"
  34. size="small"
  35. style="width: 240px"
  36. value-format="yyyy-MM-dd"
  37. type="daterange"
  38. range-separator="-"
  39. start-placeholder="开始日期"
  40. end-placeholder="结束日期"
  41. ></el-date-picker>
  42. </el-form-item>
  43. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  44. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  45. </el-form>
  46. </div>
  47. <div class="page-content-box">
  48. <div class="for-max-big-box scrollbar-box">
  49. <div class="for-big-box" v-for="(item,index) in dataList" :key="index">
  50. <div class="top-box">
  51. <p class="title-p">{{item.examTypeName}}</p>
  52. <p class="text-p" v-if="item.conditionType != 4">满足前置条件后可参加考试</p>
  53. <p class="text-p" v-else>已满足前置条件,可参加考试</p>
  54. </div>
  55. <div class="bottom-box">
  56. <p class="text-big-p">{{item.examName}}</p>
  57. <p class="text-p">{{parseTime(item.startTime,"{y}-{m}-{d} {h}:{i}")}} 至 {{parseTime(item.endTime,"{y}-{m}-{d} {h}:{i}")}}</p>
  58. <p class="time-p">时长:{{item.answerDuration}}分钟 丨 总分:{{item.totalScore}}分 丨 及格分:{{item.passScore}}分 丨 可考试次数:{{item.attemptLimit===0?'无限':item.attemptLimit}}次</p>
  59. </div>
  60. <p class="position-p-1" v-if="item.conditionType == 1" @click="tableButton(1,item)">完成学时要求后解锁</p>
  61. <p class="position-p-1" v-if="item.conditionType == 2" @click="tableButton(2,item)">完成考前课程学习后解锁</p>
  62. <p class="position-p-1" v-if="item.conditionType == 3" @click="tableButton(3,item)">完成模拟考试练习后解锁</p>
  63. <p class="position-p-3" v-if="item.conditionType == 4" @click="tableButton(4,item)">开始考试</p>
  64. </div>
  65. </div>
  66. <pagination :page-sizes="[20, 30, 40, 50]"
  67. style="margin-right:20px;"
  68. v-show="total>0"
  69. :total="total"
  70. :page.sync="queryParams.page"
  71. :limit.sync="queryParams.pageSize"
  72. @pagination="getList"
  73. />
  74. </div>
  75. </div>
  76. <el-dialog class="preExam-dialog"
  77. :modal-append-to-body="false"
  78. :close-on-click-modal="false" :close-on-press-escape="false"
  79. title="考试承诺书"
  80. :visible.sync="preExamDialogType"
  81. v-if="preExamDialogType"
  82. width="840px"
  83. append-to-body>
  84. <div style="height:600px;" class="scrollbar-box">
  85. <richTextPdf ref="richTextPdf" :content="richTextHtml" />
  86. </div>
  87. <div slot="footer" class="dialog-footer dialog-footer-box">
  88. <p class="dialog-footer-button-null"></p>
  89. <p class="dialog-footer-button-border" v-if="preButtonType" @click="preExamDialogCancel">下载</p>
  90. <p class="dialog-footer-button-primary" @click="examUserExamStart">确认</p>
  91. <p class="dialog-footer-button-null"></p>
  92. </div>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. //import { getDicts } from "@/api/commonality/noPermission";
  98. //import { systemUserSelect } from "@/api/commonality/permission";
  99. //import { getInfo } from "@/api/basicsModules/index";
  100. //import addPage from "./addPage.vue";
  101. import { examUserExamList,examUserExamTypeSelectExamType,examUserExamStart,examUserExamCommitmentConfirm, } from "@/api/safetyEducationExaminationNew/index";
  102. import richTextPdf from '@/views/safetyEducationExaminationNew/components/richTextPdf.vue';
  103. export default {
  104. name: 'index',
  105. components: { richTextPdf },
  106. data() {
  107. return {
  108. //页面状态
  109. pageType: 1,
  110. //横向列表
  111. topDataList:[],
  112. //查询条件
  113. examTypeId:'',
  114. examStatus:'',
  115. queryParams: {
  116. page: 1,
  117. pageSize: 20,
  118. searchValue: '',
  119. },
  120. //时间数据
  121. dateRange: [],
  122. //列表数据
  123. dataList: [],
  124. //数据数量
  125. total: 0,
  126. //组件传参
  127. propsData: {},
  128. //考前承诺相关
  129. preExamDialogType:false,
  130. preButtonType:false,
  131. richTextHtml: '',
  132. preData:null,
  133. }
  134. },
  135. created() {
  136. },
  137. mounted() {
  138. if(sessionStorage.getItem('skipQueryParamsData')){
  139. let skipQueryParamsData = JSON.parse(sessionStorage.getItem('skipQueryParamsData'))
  140. this.$set(this,'queryParams',skipQueryParamsData.queryParams);
  141. this.$set(this,'dateRange',skipQueryParamsData.dateRange);
  142. this.$set(this,'examTypeId',skipQueryParamsData.examTypeId);
  143. this.$set(this,'examStatus',skipQueryParamsData.examStatus);
  144. sessionStorage.removeItem('skipQueryParamsData');
  145. }
  146. this.examUserExamTypeSelectExamType();
  147. },
  148. methods: {
  149. topCheckButton(examTypeId){
  150. if(this.examTypeId !== examTypeId){
  151. this.$set(this,'examTypeId',examTypeId);
  152. this.handleQuery()
  153. }
  154. },
  155. //切换按钮
  156. tableTypeButton(val){
  157. if(this.examStatus !== val){
  158. this.$set(this,'examStatus',val);
  159. this.handleQuery();
  160. }
  161. },
  162. //查询按钮
  163. handleQuery() {
  164. this.$set(this.queryParams, 'page', 1)
  165. this.getList()
  166. },
  167. //重置按钮
  168. resetQuery() {
  169. this.$set(this, 'dateRange', [])
  170. this.$set(this, 'queryParams', {
  171. page: 1,
  172. pageSize: 20,
  173. searchValue: '',
  174. })
  175. this.getList()
  176. },
  177. //获取数据列表
  178. getList() {
  179. let obj = JSON.parse(JSON.stringify(this.queryParams))
  180. obj.examTypeId = this.examTypeId;
  181. obj.examStatus = this.examStatus;
  182. if (this.dateRange[0]) {
  183. obj.startTime = this.dateRange[0] + 'T00:00:00'
  184. obj.endTime = this.dateRange[1] + 'T23:59:59'
  185. } else {
  186. obj.startTime = ''
  187. obj.endTime = ''
  188. }
  189. examUserExamList(obj).then(response => {
  190. this.$set(this, 'dataList', response.data.records)
  191. this.$set(this, 'total', response.data.total)
  192. })
  193. },
  194. //下载承诺书
  195. preExamDialogCancel(){
  196. this.msgSuccess('正在下载,请耐心等候')
  197. this.$refs['richTextPdf'].downloadPDF();
  198. },
  199. //确认承诺-并考试
  200. examUserExamStart(){
  201. if(this.preData.attemptId){
  202. this.examUserExamCommitmentConfirm(1,this.preData.attemptId);
  203. }else{
  204. examUserExamStart({examId:this.preData.examId,examScene:1,}).then(response => {
  205. if(response.data.attemptId){
  206. this.examUserExamCommitmentConfirm(2,response.data.attemptId);
  207. }else{
  208. this.msgError(response.message)
  209. }
  210. })
  211. }
  212. },
  213. examUserExamCommitmentConfirm(type,attemptId){
  214. examUserExamCommitmentConfirm({attemptId:attemptId}).then(response => {
  215. if(type == 1){
  216. this.$router.push({
  217. path: '/startTheExam',
  218. query: {
  219. attemptId: attemptId,
  220. type: '1',
  221. examKind:this.preData.examKind,
  222. }
  223. })
  224. }else if(type == 2){
  225. this.$router.push({
  226. path: '/startTheExam',
  227. query: {
  228. examId: this.preData.examId,
  229. attemptId: attemptId,
  230. type: '1',
  231. examKind:this.preData.examKind,
  232. }
  233. })
  234. }
  235. })
  236. },
  237. //开始考试判断是否有承诺书
  238. setRichExamData(item){
  239. if(item.commitmentEnabled == 1 && !item.commitmentConfirmed){
  240. this.$set(this,'preButtonType',item.commitmentPrintEnabled == 1?true:false);
  241. this.$set(this,'richTextHtml',item.commitmentContent);
  242. this.$set(this,'preData',item);
  243. this.$set(this,'preExamDialogType',true);
  244. }else{
  245. if(item.attemptId){
  246. this.$router.push({
  247. path: '/startTheExam',
  248. query: {
  249. attemptId: item.attemptId,
  250. type: '1',
  251. examKind:item.examKind,
  252. }
  253. })
  254. }else{
  255. examUserExamStart({examId:item.examId,examScene:1,}).then(response => {
  256. if(response.data.attemptId){
  257. this.$router.push({
  258. path: '/startTheExam',
  259. query: {
  260. examId: item.examId,
  261. attemptId: response.data.attemptId,
  262. type: '1',
  263. examKind:item.examKind,
  264. }
  265. })
  266. }else{
  267. this.msgError(response.message)
  268. }
  269. })
  270. }
  271. }
  272. },
  273. //操作按钮
  274. tableButton(type, item) {
  275. let self = this
  276. if (type == 1) {
  277. if(item.examStudy&&item.courseId){
  278. //学习课程
  279. this.$router.push({
  280. path: '/learningCourse',
  281. query: {
  282. courseId: item.courseId,
  283. examId: item.examId,
  284. }
  285. })
  286. }else{
  287. //学时要求
  288. let obj = {
  289. examName:item.examName,
  290. knowledgePointIds:item.knowledgePointIds,
  291. completedStudyHours:item.completedStudyHours,
  292. studyHoursRequirement:item.studyHoursRequirement,
  293. }
  294. let text = Encrypt(JSON.stringify(obj))
  295. self.$router.push({
  296. path: '/safetyEducationExaminationNew/safetyEducation/knowledgeLearning',
  297. query: {
  298. text : text
  299. }
  300. })
  301. }
  302. }else if(type == 2){
  303. //学习课程
  304. this.$router.push({
  305. path: '/learningCourse',
  306. query: {
  307. courseId: item.courseId,
  308. examId: item.examId,
  309. }
  310. })
  311. }else if(type == 3){
  312. //模拟考试
  313. if(item.mockExamId){
  314. this.$router.push({
  315. path: '/mockExam',
  316. query: {
  317. examId: item.examId,
  318. attemptId: item.mockExamId,
  319. }
  320. })
  321. }else{
  322. examUserExamStart({examId:item.examId,examScene:2,}).then(response => {
  323. if(response.data.attemptId){
  324. this.$router.push({
  325. path: '/mockExam',
  326. query: {
  327. examId: item.examId,
  328. attemptId: response.data.attemptId,
  329. }
  330. })
  331. }else{
  332. this.msgError(response.message)
  333. }
  334. })
  335. }
  336. }else if(type == 4){
  337. //在线考试//补考
  338. this.setRichExamData(item);
  339. }else if (type == 6) {
  340. //返回并刷新
  341. this.$set(this, 'pageType', 1)
  342. this.getList()
  343. }
  344. },
  345. examUserExamTypeSelectExamType(){
  346. let self = this;
  347. examUserExamTypeSelectExamType({examType:1}).then(response => {
  348. let num = 0;
  349. for(let i=0;i<response.data.length;i++){
  350. num = self.accAdd(num,response.data[i].examTypeCount);
  351. }
  352. let list = [{
  353. examTypeId:'',
  354. examTypeName:'全部',
  355. examTypeCount:num
  356. }];
  357. this.$set(this,'topDataList',[...list,...response.data])
  358. this.getList();
  359. })
  360. },
  361. //加法
  362. accAdd(arg1,arg2){
  363. var r1,r2,m;
  364. try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
  365. try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
  366. m=Math.pow(10,Math.max(r1,r2))
  367. return ((arg1*m+arg2*m)/m).toFixed(0);
  368. },
  369. },
  370. beforeRouteLeave(to, from, next) {
  371. if (to.name === 'learningCourse'||to.name === 'mockExam'||to.name === 'startTheExam') {
  372. const skipQueryParamsData = {
  373. queryParams: this.queryParams,
  374. dateRange: this.dateRange,
  375. examTypeId: this.examTypeId,
  376. examStatus: this.examStatus,
  377. };
  378. sessionStorage.setItem('skipQueryParamsData', JSON.stringify(skipQueryParamsData));
  379. } else {
  380. sessionStorage.removeItem('skipQueryParamsData');
  381. }
  382. next(); // 必须调用 next() 放行路由
  383. },
  384. }
  385. </script>
  386. <style scoped lang="scss">
  387. .onlineExam {
  388. .onlineExamPage {
  389. .pageTitle{
  390. height:60px;
  391. line-height:60px;
  392. padding:0 20px;
  393. border-bottom:1px solid #dedede;
  394. }
  395. .page-form-title-box{
  396. padding-top:8px;
  397. height: 72px;
  398. }
  399. .top-max-button-box{
  400. padding:20px 20px 8px;
  401. p{
  402. display: inline-block;
  403. padding:0 20px;
  404. text-align: center;
  405. color:#666;
  406. border:1px solid #666;
  407. line-height:40px;
  408. font-size:16px;
  409. border-radius:4px;
  410. min-width:80px;
  411. margin-right:10px;
  412. cursor: pointer;
  413. }
  414. .check-button{
  415. background-color: #0183fa;
  416. color:#fff;
  417. border:1px solid #0183fa;
  418. }
  419. }
  420. .table-top-button-box{
  421. display: inline-block;
  422. vertical-align: top;
  423. margin-right:10px;
  424. div{
  425. display: flex;
  426. p{
  427. border:1px solid #DCDFE6;
  428. width:80px;
  429. text-align: center;
  430. height:40px;
  431. line-height:40px;
  432. cursor: pointer;
  433. font-size:14px;
  434. }
  435. p:nth-child(1){
  436. border-top-left-radius:4px;
  437. border-bottom-left-radius:4px;
  438. }
  439. p:nth-child(2){
  440. border-left:none;
  441. border-right:none;
  442. }
  443. p:nth-child(3){
  444. border-top-right-radius:4px;
  445. border-bottom-right-radius:4px;
  446. }
  447. p:nth-child(4){
  448. border-top-right-radius:4px;
  449. border-bottom-right-radius:4px;
  450. }
  451. .check-table-button{
  452. border:1px solid #0183fa;
  453. background-color: #0183fa;
  454. color:#fff;
  455. }
  456. }
  457. }
  458. .page-content-box{
  459. padding:10px 0;
  460. }
  461. .for-max-big-box{
  462. flex:1;
  463. .for-big-box{
  464. display: inline-block;
  465. width:760px;
  466. margin:10px 0 10px 20px;
  467. border-radius:10px;
  468. overflow: hidden;
  469. box-shadow: 0 2px 8px rgba(37, 50, 74, 0.12);
  470. position: relative;
  471. padding:20px;
  472. .top-box{
  473. height:60px;
  474. }
  475. .bottom-box{
  476. background-color: rgba(1,131,250,0.1);
  477. padding:10px 20px 20px;
  478. border-radius:10px;
  479. margin-top:10px;
  480. }
  481. .title-p{
  482. color:#0183fa;
  483. font-size:16px;
  484. font-weight:700;
  485. line-height:20px;
  486. }
  487. .text-p{
  488. font-size:14px;
  489. margin-top:10px;
  490. line-height:20px;
  491. }
  492. .text-big-p{
  493. font-size:14px;
  494. margin-top:10px;
  495. line-height:20px;
  496. }
  497. .time-p{
  498. border-radius:4px;
  499. font-size:14px;
  500. margin-top:20px;
  501. line-height:20px;
  502. }
  503. .position-p-1{
  504. position:absolute;
  505. top:30px;
  506. right:30px;
  507. border:1px solid #0183fa;
  508. color:#0183fa;
  509. background-color: rgba(1,131,250,0.2);
  510. border-radius:4px;
  511. font-size:14px;
  512. line-height:30px;
  513. width:180px;
  514. text-align: center;
  515. cursor: pointer;
  516. }
  517. .position-p-3{
  518. position:absolute;
  519. top:30px;
  520. right:30px;
  521. border:1px solid #0183fa;
  522. border-radius:4px;
  523. font-size:14px;
  524. line-height:30px;
  525. width:180px;
  526. text-align: center;
  527. cursor: pointer;
  528. color:#fff!important;
  529. background-color: #0183fa!important;
  530. }
  531. }
  532. }
  533. }
  534. }
  535. </style>