index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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. examList:[],
  85. myListExam: [],
  86. levels: [
  87. {
  88. type: 1,
  89. value: "中等",
  90. },
  91. {
  92. type: 2,
  93. value: "较难",
  94. },
  95. {
  96. type: 3,
  97. value: "难",
  98. },
  99. ],
  100. passeds: [
  101. {
  102. type: 0,
  103. value: "未通过",
  104. },
  105. {
  106. type: 1,
  107. value: "已通过",
  108. },
  109. ],
  110. //table状态
  111. tableType: 1,
  112. //页面状态
  113. pageType: 1,
  114. //传参数据
  115. transferData:{},
  116. //违规考试id
  117. violationId:"",
  118. // 选中数组
  119. ids: [],
  120. // 非单个禁用
  121. single: true,
  122. // 非多个禁用
  123. multiple: true,
  124. // 总条数
  125. total: 0,
  126. queryParams: {
  127. pageNum: 1,
  128. pageSize:20,
  129. joinUserId: null,
  130. deptId: null,
  131. deptName: null,
  132. examId: null,
  133. title: null,
  134. totalTime: null,
  135. userTime: null,
  136. totalScore: null,
  137. qualifyScore: null,
  138. objScore: null,
  139. subjScore: null,
  140. userScore: null,
  141. hasSaq: null,
  142. state: null,
  143. limitTime: null,
  144. userId: null,
  145. },
  146. infoParams: {
  147. pageNum: 1,
  148. pageSize:20,
  149. scopeType: 1
  150. }
  151. };
  152. },
  153. created() {
  154. },
  155. mounted(){
  156. this.getList();
  157. },
  158. methods: {
  159. // 多选框选中数据
  160. handleSelectionChange(selection) {
  161. this.ids = selection.map(item => item.id)
  162. this.single = selection.length!==1
  163. this.multiple = !selection.length
  164. },
  165. /** 查询我的考试记录列表 */
  166. getMyListExam() {
  167. this.loading = true;
  168. listPaperAll(this.infoParams).then(response => {
  169. this.myListExam = response.rows;
  170. this.total = response.total;
  171. this.loading = false;
  172. });
  173. // myListExam({}).then(response => {
  174. // this.myListExam = response.rows;
  175. // // this.total = response.total;
  176. // this.loading = false;
  177. // });
  178. },
  179. pageSwitch(type,item){
  180. if(this.pageType!=type){
  181. if(type==1){
  182. this.pageType = type;
  183. }else if(type==2){ //立即参加
  184. // 组卷
  185. createPaper({examId:item.id}).then(response => {
  186. if(response.code == 303){
  187. // 需要完成安全培训
  188. this.$confirm(response.msg)
  189. .then(_ => {
  190. localStorage.setItem('startLearningInfoId',response.data.courseId);
  191. this.$router.push({
  192. path: `/safetyEducationExam/safeLearning/safeLearning`,
  193. // query:{
  194. // id: response.data.courseId,
  195. // }
  196. })
  197. })
  198. .catch(_ => {});
  199. }else{
  200. // 开始考试
  201. paperId(response.data).then(response => {
  202. this.transferData = response.data;
  203. this.pageType = type;
  204. })
  205. }
  206. });
  207. }else if(type==3){ //查看详情
  208. }
  209. }
  210. },
  211. tableSwitch(type){
  212. if(this.tableType!=type){
  213. this.tableType = type;
  214. this.getList();
  215. }
  216. if(this.tableType == 2){
  217. this.getMyListExam()
  218. }
  219. },
  220. /** 查询考试列表 */
  221. getList() {
  222. let prams = {}
  223. // 交卷参数需要传值
  224. if(this.$route.query.violationId){
  225. this.violationId = this.$route.query.violationId
  226. }
  227. if(this.$route.query.scopeType){
  228. prams.scopeType = this.$route.query.scopeType
  229. }
  230. this.$router.push({query:{}})
  231. this.loading = true;
  232. prams.scopeType = 4;
  233. onlineExamList(prams).then(response => {
  234. this.examList = response.rows;
  235. this.total = response.total;
  236. this.loading = false;
  237. });
  238. },
  239. }
  240. };
  241. </script>
  242. <style scoped lang="scss">
  243. .exam_my{
  244. flex:1;
  245. overflow: hidden;
  246. display: flex!important;
  247. flex-direction: column;
  248. .pageOne{
  249. flex:1;
  250. padding-bottom:20px;
  251. display: flex!important;
  252. flex-direction: column;
  253. .el-table-box{
  254. flex:1;
  255. display: flex !important;
  256. flex-direction: column;
  257. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  258. padding: 20px !important;
  259. border-radius:10px;
  260. }
  261. p{
  262. margin:0;
  263. }
  264. .add-button-one-120{
  265. height:40px;
  266. margin:20px 0 10px 20px;
  267. }
  268. .reset-button-one{
  269. height:40px;
  270. width:90px;
  271. font-size:14px;
  272. margin:20px 0 10px 20px;
  273. }
  274. .for-max-box-one{
  275. display: flex;
  276. flex-direction: column;
  277. border-radius:10px;
  278. margin:10px 20px 0;
  279. padding:20px;
  280. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  281. }
  282. .for-max-box{
  283. flex:1;
  284. overflow-y: scroll;
  285. .for-box{
  286. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  287. margin:10px 20px 20px;
  288. border-radius:10px;
  289. height:120px;
  290. display: flex;
  291. .for-title-box{
  292. width:550px;
  293. margin:26px 0 32px 20px;
  294. .for-title-box-top{
  295. display: flex;
  296. p:nth-child(1){
  297. max-width:350px;
  298. height:30px;
  299. line-height:30px;
  300. font-size:16px;
  301. display:block;
  302. overflow:hidden;
  303. text-overflow:ellipsis;
  304. white-space:nowrap;
  305. }
  306. p:nth-child(2){
  307. height:30px;
  308. line-height:30px;
  309. width:60px;
  310. font-size:14px;
  311. margin:0 12px 0 12px;
  312. text-align: center;
  313. }
  314. p:nth-child(3){
  315. height:30px;
  316. line-height:30px;
  317. padding:0 10px;
  318. font-size:14px;
  319. text-align: center;
  320. border-radius:4px;
  321. }
  322. .border-colorA{
  323. color:#0183FA;
  324. border:1px solid #0183FA;
  325. }
  326. .border-colorB{
  327. color:#FFC76E;
  328. border:1px solid #FFC76E;
  329. }
  330. .border-colorC{
  331. color:#FF3B3B ;
  332. border:1px solid #FF3B3B ;
  333. }
  334. .border-colorD{
  335. color:#14AE10 ;
  336. border:1px solid #14AE10 ;
  337. }
  338. }
  339. .for-title-box-bottom{
  340. line-height:48px;
  341. font-size:14px;
  342. }
  343. }
  344. .for-text-box{
  345. line-height:110px;
  346. display: flex;
  347. font-size:16px;
  348. width:240px;font-family: Microsoft YaHei;
  349. font-weight: bold;
  350. }
  351. .null-p{
  352. flex:1;
  353. }
  354. .for-right-button{
  355. cursor:pointer;
  356. font-size:16px;
  357. line-height:110px;
  358. margin-right:80px;
  359. i{
  360. margin-left:5px;
  361. }
  362. }
  363. }
  364. .null-box{
  365. height:100%;
  366. width:100%;
  367. position: relative;
  368. img{
  369. width:276px;
  370. height:274px;
  371. position: absolute;
  372. top:50%;
  373. left:50%;
  374. margin-top:-207px;
  375. margin-left:-138px;
  376. }
  377. p{
  378. width:276px;
  379. position: absolute;
  380. color:#999;
  381. text-align: center;
  382. top:50%;
  383. left:50%;
  384. margin-top:100px;
  385. margin-left:-174px;
  386. }
  387. }
  388. }
  389. .for-max-box::-webkit-scrollbar{
  390. width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
  391. height: 4px;
  392. }
  393. .for-max-box::-webkit-scrollbar-thumb{
  394. border-radius: 5px;
  395. -webkit-box-shadow: inset 0 0 5px #999;
  396. background: #fff;
  397. }
  398. }
  399. }
  400. </style>