index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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, } 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. tableButtonType: this.hasPermiDom(['demo:demo:detail', 'demo:demo:edit', 'demo:demo:del']),
  109. //页面状态
  110. pageType: 1,
  111. //横向列表
  112. topDataList:[],
  113. //查询条件
  114. examTypeId:'',
  115. examStatus:'',
  116. queryParams: {
  117. page: 1,
  118. pageSize: 20,
  119. searchValue: '',
  120. },
  121. //时间数据
  122. dateRange: [],
  123. //列表数据
  124. dataList: [],
  125. //数据数量
  126. total: 0,
  127. //组件传参
  128. propsData: {},
  129. //考前承诺相关
  130. preExamDialogType:false,
  131. preButtonType:false,
  132. richTextHtml: '',
  133. preData:null,
  134. }
  135. },
  136. created() {
  137. },
  138. mounted() {
  139. this.examUserExamTypeSelectExamType();
  140. },
  141. methods: {
  142. topCheckButton(examTypeId){
  143. if(this.examTypeId !== examTypeId){
  144. this.$set(this,'examTypeId',examTypeId);
  145. this.handleQuery()
  146. }
  147. },
  148. //切换按钮
  149. tableTypeButton(val){
  150. if(this.examStatus !== val){
  151. this.$set(this,'examStatus',val);
  152. this.handleQuery();
  153. }
  154. },
  155. //查询按钮
  156. handleQuery() {
  157. this.$set(this.queryParams, 'page', 1)
  158. this.getList()
  159. },
  160. //重置按钮
  161. resetQuery() {
  162. this.$set(this, 'dateRange', [])
  163. this.$set(this, 'queryParams', {
  164. page: 1,
  165. pageSize: 20,
  166. searchValue: '',
  167. })
  168. this.getList()
  169. },
  170. //获取数据列表
  171. getList() {
  172. let obj = JSON.parse(JSON.stringify(this.queryParams))
  173. obj.examTypeId = this.examTypeId;
  174. obj.examStatus = this.examStatus;
  175. if (this.dateRange[0]) {
  176. obj.startTime = this.dateRange[0] + 'T00:00:00'
  177. obj.endTime = this.dateRange[1] + 'T23:59:59'
  178. } else {
  179. obj.startTime = ''
  180. obj.endTime = ''
  181. }
  182. examUserExamList(obj).then(response => {
  183. this.$set(this, 'dataList', response.data.records)
  184. this.$set(this, 'total', response.data.total)
  185. })
  186. },
  187. //下载承诺书
  188. preExamDialogCancel(){
  189. this.msgSuccess('正在下载,请耐心等候')
  190. this.$refs['richTextPdf'].downloadPDF();
  191. },
  192. //确认承诺-并考试
  193. examUserExamStart(){
  194. if(this.preData.attemptId){
  195. this.$router.push({
  196. path: '/startTheExam',
  197. query: {
  198. attemptId: this.preData.attemptId,
  199. type: '1',
  200. examKind:this.preData.examKind,
  201. }
  202. })
  203. }else{
  204. examUserExamStart({examId:this.preData.examId,examScene:1,}).then(response => {
  205. if(response.data.attemptId){
  206. this.$router.push({
  207. path: '/startTheExam',
  208. query: {
  209. examId: this.preData.examId,
  210. attemptId: response.data.attemptId,
  211. type: '1',
  212. examKind:this.preData.examKind,
  213. }
  214. })
  215. }else{
  216. this.msgError(response.message)
  217. }
  218. })
  219. }
  220. },
  221. //开始考试判断是否有承诺书
  222. setRichExamData(item){
  223. if(item.commitmentEnabled == 1){
  224. this.$set(this,'preButtonType',item.commitmentPrintEnabled == 1?true:false);
  225. this.$set(this,'richTextHtml',item.commitmentContent);
  226. this.$set(this,'preData',item);
  227. this.$set(this,'preExamDialogType',true);
  228. }else{
  229. if(item.attemptId){
  230. this.$router.push({
  231. path: '/startTheExam',
  232. query: {
  233. attemptId: item.attemptId,
  234. type: '1',
  235. examKind:item.examKind,
  236. }
  237. })
  238. }else{
  239. examUserExamStart({examId:item.examId,examScene:1,}).then(response => {
  240. if(response.data.attemptId){
  241. this.$router.push({
  242. path: '/startTheExam',
  243. query: {
  244. examId: item.examId,
  245. attemptId: response.data.attemptId,
  246. type: '1',
  247. examKind:item.examKind,
  248. }
  249. })
  250. }else{
  251. this.msgError(response.message)
  252. }
  253. })
  254. }
  255. }
  256. },
  257. //操作按钮
  258. tableButton(type, item) {
  259. let self = this
  260. if (type == 1) {
  261. //学时要求
  262. self.$router.push({
  263. path: '/safetyEducationExaminationNew/safetyEducation/knowledgeLearning',
  264. query: {}
  265. })
  266. }else if(type == 2){
  267. //学习课程
  268. this.$router.push({
  269. path: '/learningCourse',
  270. query: {
  271. courseId: item.courseId,
  272. examId: item.examId,
  273. }
  274. })
  275. }else if(type == 3){
  276. //模拟考试
  277. if(item.mockExamId){
  278. this.$router.push({
  279. path: '/mockExam',
  280. query: {
  281. examId: item.examId,
  282. attemptId: item.mockExamId,
  283. }
  284. })
  285. }else{
  286. examUserExamStart({examId:item.examId,examScene:2,}).then(response => {
  287. if(response.data.attemptId){
  288. this.$router.push({
  289. path: '/mockExam',
  290. query: {
  291. examId: item.examId,
  292. attemptId: response.data.attemptId,
  293. }
  294. })
  295. }else{
  296. this.msgError(response.message)
  297. }
  298. })
  299. }
  300. }else if(type == 4){
  301. //在线考试//补考
  302. this.setRichExamData(item);
  303. }else if (type == 6) {
  304. //返回并刷新
  305. this.$set(this, 'pageType', 1)
  306. this.getList()
  307. }
  308. },
  309. examUserExamTypeSelectExamType(){
  310. let self = this;
  311. examUserExamTypeSelectExamType({examType:1}).then(response => {
  312. let num = 0;
  313. for(let i=0;i<response.data.length;i++){
  314. num = self.accAdd(num,response.data[i].examTypeCount);
  315. }
  316. let list = [{
  317. examTypeId:'',
  318. examTypeName:'全部',
  319. examTypeCount:num
  320. }];
  321. this.$set(this,'topDataList',[...list,...response.data])
  322. this.getList();
  323. })
  324. },
  325. //加法
  326. accAdd(arg1,arg2){
  327. var r1,r2,m;
  328. try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
  329. try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
  330. m=Math.pow(10,Math.max(r1,r2))
  331. return ((arg1*m+arg2*m)/m).toFixed(0);
  332. },
  333. }
  334. }
  335. </script>
  336. <style scoped lang="scss">
  337. .onlineExam {
  338. .onlineExamPage {
  339. .pageTitle{
  340. height:60px;
  341. line-height:60px;
  342. padding:0 20px;
  343. border-bottom:1px solid #dedede;
  344. }
  345. .page-form-title-box{
  346. padding-top:8px;
  347. height: 72px;
  348. }
  349. .top-max-button-box{
  350. padding:20px 20px 8px;
  351. p{
  352. display: inline-block;
  353. padding:0 20px;
  354. text-align: center;
  355. color:#666;
  356. border:1px solid #666;
  357. line-height:40px;
  358. font-size:16px;
  359. border-radius:4px;
  360. min-width:80px;
  361. margin-right:10px;
  362. cursor: pointer;
  363. }
  364. .check-button{
  365. background-color: #0183fa;
  366. color:#fff;
  367. border:1px solid #0183fa;
  368. }
  369. }
  370. .table-top-button-box{
  371. display: inline-block;
  372. vertical-align: top;
  373. margin-right:10px;
  374. div{
  375. display: flex;
  376. p{
  377. border:1px solid #DCDFE6;
  378. width:80px;
  379. text-align: center;
  380. height:40px;
  381. line-height:40px;
  382. cursor: pointer;
  383. font-size:14px;
  384. }
  385. p:nth-child(1){
  386. border-top-left-radius:4px;
  387. border-bottom-left-radius:4px;
  388. }
  389. p:nth-child(2){
  390. border-left:none;
  391. }
  392. p:nth-child(3){
  393. border-top-right-radius:4px;
  394. border-bottom-right-radius:4px;
  395. }
  396. p:nth-child(4){
  397. border-top-right-radius:4px;
  398. border-bottom-right-radius:4px;
  399. }
  400. .check-table-button{
  401. border:1px solid #0183fa;
  402. background-color: #0183fa;
  403. color:#fff;
  404. }
  405. }
  406. }
  407. .page-content-box{
  408. padding:10px 0;
  409. }
  410. .for-max-big-box{
  411. flex:1;
  412. .for-big-box{
  413. display: inline-block;
  414. width:760px;
  415. margin:10px 0 10px 20px;
  416. border-radius:10px;
  417. overflow: hidden;
  418. box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
  419. position: relative;
  420. padding:20px;
  421. .top-box{
  422. height:60px;
  423. }
  424. .bottom-box{
  425. background-color: rgba(1,131,250,0.1);
  426. padding:10px 20px 20px;
  427. border-radius:10px;
  428. margin-top:10px;
  429. }
  430. .title-p{
  431. color:#0183fa;
  432. font-size:16px;
  433. font-weight:700;
  434. line-height:20px;
  435. }
  436. .text-p{
  437. font-size:14px;
  438. margin-top:10px;
  439. line-height:20px;
  440. }
  441. .text-big-p{
  442. font-size:14px;
  443. margin-top:10px;
  444. line-height:20px;
  445. }
  446. .time-p{
  447. border-radius:4px;
  448. font-size:14px;
  449. margin-top:20px;
  450. line-height:20px;
  451. }
  452. .position-p-1{
  453. position:absolute;
  454. top:30px;
  455. right:30px;
  456. border:1px solid #0183fa;
  457. color:#0183fa;
  458. background-color: rgba(1,131,250,0.2);
  459. border-radius:4px;
  460. font-size:14px;
  461. line-height:30px;
  462. width:180px;
  463. text-align: center;
  464. cursor: pointer;
  465. }
  466. .position-p-3{
  467. position:absolute;
  468. top:30px;
  469. right:30px;
  470. border:1px solid #0183fa;
  471. border-radius:4px;
  472. font-size:14px;
  473. line-height:30px;
  474. width:180px;
  475. text-align: center;
  476. cursor: pointer;
  477. color:#fff!important;
  478. background-color: #0183fa!important;
  479. }
  480. }
  481. }
  482. }
  483. }
  484. </style>