index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <!-- 模拟考试 -->
  2. <template>
  3. <div class="app-container mockExam">
  4. <div class="page-container mockExamPage" 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 === 2?'check-table-button':''" @click="tableTypeButton(2)">已完成</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-3" v-if="item.conditionType == 3" @click="tableButton(3,item)">开始模拟考试</p>
  63. <!--<p class="position-p-2" @click="tableButton(2)">历史错题</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. </div>
  77. </template>
  78. <script>
  79. //import { getDicts } from "@/api/commonality/noPermission";
  80. //import { systemUserSelect } from "@/api/commonality/permission";
  81. //import { getInfo } from "@/api/basicsModules/index";
  82. //import addPage from "./addPage.vue";
  83. import { examUserExamMockList,examUserExamTypeSelectExamType,examUserExamStart, } from "@/api/safetyEducationExaminationNew/index";
  84. export default {
  85. name: 'index',
  86. data() {
  87. return {
  88. tableButtonType: this.hasPermiDom(['demo:demo:detail', 'demo:demo:edit', 'demo:demo:del']),
  89. //页面状态
  90. pageType: 1,
  91. //横向列表
  92. topDataList:[],
  93. //查询条件
  94. examTypeId:'',
  95. examStatus:'',
  96. queryParams: {
  97. page: 1,
  98. pageSize: 20,
  99. searchValue: '',
  100. },
  101. //时间数据
  102. dateRange: [],
  103. //列表数据
  104. dataList: [],
  105. //数据数量
  106. total: 0,
  107. //组件传参
  108. propsData: {}
  109. }
  110. },
  111. created() {
  112. },
  113. mounted() {
  114. if(sessionStorage.getItem('skipQueryParamsData')){
  115. let skipQueryParamsData = JSON.parse(sessionStorage.getItem('skipQueryParamsData'))
  116. this.$set(this,'queryParams',skipQueryParamsData.queryParams);
  117. this.$set(this,'dateRange',skipQueryParamsData.dateRange);
  118. this.$set(this,'examTypeId',skipQueryParamsData.examTypeId);
  119. this.$set(this,'examStatus',skipQueryParamsData.examStatus);
  120. sessionStorage.removeItem('skipQueryParamsData');
  121. }
  122. this.examUserExamTypeSelectExamType();
  123. },
  124. methods: {
  125. topCheckButton(examTypeId){
  126. if(this.examTypeId != examTypeId){
  127. this.$set(this,'examTypeId',examTypeId);
  128. this.handleQuery()
  129. }
  130. },
  131. //切换按钮
  132. tableTypeButton(val){
  133. if(this.examStatus !== val){
  134. this.$set(this,'examStatus',val);
  135. this.handleQuery();
  136. }
  137. },
  138. //查询按钮
  139. handleQuery() {
  140. this.$set(this.queryParams, 'page', 1)
  141. this.getList()
  142. },
  143. //重置按钮
  144. resetQuery() {
  145. this.$set(this, 'dateRange', [])
  146. this.$set(this, 'queryParams', {
  147. page: 1,
  148. pageSize: 20,
  149. searchValue: '',
  150. })
  151. this.getList()
  152. },
  153. //获取数据列表
  154. getList() {
  155. let obj = JSON.parse(JSON.stringify(this.queryParams))
  156. obj.examTypeId = this.examTypeId;
  157. obj.examStatus = this.examStatus;
  158. if (this.dateRange[0]) {
  159. obj.startTime = this.dateRange[0] + 'T00:00:00'
  160. obj.endTime = this.dateRange[1] + 'T23:59:59'
  161. } else {
  162. obj.startTime = ''
  163. obj.endTime = ''
  164. }
  165. examUserExamMockList(obj).then(response => {
  166. this.$set(this, 'dataList', response.data.records)
  167. this.$set(this, 'total', response.data.total)
  168. })
  169. },
  170. //操作按钮
  171. tableButton(type, item) {
  172. let self = this
  173. if (type == 1) {
  174. if(item.examStudy&&item.courseId){
  175. //学习课程
  176. this.$router.push({
  177. path: '/learningCourse',
  178. query: {
  179. courseId: item.courseId,
  180. examId: item.examId,
  181. }
  182. })
  183. }else{
  184. //学时要求
  185. let obj = {
  186. examName:item.examName,
  187. knowledgePointIds:item.knowledgePointIds,
  188. completedStudyHours:item.completedStudyHours,
  189. studyHoursRequirement:item.studyHoursRequirement,
  190. }
  191. let text = Encrypt(JSON.stringify(obj))
  192. self.$router.push({
  193. path: '/safetyEducationExaminationNew/safetyEducation/knowledgeLearning',
  194. query: {
  195. text : text
  196. }
  197. })
  198. }
  199. }else if(type == 2){
  200. //学习课程
  201. this.$router.push({
  202. path: '/learningCourse',
  203. query: {
  204. courseId: item.courseId,
  205. examId: item.examId,
  206. }
  207. })
  208. }else if(type == 3){
  209. //模拟考试
  210. if(item.attemptId){
  211. this.$router.push({
  212. path: '/mockExam',
  213. query: {
  214. examId: item.examId,
  215. attemptId: item.attemptId,
  216. }
  217. })
  218. }else{
  219. examUserExamStart({examId:item.examId,examScene:2,}).then(response => {
  220. if(response.data.attemptId){
  221. this.$router.push({
  222. path: '/mockExam',
  223. query: {
  224. examId: item.examId,
  225. attemptId: response.data.attemptId,
  226. }
  227. })
  228. }else{
  229. this.msgError(response.message)
  230. }
  231. })
  232. }
  233. }else if (type == 6) {
  234. //返回并刷新
  235. this.$set(this, 'pageType', 1)
  236. this.getList()
  237. }
  238. },
  239. examUserExamTypeSelectExamType(){
  240. let self = this;
  241. examUserExamTypeSelectExamType({examType:2}).then(response => {
  242. let num = 0;
  243. for(let i=0;i<response.data.length;i++){
  244. num = self.accAdd(num,response.data[i].examTypeCount);
  245. }
  246. let list = [{
  247. examTypeId:'',
  248. examTypeName:'全部',
  249. examTypeCount:num
  250. }];
  251. this.$set(this,'topDataList',[...list,...response.data])
  252. this.getList();
  253. })
  254. },
  255. //加法
  256. accAdd(arg1,arg2){
  257. var r1,r2,m;
  258. try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
  259. try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
  260. m=Math.pow(10,Math.max(r1,r2))
  261. return ((arg1*m+arg2*m)/m).toFixed(0);
  262. },
  263. },
  264. beforeRouteLeave(to, from, next) {
  265. if (to.name === 'learningCourse'||to.name === 'mockExam') {
  266. const skipQueryParamsData = {
  267. queryParams: this.queryParams,
  268. dateRange: this.dateRange,
  269. examTypeId: this.examTypeId,
  270. examStatus: this.examStatus,
  271. };
  272. sessionStorage.setItem('skipQueryParamsData', JSON.stringify(skipQueryParamsData));
  273. } else {
  274. sessionStorage.removeItem('skipQueryParamsData');
  275. }
  276. next(); // 必须调用 next() 放行路由
  277. },
  278. }
  279. </script>
  280. <style scoped lang="scss">
  281. .mockExam {
  282. .mockExamPage {
  283. .pageTitle{
  284. height:60px;
  285. line-height:60px;
  286. padding:0 20px;
  287. border-bottom:1px solid #dedede;
  288. }
  289. .page-form-title-box{
  290. padding-top:8px;
  291. height: 72px;
  292. }
  293. .top-max-button-box{
  294. padding:20px 20px 8px;
  295. p{
  296. display: inline-block;
  297. padding:0 20px;
  298. text-align: center;
  299. color:#666;
  300. border:1px solid #666;
  301. line-height:40px;
  302. font-size:16px;
  303. border-radius:4px;
  304. min-width:80px;
  305. margin-right:10px;
  306. cursor: pointer;
  307. }
  308. .check-button{
  309. background-color: #0183fa;
  310. color:#fff;
  311. border:1px solid #0183fa;
  312. }
  313. }
  314. .table-top-button-box{
  315. display: inline-block;
  316. vertical-align: top;
  317. margin-right:10px;
  318. div{
  319. display: flex;
  320. p{
  321. border:1px solid #DCDFE6;
  322. width:80px;
  323. text-align: center;
  324. height:40px;
  325. line-height:40px;
  326. cursor: pointer;
  327. font-size:14px;
  328. }
  329. p:nth-child(1){
  330. border-top-left-radius:4px;
  331. border-bottom-left-radius:4px;
  332. }
  333. p:nth-child(2){
  334. border-left:none;
  335. }
  336. p:nth-child(3){
  337. border-top-right-radius:4px;
  338. border-bottom-right-radius:4px;
  339. }
  340. p:nth-child(4){
  341. border-top-right-radius:4px;
  342. border-bottom-right-radius:4px;
  343. }
  344. .check-table-button{
  345. border:1px solid #0183fa;
  346. background-color: #0183fa;
  347. color:#fff;
  348. }
  349. }
  350. }
  351. .page-content-box{
  352. padding:10px 0;
  353. }
  354. .for-max-big-box{
  355. flex:1;
  356. .for-big-box{
  357. display: inline-block;
  358. width:760px;
  359. margin:10px 0 10px 20px;
  360. border-radius:10px;
  361. overflow: hidden;
  362. box-shadow: 0 2px 8px rgba(37, 50, 74, 0.12);
  363. position: relative;
  364. padding:20px;
  365. .top-box{
  366. height:60px;
  367. }
  368. .bottom-box{
  369. background-color: rgba(1,131,250,0.1);
  370. padding:10px 20px 20px;
  371. border-radius:10px;
  372. margin-top:10px;
  373. }
  374. .title-p{
  375. color:#0183fa;
  376. font-size:16px;
  377. font-weight:700;
  378. line-height:20px;
  379. }
  380. .text-p{
  381. font-size:14px;
  382. margin-top:10px;
  383. line-height:20px;
  384. }
  385. .text-big-p{
  386. font-size:14px;
  387. margin-top:10px;
  388. line-height:20px;
  389. }
  390. .time-p{
  391. border-radius:4px;
  392. font-size:14px;
  393. margin-top:20px;
  394. line-height:20px;
  395. }
  396. .position-p-1{
  397. position:absolute;
  398. top:30px;
  399. right:30px;
  400. border:1px solid #0183fa;
  401. color:#0183fa;
  402. background-color: rgba(1,131,250,0.2);
  403. border-radius:4px;
  404. font-size:14px;
  405. line-height:30px;
  406. width:180px;
  407. text-align: center;
  408. cursor: pointer;
  409. }
  410. .position-p-2{
  411. position:absolute;
  412. bottom:100px;
  413. right:40px;
  414. border:1px solid #0183fa;
  415. color:#fff;
  416. background-color: rgba(1,131,250,1);
  417. border-radius:4px;
  418. font-size:14px;
  419. line-height:30px;
  420. width:80px;
  421. text-align: center;
  422. cursor: pointer;
  423. }
  424. .position-p-3{
  425. position:absolute;
  426. top:30px;
  427. right:30px;
  428. border:1px solid #0183fa;
  429. border-radius:4px;
  430. font-size:14px;
  431. line-height:30px;
  432. width:180px;
  433. text-align: center;
  434. cursor: pointer;
  435. color:#fff!important;
  436. background-color: #0183fa!important;
  437. }
  438. }
  439. }
  440. }
  441. }
  442. </style>