ExamIndex.vue 6.3 KB

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