AutoBuildPaperStructManage.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div>
  3. <el-dialog
  4. :visible.sync="modalIsShow"
  5. title="试卷结构列表"
  6. :modal="false"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. fullscreen
  11. @opened="dialogOpened"
  12. >
  13. <!-- 正文信息 -->
  14. <div class="part-box">
  15. <el-form class="part-filter-form" :inline="true" :model="filter">
  16. <el-form-item label="课程名称">
  17. <course-select v-model="filter.courseId" :disabled="!!courseId">
  18. </course-select>
  19. </el-form-item>
  20. <el-form-item label="结构名称">
  21. <el-input
  22. v-model="filter.structName"
  23. placeholder="结构名称"
  24. ></el-input>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="danger" @click="toPage(1)">查询</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <div class="part-box-action">
  31. <el-button
  32. type="danger"
  33. plain
  34. icon="el-icon-delete"
  35. @click="toBatchDelete"
  36. >批量删除</el-button
  37. >
  38. </div>
  39. </div>
  40. <div class="part-box">
  41. <el-table
  42. v-loading="loading"
  43. element-loading-text="加载中"
  44. :data="dataList"
  45. @selection-change="tableSelectChange"
  46. >
  47. <el-table-column
  48. type="selection"
  49. width="50"
  50. align="center"
  51. ></el-table-column>
  52. <el-table-column label="试卷结构名称" prop="structName">
  53. </el-table-column>
  54. <el-table-column label="关联课程">
  55. <template slot-scope="scope">
  56. <span
  57. >{{ scope.row.courseName }}({{ scope.row.courseCode }})</span
  58. >
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="大题数" prop="detailCount" width="100">
  62. </el-table-column>
  63. <el-table-column label="小题数" prop="questionCount" width="100">
  64. </el-table-column>
  65. <el-table-column label="总分" prop="totalScore" width="100">
  66. </el-table-column>
  67. <el-table-column label="创建人" prop="creatorName" width="120">
  68. </el-table-column>
  69. <el-table-column label="创建时间" width="170" prop="creationTime">
  70. </el-table-column>
  71. <el-table-column label="操作" width="180" fixed="right">
  72. <template slot-scope="scope">
  73. <div class="operate_left">
  74. <el-button
  75. size="mini"
  76. type="primary"
  77. plain
  78. @click="toEdit(scope.row)"
  79. >编辑</el-button
  80. >
  81. <el-button
  82. size="mini"
  83. type="danger"
  84. plain
  85. @click="toDelete(scope.row)"
  86. >删除</el-button
  87. >
  88. </div>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <div class="part-page">
  93. <el-pagination
  94. :current-page="currentPage"
  95. :page-size="pageSize"
  96. :page-sizes="[10, 20, 50, 100, 200, 300]"
  97. layout="total, sizes, prev, pager, next, jumper"
  98. :total="total"
  99. @current-change="toPage"
  100. @size-change="handleSizeChange"
  101. >
  102. </el-pagination>
  103. </div>
  104. </div>
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <script>
  109. import {
  110. autoBuildPaperStructPageListApi,
  111. autoBuildPaperStructDeleteApi,
  112. } from "../api";
  113. export default {
  114. name: "AutoBuildPaperStructManage",
  115. props: {
  116. courseId: {
  117. type: [String, Number],
  118. default: "",
  119. },
  120. },
  121. data() {
  122. return {
  123. modalIsShow: false,
  124. loading: false,
  125. filter: {
  126. courseId: "",
  127. structName: "",
  128. },
  129. dataList: [],
  130. currentPage: 1,
  131. pageSize: 10,
  132. total: 0,
  133. selectedQuestionIds: [],
  134. };
  135. },
  136. methods: {
  137. dialogOpened() {
  138. this.filter.courseId = this.courseId;
  139. this.toPage(1);
  140. },
  141. cancel() {
  142. this.modalIsShow = false;
  143. },
  144. open() {
  145. this.modalIsShow = true;
  146. },
  147. toPage(page) {
  148. this.currentPage = page;
  149. this.getList();
  150. },
  151. async getList() {
  152. this.loading = true;
  153. let data = {
  154. ...this.filter,
  155. curPage: this.currentPage,
  156. pageSize: this.pageSize,
  157. };
  158. const res = await autoBuildPaperStructPageListApi(data).catch(() => {});
  159. this.loading = false;
  160. if (!res) return;
  161. this.dataList = res.data.content;
  162. this.total = res.data.totalElements;
  163. },
  164. handleSizeChange(val) {
  165. this.pageSize = val;
  166. this.toPage(1);
  167. },
  168. tableSelectChange(selections) {
  169. this.selectedQuestionIds = selections.map((item) => item.id);
  170. },
  171. toEdit(row) {
  172. console.log(row);
  173. },
  174. async toDelete(row) {
  175. const confirm = await this.$confirm("确认删除结构吗?", "提示", {
  176. type: "warning",
  177. }).catch(() => {});
  178. if (confirm !== "confirm") return;
  179. this.deleteStruct([row.id]);
  180. },
  181. async deleteStruct(ids) {
  182. this.loading = true;
  183. const res = await autoBuildPaperStructDeleteApi(ids.join()).catch(
  184. (error) => {
  185. this.$message.error(error.response.data.desc);
  186. }
  187. );
  188. if (!res) return;
  189. this.$message.success("删除成功");
  190. this.getList();
  191. },
  192. async toBatchDelete() {
  193. if (!this.selectedQuestionIds.length) {
  194. this.$message.error("请选择试题!");
  195. return;
  196. }
  197. const confirm = await this.$confirm("确认删除选中数据吗?", "提示", {
  198. type: "warning",
  199. }).catch(() => {});
  200. if (confirm !== "confirm") return;
  201. this.deleteStruct(this.selectedQuestionIds);
  202. },
  203. },
  204. };
  205. </script>