QuestionRecycle.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div class="content question-recycle">
  3. <div class="part-box">
  4. <div class="part-box-header">
  5. <h2 class="part-box-title">回收站</h2>
  6. <el-button type="danger" plain @click="goback">返回</el-button>
  7. </div>
  8. <div class="part-box-action">
  9. <div>
  10. <el-button
  11. type="primary"
  12. plain
  13. icon="el-icon-data-analysis"
  14. @click="toBatchRecover"
  15. >恢复</el-button
  16. >
  17. <el-button
  18. type="danger"
  19. plain
  20. icon="el-icon-lock"
  21. @click="toBatchDelete"
  22. >删除</el-button
  23. >
  24. </div>
  25. <div>
  26. <el-button
  27. type="primary"
  28. plain
  29. icon="el-icon-folder-opened"
  30. @click="toClear"
  31. >清空回收站</el-button
  32. >
  33. </div>
  34. </div>
  35. </div>
  36. <div class="part-box">
  37. <el-table
  38. v-loading="loading"
  39. element-loading-text="加载中"
  40. :data="dataList"
  41. @selection-change="tableSelectChange"
  42. >
  43. <el-table-column
  44. type="selection"
  45. width="50"
  46. align="center"
  47. ></el-table-column>
  48. <el-table-column label="文件夹/试题">
  49. <template slot-scope="scope">
  50. <rich-text
  51. class="row-question-body"
  52. title="点击查看试题"
  53. :text-json="scope.row.quesBody"
  54. @click="toViewQuestion(scope.row)"
  55. ></rich-text>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="课程" width="120">
  59. <template slot-scope="scope">
  60. <span>{{ scope.row.course.name }}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="题型" width="100">
  64. <template slot-scope="scope">
  65. <span>{{ scope.row.questionType | questionType }}</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="操作人" width="120">
  69. <template slot-scope="scope">
  70. <span>{{ scope.row.creator }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="删除时间" width="170" prop="creationTime">
  74. </el-table-column>
  75. <el-table-column label="操作" width="180" fixed="right">
  76. <template slot-scope="scope">
  77. <div class="operate_left">
  78. <el-button
  79. size="mini"
  80. type="primary"
  81. plain
  82. @click="toRecover(scope.row)"
  83. >恢复</el-button
  84. >
  85. <el-button
  86. size="mini"
  87. type="danger"
  88. plain
  89. @click="toDelete(scope.row)"
  90. >删除</el-button
  91. >
  92. </div>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. <div class="part-page">
  97. <el-pagination
  98. :current-page="currentPage"
  99. :page-size="pageSize"
  100. :page-sizes="[10, 20, 50, 100, 200, 300]"
  101. layout="total, sizes, prev, pager, next, jumper"
  102. :total="total"
  103. @current-change="toPage"
  104. @size-change="handleSizeChange"
  105. >
  106. </el-pagination>
  107. </div>
  108. </div>
  109. </div>
  110. </template>
  111. <script>
  112. import {
  113. questionRecycleListApi,
  114. recoverQuestionApi,
  115. thoroughDeleteQuestionApi,
  116. clearQuestionRecycleApi,
  117. } from "../api";
  118. export default {
  119. name: "QuestionRecycle",
  120. data() {
  121. return {
  122. dataList: [],
  123. currentPage: 1,
  124. pageSize: 10,
  125. total: 0,
  126. selectedIds: [],
  127. };
  128. },
  129. mounted() {
  130. // this.toPage(1);
  131. },
  132. methods: {
  133. toPage(page) {
  134. this.currentPage = page;
  135. this.getList();
  136. },
  137. async getList() {
  138. this.selectedIds = [];
  139. this.loading = true;
  140. const res = await questionRecycleListApi({
  141. curPage: this.currentPage,
  142. pageSize: this.pageSize,
  143. }).catch(() => {});
  144. this.loading = false;
  145. if (!res) return;
  146. this.dataList = res.data.content;
  147. this.total = res.data.totalElements;
  148. },
  149. tableSelectChange(selections) {
  150. this.selectedIds = selections.map((item) => item.id);
  151. },
  152. async toClear() {
  153. const confirm = await this.$confirm("确认要清空回收站吗?", "提示", {
  154. type: "warning",
  155. }).catch(() => {});
  156. if (confirm !== "confirm") return;
  157. this.loading = true;
  158. const res = await clearQuestionRecycleApi().catch((error) => {
  159. this.$notify({
  160. message: error.response.data.desc,
  161. type: "error",
  162. });
  163. });
  164. if (!res) return;
  165. this.$notify({
  166. message: "操作成功",
  167. type: "success",
  168. });
  169. this.toPage(1);
  170. },
  171. async toDelete(row) {
  172. const confirm = await this.$confirm("确认彻底删除数据吗?", "提示", {
  173. type: "warning",
  174. }).catch(() => {});
  175. if (confirm !== "confirm") return;
  176. this.deleteData([row.id]);
  177. },
  178. async deleteData(ids) {
  179. this.loading = true;
  180. const res = await thoroughDeleteQuestionApi(ids).catch((error) => {
  181. this.$notify({
  182. message: error.response.data.desc,
  183. type: "error",
  184. });
  185. });
  186. if (!res) return;
  187. this.$notify({
  188. message: "删除成功",
  189. type: "success",
  190. });
  191. this.getList();
  192. },
  193. async toBatchDelete() {
  194. if (!this.selectedIds.length) {
  195. this.$message.error("请选择数据!");
  196. return;
  197. }
  198. const confirm = await this.$confirm("确认彻底删除选中数据吗?", "提示", {
  199. type: "warning",
  200. }).catch(() => {});
  201. if (confirm !== "confirm") return;
  202. this.deleteData(this.selectedIds);
  203. },
  204. async toRecover(row) {
  205. const confirm = await this.$confirm("确认恢复数据吗?", "提示", {
  206. type: "warning",
  207. }).catch(() => {});
  208. if (confirm !== "confirm") return;
  209. this.recoverData([row.id]);
  210. },
  211. async recoverData(ids) {
  212. this.loading = true;
  213. const res = await recoverQuestionApi(ids).catch((error) => {
  214. this.$notify({
  215. message: error.response.data.desc,
  216. type: "error",
  217. });
  218. });
  219. if (!res) return;
  220. this.$notify({
  221. message: "操作成功",
  222. type: "success",
  223. });
  224. this.getList();
  225. },
  226. async toBatchRecover() {
  227. if (!this.selectedIds.length) {
  228. this.$message.error("请选择数据!");
  229. return;
  230. }
  231. const confirm = await this.$confirm("确认恢复选中数据吗?", "提示", {
  232. type: "warning",
  233. }).catch(() => {});
  234. if (confirm !== "confirm") return;
  235. this.recoverData(this.selectedIds);
  236. },
  237. toViewQuestion(row) {
  238. console.log(row);
  239. },
  240. },
  241. };
  242. </script>