GenPaper.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  1. <template>
  2. <section class="content gen-paper">
  3. <div class="part-box">
  4. <!-- <h2 class="part-box-title">卷库列表</h2> -->
  5. <el-form class="part-filter-form" :inline="true" :model="formSearch">
  6. <el-form-item label="课程">
  7. <el-select
  8. v-model="formSearch.courseId"
  9. filterable
  10. :remote-method="getCourses"
  11. remote
  12. clearable
  13. placeholder="全部"
  14. @clear="getCourses('')"
  15. >
  16. <el-option
  17. v-for="item in courseInfoSelect"
  18. :key="item.courseId"
  19. :label="item.courseInfo"
  20. :value="item.courseId"
  21. >
  22. </el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="试卷">
  26. <el-input v-model="formSearch.name" placeholder="试卷名称"></el-input>
  27. </el-form-item>
  28. <!-- <el-form-item label="层次">
  29. <el-select v-model="formSearch.level" clearable placeholder="请选择">
  30. <el-option
  31. v-for="item in levelList"
  32. :key="item.value"
  33. :label="item.label"
  34. :value="item.value"
  35. >
  36. </el-option>
  37. </el-select>
  38. </el-form-item> -->
  39. <el-form-item label="录入人">
  40. <el-input
  41. v-model="formSearch.creator"
  42. placeholder="录入人"
  43. ></el-input>
  44. </el-form-item>
  45. <el-form-item label="修改人">
  46. <el-input
  47. v-model="formSearch.lastModifyName"
  48. placeholder="修改人"
  49. ></el-input>
  50. </el-form-item>
  51. <el-form-item>
  52. <el-button type="primary" @click="searchFrom">查询</el-button>
  53. <el-button type="danger" plain @click="resetForm">重置</el-button>
  54. </el-form-item>
  55. </el-form>
  56. <!-- <div class="part-box-action">
  57. <div>
  58. <el-button
  59. type="danger"
  60. plain
  61. icon="icon icon-delete"
  62. :disabled="noBatchSelected"
  63. @click="batchDeleteGenPaper"
  64. >删除成卷
  65. </el-button>
  66. <el-button
  67. type="danger"
  68. plain
  69. icon="icon icon-delete"
  70. :disabled="noBatchSelected"
  71. @click="recoveryPapers"
  72. >回收
  73. </el-button>
  74. <el-button
  75. type="primary"
  76. plain
  77. icon="icon icon-export"
  78. :disabled="noBatchSelected"
  79. @click="openBatchExportPaperDialog"
  80. >下载成卷</el-button
  81. >
  82. <el-button
  83. type="danger"
  84. plain
  85. icon="el-icon-delete"
  86. @click="toRecycle"
  87. >回收站</el-button
  88. >
  89. </div>
  90. <div>
  91. <el-button
  92. type="primary"
  93. icon="icon icon-plus-white"
  94. @click="genPaperDetail"
  95. >组卷</el-button
  96. >
  97. </div>
  98. </div> -->
  99. </div>
  100. <div class="part-box">
  101. <div class="icon-btn-group">
  102. <svg-btn name="zujuan" @click="genPaperDetail">组卷</svg-btn>
  103. <svg-btn
  104. name="daoru"
  105. :disabled="noBatchSelected"
  106. @click="openBatchExportPaperDialog"
  107. >下载</svg-btn
  108. >
  109. <svg-btn
  110. name="shanchu"
  111. :disabled="noBatchSelected"
  112. @click="batchDeleteGenPaper"
  113. >删除</svg-btn
  114. >
  115. </div>
  116. <el-table
  117. v-loading="loading"
  118. element-loading-text="拼命加载中"
  119. :data="tableData"
  120. @selection-change="selectChange"
  121. >
  122. <el-table-column
  123. type="selection"
  124. width="50"
  125. align="center"
  126. ></el-table-column>
  127. <el-table-column label="课程名称" width="180">
  128. <template slot-scope="scope">
  129. <span>{{ scope.row.course.name }}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="课程代码" width="80">
  133. <template slot-scope="scope">
  134. <span>{{ scope.row.course.code }}</span>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="试卷名称" width="180">
  138. <template slot-scope="scope">
  139. <span>{{ scope.row.name }}</span>
  140. </template>
  141. </el-table-column>
  142. <el-table-column
  143. label="试卷总分"
  144. width="103"
  145. sortable
  146. prop="totalScore"
  147. >
  148. </el-table-column>
  149. <el-table-column
  150. label="试卷难度"
  151. width="103"
  152. sortable
  153. prop="difficulty"
  154. >
  155. </el-table-column>
  156. <el-table-column
  157. label="大题数量"
  158. width="103"
  159. sortable
  160. prop="paperDetailCount"
  161. >
  162. </el-table-column>
  163. <el-table-column label="录入员" width="150">
  164. <template slot-scope="scope">
  165. <span>{{ scope.row.creator }}</span>
  166. </template>
  167. </el-table-column>
  168. <el-table-column
  169. label="创建时间"
  170. width="153"
  171. sortable
  172. prop="creationTime"
  173. >
  174. </el-table-column>
  175. <el-table-column label="修改人" width="120">
  176. <template slot-scope="scope">
  177. <span>{{ scope.row.lastModifyName }}</span>
  178. </template>
  179. </el-table-column>
  180. <el-table-column
  181. label="修改时间"
  182. width="153"
  183. sortable
  184. prop="updateTime"
  185. >
  186. </el-table-column>
  187. <el-table-column label="操作" width="180" fixed="right">
  188. <template slot-scope="scope">
  189. <div class="operate_left">
  190. <el-button
  191. size="medium"
  192. type="text"
  193. class="normal"
  194. @click="editGenPaper(scope.row)"
  195. >编辑</el-button
  196. >
  197. <el-button
  198. size="medium"
  199. type="text"
  200. class="normal"
  201. @click="openExportDialog(scope.row)"
  202. >下载</el-button
  203. >
  204. <el-button
  205. size="medium"
  206. type="text"
  207. class="normal"
  208. @click="previewPDF2(scope.row)"
  209. >预览</el-button
  210. >
  211. <!-- <el-dropdown>
  212. <el-button type="primary" size="mini" plain>
  213. 更多 <i class="el-icon-more el-icon--right"></i>
  214. </el-button>
  215. <el-dropdown-menu slot="dropdown" class="action-dropdown">
  216. <el-dropdown-item>
  217. <el-button
  218. size="mini"
  219. type="danger"
  220. plain
  221. @click="recoveryPaper(scope.row)"
  222. >
  223. 回收
  224. </el-button>
  225. </el-dropdown-item>
  226. <el-dropdown-item>
  227. <el-button
  228. size="mini"
  229. type="primary"
  230. plain
  231. @click="openExportDialog(scope.row)"
  232. >下载</el-button
  233. >
  234. </el-dropdown-item>
  235. <el-dropdown-item>
  236. <el-button
  237. size="mini"
  238. type="primary"
  239. plain
  240. @click="previewPDF2(scope.row)"
  241. >预览</el-button
  242. >
  243. </el-dropdown-item>
  244. </el-dropdown-menu>
  245. </el-dropdown> -->
  246. </div>
  247. </template>
  248. </el-table-column>
  249. </el-table>
  250. <div class="part-page">
  251. <el-pagination
  252. :current-page="currentPage"
  253. :page-size="pageSize"
  254. :page-sizes="[10, 20, 50, 100, 200, 300]"
  255. layout="total, sizes, prev, pager, next, jumper"
  256. :total="total"
  257. @current-change="handleCurrentChange"
  258. @size-change="handleSizeChange"
  259. >
  260. </el-pagination>
  261. </div>
  262. </div>
  263. <!-- 下载 -->
  264. <el-dialog
  265. title="导出"
  266. :visible.sync="exportDialog"
  267. width="600px"
  268. :modal="true"
  269. append-to-body
  270. custom-class="side-dialog"
  271. >
  272. <el-form :model="exportModel" label-position="right" label-width="80px">
  273. <el-form-item v-if="isShow" label="课程名称">
  274. {{ exportModel.courseName }}
  275. </el-form-item>
  276. <el-form-item v-if="isShow" label="课程代码">
  277. {{ exportModel.courseCode }}
  278. </el-form-item>
  279. <el-form-item label="导出内容">
  280. <el-radio-group
  281. v-model="exportModel.exportContent"
  282. @change="exportContentChange"
  283. >
  284. <el-radio v-if="exportModel.id" label="PAPER">试卷</el-radio>
  285. <el-radio v-if="exportModel.id" label="ANSWER">答案</el-radio>
  286. <el-radio label="THEMIS_PACKAGE">数据包</el-radio>
  287. <el-radio label="CARD_PACKAGE">题卡数据</el-radio>
  288. <el-radio label="CARD_PDF">题卡PDF</el-radio>
  289. </el-radio-group>
  290. </el-form-item>
  291. <el-form-item v-if="showSeqMode()" label="小题序号">
  292. <el-radio-group v-model="exportModel.seqMode" class="input">
  293. <!-- <el-radio label="MODE1">单题型连续</el-radio>
  294. <el-radio label="MODE2">客观题整体连续</el-radio> -->
  295. <el-radio label="MODE3">按大题独立</el-radio>
  296. <el-radio label="MODE5">整卷连续</el-radio>
  297. </el-radio-group>
  298. </el-form-item>
  299. <el-form-item
  300. v-if="exportModel.exportContent === 'PAPER'"
  301. label="试卷模板"
  302. >
  303. <el-select
  304. v-model="curPaperTemp"
  305. placeholder="请选择试卷模板"
  306. value-key="id"
  307. @change="paperTempChange"
  308. >
  309. <el-option
  310. v-for="item in paperTempList"
  311. :key="item.id"
  312. :label="item.name"
  313. :value="item"
  314. >
  315. </el-option>
  316. </el-select>
  317. </el-form-item>
  318. <!-- <el-form-item
  319. v-if="exportModel.exportContent === 'ANSWER'"
  320. label="答案模板"
  321. >
  322. <el-select
  323. v-model="exportModel.templateId"
  324. filterable
  325. :remote-method="getTemplates"
  326. remote
  327. clearable
  328. placeholder="请选择答案模板"
  329. @clear="getTemplates('')"
  330. >
  331. <el-option
  332. v-for="item in templateList"
  333. :key="item.id"
  334. :label="item.fileName"
  335. :value="item.id"
  336. >
  337. </el-option>
  338. </el-select>
  339. </el-form-item> -->
  340. <el-form-item
  341. v-if="exportModel.exportContent === 'ANSWER'"
  342. label="页数模式"
  343. >
  344. <el-radio-group v-model="pageCountMode" style="width: 160px">
  345. <el-radio-button label="SIMPLE">单页</el-radio-button>
  346. <el-radio-button label="DOUBLE">双页</el-radio-button>
  347. </el-radio-group>
  348. </el-form-item>
  349. </el-form>
  350. <paper-build-config
  351. v-if="exportModel.exportContent === 'PAPER'"
  352. ref="PaperBuildConfig"
  353. :config-sources="configSources"
  354. :show-confirm-btn="false"
  355. ></paper-build-config>
  356. <div slot="footer">
  357. <el-button
  358. type="primary"
  359. :loading="downloading"
  360. @click="exportPaperInfo"
  361. >开始导出</el-button
  362. >
  363. </div>
  364. </el-dialog>
  365. <!-- 试卷属性 -->
  366. <el-dialog
  367. title="属性修改"
  368. :visible.sync="quesPropertyDialog"
  369. width="500px"
  370. :modal="true"
  371. append-to-body
  372. custom-class="side-dialog"
  373. >
  374. <el-form :loading="quesLoading" :inline="true" label-width="100px">
  375. <el-form-item>
  376. <span slot="label">
  377. <el-checkbox
  378. v-model="difficultyDegreeDis"
  379. style="margin-right: 30px"
  380. ></el-checkbox>
  381. <span>难度</span>
  382. </span>
  383. <el-select
  384. v-model="difficulty"
  385. class="dialog_input_width"
  386. :disabled="!difficultyDegreeDis"
  387. >
  388. <el-option
  389. v-for="item in difficultyList"
  390. :key="item.value"
  391. :label="item.label"
  392. :value="item.value"
  393. ></el-option>
  394. </el-select>
  395. </el-form-item>
  396. <el-form-item>
  397. <span slot="label">
  398. <el-checkbox
  399. v-model="publicityDis"
  400. style="margin-right: 16px"
  401. ></el-checkbox>
  402. <span>公开度</span>
  403. </span>
  404. <el-select
  405. v-model="publicity"
  406. class="dialog_input_width"
  407. :disabled="!publicityDis"
  408. >
  409. <el-option
  410. v-for="item in publicityList"
  411. :key="item.value"
  412. :label="item.label"
  413. :value="item.value"
  414. ></el-option>
  415. </el-select>
  416. </el-form-item>
  417. </el-form>
  418. <div slot="footer">
  419. <el-button
  420. v-loading.fullscreen.lock="quesLoading"
  421. type="primary"
  422. @click="updateQuesPropertyByPaper()"
  423. >保存</el-button
  424. >
  425. <el-button type="danger" plain @click="resetQuesProForm"
  426. >重置</el-button
  427. >
  428. <el-button type="danger" plain @click="closePropertyDialog"
  429. >返 回</el-button
  430. >
  431. </div>
  432. </el-dialog>
  433. <!-- paper-view-frame -->
  434. <div v-if="paperPreviewUrl" class="design-preview-frame">
  435. <iframe
  436. :src="paperPreviewUrl"
  437. frameborder="0"
  438. width="1000"
  439. height="800"
  440. ></iframe>
  441. </div>
  442. <div v-if="answerPreviewUrl" class="design-preview-frame">
  443. <iframe
  444. :src="answerPreviewUrl"
  445. frameborder="0"
  446. width="1000"
  447. height="800"
  448. ></iframe>
  449. </div>
  450. </section>
  451. </template>
  452. <script>
  453. import PaperBuildConfig from "../../paper-export/components/PaperBuildConfig.vue";
  454. import { QUESTION_API } from "@/constants/constants";
  455. import { LEVEL_TYPE, PUBLICITY_LIST } from "../constants/constants";
  456. import { mapState } from "vuex";
  457. import { downloadByApi } from "@/plugins/download";
  458. import {
  459. paperTemplateListApi,
  460. paperPdfDownloadApi,
  461. answerPdfDownloadApi,
  462. } from "../../paper-export/api";
  463. import { deepCopy } from "@/plugins/utils";
  464. export default {
  465. components: {
  466. PaperBuildConfig,
  467. },
  468. data() {
  469. return {
  470. templateList: [],
  471. publicityDis: false,
  472. difficultyDegreeDis: false,
  473. quesLoading: false,
  474. quesPropertyDialog: false,
  475. difficultyDegree: 0.1,
  476. difficulty: "易",
  477. publicity: true,
  478. difficultyList: [
  479. { label: "难", value: "难" },
  480. { label: "中", value: "中" },
  481. { label: "易", value: "易" },
  482. ],
  483. publicityList: PUBLICITY_LIST,
  484. isClear: 0,
  485. courseLoading: false,
  486. formSearch: {
  487. courseId: "",
  488. courseName: "",
  489. creator: "",
  490. lastModifyName: "",
  491. // level: "",
  492. name: "",
  493. },
  494. tableData: [],
  495. currentPage: 1,
  496. pageSize: 10,
  497. total: 0,
  498. loading: false,
  499. courseList: [],
  500. levelList: LEVEL_TYPE,
  501. dialogVisible: false,
  502. selectedPaperIds: [],
  503. fileList: [],
  504. uploadAction: "",
  505. formUpload: {
  506. paperName: "",
  507. },
  508. uploadData: {},
  509. fileLoading: false,
  510. exportDialog: false,
  511. exportModel: {
  512. id: "",
  513. courseCode: "",
  514. courseName: "",
  515. templateId: "",
  516. exportContent: "",
  517. seqMode: "MODE3",
  518. },
  519. pageCountMode: "SIMPLE",
  520. isShow: true,
  521. examList: [],
  522. dialogModel: false,
  523. rowIds: [],
  524. isShowPrintExamPackage: false,
  525. isShowPrintExamPackagePassword: false,
  526. printExamPackagePassword: "",
  527. printFrom: {
  528. examId: "",
  529. },
  530. rules: {
  531. examId: [{ required: true, message: "请输入名称", trigger: "change" }],
  532. },
  533. // pdf download
  534. paperPreviewUrl: "",
  535. answerPreviewUrl: "",
  536. downloading: false,
  537. curPaperTemp: null,
  538. paperTempList: [],
  539. configSources: [],
  540. configModalForm: {},
  541. };
  542. },
  543. computed: {
  544. paperIds() {
  545. var paperIds = "";
  546. for (let paperId of this.selectedPaperIds) {
  547. if (!paperIds) {
  548. paperIds += paperId;
  549. } else {
  550. paperIds += "," + paperId;
  551. }
  552. }
  553. return paperIds;
  554. },
  555. courseInfoSelect() {
  556. var courseList = [];
  557. for (let course of this.courseList) {
  558. var courseInfo = course.name + "(" + course.code + ")";
  559. var courseId = course.id;
  560. var courseName = course.name;
  561. courseList.push({
  562. courseId: courseId,
  563. courseInfo: courseInfo,
  564. courseName: courseName,
  565. });
  566. }
  567. return courseList;
  568. },
  569. noBatchSelected() {
  570. return this.selectedPaperIds.length === 0;
  571. },
  572. ...mapState({ user: (state) => state.user }),
  573. },
  574. watch: {
  575. $route: "initVue",
  576. },
  577. created() {
  578. this.initVue();
  579. this.registWindowSubmit();
  580. },
  581. beforeDestroy() {
  582. delete window.submitPaperTemp;
  583. },
  584. methods: {
  585. exportContentChange(val) {
  586. if (val === "PAPER") {
  587. this.getPaperTempList();
  588. return;
  589. }
  590. if (val === "ANSWER") {
  591. this.getTemplates("");
  592. return;
  593. }
  594. },
  595. getTemplates(name) {
  596. this.exportModel.templateId = "";
  597. var url = QUESTION_API + "/exportTemplate/page/1/20";
  598. let type;
  599. if (this.exportModel.exportContent == "PAPER") {
  600. type = "PAPER_EXPORT";
  601. } else if (this.exportModel.exportContent == "ANSWER") {
  602. type = "ANSWER_EXPORT";
  603. } else {
  604. return;
  605. }
  606. let params = {
  607. rootOrgId: this.user.rootOrgId,
  608. fileName: name,
  609. enable: true,
  610. type: type,
  611. };
  612. this.$httpWithMsg.get(url, { params: params }).then((response) => {
  613. this.templateList = response.data.content;
  614. });
  615. },
  616. recoveryPaper(row) {
  617. this.$confirm("确认回收试卷吗?", "提示", {
  618. type: "warning",
  619. }).then(() => {
  620. this.loading = true;
  621. this.$http.put(QUESTION_API + "/paper_storage/recovery/" + row.id).then(
  622. () => {
  623. this.$notify({
  624. message: "操作成功",
  625. type: "success",
  626. });
  627. this.searchGenPaper();
  628. },
  629. (response) => {
  630. this.$notify({
  631. message: response.response.data.desc,
  632. type: "error",
  633. });
  634. this.loading = false;
  635. }
  636. );
  637. });
  638. },
  639. recoveryPapers() {
  640. var paperIds = this.paperIds;
  641. if (this.selectedPaperIds.length != 0) {
  642. this.$confirm("确认回收试卷吗?", "提示", {
  643. type: "warning",
  644. }).then(() => {
  645. this.loading = true;
  646. this.$http
  647. .put(QUESTION_API + "/paper_storage/recovery/" + paperIds)
  648. .then(
  649. () => {
  650. this.$notify({
  651. message: "操作成功",
  652. type: "success",
  653. });
  654. this.selectedPaperIds = [];
  655. this.searchGenPaper();
  656. },
  657. (response) => {
  658. this.$notify({
  659. message: response.response.data.desc,
  660. type: "error",
  661. });
  662. this.loading = false;
  663. }
  664. );
  665. });
  666. } else {
  667. this.$notify({
  668. message: "请勾选回收的试卷",
  669. type: "warning",
  670. });
  671. }
  672. },
  673. showSeqMode() {
  674. let element = this.exportModel.exportContent;
  675. if (element == "PAPER" || element == "ANSWER") {
  676. return true;
  677. }
  678. return false;
  679. },
  680. updateQuesPropertyByPaper() {
  681. if (!this.difficultyDegreeDis && !this.publicityDis) {
  682. this.$notify({
  683. title: "警告",
  684. message: "请勾选难度或公开度",
  685. type: "warning",
  686. });
  687. return;
  688. }
  689. var params = "?ids=" + this.selectedPaperIds;
  690. if (this.difficultyDegreeDis) {
  691. params = params + "&difficulty=" + this.difficulty;
  692. }
  693. if (this.publicityDis) {
  694. params = params + "&publicity=" + this.publicity;
  695. }
  696. this.quesLoading = true;
  697. this.$httpWithMsg
  698. .put(QUESTION_API + "/question/updatePro/paperIds" + params)
  699. .then(() => {
  700. this.$notify({
  701. message: "更新成功",
  702. type: "success",
  703. });
  704. this.searchGenPaper();
  705. this.quesLoading = false;
  706. this.closePropertyDialog();
  707. })
  708. .catch(() => {
  709. this.quesLoading = false;
  710. });
  711. },
  712. openQuesPro() {
  713. if (!this.selectedPaperIds || this.selectedPaperIds.length < 1) {
  714. this.$notify({
  715. title: "警告",
  716. message: "请选择试卷",
  717. type: "warning",
  718. });
  719. return;
  720. }
  721. this.difficultyDegree = 0.1;
  722. this.difficulty = "易";
  723. this.publicity = true;
  724. this.quesPropertyDialog = true;
  725. },
  726. closePropertyDialog() {
  727. this.quesPropertyDialog = false;
  728. },
  729. resetQuesProForm() {
  730. this.difficultyDegree = 0.1;
  731. this.difficulty = "易";
  732. this.publicity = true;
  733. },
  734. resetForm() {
  735. this.formSearch = {
  736. courseId: "",
  737. courseName: "",
  738. // level: "",
  739. name: "",
  740. };
  741. },
  742. //查询
  743. searchFrom() {
  744. this.currentPage = 1;
  745. this.searchGenPaper();
  746. },
  747. searchGenPaper() {
  748. var pageNo = this.currentPage;
  749. this.currentPage = 1;
  750. this.loading = true;
  751. var url = QUESTION_API + "/genPaper/" + pageNo + "/" + this.pageSize;
  752. this.$http.get(url, { params: this.formSearch }).then((response) => {
  753. this.tableData = response.data.content;
  754. this.total = response.data.totalElements;
  755. this.currentPage = Number(pageNo);
  756. });
  757. this.loading = false;
  758. },
  759. genPaperDetail() {
  760. var courseId = this.formSearch.courseId;
  761. if (!courseId) {
  762. this.$notify({
  763. title: "警告",
  764. message: "请选择课程",
  765. type: "warning",
  766. });
  767. } else {
  768. let genPaperData = { ...this.formSearch };
  769. var course = this.getCourseObj(this.formSearch.courseId);
  770. if (course) {
  771. genPaperData.courseName = course.name;
  772. genPaperData.courseCode = course.code;
  773. }
  774. sessionStorage.setItem("gen_paper", JSON.stringify(genPaperData));
  775. sessionStorage.setItem("gen_paper_currentPage", this.currentPage);
  776. this.$router.push({
  777. name: "gen_paper_detail",
  778. params: { courseId: courseId },
  779. });
  780. }
  781. },
  782. handleCurrentChange(val) {
  783. this.currentPage = val;
  784. this.searchGenPaper();
  785. },
  786. handleSizeChange(val) {
  787. this.pageSize = val;
  788. this.currentPage = 1;
  789. this.searchGenPaper();
  790. },
  791. getCourseObj(courseId) {
  792. for (let course of this.courseList) {
  793. if (course.id == courseId) {
  794. return course;
  795. }
  796. }
  797. return "";
  798. },
  799. editGenPaper(row) {
  800. var course = this.getCourseObj(this.formSearch.courseId);
  801. if (course) {
  802. this.formSearch.courseName = course.name;
  803. }
  804. sessionStorage.setItem("gen_paper", JSON.stringify(this.formSearch));
  805. sessionStorage.setItem("gen_paper_currentPage", this.currentPage);
  806. sessionStorage.setItem("question_back", "false");
  807. this.$router.push({
  808. path: "/edit_paper/" + row.id + "/gen_paper",
  809. });
  810. },
  811. deleteGenPaper(row) {
  812. this.$confirm("确认删除试卷吗?", "提示", {
  813. type: "warning",
  814. }).then(() => {
  815. this.loading = true;
  816. this.$http.delete(QUESTION_API + "/paper/" + row.id).then(
  817. () => {
  818. this.$notify({
  819. message: "删除成功",
  820. type: "success",
  821. });
  822. this.searchGenPaper();
  823. },
  824. (response) => {
  825. this.$notify({
  826. message: response.response.data.desc,
  827. type: "error",
  828. });
  829. this.loading = false;
  830. }
  831. );
  832. });
  833. },
  834. selectChange(row) {
  835. this.selectedPaperIds = [];
  836. row.forEach((element) => {
  837. this.selectedPaperIds.push(element.id);
  838. });
  839. },
  840. batchDeleteGenPaper() {
  841. var paperIds = this.paperIds;
  842. if (this.selectedPaperIds.length != 0) {
  843. this.$confirm("确认删除试卷吗?", "提示", {
  844. type: "warning",
  845. }).then(() => {
  846. this.loading = true;
  847. this.$http.delete(QUESTION_API + "/paper/" + paperIds).then(
  848. () => {
  849. this.$notify({
  850. message: "删除成功",
  851. type: "success",
  852. });
  853. this.searchGenPaper();
  854. this.selectedPaperIds = [];
  855. },
  856. (response) => {
  857. this.$notify({
  858. message: response.response.data.desc,
  859. type: "error",
  860. });
  861. this.loading = false;
  862. }
  863. );
  864. });
  865. } else {
  866. this.$notify({
  867. message: "请勾选删除的数据",
  868. type: "warning",
  869. });
  870. }
  871. },
  872. //查询所有课程
  873. getCourses(query) {
  874. if (query) {
  875. query = query.trim();
  876. }
  877. this.courseLoading = true;
  878. this.$http
  879. .get(QUESTION_API + "/course/query?name=" + query + "&enable=true")
  880. .then((response) => {
  881. this.courseList = response.data;
  882. this.courseLoading = false;
  883. });
  884. },
  885. //打开导出弹框
  886. openExportDialog(row) {
  887. this.isShow = true;
  888. this.exportDialog = true;
  889. this.exportModel.id = row.id;
  890. this.exportModel.courseCode = row.course.code;
  891. this.exportModel.courseName = row.course.name;
  892. this.exportModel.exportContent = "";
  893. this.exportModel.templateId = "";
  894. /* 分布式印刷数据包设置 */
  895. this.isShowPrintExamPackage = true;
  896. this.isShowPrintExamPackagePassword = false;
  897. this.printExamPackagePassword = "";
  898. },
  899. //打开批量弹出框
  900. openBatchExportPaperDialog() {
  901. if (this.selectedPaperIds.length != 0) {
  902. this.exportDialog = true;
  903. this.isShow = false;
  904. this.exportModel.exportContent = "";
  905. this.exportModel.templateId = "";
  906. // 多于两个试卷时候,将无法导出试卷。todo
  907. if (this.selectedPaperIds.length === 1) {
  908. this.exportModel.id = this.selectedPaperIds[0];
  909. } else {
  910. this.exportModel.id = "";
  911. }
  912. } else {
  913. this.$notify({
  914. message: "请勾选导出的数据",
  915. type: "warning",
  916. });
  917. }
  918. /* 分布式印刷数据包设置 */
  919. this.isShowPrintExamPackage = false;
  920. this.isShowPrintExamPackagePassword = false;
  921. this.printExamPackagePassword = "";
  922. },
  923. //导出试卷,答案,机考数据包
  924. async exportPaperInfo() {
  925. // 下载pdf
  926. if (this.exportModel.exportContent === "PAPER") {
  927. if (!this.curPaperTemp) {
  928. this.$notify({
  929. message: "请选择试卷模板",
  930. type: "error",
  931. });
  932. return;
  933. }
  934. this.toDownloadPaperPdf();
  935. return;
  936. }
  937. if (this.exportModel.exportContent === "ANSWER") {
  938. // if (!this.exportModel.templateId) {
  939. // this.$notify({
  940. // message: "请选择答案模板",
  941. // type: "error",
  942. // });
  943. // return;
  944. // }
  945. this.toDownloadAnswerPdf();
  946. return;
  947. }
  948. if (
  949. !this.exportModel.exportContent ||
  950. this.exportModel.exportContent == ""
  951. ) {
  952. this.$notify({
  953. message: "请选择导出内容",
  954. type: "error",
  955. });
  956. return false;
  957. }
  958. let element = this.exportModel.exportContent;
  959. if (
  960. (element == "PAPER" || element == "ANSWER") &&
  961. !this.exportModel.templateId
  962. ) {
  963. this.$notify({
  964. message: "请选择模板",
  965. type: "error",
  966. });
  967. return false;
  968. }
  969. if (this.printExamPackagePassword.length > 0) {
  970. var reg = /^[0-9A-Za-z]{6,12}$/;
  971. if (!reg.test(this.printExamPackagePassword)) {
  972. this.$notify({
  973. message: "加密密码请输入6至12位的数字或字母!",
  974. type: "error",
  975. });
  976. return false;
  977. }
  978. }
  979. if (this.downloading) return;
  980. this.downloading = true;
  981. const params = {
  982. psw: this.printExamPackagePassword,
  983. seqMode: this.exportModel.seqMode,
  984. templateId: this.exportModel.templateId,
  985. };
  986. let url = "";
  987. if (this.isShow) {
  988. url = `${QUESTION_API}/paper/export/${this.exportModel.id}/${this.exportModel.exportContent}/onLine`;
  989. } else {
  990. url = `${QUESTION_API}/paper/batch_export/${this.paperIds}/${this.exportModel.exportContent}/onLine`;
  991. }
  992. const res = await downloadByApi(() => {
  993. return this.$httpWithMsg.get(url, {
  994. params,
  995. responseType: "blob",
  996. });
  997. }).catch((e) => {
  998. this.$message.error(e || "下载失败,请重新尝试!");
  999. });
  1000. this.exportDialog = false;
  1001. this.downloading = false;
  1002. if (!res) return;
  1003. this.$message.success("下载成功!");
  1004. },
  1005. removeItem() {
  1006. sessionStorage.removeItem("gen_paper");
  1007. sessionStorage.removeItem("gen_paper_currentPage");
  1008. },
  1009. previewPDF2(row) {
  1010. window.open(
  1011. this.getRouterPath({
  1012. name: "PaperTemplateBuild",
  1013. params: {
  1014. paperId: row.id,
  1015. },
  1016. })
  1017. );
  1018. },
  1019. toRecycle() {
  1020. this.$router.push({
  1021. name: "PaperRecycle",
  1022. });
  1023. },
  1024. initVue() {
  1025. this.isClear = this.$route.params.isClear;
  1026. if (this.isClear == 0 || !this.isClear) {
  1027. this.removeItem();
  1028. this.formSearch = {
  1029. courseId: "",
  1030. courseName: "",
  1031. // level: "",
  1032. name: "",
  1033. };
  1034. this.currentPage = 1;
  1035. } else {
  1036. this.formSearch = JSON.parse(sessionStorage.getItem("gen_paper"));
  1037. this.currentPage =
  1038. sessionStorage.getItem("gen_paper_currentPage") == null
  1039. ? 1
  1040. : parseInt(sessionStorage.getItem("gen_paper_currentPage"));
  1041. }
  1042. this.getCourses(this.formSearch.courseName);
  1043. this.searchGenPaper();
  1044. },
  1045. // download paper pdf
  1046. async getPaperTempList() {
  1047. if (this.paperTempList.length) return;
  1048. const res = await paperTemplateListApi("PAPER_EXPORT");
  1049. this.paperTempList = res.data;
  1050. },
  1051. paperTempChange(paperTemp) {
  1052. // console.log(paperTemp);
  1053. let paperTempJson = paperTemp.content
  1054. ? JSON.parse(paperTemp.content)
  1055. : { pages: [], pageConfig: {} };
  1056. this.getConfigSources(paperTempJson.pages);
  1057. },
  1058. getConfigSources(pages) {
  1059. let sources = [],
  1060. fieldAble = {};
  1061. pages.forEach((page) => {
  1062. page.columns.forEach((column) => {
  1063. column.elements.forEach((element) => {
  1064. if (element.type !== "PAPER_PROPS") return;
  1065. if (!sources.length) {
  1066. sources = deepCopy(element.props);
  1067. }
  1068. element.props.forEach((prop) => {
  1069. fieldAble[prop.field] = fieldAble[prop.field] || prop.enable;
  1070. });
  1071. });
  1072. });
  1073. });
  1074. sources.forEach((item) => {
  1075. item.enable = fieldAble[item.field];
  1076. });
  1077. this.configSources = sources;
  1078. },
  1079. async toDownloadPaperPdf() {
  1080. const valid = await this.$refs.PaperBuildConfig.checkData().catch(
  1081. () => {}
  1082. );
  1083. if (!valid) return;
  1084. if (this.downloading) return;
  1085. this.downloading = true;
  1086. const configModalForm = this.$refs.PaperBuildConfig.getData();
  1087. window.paperSet = {
  1088. paperTemp: this.curPaperTemp,
  1089. seqMode: this.exportModel.seqMode,
  1090. configModalForm,
  1091. };
  1092. console.log("window.paperSet", window.paperSet);
  1093. const { href } = this.$router.resolve({
  1094. name: "PaperTemplateBuild",
  1095. params: {
  1096. paperId: this.exportModel.id,
  1097. viewType: "frame",
  1098. },
  1099. query: {
  1100. t: Date.now(),
  1101. },
  1102. });
  1103. // console.log(href);
  1104. this.paperPreviewUrl = href;
  1105. },
  1106. toDownloadAnswerPdf() {
  1107. if (this.downloading) return;
  1108. this.downloading = true;
  1109. window.answerSet = {
  1110. // answerTemplateId: this.exportModel.templateId,
  1111. pageCountMode: this.pageCountMode,
  1112. seqMode: this.exportModel.seqMode,
  1113. };
  1114. const { href } = this.$router.resolve({
  1115. name: "AnswerTemplateBuild",
  1116. params: {
  1117. paperId: this.exportModel.id,
  1118. viewType: "frame",
  1119. },
  1120. query: {
  1121. t: Date.now(),
  1122. },
  1123. });
  1124. this.answerPreviewUrl = href;
  1125. },
  1126. registWindowSubmit() {
  1127. window.submitPaperTemp = async ({
  1128. success,
  1129. errorMsg,
  1130. htmlCont,
  1131. templateId,
  1132. }) => {
  1133. if (!success) {
  1134. this.downloading = false;
  1135. if (templateId) {
  1136. delete window.paperSet;
  1137. this.paperPreviewUrl = "";
  1138. } else {
  1139. delete window.answerSet;
  1140. this.answerPreviewUrl = "";
  1141. }
  1142. this.$message.error(errorMsg);
  1143. this.exportDialog = false;
  1144. return;
  1145. }
  1146. // this.paperPreviewUrl = "";
  1147. if (templateId) {
  1148. const res = await downloadByApi(() => {
  1149. return paperPdfDownloadApi({
  1150. content: htmlCont,
  1151. templateId,
  1152. paperId: this.exportModel.id,
  1153. });
  1154. }).catch((e) => {
  1155. this.$message.error(e || "下载失败,请重新尝试!");
  1156. });
  1157. this.exportDialog = false;
  1158. this.downloading = false;
  1159. if (!res) return;
  1160. this.$message.success("下载成功!");
  1161. delete window.paperSet;
  1162. } else {
  1163. const res = await downloadByApi(() => {
  1164. return answerPdfDownloadApi({
  1165. content: htmlCont,
  1166. size: "A4",
  1167. paperId: this.exportModel.id,
  1168. });
  1169. }).catch((e) => {
  1170. this.$message.error(e || "下载失败,请重新尝试!");
  1171. });
  1172. this.exportDialog = false;
  1173. this.downloading = false;
  1174. if (!res) return;
  1175. this.$message.success("下载成功!");
  1176. delete window.answerSet;
  1177. }
  1178. };
  1179. },
  1180. },
  1181. };
  1182. </script>