index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <!--个人考试-->
  2. <template>
  3. <div class="app-container exam_my">
  4. <div class="pageOne" v-if="pageType==1">
  5. <!--<p class="add-button-one-120"-->
  6. <!--v-if="tableType==1"-->
  7. <!--@click="tableSwitch(2)"-->
  8. <!--&gt;<i class="el-icon-document"></i>考试记录</p>-->
  9. <p class="reset-button-one"
  10. v-if="tableType==2"
  11. @click="tableSwitch(1)"
  12. ><i class="el-icon-arrow-left"></i>返回</p>
  13. <div class="el-table-box" v-if="tableType==1">
  14. <el-table v-loading="loading" border :data="examList">
  15. <el-table-column label="考试名称" align="left" prop="title" show-overflow-tooltip/>
  16. <el-table-column label="描述" align="left" prop="content" show-overflow-tooltip/>
  17. <el-table-column label="考试类型" align="left" prop="content">
  18. <template slot-scope="scope">
  19. <p :class="scope.row.scopeType==1?'border-colorA':(scope.row.scopeType==2?'border-colorB':(scope.row.scopeType==3?'border-colorC':(scope.row.scopeType==4?'border-colorD':'')))">{{scope.row.scopeType==1?'安全准入考试':scope.row.scopeType==2?'负面清单考试':(scope.row.scopeType==3?'黑名单考试':scope.row.scopeType==4?'模拟考试':'')}}</p>
  20. </template>
  21. </el-table-column>
  22. <el-table-column label="试卷总分" align="left" prop="totalScore"/>
  23. <el-table-column label="及格分数" align="left" prop="qualifyScore"/>
  24. <el-table-column label="考试时长" align="left" prop="totalTime"/>
  25. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="130">
  26. <template slot-scope="scope">
  27. <div class="button-box" style="width:90px;margin:0 auto;">
  28. <p class="table-min-button"
  29. @click="pageSwitch(2,scope.row)"
  30. >立即参加
  31. </p>
  32. </div>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. <pagination :page-sizes="[20, 30, 40, 50]"
  37. v-show="total > 0 && tableType == 1"
  38. :total="total"
  39. layout="total, prev, pager, next, sizes, jumper"
  40. :page.sync="queryParams.pageNum"
  41. :limit.sync="queryParams.pageSize"
  42. @pagination="getList"
  43. />
  44. </div>
  45. <div class="for-max-box for-max-box-one" v-if="tableType==2">
  46. <el-table v-loading="loading" border :data="myListExam" @selection-change="handleSelectionChange">
  47. <el-table-column label="考试名称" align="left" prop="title" />
  48. <el-table-column label="考试得分" align="left" prop="userScore" />
  49. <el-table-column label="是否合格" align="left" prop="passed" >
  50. <template slot-scope="scope">
  51. <span>{{scope.row.userScore >= scope.row.qualifyScore ?'是':'否'}}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="考试时间" align="left" prop="createTime" width="180"/>
  55. </el-table>
  56. <pagination :page-sizes="[20, 30, 40, 50]"
  57. v-show="total>0"
  58. :total="total"
  59. layout="total, prev, pager, next, sizes, jumper"
  60. :page.sync="infoParams.pageNum"
  61. :limit.sync="infoParams.pageSize"
  62. @pagination="getMyListExam"
  63. />
  64. </div>
  65. </div>
  66. <exam-start v-if="pageType==2" :transferData="transferData" :violationId="violationId"></exam-start>
  67. <exam-info v-if="pageType==3"></exam-info>
  68. </div>
  69. </template>
  70. <script>
  71. import { onlineExamList } from "@/api/exam/exam";
  72. import examStart from "./exam_start.vue";
  73. import examInfo from "./exam_info.vue";
  74. import { myListExam, getExam } from "@/api/exam/user_exam";
  75. import { createPaper,paperId,listPaperAll } from "@/api/exam/paper";
  76. export default {
  77. components: {
  78. examStart,
  79. examInfo
  80. },
  81. name: "Exam",
  82. data() {
  83. return {
  84. loading:false,
  85. examList:[],
  86. myListExam: [],
  87. levels: [
  88. {
  89. type: 1,
  90. value: "中等",
  91. },
  92. {
  93. type: 2,
  94. value: "较难",
  95. },
  96. {
  97. type: 3,
  98. value: "难",
  99. },
  100. ],
  101. passeds: [
  102. {
  103. type: 0,
  104. value: "未通过",
  105. },
  106. {
  107. type: 1,
  108. value: "已通过",
  109. },
  110. ],
  111. //table状态
  112. tableType: 1,
  113. //页面状态
  114. pageType: 1,
  115. //传参数据
  116. transferData:{},
  117. //违规考试id
  118. violationId:"",
  119. // 选中数组
  120. ids: [],
  121. // 非单个禁用
  122. single: true,
  123. // 非多个禁用
  124. multiple: true,
  125. // 总条数
  126. total: 0,
  127. queryParams: {
  128. pageNum: 1,
  129. pageSize:20,
  130. joinUserId: null,
  131. deptId: null,
  132. deptName: null,
  133. examId: null,
  134. title: null,
  135. totalTime: null,
  136. userTime: null,
  137. totalScore: null,
  138. qualifyScore: null,
  139. objScore: null,
  140. subjScore: null,
  141. userScore: null,
  142. hasSaq: null,
  143. state: null,
  144. limitTime: null,
  145. userId: null,
  146. },
  147. infoParams: {
  148. pageNum: 1,
  149. pageSize:20,
  150. scopeType: 1
  151. }
  152. };
  153. },
  154. created() {
  155. },
  156. mounted(){
  157. this.getList();
  158. },
  159. methods: {
  160. // 多选框选中数据
  161. handleSelectionChange(selection) {
  162. this.ids = selection.map(item => item.id)
  163. this.single = selection.length!==1
  164. this.multiple = !selection.length
  165. },
  166. /** 查询我的考试记录列表 */
  167. getMyListExam() {
  168. this.loading = true;
  169. listPaperAll(this.infoParams).then(response => {
  170. this.myListExam = response.rows;
  171. this.total = response.total;
  172. this.loading = false;
  173. });
  174. // myListExam({}).then(response => {
  175. // this.myListExam = response.rows;
  176. // // this.total = response.total;
  177. // this.loading = false;
  178. // });
  179. },
  180. pageSwitch(type,item){
  181. if(this.pageType!=type){
  182. if(type==1){
  183. this.pageType = type;
  184. }else if(type==2){ //立即参加
  185. // 组卷
  186. createPaper({examId:item.id}).then(response => {
  187. if(response.code == 303){
  188. // 需要完成安全培训
  189. this.$confirm(response.msg)
  190. .then(_ => {
  191. localStorage.setItem('startLearningInfoId',response.data.courseId);
  192. this.$router.push({
  193. path: `/safetyEducationExam/safeLearning/safeLearning`,
  194. // query:{
  195. // id: response.data.courseId,
  196. // }
  197. })
  198. })
  199. .catch(_ => {});
  200. }else{
  201. // 开始考试
  202. paperId(response.data).then(response => {
  203. this.transferData = response.data;
  204. this.pageType = type;
  205. })
  206. }
  207. });
  208. }else if(type==3){ //查看详情
  209. }
  210. }
  211. },
  212. tableSwitch(type){
  213. if(this.tableType!=type){
  214. this.tableType = type;
  215. this.getList();
  216. }
  217. if(this.tableType == 2){
  218. this.getMyListExam()
  219. }
  220. },
  221. /** 查询考试列表 */
  222. getList() {
  223. let prams = {}
  224. // 交卷参数需要传值
  225. if(this.$route.query.violationId){
  226. this.violationId = this.$route.query.violationId
  227. }
  228. if(this.$route.query.scopeType){
  229. prams.scopeType = this.$route.query.scopeType
  230. }
  231. this.$router.push({query:{}})
  232. this.loading = true;
  233. prams.scopeType = 4;
  234. onlineExamList(prams).then(response => {
  235. this.examList = response.rows;
  236. this.total = response.total;
  237. this.loading = false;
  238. });
  239. },
  240. }
  241. };
  242. </script>
  243. <style scoped lang="scss">
  244. .exam_my{
  245. flex:1;
  246. overflow: hidden;
  247. display: flex!important;
  248. flex-direction: column;
  249. .pageOne{
  250. flex:1;
  251. padding-bottom:20px;
  252. display: flex!important;
  253. flex-direction: column;
  254. .el-table-box{
  255. flex:1;
  256. display: flex !important;
  257. flex-direction: column;
  258. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  259. padding: 20px !important;
  260. border-radius:10px;
  261. }
  262. p{
  263. margin:0;
  264. }
  265. .add-button-one-120{
  266. height:40px;
  267. margin:20px 0 10px 20px;
  268. }
  269. .reset-button-one{
  270. height:40px;
  271. width:90px;
  272. font-size:14px;
  273. margin:20px 0 10px 20px;
  274. }
  275. .for-max-box-one{
  276. display: flex;
  277. flex-direction: column;
  278. border-radius:10px;
  279. margin:10px 20px 0;
  280. padding:20px;
  281. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  282. }
  283. .for-max-box{
  284. flex:1;
  285. overflow-y: scroll;
  286. .for-box{
  287. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  288. margin:10px 20px 20px;
  289. border-radius:10px;
  290. height:120px;
  291. display: flex;
  292. .for-title-box{
  293. width:550px;
  294. margin:26px 0 32px 20px;
  295. .for-title-box-top{
  296. display: flex;
  297. p:nth-child(1){
  298. max-width:350px;
  299. height:30px;
  300. line-height:30px;
  301. font-size:16px;
  302. display:block;
  303. overflow:hidden;
  304. text-overflow:ellipsis;
  305. white-space:nowrap;
  306. }
  307. p:nth-child(2){
  308. height:30px;
  309. line-height:30px;
  310. width:60px;
  311. font-size:14px;
  312. margin:0 12px 0 12px;
  313. text-align: center;
  314. }
  315. p:nth-child(3){
  316. height:30px;
  317. line-height:30px;
  318. padding:0 10px;
  319. font-size:14px;
  320. text-align: center;
  321. border-radius:4px;
  322. }
  323. .border-colorA{
  324. color:#0183FA;
  325. border:1px solid #0183FA;
  326. }
  327. .border-colorB{
  328. color:#FFC76E;
  329. border:1px solid #FFC76E;
  330. }
  331. .border-colorC{
  332. color:#FF3B3B ;
  333. border:1px solid #FF3B3B ;
  334. }
  335. .border-colorD{
  336. color:#14AE10 ;
  337. border:1px solid #14AE10 ;
  338. }
  339. }
  340. .for-title-box-bottom{
  341. line-height:48px;
  342. font-size:14px;
  343. }
  344. }
  345. .for-text-box{
  346. line-height:110px;
  347. display: flex;
  348. font-size:16px;
  349. width:240px;font-family: Microsoft YaHei;
  350. font-weight: bold;
  351. }
  352. .null-p{
  353. flex:1;
  354. }
  355. .for-right-button{
  356. cursor:pointer;
  357. font-size:16px;
  358. line-height:110px;
  359. margin-right:80px;
  360. i{
  361. margin-left:5px;
  362. }
  363. }
  364. }
  365. .null-box{
  366. height:100%;
  367. width:100%;
  368. position: relative;
  369. img{
  370. width:276px;
  371. height:274px;
  372. position: absolute;
  373. top:50%;
  374. left:50%;
  375. margin-top:-207px;
  376. margin-left:-138px;
  377. }
  378. p{
  379. width:276px;
  380. position: absolute;
  381. color:#999;
  382. text-align: center;
  383. top:50%;
  384. left:50%;
  385. margin-top:100px;
  386. margin-left:-174px;
  387. }
  388. }
  389. }
  390. .for-max-box::-webkit-scrollbar{
  391. width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
  392. height: 4px;
  393. }
  394. .for-max-box::-webkit-scrollbar-thumb{
  395. border-radius: 5px;
  396. -webkit-box-shadow: inset 0 0 5px #999;
  397. background: #fff;
  398. }
  399. }
  400. }
  401. </style>