AutoBuildPaperStructManage.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <div>
  3. <el-dialog
  4. :visible.sync="modalIsShow"
  5. title="试卷结构列表"
  6. :modal="true"
  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="primary" @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="220" 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="toUse(scope.row)"
  79. >使用</el-button
  80. >
  81. <el-button
  82. size="mini"
  83. type="primary"
  84. plain
  85. @click="toEdit(scope.row)"
  86. >编辑</el-button
  87. >
  88. <el-button
  89. size="mini"
  90. type="danger"
  91. plain
  92. @click="toDelete(scope.row)"
  93. >删除</el-button
  94. >
  95. </div>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <div class="part-page">
  100. <el-pagination
  101. :current-page="currentPage"
  102. :page-size="pageSize"
  103. :page-sizes="[10, 20, 50, 100, 200, 300]"
  104. layout="total, sizes, prev, pager, next, jumper"
  105. :total="total"
  106. @current-change="toPage"
  107. @size-change="handleSizeChange"
  108. >
  109. </el-pagination>
  110. </div>
  111. </div>
  112. </el-dialog>
  113. <!-- ModifyAutoBuildPaperStruct -->
  114. <modify-auto-build-paper-struct
  115. ref="ModifyAutoBuildPaperStruct"
  116. :instance="curRow"
  117. @modified="getList"
  118. ></modify-auto-build-paper-struct>
  119. </div>
  120. </template>
  121. <script>
  122. import {
  123. autoBuildPaperStructPageListApi,
  124. autoBuildPaperStructDeleteApi,
  125. } from "../api";
  126. import ModifyAutoBuildPaperStruct from "./ModifyAutoBuildPaperStruct.vue";
  127. export default {
  128. name: "AutoBuildPaperStructManage",
  129. components: { ModifyAutoBuildPaperStruct },
  130. props: {
  131. courseId: {
  132. type: [String, Number],
  133. default: "",
  134. },
  135. },
  136. data() {
  137. return {
  138. modalIsShow: false,
  139. loading: false,
  140. filter: {
  141. courseId: "",
  142. structName: "",
  143. },
  144. dataList: [],
  145. currentPage: 1,
  146. pageSize: 10,
  147. total: 0,
  148. curRow: {},
  149. selectedQuestionIds: [],
  150. };
  151. },
  152. methods: {
  153. dialogOpened() {
  154. this.filter.courseId = this.courseId;
  155. this.toPage(1);
  156. },
  157. cancel() {
  158. this.modalIsShow = false;
  159. },
  160. open() {
  161. this.modalIsShow = true;
  162. },
  163. toPage(page) {
  164. this.currentPage = page;
  165. this.getList();
  166. },
  167. async getList() {
  168. this.loading = true;
  169. let data = {
  170. ...this.filter,
  171. curPage: this.currentPage,
  172. pageSize: this.pageSize,
  173. };
  174. const res = await autoBuildPaperStructPageListApi(data).catch(() => {});
  175. this.loading = false;
  176. if (!res) return;
  177. this.dataList = res.data.content;
  178. this.total = res.data.totalElements;
  179. },
  180. handleSizeChange(val) {
  181. this.pageSize = val;
  182. this.toPage(1);
  183. },
  184. tableSelectChange(selections) {
  185. this.selectedQuestionIds = selections.map((item) => item.id);
  186. },
  187. toUse(row) {
  188. this.$emit("selected", row);
  189. this.cancel();
  190. },
  191. toEdit(row) {
  192. this.curRow = row;
  193. this.$refs.ModifyAutoBuildPaperStruct.open();
  194. },
  195. async toDelete(row) {
  196. const confirm = await this.$confirm("确认删除结构吗?", "提示", {
  197. type: "warning",
  198. }).catch(() => {});
  199. if (confirm !== "confirm") return;
  200. this.deleteStruct([row.id]);
  201. },
  202. async deleteStruct(ids) {
  203. this.loading = true;
  204. const res = await autoBuildPaperStructDeleteApi(ids.join()).catch(
  205. () => {}
  206. );
  207. this.loading = false;
  208. if (!res) return;
  209. this.$message.success("删除成功");
  210. this.getList();
  211. },
  212. async toBatchDelete() {
  213. if (!this.selectedQuestionIds.length) {
  214. this.$message.error("请选择试题!");
  215. return;
  216. }
  217. const confirm = await this.$confirm("确认删除选中数据吗?", "提示", {
  218. type: "warning",
  219. }).catch(() => {});
  220. if (confirm !== "confirm") return;
  221. this.deleteStruct(this.selectedQuestionIds);
  222. },
  223. },
  224. };
  225. </script>