GenPaper.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. <template>
  2. <div>
  3. <section class="content">
  4. <div class="box box-info">
  5. <div class="box-header with-border">
  6. <h3 class="box-title">考试试卷管理</h3>
  7. </div>
  8. <div class="box-body">
  9. <el-form
  10. :inline="true"
  11. :model="formSearch"
  12. label-position="right"
  13. label-width="110px"
  14. >
  15. <el-form-item label="课程名称" class="pull-left">
  16. <el-select
  17. v-model="formSearch.courseNo"
  18. :remote-method="getCourses"
  19. :loading="courseLoading"
  20. remote
  21. filterable
  22. clearable
  23. placeholder="全部"
  24. >
  25. <el-option
  26. v-for="item in courseInfoSelect"
  27. :label="item.courseInfo"
  28. :value="item.courseNo"
  29. :key="item.courseNo"
  30. >
  31. </el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="试卷名称" class="pull-left">
  35. <el-input
  36. v-model="formSearch.name"
  37. placeholder="试卷名称"
  38. ></el-input>
  39. </el-form-item>
  40. <el-form-item label="层次" class="pull-left">
  41. <el-select v-model="formSearch.level">
  42. <el-option label="请选择" value=""> </el-option>
  43. <el-option
  44. v-for="item in levelList"
  45. :label="item.label"
  46. :value="item.value"
  47. :key="item.value"
  48. >
  49. </el-option>
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item class="pull-right">
  53. <el-button
  54. size="small"
  55. type="primary"
  56. icon="search"
  57. @click="searchGenPaper"
  58. >查询</el-button
  59. >
  60. <el-button
  61. size="small"
  62. type="primary"
  63. icon="plus"
  64. @click="genPaperDetail"
  65. >组卷</el-button
  66. >
  67. <el-button
  68. size="small"
  69. type="danger"
  70. icon="delete"
  71. @click="batchDeleteGenPaper"
  72. >批量删除
  73. </el-button>
  74. <el-button
  75. size="small"
  76. type="primary"
  77. icon="upload2"
  78. @click="openBatchExportPaperDialog"
  79. >
  80. 批量导出
  81. </el-button>
  82. </el-form-item>
  83. </el-form>
  84. <el-table
  85. v-loading="loading"
  86. element-loading-text="拼命加载中"
  87. :data="tableData"
  88. border
  89. style="width: 100%"
  90. @selection-change="selectChange"
  91. >
  92. <el-table-column type="selection" width="55"></el-table-column>
  93. <el-table-column label="课程名称" width="150">
  94. <template slot-scope="scope">
  95. <div>
  96. <span>{{ scope.row.course.name }}</span>
  97. </div>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="课程代码" width="120">
  101. <template slot-scope="scope">
  102. <div>
  103. <span>{{ scope.row.course.code }}</span>
  104. </div>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="试卷名称" width="150">
  108. <template slot-scope="scope">
  109. <div>
  110. <span>{{ scope.row.name }}</span>
  111. </div>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="试卷总分" width="100">
  115. <template slot-scope="scope">
  116. <div>
  117. <span>{{ scope.row.totalScore }}</span>
  118. </div>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="试卷难度" width="100">
  122. <template slot-scope="scope">
  123. <div>
  124. <span>{{ scope.row.difficultyDegree }}</span>
  125. </div>
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="大题数量" width="100">
  129. <template slot-scope="scope">
  130. <div>
  131. <span>{{ scope.row.paperDetailCount }}</span>
  132. </div>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="录入员" width="100">
  136. <template slot-scope="scope">
  137. <div>
  138. <span>{{ scope.row.creator }}</span>
  139. </div>
  140. </template>
  141. </el-table-column>
  142. <el-table-column label="创建时间" width="120">
  143. <template slot-scope="scope">
  144. <div>
  145. <span>{{ scope.row.createTime }}</span>
  146. </div>
  147. </template>
  148. </el-table-column>
  149. <el-table-column label="最后修改人" width="120">
  150. <template slot-scope="scope">
  151. <div>
  152. <span>{{ scope.row.lastModifyName }}</span>
  153. </div>
  154. </template>
  155. </el-table-column>
  156. <el-table-column label="操作" width="330">
  157. <template slot-scope="scope">
  158. <div>
  159. <el-button
  160. @click="openExportDialog(scope.row);"
  161. type="success"
  162. size="mini"
  163. >导出</el-button
  164. >
  165. <el-button
  166. @click="editGenPaper(scope.row);"
  167. type="info"
  168. size="mini"
  169. >编辑</el-button
  170. >
  171. <el-button
  172. @click="deleteGenPaper(scope.row);"
  173. type="danger"
  174. size="mini"
  175. >删除</el-button
  176. >
  177. <el-button
  178. @click="previewPDF2(scope.row);"
  179. type="warning"
  180. size="mini"
  181. >预览PDF</el-button
  182. >
  183. <el-button
  184. @click="openPrint(scope.row);"
  185. type="warning"
  186. size="mini"
  187. >传至印刷</el-button
  188. >
  189. </div>
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. <div class="page pull-right">
  194. <el-pagination
  195. @current-change="handleCurrentChange"
  196. :current-page="currentPage"
  197. :page-size="pageSize"
  198. layout="total, prev, pager, next, jumper"
  199. :total="total"
  200. >
  201. </el-pagination>
  202. </div>
  203. </div>
  204. </div>
  205. <el-dialog title="导出" :visible.sync="exportDialog">
  206. <el-form :model="exportModel" label-position="right" label-width="80px">
  207. <el-row v-if="isShow">
  208. <el-col :md="12">
  209. <el-form-item label="课程名称">
  210. {{ exportModel.courseName }}
  211. </el-form-item>
  212. </el-col>
  213. </el-row>
  214. <el-row v-if="isShow">
  215. <el-col :md="12">
  216. <el-form-item label="课程代码">
  217. {{ exportModel.courseCode }}
  218. </el-form-item>
  219. </el-col>
  220. </el-row>
  221. <el-row>
  222. <el-col :md="24">
  223. <el-form-item label="导出内容">
  224. <el-checkbox-group v-model="exportModel.exportContentList">
  225. <el-checkbox label="PAPER">试卷</el-checkbox>
  226. <el-checkbox label="ANSWER">答案</el-checkbox>
  227. <el-checkbox label="COMPUTERTEST_PACKAGE"
  228. >机考数据包</el-checkbox
  229. >
  230. <el-checkbox
  231. v-if="isShowPrintExamPackage"
  232. label="PRINT_EXAM_PACKAGE"
  233. >分布式印刷数据包
  234. </el-checkbox>
  235. <el-input
  236. v-if="isShowPrintExamPackagePassword"
  237. v-model="printExamPackagePassword"
  238. placeholder="加密密码 (可选)"
  239. type="password"
  240. style="width: 150px"
  241. ></el-input>
  242. </el-checkbox-group>
  243. </el-form-item>
  244. </el-col>
  245. </el-row>
  246. <el-row>
  247. <el-col :md="24" class="text-center">
  248. <el-button type="primary" @click="exportPaperInfo"
  249. >开始导出</el-button
  250. >
  251. </el-col>
  252. </el-row>
  253. </el-form>
  254. </el-dialog>
  255. <el-dialog title="传送印刷平台" v-model="dialogModel">
  256. <el-form>
  257. <el-row>
  258. <el-form-item label="学校名称" label-width="120px">
  259. <el-input v-model="this.Org.name" :disabled="true"></el-input>
  260. </el-form-item>
  261. </el-row>
  262. <el-row>
  263. <el-form-item label="考试名称" label-width="120px">
  264. <el-select
  265. v-model="examId"
  266. filterable
  267. clearable
  268. :remote-method="getExams"
  269. remote
  270. placeholder="请选择"
  271. >
  272. <el-option
  273. v-for="item in examList"
  274. :label="item.name"
  275. :value="item.id"
  276. :key="item.id"
  277. ></el-option>
  278. </el-select>
  279. </el-form-item>
  280. </el-row>
  281. </el-form>
  282. <div slot="footer" class="dialog-footer">
  283. <el-button @click="cancel">取 消</el-button>
  284. <el-button type="primary" @click="sendPrint">确 定</el-button>
  285. </div>
  286. </el-dialog>
  287. </section>
  288. </div>
  289. </template>
  290. <script>
  291. import {
  292. CORE_API,
  293. EXAM_WORK_API,
  294. LEVEL_TYPE,
  295. Q_API
  296. } from "../constants/constants";
  297. import { mapState } from "vuex";
  298. export default {
  299. data() {
  300. return {
  301. isClear: 0,
  302. courseLoading: false,
  303. formSearch: {
  304. courseNo: "",
  305. courseName: "",
  306. level: "",
  307. name: ""
  308. },
  309. tableData: [],
  310. currentPage: 1,
  311. pageSize: 10,
  312. total: 0,
  313. loading: false,
  314. courseList: [],
  315. levelList: LEVEL_TYPE,
  316. dialogVisible: false,
  317. selectedPaperIds: [],
  318. fileList: [],
  319. uploadAction: "",
  320. formUpload: {
  321. paperName: ""
  322. },
  323. uploadData: {},
  324. fileLoading: false,
  325. exportDialog: false,
  326. exportModel: {
  327. id: "",
  328. courseCode: "",
  329. courseName: "",
  330. exportContentList: []
  331. },
  332. isShow: true,
  333. examList: [],
  334. Org: {},
  335. dialogModel: false,
  336. examId: "",
  337. rowId: "",
  338. isShowPrintExamPackage: false,
  339. isShowPrintExamPackagePassword: false,
  340. printExamPackagePassword: ""
  341. };
  342. },
  343. methods: {
  344. searchGenPaper() {
  345. this.loading = true;
  346. var url = Q_API + "/genPaper/" + this.currentPage + "/" + this.pageSize;
  347. this.$http.get(url, { params: this.formSearch }).then(response => {
  348. this.tableData = response.data.content;
  349. this.total = response.data.totalElements;
  350. });
  351. this.loading = false;
  352. },
  353. genPaperDetail() {
  354. var courseNo = this.formSearch.courseNo;
  355. this.getCourseName(courseNo);
  356. var courseName = this.formSearch.courseName;
  357. var level = this.formSearch.level;
  358. if (!courseNo) {
  359. this.$notify({
  360. message: "请选择课程",
  361. type: "error"
  362. });
  363. } else {
  364. sessionStorage.setItem("gen_paper_courseNo", this.formSearch.courseNo);
  365. sessionStorage.setItem("gen_paper_name", this.formSearch.name);
  366. sessionStorage.setItem(
  367. "gen_paper_specialtyNo",
  368. this.formSearch.specialtyNo
  369. );
  370. sessionStorage.setItem("gen_paper_currentPage", this.currentPage);
  371. sessionStorage.setItem("gen_paper_courseName", courseName);
  372. this.$router.push({
  373. path: "/questions/gen_paper_detail/" + courseNo + "/" + level
  374. });
  375. }
  376. },
  377. handleCurrentChange(val) {
  378. this.currentPage = val;
  379. this.searchGenPaper();
  380. },
  381. getCourseName(courseNo) {
  382. for (let course of this.courseList) {
  383. if (course.code == courseNo) {
  384. this.formSearch.courseName = course.name;
  385. this.formSearch.level = course.level;
  386. console.log(course.level);
  387. }
  388. }
  389. },
  390. exportGenPaper(row) {
  391. window.open(
  392. Q_API + "/paper/export/" + row.id + "/" + this.user.rootOrgName
  393. );
  394. },
  395. editGenPaper(row) {
  396. sessionStorage.setItem("gen_paper_courseNo", this.formSearch.courseNo);
  397. sessionStorage.setItem("gen_paper_name", this.formSearch.name);
  398. sessionStorage.setItem(
  399. "gen_paper_specialtyNo",
  400. this.formSearch.specialtyNo
  401. );
  402. sessionStorage.setItem("gen_paper_currentPage", this.currentPage);
  403. this.$router.push({ path: "/edit_paper/" + row.id + "/gen_paper" });
  404. },
  405. deleteGenPaper(row) {
  406. this.$confirm("确认删除试卷吗?", "提示", {
  407. type: "warning"
  408. }).then(() => {
  409. this.loading = true;
  410. this.$http.delete(Q_API + "/paper/" + row.id).then(
  411. () => {
  412. this.$notify({
  413. message: "删除成功",
  414. type: "success"
  415. });
  416. this.searchGenPaper();
  417. },
  418. response => {
  419. this.$notify({
  420. message: response.data.msg,
  421. type: "error"
  422. });
  423. this.loading = false;
  424. }
  425. );
  426. });
  427. },
  428. selectChange(row) {
  429. this.selectedPaperIds = [];
  430. row.forEach(element => {
  431. this.selectedPaperIds.push(element.id);
  432. });
  433. },
  434. batchDeleteGenPaper() {
  435. var paperIds = this.paperIds;
  436. console.log("试卷id:", paperIds);
  437. if (this.selectedPaperIds.length != 0) {
  438. this.$confirm("确认删除试卷吗?", "提示", {
  439. type: "warning"
  440. }).then(() => {
  441. this.loading = true;
  442. this.$http.delete(Q_API + "/paper/" + paperIds).then(
  443. () => {
  444. this.$notify({
  445. message: "删除成功",
  446. type: "success"
  447. });
  448. this.searchGenPaper();
  449. this.selectedPaperIds = [];
  450. },
  451. response => {
  452. this.$notify({
  453. message: response.data.msg,
  454. type: "error"
  455. });
  456. this.loading = false;
  457. }
  458. );
  459. });
  460. } else {
  461. this.$notify({
  462. message: "请勾选删除的数据",
  463. type: "warning"
  464. });
  465. }
  466. },
  467. //查询所有课程
  468. getCourses(query) {
  469. query = query.trim();
  470. if (query) {
  471. if (!(query.indexOf("(") > -1 && query.indexOf(")") > -1)) {
  472. this.courseLoading = true;
  473. this.$http
  474. .get(CORE_API + "/course/query?name=" + query + "&enable=true")
  475. .then(response => {
  476. this.courseList = response.data;
  477. this.courseLoading = false;
  478. });
  479. }
  480. } else {
  481. this.courseList = [];
  482. }
  483. },
  484. //打开导出弹框
  485. openExportDialog(row) {
  486. this.isShow = true;
  487. this.isShow = true;
  488. this.exportDialog = true;
  489. this.exportModel.id = row.id;
  490. this.exportModel.courseCode = row.course.code;
  491. this.exportModel.courseName = row.course.name;
  492. this.exportModel.exportContentList = [];
  493. /* 分布式印刷数据包设置 */
  494. this.isShowPrintExamPackage = true;
  495. this.isShowPrintExamPackagePassword = false;
  496. this.printExamPackagePassword = "";
  497. },
  498. //打开批量弹出框
  499. openBatchExportPaperDialog() {
  500. if (this.selectedPaperIds.length != 0) {
  501. this.exportDialog = true;
  502. this.isShow = false;
  503. this.isShow = false;
  504. this.exportModel.exportContentList = [];
  505. } else {
  506. this.$notify({
  507. message: "请勾选导出的数据",
  508. type: "warning"
  509. });
  510. }
  511. /* 分布式印刷数据包设置 */
  512. this.isShowPrintExamPackage = false;
  513. this.isShowPrintExamPackagePassword = false;
  514. this.printExamPackagePassword = "";
  515. },
  516. //导出试卷,答案,机考数据包
  517. exportPaperInfo() {
  518. if (this.exportModel.exportContentList.length == 0) {
  519. this.$notify({
  520. message: "请选择导出内容",
  521. type: "error"
  522. });
  523. return false;
  524. }
  525. if (this.printExamPackagePassword.length > 0) {
  526. var reg = /^[0-9A-Za-z]{6,12}$/;
  527. if (!reg.test(this.printExamPackagePassword)) {
  528. this.$notify({
  529. message: "加密密码请输入6至12位的数字或字母!",
  530. type: "error"
  531. });
  532. return false;
  533. }
  534. }
  535. var key = this.user.key;
  536. var token = this.user.token;
  537. if (this.isShow) {
  538. console.log("单个导出");
  539. window.location.href =
  540. Q_API +
  541. "/paper/export/" +
  542. this.exportModel.id +
  543. "/" +
  544. this.exportModel.exportContentList +
  545. "/" +
  546. this.user.rootOrgName +
  547. "/" +
  548. this.user.displayName +
  549. "/onLine" +
  550. "?psw=" +
  551. this.printExamPackagePassword +
  552. "&$key=" +
  553. key +
  554. "&$token=" +
  555. token;
  556. this.exportDialog = false;
  557. } else {
  558. console.log("批量导出");
  559. var paperIds = this.paperIds;
  560. console.log(paperIds);
  561. window.location.href =
  562. Q_API +
  563. "/paper/batch_export/" +
  564. paperIds +
  565. "/" +
  566. this.exportModel.exportContentList +
  567. "/" +
  568. this.user.rootOrgName +
  569. "/" +
  570. this.user.displayName +
  571. "/onLine" +
  572. "?$key=" +
  573. key +
  574. "&$token=" +
  575. token;
  576. this.exportDialog = false;
  577. console.log(paperIds);
  578. }
  579. },
  580. removeItem() {
  581. sessionStorage.removeItem("gen_paper_courseNo");
  582. sessionStorage.removeItem("gen_paper_name");
  583. sessionStorage.removeItem("gen_paper_specialtyNo");
  584. sessionStorage.removeItem("gen_paper_currentPage");
  585. },
  586. previewPDF2(row) {
  587. window.open(Q_API + "/paper/pdf/" + row.id);
  588. },
  589. openPrint(row) {
  590. this.dialogModel = true;
  591. this.examId = "";
  592. this.rowId = row.id;
  593. console.log("this.examList:", this.examList);
  594. },
  595. cancel() {
  596. this.dialogModel = false;
  597. },
  598. //传至印刷模块
  599. sendPrint() {
  600. var orgId = "";
  601. for (let exam of this.examList) {
  602. if ((exam.id = this.examId)) {
  603. orgId = exam.rootOrgId;
  604. }
  605. }
  606. if (orgId != "") {
  607. this.$http.get(
  608. Q_API + "/sendPrint/" + this.rowId + "/" + this.examId + "/" + orgId
  609. );
  610. this.$notify({
  611. message: "已推送",
  612. type: "success"
  613. });
  614. this.dialogModel = false;
  615. }
  616. },
  617. //查询考试
  618. getExams(query) {
  619. query = query.trim();
  620. this.$http
  621. .get(
  622. EXAM_WORK_API + "/exam/queryByNameLike?name=" + query + "&enable=true"
  623. )
  624. .then(response => {
  625. this.examList = response.data;
  626. });
  627. },
  628. searchExamList() {
  629. //查询所有考试
  630. this.$http
  631. .get(EXAM_WORK_API + "/exam/queryByNameLike?name=&enable=true")
  632. .then(response => {
  633. var list = response.data;
  634. for (var i = 0; i < list.length; i++) {
  635. if (list[i].examType == "TRADITION") {
  636. this.examList.push(list[i]);
  637. }
  638. }
  639. });
  640. },
  641. //根据orgId查询学校名称
  642. searchOrgName() {
  643. this.$http
  644. .get(CORE_API + "/org/rootOrg/" + this.user.rootOrgId)
  645. .then(response => {
  646. this.Org = response.data;
  647. });
  648. }
  649. },
  650. computed: {
  651. paperIds() {
  652. var paperIds = "";
  653. for (let paperId of this.selectedPaperIds) {
  654. if (!paperIds) {
  655. paperIds += paperId;
  656. } else {
  657. paperIds += "," + paperId;
  658. }
  659. }
  660. return paperIds;
  661. },
  662. courseInfoSelect() {
  663. var courseList = [];
  664. for (let course of this.courseList) {
  665. var courseInfo = course.name + "(" + course.code + ")";
  666. var courseNo = course.code;
  667. var courseName = course.name;
  668. courseList.push({
  669. courseNo: courseNo,
  670. courseInfo: courseInfo,
  671. courseName: courseName
  672. });
  673. }
  674. return courseList;
  675. },
  676. ...mapState({ user: state => state.user })
  677. },
  678. created() {
  679. this.isClear = this.$route.params.isClear;
  680. if (this.isClear == 0 || !this.isClear) {
  681. this.removeItem();
  682. } else {
  683. this.formSearch.courseNo =
  684. sessionStorage.getItem("gen_paper_courseNo") == "null"
  685. ? ""
  686. : sessionStorage.getItem("gen_paper_courseNo");
  687. this.formSearch.specialtyNo =
  688. sessionStorage.getItem("gen_paper_specialtyNo") == "null"
  689. ? ""
  690. : sessionStorage.getItem("gen_paper_specialtyNo");
  691. this.formSearch.name =
  692. sessionStorage.getItem("gen_paper_name") == "null"
  693. ? ""
  694. : sessionStorage.getItem("gen_paper_name");
  695. this.currentPage =
  696. sessionStorage.getItem("gen_paper_currentPage") == null
  697. ? 1
  698. : parseInt(sessionStorage.getItem("gen_paper_currentPage"));
  699. }
  700. this.searchGenPaper();
  701. this.searchExamList();
  702. this.searchOrgName();
  703. }
  704. };
  705. </script>