index.vue 12 KB

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