QuestionManage.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. <template>
  2. <div class="content question-manage">
  3. <!-- 正文信息 -->
  4. <div class="part-box">
  5. <!-- <h2 class="part-box-title">题库列表</h2> -->
  6. <div class="search-box">
  7. <el-form class="part-filter-form" :inline="true" :model="filter">
  8. <el-form-item label="课程名称">
  9. <course-select v-model="filter.courseId" @change="courseChange">
  10. </course-select>
  11. </el-form-item>
  12. <el-form-item label="题型">
  13. <source-detail-select v-model="filter" :course-id="filter.courseId">
  14. </source-detail-select>
  15. </el-form-item>
  16. <el-form-item label="题目内容">
  17. <el-input
  18. v-model="filter.questionBody"
  19. placeholder="题目内容"
  20. ></el-input>
  21. </el-form-item>
  22. <el-form-item label="属性">
  23. <!-- <property-tree-select
  24. v-model="filter.questionProperty"
  25. :course-id="filter.courseId"
  26. ></property-tree-select> -->
  27. <property-tree-select
  28. v-model="filter.questionProperty"
  29. :course-id="filter.courseId"
  30. ></property-tree-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button type="primary" @click="toPage(1)">查询</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <div class="right-btns">
  37. <tool-tip-btn
  38. name="shititongji"
  39. content="试题统计"
  40. @click="toStatistics"
  41. ></tool-tip-btn>
  42. <tool-tip-btn
  43. name="tixingguanli"
  44. content="题型管理"
  45. @click="toSourceDetailManage"
  46. ></tool-tip-btn>
  47. </div>
  48. </div>
  49. <!-- <div class="part-box-action"> -->
  50. <!-- <div> -->
  51. <!-- <el-button
  52. type="primary"
  53. plain
  54. icon="el-icon-data-analysis"
  55. @click="toStatistics"
  56. >试题统计</el-button
  57. > -->
  58. <!-- <el-button
  59. v-if="authButtons.includes('import_test_paper-safe')"
  60. type="danger"
  61. plain
  62. icon="el-icon-lock"
  63. @click="toSafetySet"
  64. >安全设置</el-button
  65. > -->
  66. <!-- <el-button
  67. type="primary"
  68. plain
  69. icon="el-icon-setting"
  70. @click="toSourceDetailManage"
  71. >题型管理</el-button
  72. > -->
  73. <!-- <el-button
  74. type="danger"
  75. plain
  76. icon="el-icon-delete"
  77. @click="toRecycle"
  78. >回收站</el-button
  79. > -->
  80. <!-- </div> -->
  81. <!-- <div> -->
  82. <!-- <el-button
  83. type="primary"
  84. plain
  85. icon="el-icon-position"
  86. @click="toBatchMove"
  87. >移动</el-button
  88. >
  89. <el-button
  90. type="primary"
  91. plain
  92. icon="el-icon-copy-document"
  93. @click="toBatchCopy"
  94. >复制</el-button
  95. >
  96. <el-button
  97. type="danger"
  98. plain
  99. icon="el-icon-circle-close"
  100. @click="toBatchDelete"
  101. >删除</el-button
  102. > -->
  103. <!-- <el-button
  104. type="primary"
  105. plain
  106. icon="el-icon-folder-opened"
  107. @click="toAddFolder"
  108. >新建文件夹</el-button
  109. > -->
  110. <!-- <el-button
  111. v-if="!gptQuestionEnable"
  112. type="primary"
  113. icon="el-icon-circle-plus-outline"
  114. plain
  115. @click="toCreateQuestion"
  116. >创建试题</el-button
  117. >
  118. <el-dropdown v-if="gptQuestionEnable">
  119. <el-button type="primary" plain icon="el-icon-circle-plus-outline"
  120. >创建试题</el-button
  121. >
  122. <el-dropdown-menu slot="dropdown" class="action-dropdown">
  123. <el-dropdown-item>
  124. <el-button
  125. size="mini"
  126. type="primary"
  127. plain
  128. @click="toCreateQuestion"
  129. >手动创建</el-button
  130. >
  131. </el-dropdown-item>
  132. <el-dropdown-item>
  133. <el-button
  134. size="mini"
  135. type="primary"
  136. plain
  137. @click="toGPTQuestion"
  138. >AI命题</el-button
  139. >
  140. </el-dropdown-item>
  141. </el-dropdown-menu>
  142. </el-dropdown> -->
  143. <!-- <el-button
  144. type="primary"
  145. plain
  146. icon="el-icon-upload2"
  147. @click="toImportQuestion"
  148. >批量导入</el-button
  149. > -->
  150. <!-- </div> -->
  151. <!-- </div> -->
  152. </div>
  153. <div class="folder-question">
  154. <div class="folder-list">
  155. <question-folder
  156. ref="QuestionFolder"
  157. is-edit
  158. @selected="folderFilterSelected"
  159. ></question-folder>
  160. </div>
  161. <div class="question-list">
  162. <div class="icon-btn-group">
  163. <svg-btn
  164. name="新增"
  165. @click="toCreateQuestion"
  166. v-if="!gptQuestionEnable"
  167. >新增</svg-btn
  168. >
  169. <el-dropdown v-else>
  170. <svg-btn name="xinzeng">新增</svg-btn>
  171. <el-dropdown-menu slot="dropdown" class="action-dropdown">
  172. <el-dropdown-item>
  173. <el-button
  174. size="mini"
  175. type="primary"
  176. plain
  177. @click="toCreateQuestion"
  178. >手动创建</el-button
  179. >
  180. </el-dropdown-item>
  181. <el-dropdown-item>
  182. <el-button
  183. size="mini"
  184. type="primary"
  185. plain
  186. @click="toGPTQuestion"
  187. >AI命题</el-button
  188. >
  189. </el-dropdown-item>
  190. </el-dropdown-menu>
  191. </el-dropdown>
  192. <svg-btn name="daoru" @click="toImportQuestion">导入</svg-btn>
  193. <svg-btn name="yidong" @click="toBatchMove">移动</svg-btn>
  194. <svg-btn name="fuzhi" @click="toBatchCopy">复制</svg-btn>
  195. <svg-btn name="shanchu" @click="toBatchDelete">删除</svg-btn>
  196. </div>
  197. <el-table
  198. v-loading="loading"
  199. element-loading-text="加载中"
  200. :data="questionList"
  201. @selection-change="tableSelectChange"
  202. >
  203. <el-table-column
  204. type="selection"
  205. width="50"
  206. align="center"
  207. ></el-table-column>
  208. <el-table-column label="题干" min-width="200">
  209. <div slot-scope="scope" @click="toViewQuestion(scope.row)">
  210. <rich-text
  211. class="row-question-body"
  212. title="点击查看试题"
  213. :text-json="scope.row.quesBody"
  214. ></rich-text>
  215. </div>
  216. </el-table-column>
  217. <el-table-column label="课程" width="120">
  218. <template slot-scope="scope">
  219. <span>{{ scope.row.course.name }}</span>
  220. </template>
  221. </el-table-column>
  222. <el-table-column label="题型" prop="sourceDetailName" width="100">
  223. </el-table-column>
  224. <el-table-column label="难度" prop="difficulty" width="80">
  225. </el-table-column>
  226. <el-table-column label="使用量" prop="usageAmount" width="80">
  227. </el-table-column>
  228. <el-table-column label="创建人" prop="creator" width="120">
  229. </el-table-column>
  230. <el-table-column label="创建时间" width="170" prop="creationTime">
  231. </el-table-column>
  232. <el-table-column label="操作" width="180" fixed="right">
  233. <template slot-scope="scope">
  234. <div class="operate_left">
  235. <el-button
  236. size="medium"
  237. type="text"
  238. class="normal"
  239. @click="toEditQuestion(scope.row)"
  240. >编辑</el-button
  241. >
  242. <el-dropdown>
  243. <el-button type="text" size="medium" class="normal">
  244. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  245. </el-button>
  246. <el-dropdown-menu slot="dropdown" class="action-dropdown">
  247. <el-dropdown-item>
  248. <el-button
  249. size="mini"
  250. type="primary"
  251. plain
  252. @click="toMoveQuestion(scope.row)"
  253. >移动</el-button
  254. >
  255. </el-dropdown-item>
  256. <el-dropdown-item>
  257. <el-button
  258. size="mini"
  259. type="primary"
  260. plain
  261. @click="toCopyQuestion(scope.row)"
  262. >复制</el-button
  263. >
  264. </el-dropdown-item>
  265. <el-dropdown-item>
  266. <el-button
  267. size="mini"
  268. type="danger"
  269. plain
  270. @click="toDeleteQuestion(scope.row)"
  271. >删除</el-button
  272. >
  273. </el-dropdown-item>
  274. </el-dropdown-menu>
  275. </el-dropdown>
  276. </div>
  277. </template>
  278. </el-table-column>
  279. </el-table>
  280. <div class="part-page">
  281. <el-pagination
  282. :current-page="currentPage"
  283. :page-size="pageSize"
  284. :page-sizes="[10, 20, 50, 100, 200, 300]"
  285. layout="total, sizes, prev, pager, next, jumper"
  286. :total="total"
  287. @current-change="toPage"
  288. @size-change="handleSizeChange"
  289. >
  290. </el-pagination>
  291. </div>
  292. </div>
  293. </div>
  294. <!-- QuestionEditDialog -->
  295. <question-edit-dialog
  296. ref="QuestionEditDialog"
  297. :question="curQuestion"
  298. @modified="getList"
  299. ></question-edit-dialog>
  300. <!-- QuestionPreviewDialog -->
  301. <question-preview-dialog
  302. ref="QuestionPreviewDialog"
  303. :question="curQuestion"
  304. ></question-preview-dialog>
  305. <!-- QuestionStatisticsDialog -->
  306. <question-statistics-dialog
  307. ref="QuestionStatisticsDialog"
  308. :course-id="filter.courseId"
  309. ></question-statistics-dialog>
  310. <!-- QuestionSafetySetDialog -->
  311. <question-safety-set-dialog
  312. ref="QuestionSafetySetDialog"
  313. ></question-safety-set-dialog>
  314. <!-- QuestionFolderDialog -->
  315. <question-folder-dialog
  316. ref="QuestionFolderDialog"
  317. :is-edit="false"
  318. @selected="folderSelected"
  319. ></question-folder-dialog>
  320. <!-- QuestionImportDialog -->
  321. <question-import-dialog
  322. ref="QuestionImportDialog"
  323. @modified="questionImported"
  324. ></question-import-dialog>
  325. <!-- FolderQuestionManageDialog -->
  326. <folder-question-manage-dialog
  327. ref="FolderQuestionManageDialog"
  328. ></folder-question-manage-dialog>
  329. <!-- QuestionImportEdit -->
  330. <question-import-edit
  331. ref="QuestionImportEdit"
  332. :data="questionImportData"
  333. @modified="toPage(1)"
  334. ></question-import-edit>
  335. <!-- GptQuestionDialog -->
  336. <gpt-question-dialog
  337. v-if="gptQuestionEnable"
  338. ref="GptQuestionDialog"
  339. :course="{
  340. courseId: curCourse.id,
  341. courseCode: curCourse.code,
  342. courseName: curCourse.name,
  343. }"
  344. @modified="getList"
  345. ></gpt-question-dialog>
  346. <router-view></router-view>
  347. </div>
  348. </template>
  349. <script>
  350. import {
  351. // questionPageListApi,
  352. deleteQuestionApi,
  353. moveQuestionApi,
  354. copyQuestionApi,
  355. checkGptQuestionEnableApi,
  356. aiQuestionConfirmApi,
  357. classifyQuestionPageListApi,
  358. } from "../api";
  359. import QuestionStatisticsDialog from "../components/QuestionStatisticsDialog.vue";
  360. import QuestionSafetySetDialog from "../components/QuestionSafetySetDialog.vue";
  361. import QuestionFolderDialog from "../components/QuestionFolderDialog.vue";
  362. import QuestionImportDialog from "../components/QuestionImportDialog.vue";
  363. import QuestionEditDialog from "../components/QuestionEditDialog.vue";
  364. import QuestionPreviewDialog from "../components/QuestionPreviewDialog.vue";
  365. import FolderQuestionManageDialog from "../components/FolderQuestionManageDialog.vue";
  366. import PropertyTreeSelect from "../components/PropertyTreeSelect.vue";
  367. import QuestionImportEdit from "../components/QuestionImportEdit.vue";
  368. import GptQuestionDialog from "../components/GptQuestionDialog.vue";
  369. import { mapActions, mapGetters } from "vuex";
  370. import { USER_SIGNIN } from "../../portal/store/user";
  371. import QuestionFolder from "@/modules/question/components/QuestionFolder.vue";
  372. export default {
  373. name: "QuestionMamage",
  374. components: {
  375. QuestionStatisticsDialog,
  376. QuestionSafetySetDialog,
  377. QuestionFolderDialog,
  378. QuestionImportDialog,
  379. QuestionEditDialog,
  380. QuestionPreviewDialog,
  381. FolderQuestionManageDialog,
  382. PropertyTreeSelect,
  383. QuestionImportEdit,
  384. GptQuestionDialog,
  385. QuestionFolder,
  386. },
  387. data() {
  388. return {
  389. filter: {
  390. courseId: "",
  391. questionType: "",
  392. sourceDetailId: "",
  393. questionBody: "",
  394. // questionProperty: [],
  395. questionProperty: [],
  396. classifyId: "",
  397. // courseId: "",
  398. // questionType: "",
  399. // sourceDetailId: "",
  400. // questionProperty: [],
  401. },
  402. curFolderAction: "",
  403. folderList: [],
  404. questionList: [],
  405. selectedQuestionIds: [],
  406. currentPage: 1,
  407. pageSize: 10,
  408. total: 0,
  409. loading: false,
  410. curQuestion: {},
  411. curFolder: {},
  412. curCourse: {},
  413. curMoveType: "",
  414. questionImportData: {},
  415. gptQuestionEnable: false,
  416. curActionQids: [],
  417. };
  418. },
  419. computed: {
  420. user() {
  421. return this.$store.state.user;
  422. },
  423. ...mapGetters(["authButtons"]),
  424. },
  425. mounted() {
  426. this.$refs.QuestionFolder.selectDefaultNode();
  427. this.checkGptEnable();
  428. this.toPage(1);
  429. },
  430. methods: {
  431. folderFilterSelected(folder) {
  432. console.log("left tree choose folder:", folder);
  433. if (!folder) return;
  434. this.curFolder = folder;
  435. this.filter = {
  436. classifyId: folder.id,
  437. courseId: "",
  438. questionType: "",
  439. sourceDetailId: "",
  440. questionProperty: [],
  441. };
  442. this.toPage(1);
  443. },
  444. ...mapActions([USER_SIGNIN]),
  445. async checkGptEnable() {
  446. const res = await checkGptQuestionEnableApi();
  447. this.gptQuestionEnable = res.data;
  448. },
  449. toPage(page) {
  450. this.currentPage = page;
  451. this.getList();
  452. },
  453. async getList() {
  454. this.loading = true;
  455. this.selectedQuestionIds = [];
  456. let data = {
  457. ...this.filter,
  458. // pageNumber: this.currentPage,
  459. pageNumber: this.currentPage,
  460. pageSize: this.pageSize,
  461. };
  462. // data.questionProperty = data.questionProperty.join();
  463. data.questionProperty = data.questionProperty.join();
  464. // const res = await questionPageListApi(data).catch(() => {});
  465. const res = await classifyQuestionPageListApi(data).catch(() => {});
  466. this.loading = false;
  467. if (!res) return;
  468. this.questionList = res.data.content;
  469. this.total = res.data.totalElements;
  470. },
  471. handleSizeChange(val) {
  472. this.pageSize = val;
  473. this.toPage(1);
  474. },
  475. tableSelectChange(selections) {
  476. this.selectedQuestionIds = selections.map((item) => item.id);
  477. },
  478. courseChange(val) {
  479. this.curCourse = val || {};
  480. },
  481. toStatistics() {
  482. if (!this.filter.courseId) {
  483. this.$message.error("请先选择课程!");
  484. return;
  485. }
  486. // this.$refs.QuestionStatisticsDialog.open();
  487. this.$router.push({
  488. name: "QuestionTypeStatistics",
  489. query: {
  490. courseId: this.filter.courseId,
  491. courseName: this.curCourse.name,
  492. },
  493. });
  494. },
  495. toSafetySet() {
  496. this.$refs.QuestionSafetySetDialog.open();
  497. },
  498. toSourceDetailManage() {
  499. if (!this.filter.courseId) {
  500. this.$message.error("请先选择课程!");
  501. return;
  502. }
  503. window.sessionStorage.setItem(
  504. "courseInfo",
  505. JSON.stringify(this.curCourse)
  506. );
  507. this.$router.push({
  508. name: "SourceDetailManage",
  509. });
  510. },
  511. toCreateQuestion() {
  512. if (!this.filter.courseId) {
  513. this.$message.error("请先选择课程!");
  514. return;
  515. }
  516. this.curQuestion = {
  517. courseId: this.curCourse.id,
  518. courseCode: this.curCourse.code,
  519. courseName: this.curCourse.name,
  520. };
  521. this.$refs.QuestionEditDialog.open();
  522. },
  523. toImportQuestion() {
  524. this.$refs.QuestionImportDialog.open();
  525. // this.questionImportData = {
  526. // importData: {
  527. // courseId: 9,
  528. // courseName: "化学",
  529. // },
  530. // };
  531. // this.$refs.QuestionImportEdit.open();
  532. },
  533. toViewQuestion(row) {
  534. this.curQuestion = row;
  535. this.$refs.QuestionPreviewDialog.open();
  536. },
  537. toEditQuestion(row) {
  538. this.curQuestion = row;
  539. this.$refs.QuestionEditDialog.open();
  540. },
  541. toMoveQuestion(row) {
  542. // this.curQuestion = row;
  543. this.curActionQids = [row.id];
  544. this.curFolderAction = "move";
  545. this.$refs.QuestionFolderDialog.open();
  546. },
  547. toCopyQuestion(row) {
  548. // this.curQuestion = row;
  549. this.curActionQids = [row.id];
  550. this.curFolderAction = "copy";
  551. this.$refs.QuestionFolderDialog.open();
  552. },
  553. async folderSelected(folder) {
  554. if (folder.id === this.curFolder.id && this.curFolderAction === "move") {
  555. this.$message.error("内容就在当前当前文件中");
  556. return;
  557. }
  558. let res = null;
  559. // if (this.curFolderAction === "move") {
  560. // res = await moveQuestionApi(this.curQuestion.id, folder.id).catch(
  561. // () => {}
  562. // );
  563. // } else {
  564. // res = await copyQuestionApi(this.curQuestion.id, folder.id).catch(
  565. // () => {}
  566. // );
  567. // }
  568. if (this.curFolderAction === "move") {
  569. res = await moveQuestionApi(this.curActionQids.join(), folder.id).catch(
  570. () => {}
  571. );
  572. } else {
  573. res = await copyQuestionApi(this.curActionQids.join(), folder.id).catch(
  574. () => {}
  575. );
  576. }
  577. if (!res) return;
  578. this.$message.success("操作成功!");
  579. this.getList();
  580. },
  581. async deleteQuestion(ids) {
  582. this.loading = true;
  583. const res = await deleteQuestionApi(ids.join()).catch(() => {});
  584. this.loading = false;
  585. if (!res) return;
  586. this.$notify({
  587. message: "删除成功",
  588. type: "success",
  589. });
  590. this.getList();
  591. },
  592. async toDeleteQuestion(row) {
  593. const confirm = await this.$confirm("确认删除试题吗?", "提示", {
  594. type: "warning",
  595. }).catch(() => {});
  596. if (confirm !== "confirm") return;
  597. this.deleteQuestion([row.id]);
  598. },
  599. toBatchMove() {
  600. if (!this.selectedQuestionIds.length) {
  601. this.$message.error("请选择试题!");
  602. return;
  603. }
  604. this.curActionQids = [...this.selectedQuestionIds];
  605. this.curFolderAction = "move";
  606. this.$refs.QuestionFolderDialog.open();
  607. },
  608. toBatchCopy() {
  609. if (!this.selectedQuestionIds.length) {
  610. this.$message.error("请选择试题!");
  611. return;
  612. }
  613. this.curActionQids = [...this.selectedQuestionIds];
  614. this.curFolderAction = "copy";
  615. this.$refs.QuestionFolderDialog.open();
  616. },
  617. async toBatchDelete() {
  618. if (!this.selectedQuestionIds.length) {
  619. this.$message.error("请选择试题!");
  620. return;
  621. }
  622. const confirm = await this.$confirm("确认删除选中试题吗?", "提示", {
  623. type: "warning",
  624. }).catch(() => {});
  625. if (confirm !== "confirm") return;
  626. this.deleteQuestion(this.selectedQuestionIds);
  627. },
  628. toRecycle() {
  629. this.$router.push({
  630. name: "QuestionRecycle",
  631. });
  632. },
  633. toAddFolder() {
  634. this.$refs.FolderQuestionManageDialog.open();
  635. },
  636. questionImported(data) {
  637. if (data.importType !== "word") {
  638. this.getList();
  639. return;
  640. }
  641. console.log("questionImported data", data);
  642. this.questionImportData = data;
  643. this.$refs.QuestionImportEdit.open();
  644. },
  645. async toGPTQuestion() {
  646. if (!this.filter.courseId) {
  647. this.$message.error("请先选择课程!");
  648. return;
  649. }
  650. if (!this.user.aiQuestionConfirm) {
  651. const confirm = await this.$confirm(
  652. `请务必仔细阅读本协议内容,若您不同意本协议的任何内容,将无法使用该功能,AI命题功能借助AI工具来辅助出题,提高出题效率,减轻命题老师工作量,并不确保出题的正确性及适用性,请在出题后务必仔细检查核对,以免将有问题的试题加入试卷,用于考试。`,
  653. "提示",
  654. {
  655. type: "warning",
  656. }
  657. ).catch(() => {});
  658. if (confirm !== "confirm") return;
  659. await aiQuestionConfirmApi();
  660. this.USER_SIGNIN(
  661. Object.assign({}, this.user, { aiQuestionConfirm: true })
  662. );
  663. }
  664. this.$refs.GptQuestionDialog.open();
  665. },
  666. },
  667. };
  668. </script>
  669. <style lang="scss" scoped>
  670. .question-manage {
  671. .folder-question {
  672. min-height: calc(100vh - 306px);
  673. }
  674. .search-box {
  675. display: flex;
  676. align-items: center;
  677. justify-content: space-between;
  678. .right-btns {
  679. display: flex;
  680. align-items: center;
  681. padding-bottom: 15px;
  682. }
  683. }
  684. }
  685. </style>
  686. <style lang="scss">
  687. @media screen and (max-width: 1366px) {
  688. .question-manage {
  689. .part-filter-form {
  690. .el-form-item {
  691. width: 180px !important;
  692. }
  693. }
  694. }
  695. }
  696. </style>