AuditQuestionUnsubmit.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="audit-question-unsubmit">
  3. <!-- <el-form class="part-filter-form" inline>
  4. <el-form-item label="提交人">
  5. <el-input
  6. v-model="filter.creatorName"
  7. placeholder="请输入提交人姓名"
  8. ></el-input>
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="primary" @click="toPage(1)">查询</el-button>
  12. </el-form-item>
  13. </el-form> -->
  14. <div>
  15. <el-table
  16. v-loading="loading"
  17. element-loading-text="拼命加载中"
  18. :data="dataList"
  19. >
  20. <el-table-column label="试题">
  21. <div slot-scope="scope" @click="toViewQuestion(scope.row)">
  22. <rich-text
  23. class="row-question-body"
  24. title="点击查看试题"
  25. :text-json="scope.row.quesBody"
  26. ></rich-text>
  27. </div>
  28. </el-table-column>
  29. <el-table-column label="课程">
  30. <template slot-scope="scope">
  31. <span
  32. >{{ scope.row.course.name }}({{ scope.row.course.code }})</span
  33. >
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="提交人" prop="creator" width="150">
  37. </el-table-column>
  38. <el-table-column label="修改时间" prop="updateTime" width="153">
  39. </el-table-column>
  40. <el-table-column label="操作" width="170" fixed="right">
  41. <template slot-scope="scope">
  42. <div class="operate_left">
  43. <el-button
  44. size="medium"
  45. type="text"
  46. class="normal"
  47. @click="toEdit(scope.row)"
  48. >编辑</el-button
  49. >
  50. <el-button
  51. size="medium"
  52. type="text"
  53. class="normal"
  54. @click="toSubmit(scope.row)"
  55. >提交</el-button
  56. >
  57. </div>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <div class="part-page">
  62. <el-pagination
  63. :current-page="currentPage"
  64. :page-size="pageSize"
  65. :page-sizes="[10, 20, 50, 100, 200, 300]"
  66. layout="total, sizes, prev, pager, next, jumper"
  67. :total="total"
  68. @current-change="toPage"
  69. @size-change="handleSizeChange"
  70. >
  71. </el-pagination>
  72. </div>
  73. </div>
  74. <!-- QuestionEditDialog -->
  75. <question-edit-dialog
  76. ref="QuestionEditDialog"
  77. :question="curQuestion"
  78. @modified="getList"
  79. ></question-edit-dialog>
  80. <!-- QuestionPreviewDialog -->
  81. <question-preview-dialog
  82. ref="QuestionPreviewDialog"
  83. :list-info="listInfo"
  84. :fetchPage="toPage"
  85. show-switch
  86. ></question-preview-dialog>
  87. </div>
  88. </template>
  89. <script>
  90. import { auditQuestionsUnsubmitPageListApi, submitQuestionApi } from "../api";
  91. import QuestionEditDialog from "./QuestionEditDialog.vue";
  92. import QuestionPreviewDialog from "./QuestionPreviewDialog.vue";
  93. export default {
  94. name: "AuditQuestionUnsubmit",
  95. components: { QuestionEditDialog, QuestionPreviewDialog },
  96. data() {
  97. return {
  98. filter: { creatorName: "" },
  99. dataList: [],
  100. currentPage: 1,
  101. pageSize: 10,
  102. total: 0,
  103. totalPages: 0,
  104. loading: false,
  105. curQuestion: {},
  106. curQuestionIndex: 0,
  107. };
  108. },
  109. computed: {
  110. listInfo() {
  111. return {
  112. dataList: this.dataList,
  113. curIndex: this.curQuestionIndex,
  114. pageNumber: this.currentPage,
  115. totalPages: this.totalPages,
  116. };
  117. },
  118. },
  119. mounted() {
  120. this.toPage(1);
  121. },
  122. methods: {
  123. async toPage(page) {
  124. this.currentPage = page;
  125. await this.getList();
  126. },
  127. async getList() {
  128. this.loading = true;
  129. const res = await auditQuestionsUnsubmitPageListApi({
  130. ...this.filter,
  131. curPage: this.currentPage,
  132. pageSize: this.pageSize,
  133. }).catch(() => {});
  134. this.loading = false;
  135. if (!res) return;
  136. this.dataList = res.data.content;
  137. this.total = res.data.totalElements;
  138. this.totalPages = res.data.totalPages;
  139. },
  140. handleSizeChange(val) {
  141. this.pageSize = val;
  142. this.toPage(1);
  143. },
  144. toViewQuestion(row) {
  145. this.curQuestionIndex = this.dataList.findIndex((q) => q.id === row.id);
  146. this.$refs.QuestionPreviewDialog.open();
  147. },
  148. toEdit(row) {
  149. this.curQuestion = row;
  150. this.$refs.QuestionEditDialog.open();
  151. },
  152. async toSubmit(row) {
  153. const confirm = await this.$confirm(`确定要提交该试题吗?`, "提示", {
  154. type: "warning",
  155. }).catch(() => {});
  156. if (confirm !== "confirm") return;
  157. await submitQuestionApi([row.id]);
  158. this.$message.success("操作成功!");
  159. this.$bus.emit("updateBadge");
  160. this.getList();
  161. },
  162. },
  163. };
  164. </script>