ExamIndex.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <el-container>
  3. <el-header height="220">
  4. <el-row>
  5. <el-select
  6. v-model="queryInfo.subjectId"
  7. clearable
  8. placeholder="请选择科目"
  9. style="margin-left: 5px"
  10. @change="subjectChange"
  11. >
  12. <el-option
  13. v-for="item in allSubject"
  14. :key="item.key"
  15. :label="item.value"
  16. :value="item.key"
  17. />
  18. </el-select>
  19. </el-row>
  20. </el-header>
  21. <el-main>
  22. <el-table
  23. :data="dataList"
  24. border
  25. style="width: 100%"
  26. >
  27. <el-table-column
  28. fixed="left"
  29. label="No"
  30. type="index"
  31. />
  32. <el-table-column
  33. prop="examName"
  34. label="考试名称"
  35. width="150"
  36. />
  37. <el-table-column
  38. prop="type"
  39. label="考试类型"
  40. width="90"
  41. />
  42. <el-table-column
  43. prop="startTime"
  44. label="考试时间"
  45. width="150"
  46. />
  47. <el-table-column
  48. prop="duration"
  49. label="考试时长(分钟)"
  50. width="150"
  51. />
  52. <el-table-column
  53. prop="totalScore"
  54. label="考试总分"
  55. />
  56. <el-table-column
  57. prop="passScore"
  58. label="及格分数"
  59. />
  60. <el-table-column
  61. fixed="right"
  62. label="操作"
  63. width="320"
  64. >
  65. <template slot-scope="scope">
  66. <el-button
  67. size="mini"
  68. type="warning"
  69. @click="prepareExam(scope.$index, scope.row)"
  70. >去考试</el-button>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. <el-pagination
  75. background
  76. :small="screenWidth <= 768"
  77. layout="prev, pager, next"
  78. :page-size="pageSize"
  79. :current-page="currentPage"
  80. :total="totalSize"
  81. @current-change="handleCurrentChange"
  82. @prev-click="handleCurrentChange"
  83. @next-click="handleCurrentChange"
  84. />
  85. </el-main>
  86. <el-dialog
  87. title="考试提示"
  88. :visible.sync="startExamDialog"
  89. center
  90. width="50%"
  91. >
  92. <el-alert
  93. title="点击`开始考试`后将自动进入考试,请诚信考试,考试过程中可能会对用户行为、用户视频进行截图采样,请知悉!"
  94. type="error"
  95. />
  96. <el-card style="margin-top: 25px">
  97. <span>考试名称:</span>{{ currentSelectedExam.examName }}
  98. <br>
  99. <span>考试描述:</span>{{ currentSelectedExam.examDesc }}
  100. <br>
  101. <span>考试时长:</span>{{ currentSelectedExam.duration + '分钟' }}
  102. <br>
  103. <span>试卷总分:</span>{{ currentSelectedExam.totalScore }}分
  104. <br>
  105. <span>及格分数:</span>{{ currentSelectedExam.passScore }}分
  106. <br>
  107. <span>开放类型:</span> {{ currentSelectedExam.type === 2 ? '需要密码' : '完全公开' }}
  108. <br>
  109. </el-card>
  110. <span slot="footer" class="dialog-footer">
  111. <el-button @click="startExamDialog = false">返 回</el-button>
  112. <el-button type="primary" @click="startExam(currentSelectedExam.examId)">开始考试</el-button>
  113. </span>
  114. </el-dialog>
  115. </el-container>
  116. </template>
  117. <script>
  118. import { getSubjectKV, getPapers } from '@/api/exam'
  119. export default {
  120. name: 'ExamIndex',
  121. data() {
  122. return {
  123. // 屏幕宽度, 为了控制分页条的大小
  124. screenWidth: document.body.clientWidth,
  125. currentPage: 1,
  126. pageSize: 20,
  127. totalSize: 0,
  128. dataList: [],
  129. // **********************************************************************
  130. queryInfo: {
  131. subjectId: null,
  132. pageNumber: 1,
  133. pageSize: 10
  134. },
  135. allSubject: [],
  136. // 开始考试的提示框
  137. startExamDialog: false,
  138. // 当前选中的考试的信息
  139. currentSelectedExam: {
  140. examId: 114511
  141. }
  142. }
  143. },
  144. created() {
  145. document.title = '我的试卷'
  146. this.getData(this.queryInfo)
  147. this.getSubjects()
  148. // this.getQuestionTypes()
  149. },
  150. methods: {
  151. handleCurrentChange(pageNumber) {
  152. this.currentPage = pageNumber
  153. this.queryInfo.pageNumber = this.currentPage
  154. this.queryInfo.pageSize = this.pageSize
  155. this.getData(this.queryInfo)
  156. // 回到顶部
  157. scrollTo(0, 0)
  158. },
  159. getData(queryInfo) {
  160. getPapers(queryInfo).then(resp => {
  161. if (resp.code === 0) {
  162. this.dataList = resp.data.list
  163. this.totalSize = resp.data.totalSize
  164. } else {
  165. this.$notify({
  166. title: '提示',
  167. message: resp.msg,
  168. type: 'warning',
  169. duration: 3000
  170. })
  171. }
  172. }).catch(error => {
  173. this.$notify({
  174. title: '提示',
  175. message: error.message,
  176. type: 'error',
  177. duration: 3000
  178. })
  179. })
  180. },
  181. getSubjects() {
  182. getSubjectKV().then((resp) => {
  183. if (resp.code === 0) {
  184. this.allSubject = resp.data
  185. }
  186. })
  187. },
  188. // 题库变化
  189. subjectChange(val) {
  190. this.queryInfo.subjectId = val
  191. this.queryInfo.pageNumber = this.currentPage
  192. this.queryInfo.pageSize = this.pageSize
  193. this.getData(this.queryInfo)
  194. },
  195. prepareExam(index, row) {
  196. row.password = 12345678
  197. row.type = 1
  198. if (row.type === 2) {
  199. this.$prompt('请提供考试密码', 'Tips', {
  200. confirmButtonText: '确定',
  201. cancelButtonText: '取消'
  202. }).then(({ value }) => {
  203. if (value === row.password) {
  204. this.startExamDialog = true
  205. this.currentSelectedExam = row
  206. } else {
  207. this.$message.error('密码错误o(╥﹏╥)o')
  208. }
  209. }).catch(() => {
  210. })
  211. } else {
  212. this.startExamDialog = true
  213. this.currentSelectedExam = row
  214. }
  215. },
  216. startExam(paperId) {
  217. const path = '/exam/start/' + paperId
  218. console.log(path)
  219. this.$router.push('/exam/start/' + paperId)
  220. }
  221. }
  222. }
  223. </script>
  224. <style>
  225. </style>