CheckDuplicateInfo.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div v-loading="loading" class="part-box">
  3. <div class="part-box-header">
  4. <h1 class="part-box-title">试题详情</h1>
  5. <div>
  6. <el-button type="primary" icon="icon icon-save-white" @click="retain"
  7. >保留</el-button
  8. >
  9. <el-button
  10. type="danger"
  11. plain
  12. icon="icon icon-delete"
  13. @click="deleteQues"
  14. >删除</el-button
  15. >
  16. <el-button type="danger" plain icon="icon icon-pass" @click="ignore"
  17. >跳过</el-button
  18. >
  19. <el-button type="danger" plain icon="icon icon-back" @click="back"
  20. >返回</el-button
  21. >
  22. </div>
  23. </div>
  24. <div class="part-page margin-tb-20">
  25. <el-button
  26. v-for="(city, index) in duplicateQuestions"
  27. :key="index"
  28. type="danger"
  29. :plain="duplicateQuestionIndex !== index"
  30. size="mini"
  31. @click="selChange(index)"
  32. >{{ index + 1 }}</el-button
  33. >
  34. </div>
  35. <el-row :gutter="20">
  36. <el-col :span="12">
  37. <QuestionInfo
  38. :question="curQuestion"
  39. style="height: 100%"
  40. ></QuestionInfo>
  41. </el-col>
  42. <el-col :span="12">
  43. <QuestionInfo
  44. :question="duplicateQuestion"
  45. info-type="right"
  46. style="height: 100%"
  47. ></QuestionInfo>
  48. </el-col>
  49. </el-row>
  50. </div>
  51. </template>
  52. <script>
  53. import { QUESTION_API } from "@/constants/constants";
  54. import { mapState } from "vuex";
  55. import QuestionInfo from "./QuestionInfo.vue";
  56. export default {
  57. components: {
  58. QuestionInfo,
  59. },
  60. data() {
  61. return {
  62. basePaperId: "",
  63. loading: false,
  64. ignoreIds: [],
  65. from: "",
  66. curQuestionId: "",
  67. curQuestion: {},
  68. duplicateQuestion: {},
  69. duplicateQuestions: [],
  70. duplicateQuestionIndex: 0,
  71. };
  72. },
  73. computed: {
  74. ...mapState({ user: (state) => state.user }),
  75. },
  76. //钩子函数
  77. created() {
  78. this.from = this.$route.query.from;
  79. if ("question" == this.from) {
  80. this.curQuestionId = this.$route.query.quesId;
  81. this.queryData();
  82. } else if ("list" == this.from) {
  83. this.$http
  84. .post(
  85. QUESTION_API + "/question/duplicate/next",
  86. new URLSearchParams({ ignoreIds: this.ignoreIds })
  87. )
  88. .then((response) => {
  89. if (response.data) {
  90. this.curQuestionId = response.data;
  91. this.queryData();
  92. } else {
  93. this.$notify({
  94. message: "没有需要处理的数据",
  95. type: "success",
  96. });
  97. }
  98. });
  99. } else if ("paper" == this.from) {
  100. this.basePaperId = this.$route.query.basePaperId;
  101. if (this.$route.query.quesId) {
  102. this.curQuestionId = this.$route.query.quesId;
  103. this.queryData();
  104. } else {
  105. this.$http
  106. .post(
  107. QUESTION_API + "/question/duplicate/next",
  108. new URLSearchParams({
  109. ignoreIds: this.ignoreIds,
  110. basePaperId: this.basePaperId,
  111. })
  112. )
  113. .then((response) => {
  114. if (response.data) {
  115. this.curQuestionId = response.data;
  116. this.queryData();
  117. } else {
  118. this.$notify({
  119. message: "没有需要处理的数据",
  120. type: "success",
  121. });
  122. }
  123. });
  124. }
  125. }
  126. },
  127. mounted() {
  128. setTimeout(() => {
  129. this.$store.commit("UPDATE_CURRENT_PATHS", ["题库查重", "试题详情"]);
  130. }, 200);
  131. },
  132. methods: {
  133. next() {
  134. this.$http
  135. .post(
  136. QUESTION_API + "/question/duplicate/next",
  137. new URLSearchParams({
  138. ignoreIds: this.ignoreIds,
  139. basePaperId: this.basePaperId,
  140. })
  141. )
  142. .then((response) => {
  143. if (response.data) {
  144. this.curQuestionId = response.data;
  145. this.queryData();
  146. } else {
  147. this.$notify({
  148. message: "当前已是最后一个",
  149. type: "success",
  150. });
  151. this.back();
  152. }
  153. });
  154. },
  155. ignore() {
  156. if (this.from == "question") {
  157. this.$router.push({
  158. path: "/questions/check_duplicate_list/0",
  159. });
  160. return;
  161. }
  162. this.ignoreIds.push(this.curQuestionId);
  163. this.next();
  164. },
  165. back() {
  166. this.$router.push({
  167. path: "/questions/check_duplicate_list/0",
  168. });
  169. },
  170. deleteQues() {
  171. this.$confirm("确认删除吗?", "提示", {
  172. type: "warning",
  173. }).then(() => {
  174. let quesIds = [];
  175. quesIds.push(this.curQuestionId);
  176. this.$http
  177. .post(
  178. QUESTION_API + "/question/duplicate/delete",
  179. new URLSearchParams({ questionIds: quesIds })
  180. )
  181. .then(() => {
  182. this.$notify({
  183. message: "删除成功",
  184. type: "success",
  185. });
  186. if (this.from == "question") {
  187. this.$router.push({
  188. path: "/questions/check_duplicate_list/0",
  189. });
  190. } else if (this.from == "list" || this.from == "paper") {
  191. this.next();
  192. }
  193. });
  194. });
  195. },
  196. retain() {
  197. let quesIds = [];
  198. quesIds.push(this.curQuestionId);
  199. this.$http
  200. .post(
  201. QUESTION_API + "/question/duplicate/retain",
  202. new URLSearchParams({ questionIds: quesIds })
  203. )
  204. .then(() => {
  205. this.$notify({
  206. message: "操作成功",
  207. type: "success",
  208. });
  209. if (this.from == "question") {
  210. this.$router.push({
  211. path: "/questions/check_duplicate_list/0",
  212. });
  213. } else if (this.from == "list" || this.from == "paper") {
  214. this.next();
  215. }
  216. });
  217. },
  218. selChange(val) {
  219. this.duplicateQuestion = this.duplicateQuestions[val];
  220. this.duplicateQuestionIndex = val;
  221. },
  222. async queryData() {
  223. this.$http
  224. .get(
  225. QUESTION_API + "/question/duplicate?questionId=" + this.curQuestionId
  226. )
  227. .then((response) => {
  228. this.curQuestion = response.data.curQuestion;
  229. this.duplicateQuestions = response.data.duplicateQuestions;
  230. if (this.duplicateQuestions && this.duplicateQuestions.length > 0) {
  231. this.duplicateQuestion = this.duplicateQuestions[0];
  232. }
  233. });
  234. },
  235. },
  236. };
  237. </script>