QuestionRecycle.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. v-if="scope.row.recycleType === 'QUESTION'"
  52. class="row-question-body"
  53. title="点击查看试题"
  54. :text-json="scope.row.name"
  55. ></rich-text>
  56. <div v-else>{{ scope.row.name }}</div>
  57. </template>
  58. </el-table-column>
  59. <el-table-column prop="courseName" label="课程" width="120">
  60. </el-table-column>
  61. <el-table-column prop="sourceDetailName" label="题型" width="100">
  62. </el-table-column>
  63. <el-table-column prop="operator" label="操作人" width="120">
  64. </el-table-column>
  65. <el-table-column label="删除时间" width="170" prop="deleteTime">
  66. </el-table-column>
  67. <el-table-column label="操作" width="160" fixed="right">
  68. <template slot-scope="scope">
  69. <div class="operate_left">
  70. <el-button
  71. size="mini"
  72. type="primary"
  73. plain
  74. @click="toRecover(scope.row)"
  75. >恢复</el-button
  76. >
  77. <el-button
  78. size="mini"
  79. type="danger"
  80. plain
  81. @click="toDelete(scope.row)"
  82. >删除</el-button
  83. >
  84. </div>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. </div>
  89. </div>
  90. </template>
  91. <script>
  92. import {
  93. questionRecycleListApi,
  94. recoverQuestionApi,
  95. thoroughDeleteQuestionApi,
  96. clearQuestionRecycleApi,
  97. } from "../api";
  98. export default {
  99. name: "QuestionRecycle",
  100. data() {
  101. return {
  102. dataList: [],
  103. loading: false,
  104. recycleParamList: [],
  105. };
  106. },
  107. mounted() {
  108. this.toPage(1);
  109. },
  110. methods: {
  111. toPage(page) {
  112. this.currentPage = page;
  113. this.getList();
  114. },
  115. async getList() {
  116. this.recycleParamList = [];
  117. this.loading = true;
  118. const res = await questionRecycleListApi().catch(() => {});
  119. this.loading = false;
  120. if (!res) return;
  121. res.data.forEach((item) => {
  122. if (item.recycleType === "QUESTION") {
  123. item.name = item.name ? JSON.parse(item.name) : null;
  124. }
  125. });
  126. this.dataList = res.data;
  127. },
  128. tableSelectChange(selections) {
  129. this.recycleParamList = selections.map((item) => {
  130. return {
  131. id: item.id,
  132. recycleType: item.recycleType,
  133. };
  134. });
  135. },
  136. async toClear() {
  137. const confirm = await this.$confirm("确认要清空回收站吗?", "提示", {
  138. type: "warning",
  139. }).catch(() => {});
  140. if (confirm !== "confirm") return;
  141. this.loading = true;
  142. const res = await clearQuestionRecycleApi().catch(() => {});
  143. this.loading = false;
  144. if (!res) return;
  145. this.$notify({
  146. message: "操作成功",
  147. type: "success",
  148. });
  149. this.toPage(1);
  150. },
  151. async toDelete(row) {
  152. const confirm = await this.$confirm("确认彻底删除数据吗?", "提示", {
  153. type: "warning",
  154. }).catch(() => {});
  155. if (confirm !== "confirm") return;
  156. this.deleteData([
  157. {
  158. id: row.id,
  159. recycleType: row.recycleType,
  160. },
  161. ]);
  162. },
  163. async deleteData(recycleParamList) {
  164. this.loading = true;
  165. const res = await thoroughDeleteQuestionApi(recycleParamList).catch(
  166. () => {}
  167. );
  168. this.loading = false;
  169. if (!res) return;
  170. this.$notify({
  171. message: "删除成功",
  172. type: "success",
  173. });
  174. this.getList();
  175. },
  176. async toBatchDelete() {
  177. if (!this.recycleParamList.length) {
  178. this.$message.error("请选择数据!");
  179. return;
  180. }
  181. const confirm = await this.$confirm("确认彻底删除选中数据吗?", "提示", {
  182. type: "warning",
  183. }).catch(() => {});
  184. if (confirm !== "confirm") return;
  185. this.deleteData(this.recycleParamList);
  186. },
  187. async toRecover(row) {
  188. const confirm = await this.$confirm("确认恢复数据吗?", "提示", {
  189. type: "warning",
  190. }).catch(() => {});
  191. if (confirm !== "confirm") return;
  192. this.recoverData([
  193. {
  194. id: row.id,
  195. recycleType: row.recycleType,
  196. },
  197. ]);
  198. },
  199. async recoverData(recycleParamList) {
  200. this.loading = true;
  201. const res = await recoverQuestionApi(recycleParamList).catch(() => {});
  202. this.loading = false;
  203. if (!res) return;
  204. this.$notify({
  205. message: "操作成功",
  206. type: "success",
  207. });
  208. this.getList();
  209. },
  210. async toBatchRecover() {
  211. if (!this.recycleParamList.length) {
  212. this.$message.error("请选择数据!");
  213. return;
  214. }
  215. const confirm = await this.$confirm("确认恢复选中数据吗?", "提示", {
  216. type: "warning",
  217. }).catch(() => {});
  218. if (confirm !== "confirm") return;
  219. this.recoverData(this.recycleParamList);
  220. },
  221. },
  222. };
  223. </script>