CheckDuplicateInfo.vue 6.8 KB

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