CheckDuplicateList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <section class="content">
  3. <!-- 正文信息 -->
  4. <div class="part-box">
  5. <h2 class="part-box-title">题库查重</h2>
  6. <el-form class="part-filter-form" :inline="true" :model="formSearch">
  7. <el-form-item label="课程名称">
  8. <el-select
  9. v-model="formSearch.courseNo"
  10. filterable
  11. :remote-method="getCourses"
  12. remote
  13. clearable
  14. placeholder="请选择"
  15. @clear="getCourses('')"
  16. >
  17. <el-option
  18. v-for="item in courseInfoSelect"
  19. :key="item.courseNo"
  20. :label="item.courseInfo"
  21. :value="item.courseNo"
  22. >
  23. </el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="试卷名称">
  27. <el-select
  28. v-model="formSearch.basePaperId"
  29. filterable
  30. :remote-method="getPapers"
  31. remote
  32. clearable
  33. placeholder="请选择"
  34. @clear="getPapers('')"
  35. >
  36. <el-option
  37. v-for="item in paperList"
  38. :key="item.id"
  39. :label="item.name"
  40. :value="item.id"
  41. >
  42. </el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="题干">
  46. <el-input
  47. v-model="formSearch.quesBodyText"
  48. placeholder="题干"
  49. ></el-input>
  50. </el-form-item>
  51. <el-form-item label="题型">
  52. <el-select
  53. v-model="formSearch.questionType"
  54. filterable
  55. clearable
  56. placeholder="请选择"
  57. >
  58. <el-option
  59. v-for="item in questionTypes"
  60. :key="item.value"
  61. :label="item.label"
  62. :value="item.value"
  63. >
  64. </el-option>
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item>
  68. <el-button type="danger" @click="searchFrom">查询</el-button>
  69. </el-form-item>
  70. </el-form>
  71. <div class="part-box-action">
  72. <div>
  73. <el-button
  74. type="primary"
  75. plain
  76. icon="icon icon-audit"
  77. @click="dispose"
  78. >快速审核</el-button
  79. >
  80. <el-button
  81. :disabled="noBatchSelected"
  82. type="danger"
  83. plain
  84. icon="icon icon-delete"
  85. @click="deleteQuestions"
  86. >批量删除</el-button
  87. >
  88. <el-button
  89. :disabled="noBatchSelected"
  90. type="primary"
  91. plain
  92. icon="icon icon-save"
  93. @click="retainQuestions"
  94. >批量保留</el-button
  95. >
  96. </div>
  97. </div>
  98. </div>
  99. <div class="part-box">
  100. <!-- 页面列表 -->
  101. <el-table
  102. v-loading="loading"
  103. :data="tableData"
  104. @selection-change="selectChange"
  105. >
  106. <el-table-column
  107. type="selection"
  108. width="50"
  109. align="center"
  110. ></el-table-column>
  111. <el-table-column label="课程名称" width="180">
  112. <template slot-scope="scope">
  113. <span>{{ scope.row.course.name }}</span>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="试卷名称" width="180">
  117. <template slot-scope="scope">
  118. <span>{{ scope.row.basePaperName }}</span>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="题干">
  122. <template slot-scope="scope">
  123. <rich-text
  124. class="row-question-body"
  125. title="点击查看试题"
  126. :text-json="scope.row.quesBody"
  127. @click="prevViewQues(scope.row)"
  128. ></rich-text>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="题型大类" width="100">
  132. <template slot-scope="scope">
  133. <span>{{ scope.row.quesMainType | questionMainType }}</span>
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="题型小类" width="100">
  137. <template slot-scope="scope">
  138. <span>{{ scope.row.questionType | questionType }}</span>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="最高重复比率" width="120">
  142. <template slot-scope="scope">
  143. <span>{{ scope.row.maxRepetition }}</span>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="创建时间" width="100">
  147. <template slot-scope="scope">
  148. <span>{{ scope.row.creationDate }}</span>
  149. </template>
  150. </el-table-column>
  151. <el-table-column label="创建人" width="100">
  152. <template slot-scope="scope">
  153. <span>{{ scope.row.creator }}</span>
  154. </template>
  155. </el-table-column>
  156. <el-table-column label="操作" width="190" fixed="right">
  157. <template slot-scope="scope">
  158. <div class="operate_left">
  159. <el-button
  160. size="mini"
  161. type="primary"
  162. plain
  163. @click="info(scope.row)"
  164. >
  165. 详情
  166. </el-button>
  167. <el-dropdown>
  168. <el-button type="primary" size="mini" plain>
  169. 快速审核<i class="el-icon-more el-icon--right"></i>
  170. </el-button>
  171. <el-dropdown-menu slot="dropdown" class="action-dropdown">
  172. <el-dropdown-item>
  173. <el-button
  174. size="mini"
  175. type="success"
  176. plain
  177. @click="retainQuestion(scope.row.id)"
  178. >
  179. 保留
  180. </el-button>
  181. </el-dropdown-item>
  182. <el-dropdown-item>
  183. <el-button
  184. size="mini"
  185. type="danger"
  186. plain
  187. @click="deleteQuestion(scope.row.id)"
  188. >
  189. 删除
  190. </el-button>
  191. </el-dropdown-item>
  192. </el-dropdown-menu>
  193. </el-dropdown>
  194. </div>
  195. </template>
  196. </el-table-column>
  197. </el-table>
  198. <!-- 分页栏 -->
  199. <div class="part-page">
  200. <el-pagination
  201. :current-page="currentPage"
  202. :page-size="pageSize"
  203. :page-sizes="[10, 20, 50, 100, 200, 300]"
  204. layout="total, sizes, prev, pager, next, jumper"
  205. :total="total"
  206. @current-change="handleCurrentChange"
  207. @size-change="handleSizeChange"
  208. >
  209. </el-pagination>
  210. </div>
  211. </div>
  212. <!-- 试题预览 -->
  213. <question-preview
  214. ref="QuestionPreview"
  215. :ques-model="quesModel"
  216. ></question-preview>
  217. <el-dialog title="提示" :visible.sync="deleteDialogVisible" append-to-body>
  218. <span>{{ deleteInfo }}</span>
  219. <span slot="footer" class="dialog-footer">
  220. <el-button type="primary" @click="deleteDialogVisible = false"
  221. >确定</el-button
  222. >
  223. </span>
  224. </el-dialog>
  225. </section>
  226. </template>
  227. <script>
  228. import { QUESTION_API } from "@/constants/constants";
  229. import { QUESTION_TYPES } from "../constants/constants";
  230. import { mapState } from "vuex";
  231. import QuestionPreview from "./QuestionPreview";
  232. export default {
  233. components: { QuestionPreview },
  234. data() {
  235. return {
  236. selectedQuesIds: [],
  237. formSearch: {
  238. basePaperId: "",
  239. quesBodyText: "",
  240. questionType: "",
  241. courseNo: "",
  242. courseName: "",
  243. },
  244. paperList: [],
  245. courseList: [], //课程list
  246. tableData: [],
  247. currentPage: 1,
  248. pageSize: 10,
  249. total: 10,
  250. quesModel: {},
  251. questionTypes: [],
  252. quesDialog: false,
  253. loading: false,
  254. deleteDialogVisible: false,
  255. deleteInfo: "",
  256. singleRightAnswer: "", //接收单选答案
  257. multipleRightAnswer: [], //接收多选答案
  258. isClear: 0,
  259. };
  260. },
  261. computed: {
  262. ...mapState({ user: (state) => state.user }),
  263. courseInfoSelect() {
  264. var courseList = [];
  265. for (let course of this.courseList) {
  266. var courseInfo = course.name + "(" + course.code + ")";
  267. var courseNo = course.code;
  268. courseList.push({ courseNo: courseNo, courseInfo: courseInfo });
  269. }
  270. return courseList;
  271. },
  272. answer() {
  273. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  274. return this.singleRightAnswer;
  275. } else if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  276. var obj = this.multipleRightAnswer;
  277. return obj.sort().toString();
  278. } else {
  279. return this.quesModel.quesAnswer;
  280. }
  281. },
  282. noBatchSelected() {
  283. return this.selectedQuesIds.length === 0;
  284. },
  285. },
  286. watch: {
  287. $route: "initVue",
  288. },
  289. //钩子函数
  290. created() {
  291. var url =
  292. QUESTION_API +
  293. "/org/property/" +
  294. this.user.rootOrgId +
  295. "/ROOT_ORG_QUESTION_TYPES";
  296. this.$http.get(url).then((response) => {
  297. if (response.data && response.data.length > 0) {
  298. this.questionTypes = QUESTION_TYPES.filter((m) =>
  299. response.data.includes(m.value)
  300. );
  301. }
  302. });
  303. this.initVue();
  304. },
  305. methods: {
  306. dispose() {
  307. this.$router.push({
  308. name: "check_duplicate_info",
  309. query: {
  310. from: "list",
  311. },
  312. });
  313. sessionStorage.setItem("question", JSON.stringify(this.formSearch));
  314. sessionStorage.setItem("question_currentPage", this.currentPage);
  315. },
  316. deleteQuestions() {
  317. this.$confirm("确认删除吗?", "提示", {
  318. type: "warning",
  319. }).then(() => {
  320. this.$http
  321. .post(
  322. QUESTION_API + "/question/duplicate/delete",
  323. new URLSearchParams({ questionIds: this.selectedQuesIds })
  324. )
  325. .then(() => {
  326. this.$notify({
  327. message: "删除成功",
  328. type: "success",
  329. });
  330. this.searchQues();
  331. });
  332. });
  333. },
  334. retainQuestions() {
  335. this.$http
  336. .post(
  337. QUESTION_API + "/question/duplicate/retain",
  338. new URLSearchParams({ questionIds: this.selectedQuesIds })
  339. )
  340. .then(() => {
  341. this.$notify({
  342. message: "操作成功",
  343. type: "success",
  344. });
  345. this.searchQues();
  346. });
  347. },
  348. deleteQuestion(id) {
  349. this.$confirm("确认删除吗?", "提示", {
  350. type: "warning",
  351. }).then(() => {
  352. let quesIds = [];
  353. quesIds.push(id);
  354. this.$http
  355. .post(
  356. QUESTION_API + "/question/duplicate/delete",
  357. new URLSearchParams({ questionIds: quesIds })
  358. )
  359. .then(() => {
  360. this.$notify({
  361. message: "删除成功",
  362. type: "success",
  363. });
  364. this.searchQues();
  365. });
  366. });
  367. },
  368. retainQuestion(id) {
  369. let quesIds = [];
  370. quesIds.push(id);
  371. this.$http
  372. .post(
  373. QUESTION_API + "/question/duplicate/retain",
  374. new URLSearchParams({ questionIds: quesIds })
  375. )
  376. .then(() => {
  377. this.$notify({
  378. message: "操作成功",
  379. type: "success",
  380. });
  381. this.searchQues();
  382. });
  383. },
  384. selectChange(row) {
  385. this.selectedQuesIds = [];
  386. row.forEach((element) => {
  387. this.selectedQuesIds.push(element.id);
  388. });
  389. },
  390. //查询列表
  391. searchFrom() {
  392. this.currentPage = 1;
  393. this.searchQues();
  394. },
  395. searchQues() {
  396. var pageNo = this.currentPage || 1;
  397. this.currentPage = 1;
  398. this.tableData = [];
  399. var url =
  400. QUESTION_API +
  401. "/question/to_be_dispose/" +
  402. pageNo +
  403. "/" +
  404. this.pageSize;
  405. this.loading = true;
  406. this.$http.get(url, { params: this.formSearch }).then((response) => {
  407. this.tableData = response.data.content;
  408. this.currentPage = response.data.number;
  409. this.total = response.data.totalElements;
  410. this.loading = false;
  411. });
  412. },
  413. //分页
  414. handleCurrentChange(val) {
  415. this.currentPage = val;
  416. this.searchQues();
  417. },
  418. handleSizeChange(val) {
  419. this.pageSize = val;
  420. this.currentPage = 1;
  421. this.searchQues();
  422. },
  423. getCourseName(courseNo) {
  424. for (let course of this.courseList) {
  425. if (course.code == courseNo) {
  426. this.formSearch.courseName = course.name;
  427. }
  428. }
  429. },
  430. //修改
  431. info(row) {
  432. this.$router.push({
  433. name: "check_duplicate_info",
  434. query: {
  435. quesId: row.id,
  436. from: "question",
  437. },
  438. });
  439. sessionStorage.setItem("question", JSON.stringify(this.formSearch));
  440. sessionStorage.setItem("question_currentPage", this.currentPage);
  441. },
  442. //预览
  443. prevViewQues(row) {
  444. this.quesModel = row;
  445. this.disposeSelectAnswer();
  446. this.$refs.QuestionPreview.open();
  447. },
  448. //查询所有课程
  449. getCourses(query) {
  450. this.$http
  451. .get(QUESTION_API + "/course/query?name=" + query + "&enable=true")
  452. .then((response) => {
  453. this.courseList = response.data;
  454. });
  455. },
  456. getPapers(query) {
  457. this.$http
  458. .get(QUESTION_API + "/import_paper/to_be_dispose?name=" + query)
  459. .then((response) => {
  460. this.paperList = response.data;
  461. });
  462. },
  463. //重置查询表单
  464. resetSearchForm() {
  465. this.formSearch = {
  466. questionType: "",
  467. courseNo: "",
  468. };
  469. },
  470. /*处理选择题答案显示,处理套题下选择题答案显示*/
  471. disposeSelectAnswer() {
  472. //处理选择题答案显示
  473. if (
  474. this.quesModel.questionType == "SINGLE_ANSWER_QUESTION" ||
  475. this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION"
  476. ) {
  477. let answers = [];
  478. this.quesModel.quesOptions.forEach((option, index) => {
  479. if (option.isCorrect) {
  480. answers.push(String.fromCharCode(65 + index));
  481. }
  482. });
  483. this.quesModel.quesAnswer = answers.sort().toString();
  484. }
  485. //处理套题下选择题答案显示
  486. if (this.quesModel.questionType == "NESTED_ANSWER_QUESTION") {
  487. var subQuestions = this.quesModel.subQuestions;
  488. for (var ii = 0; ii < subQuestions.length; ii++) {
  489. var subQuestion = subQuestions[ii];
  490. if (subQuestion.questionType == "SINGLE_ANSWER_QUESTION") {
  491. for (var j = 0; j < subQuestion.quesOptions.length; j++) {
  492. var option_j = subQuestion.quesOptions[j];
  493. var orderNum_j = String.fromCharCode(65 + j);
  494. if (option_j.isCorrect == 1) {
  495. subQuestion["quesAnswer"] = orderNum_j;
  496. }
  497. }
  498. }
  499. if (subQuestion.questionType == "MULTIPLE_ANSWER_QUESTION") {
  500. var subQuestionMultipleRightAnswer = [];
  501. for (var k = 0; k < subQuestion.quesOptions.length; k++) {
  502. var option2 = subQuestion.quesOptions[k];
  503. var orderNum2 = String.fromCharCode(65 + k);
  504. if (option2.isCorrect == 1) {
  505. subQuestionMultipleRightAnswer.push(orderNum2);
  506. }
  507. }
  508. subQuestion["quesAnswer"] = subQuestionMultipleRightAnswer
  509. .sort()
  510. .toString();
  511. }
  512. }
  513. }
  514. },
  515. initVue() {
  516. this.isClear = this.$route.params.isClear;
  517. if (this.isClear == 0 || !this.isClear) {
  518. sessionStorage.removeItem("question");
  519. sessionStorage.removeItem("question_currentPage");
  520. this.formSearch = {
  521. questionType: "",
  522. courseNo: "",
  523. courseLevel: "",
  524. courseName: "",
  525. publicity: "",
  526. coursePropertyName: "",
  527. firstPropertyId: "",
  528. secondPropertyId: "",
  529. };
  530. this.currentPage = 1;
  531. } else {
  532. this.formSearch = JSON.parse(sessionStorage.getItem("question"));
  533. this.currentPage = parseInt(
  534. sessionStorage.getItem("question_currentPage")
  535. );
  536. }
  537. if (this.formSearch && this.formSearch.courseName) {
  538. this.getCourses(this.formSearch.courseName);
  539. } else {
  540. this.formSearch = {
  541. questionType: "",
  542. courseNo: "",
  543. courseLevel: "",
  544. courseName: "",
  545. publicity: "",
  546. coursePropertyName: "",
  547. firstPropertyId: "",
  548. secondPropertyId: "",
  549. };
  550. }
  551. this.searchQues();
  552. },
  553. },
  554. };
  555. </script>