ExtractPaperRule.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. <template>
  2. <section class="content">
  3. <div v-show="isClear == 1">
  4. <LinkTitlesCustom :currentPaths="['考试管理', '调卷规则']" />
  5. </div>
  6. <!-- 正文信息 -->
  7. <div class="box-body">
  8. <el-form
  9. :inline="true"
  10. :model="formSearch"
  11. label-position="right"
  12. label-width="70px"
  13. >
  14. <el-row>
  15. <el-col :span="6">
  16. <el-form-item label="考试名称">
  17. <el-select
  18. class="search_width"
  19. v-model="formSearch.examId"
  20. filterable
  21. :remote-method="getExams"
  22. remote
  23. clearable
  24. @change="getExamCourses"
  25. placeholder="请选择"
  26. size="small"
  27. >
  28. <el-option
  29. v-for="item in examList"
  30. :key="item.id"
  31. :label="item.name"
  32. :value="item.id"
  33. >
  34. </el-option>
  35. </el-select>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="6">
  39. <el-form-item label="课程名称">
  40. <el-select
  41. class="search_width"
  42. v-model="formSearch.courseNo"
  43. filterable
  44. :remote-method="getCourses"
  45. remote
  46. clearable
  47. placeholder="请选择"
  48. size="small"
  49. >
  50. <el-option
  51. v-for="item in courseInfoSelect"
  52. :label="item.courseInfo"
  53. :value="item.courseNo"
  54. :key="item.courseNo"
  55. >
  56. </el-option>
  57. </el-select>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="6">
  61. <div class="search_down">
  62. <el-button size="small" type="primary" @click="searchFrom"
  63. ><i class="el-icon-search"></i> 查询</el-button
  64. >
  65. <el-button size="small" type="primary" @click="markRules"
  66. ><i class="el-icon-plus"></i> 新增</el-button
  67. >
  68. </div>
  69. </el-col>
  70. </el-row>
  71. <div
  72. style="width: 100%; border-bottom: 1px solid #ddd; margin: 10px 0;"
  73. ></div>
  74. <el-row>
  75. <el-form-item>
  76. <span>批量操作:</span>
  77. <el-button size="small" type="primary" @click="openBatchExpDialog"
  78. ><i class="el-icon-download"></i> 下载成卷
  79. </el-button>
  80. </el-form-item>
  81. </el-row>
  82. </el-form>
  83. <div style="width: 100%;margin-bottom: 10px;"></div>
  84. <!-- 页面列表 -->
  85. <el-table :data="tableData" border style="width: 100%">
  86. <el-table-column label="考试名称" width="180">
  87. <template slot-scope="scope">
  88. <span>{{ scope.row.examName }}</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="考试类型">
  92. <template slot-scope="scope">
  93. <div class="el_table_inner_left">
  94. <span v-show="scope.row.examType == 'ONLINE'">在线考试</span>
  95. <span v-show="scope.row.examType == 'TRADITION'">传统考试</span>
  96. <span v-show="scope.row.examType == 'PRACTICE'">练习考试</span>
  97. <span v-show="scope.row.examType == 'OFFLINE'">离线考试</span>
  98. <span v-show="scope.row.examType == 'PRINT_EXAM'"
  99. >分布式印刷考试</span
  100. >
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="课程名称">
  105. <template slot-scope="scope">
  106. <span>{{ scope.row.courseName }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="课程代码" width="140">
  110. <template slot-scope="scope">
  111. <span>{{ scope.row.courseCode }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="调卷类型">
  115. <template slot-scope="scope">
  116. <div class="el_table_inner_left">
  117. <span v-show="scope.row.callType == 'WHOLE_SET'">成套调用</span>
  118. <span v-show="scope.row.callType == 'RESTRUCT'">重组调用</span>
  119. </div>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="调卷规则">
  123. <template slot-scope="scope">
  124. <span v-show="scope.row.id">
  125. <el-tag type="success">已制定</el-tag>
  126. </span>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="操作" width="180">
  130. <template slot-scope="scope">
  131. <div class="operate_left">
  132. <el-button
  133. v-if="scope.row.id"
  134. size="mini"
  135. type="primary"
  136. @click="updateRules(scope.row)"
  137. plain
  138. ><i class="el-icon-edit"></i>编辑
  139. </el-button>
  140. <el-button
  141. v-if="scope.row.ifFinish == 1"
  142. size="mini"
  143. type="primary"
  144. @click="openSingleExportPaperDialog(scope.row)"
  145. plain
  146. ><i class="el-icon-download"></i> 下载
  147. </el-button>
  148. </div>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <div class="page pull-right">
  153. <el-pagination
  154. @current-change="handleCurrentChange"
  155. :current-page="currentPage"
  156. :page-size="pageSize"
  157. :page-sizes="[10, 20, 50, 100]"
  158. @size-change="handleSizeChange"
  159. layout="total, sizes, prev, pager, next, jumper"
  160. :total="total"
  161. >
  162. </el-pagination>
  163. </div>
  164. </div>
  165. <el-dialog title="导出" :visible.sync="exportDialog">
  166. <el-form :model="exportModel" label-position="right" label-width="80px">
  167. <el-row>
  168. <el-col :md="24">
  169. <el-form-item label="考试名称">
  170. <el-select
  171. v-model="exportModel.examId"
  172. filterable
  173. clearable
  174. :disabled="
  175. exportDialog.exportWay == 'SINGLE' &&
  176. exportModel.courseCode != ''
  177. "
  178. @change="checkPaperStructure"
  179. >
  180. <el-option
  181. v-for="item in examList"
  182. :key="item.id"
  183. :label="item.name"
  184. :value="item.id"
  185. >
  186. </el-option>
  187. </el-select>
  188. </el-form-item>
  189. </el-col>
  190. </el-row>
  191. <el-row v-show="exportModel.courseId">
  192. <el-col :md="24">
  193. <el-form-item label="课程名称">
  194. <el-input v-model="exportModel.courseName" disabled></el-input>
  195. </el-form-item>
  196. </el-col>
  197. </el-row>
  198. <el-row>
  199. <el-col :md="24">
  200. <el-form-item
  201. label="导出内容"
  202. v-if="exportModel.examType != 'PRINT_EXAM'"
  203. >
  204. <el-checkbox-group
  205. v-model="exportModel.exportContentList"
  206. v-if="exportModel.exportType == 'NORMAL'"
  207. >
  208. <el-checkbox label="PAPER" :disabled="paperDisabled"
  209. >试卷</el-checkbox
  210. >
  211. <el-checkbox label="ANSWER" :disabled="answerDisabled"
  212. >答案</el-checkbox
  213. >
  214. <el-checkbox
  215. label="PAPER_STRUCTURE_OBJECTIVE,PAPER_STRUCTURE_SUBJECTIVE"
  216. :disabled="structureDisabled"
  217. >试卷结构
  218. </el-checkbox>
  219. </el-checkbox-group>
  220. <el-checkbox-group
  221. v-model="exportModel.exportContentList"
  222. v-if="exportModel.exportType == 'ONLINE'"
  223. >
  224. <el-checkbox
  225. label="COMPUTERTEST_PACKAGE"
  226. :disabled="onlineDisabled"
  227. >机考数据包
  228. </el-checkbox>
  229. </el-checkbox-group>
  230. </el-form-item>
  231. <el-form-item
  232. label="导出内容"
  233. v-if="exportModel.examType == 'PRINT_EXAM'"
  234. >
  235. <el-checkbox-group v-model="exportModel.exportContentList">
  236. <el-checkbox label="PAPER" :disabled="paperDisabled"
  237. >试卷</el-checkbox
  238. >
  239. <el-checkbox label="ANSWER" :disabled="answerDisabled"
  240. >答案</el-checkbox
  241. >
  242. <el-checkbox
  243. v-if="isShowPrintExamPackage"
  244. label="PRINT_EXAM_PACKAGE"
  245. >分布式印刷数据包
  246. </el-checkbox>
  247. <el-input
  248. v-if="isShowPrintExamPackagePassword"
  249. v-model="printExamPackagePassword"
  250. placeholder="加密密码 (可选)"
  251. type="password"
  252. style="width: 150px"
  253. ></el-input>
  254. </el-checkbox-group>
  255. </el-form-item>
  256. </el-col>
  257. </el-row>
  258. <el-row>
  259. <el-col :md="24" class="text-center">
  260. <el-button type="primary" @click="exportPaperInfo"
  261. >开始导出</el-button
  262. >
  263. </el-col>
  264. </el-row>
  265. </el-form>
  266. </el-dialog>
  267. </section>
  268. </template>
  269. <script>
  270. import { CORE_API, EXAM_WORK_API, QUESTION_API } from "@/constants/constants";
  271. import { LEVEL_TYPE } from "../constants/constants";
  272. import { mapState } from "vuex";
  273. import _ from "lodash";
  274. import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
  275. export default {
  276. components: { LinkTitlesCustom },
  277. data() {
  278. return {
  279. isClear: 0,
  280. formSearch: {
  281. examId: "",
  282. courseNo: "",
  283. courseName: ""
  284. },
  285. tableData: [],
  286. currentPage: 1,
  287. levelList: LEVEL_TYPE,
  288. pageSize: 10,
  289. total: 0,
  290. examList: [], //考试list
  291. courseList: [], //课程list
  292. loading: false,
  293. paperModels: "",
  294. exportDialog: false,
  295. exportModel: {
  296. examType: "",
  297. examId: "",
  298. courseId: "",
  299. courseName: "",
  300. exportWay: "",
  301. exportType: "NORMAL",
  302. exportContentList: []
  303. },
  304. paperDisabled: true,
  305. answerDisabled: true,
  306. structureDisabled: true,
  307. onlineDisabled: true,
  308. courseAllList: [],
  309. isShowPrintExamPackage: false,
  310. isShowPrintExamPackagePassword: false,
  311. printExamPackagePassword: ""
  312. };
  313. },
  314. methods: {
  315. //初始化
  316. initialize(examId) {
  317. this.examList = [];
  318. //查询所有考试
  319. this.$http.get(EXAM_WORK_API + "/exam/" + examId).then(response => {
  320. this.examList.push(response.data);
  321. this.formSearch.examId = parseInt(examId);
  322. this.searchRulePaper();
  323. });
  324. },
  325. //查询列表
  326. searchFrom() {
  327. this.currentPage = 1;
  328. this.searchRulePaper();
  329. },
  330. searchRulePaper() {
  331. if (!this.formSearch.examId) {
  332. this.$notify({
  333. message: "请选择考试",
  334. type: "warning"
  335. });
  336. return false;
  337. }
  338. this.loading = true;
  339. let currentPage = this.currentPage;
  340. this.currentPage = 1;
  341. this.$http
  342. .get(
  343. QUESTION_API +
  344. "/findPageExtractConfig/" +
  345. currentPage +
  346. "/" +
  347. this.pageSize +
  348. "?examId=" +
  349. this.formSearch.examId +
  350. "&courseNo=" +
  351. this.formSearch.courseNo
  352. )
  353. .then(response => {
  354. this.tableData = response.data.content;
  355. this.total = response.data.totalElements;
  356. this.currentPage = Number(currentPage);
  357. this.loading = false;
  358. })
  359. .catch(error => {
  360. this.loading = false;
  361. this.$notify({
  362. message: error.body.desc,
  363. type: "error"
  364. });
  365. this.tableData = [];
  366. this.total = 0;
  367. });
  368. },
  369. //分页
  370. handleCurrentChange(val) {
  371. this.currentPage = val;
  372. this.searchRulePaper();
  373. },
  374. handleSizeChange(val) {
  375. this.pageSize = val;
  376. this.currentPage = 1;
  377. this.searchRulePaper();
  378. },
  379. //制定调卷规则
  380. markRules() {
  381. sessionStorage.setItem("extract_paper_examId", this.formSearch.examId);
  382. this.$router.push({
  383. name: "extract_paper_info_add"
  384. });
  385. },
  386. getCourseName(courseNo) {
  387. for (let course of this.courseList) {
  388. if (course.code == courseNo) {
  389. this.formSearch.courseName = course.name;
  390. }
  391. }
  392. },
  393. //编辑调卷规则
  394. updateRules(row) {
  395. this.getCourseName(this.formSearch.courseNo);
  396. sessionStorage.setItem("extract_paper_examId", row.examId);
  397. sessionStorage.setItem(
  398. "extract_paper_courseNo",
  399. this.formSearch.courseNo
  400. );
  401. sessionStorage.setItem(
  402. "extract_paper_courseName",
  403. this.formSearch.courseName
  404. );
  405. sessionStorage.setItem("extract_paper_currentPage", this.currentPage);
  406. this.$router.push({
  407. name: "extract_paper_info_edit",
  408. params: { extractConfigId: row.id }
  409. });
  410. },
  411. openSingleExportPaperDialog(row) {
  412. this.exportModel = {
  413. examType: row.examType,
  414. examId: row.examId,
  415. examName: row.examName,
  416. courseId: row.courseCode,
  417. courseName: row.courseName,
  418. exportType: "NORMAL",
  419. exportWay: "SINGLE",
  420. exportContentList: []
  421. };
  422. this.checkPaperStructure();
  423. this.exportDialog = true;
  424. /* 分布式印刷数据包设置 */
  425. //this.exportModel.examType = 'PRINT_EXAM';//todo
  426. this.isShowPrintExamPackage = true;
  427. this.isShowPrintExamPackagePassword = false;
  428. this.printExamPackagePassword = "";
  429. },
  430. openBatchExpDialog() {
  431. this.exportModel = {
  432. examType: "",
  433. examId: "",
  434. examName: "",
  435. courseId: "",
  436. courseName: "",
  437. exportType: "NORMAL",
  438. exportWay: "BATCH",
  439. exportContentList: []
  440. };
  441. this.resetDisabled();
  442. this.exportDialog = true;
  443. /* 分布式印刷数据包设置 */
  444. this.isShowPrintExamPackage = false;
  445. this.isShowPrintExamPackagePassword = false;
  446. this.printExamPackagePassword = "";
  447. },
  448. checkPaperStructure() {
  449. if (!this.exportModel.examId) {
  450. return false;
  451. }
  452. this.exportModel.exportContentList = [];
  453. let examFile = {
  454. examId: this.exportModel.examId,
  455. courseId: this.exportModel.courseId ? this.exportModel.courseId : null
  456. };
  457. this.resetDisabled();
  458. this.$http
  459. .post(QUESTION_API + "/findExamFile", examFile)
  460. .then(response => {
  461. let examFiles = response.data;
  462. if (examFiles != null && examFiles.length > 0) {
  463. this.paperDisabled = this.isDisabled(examFiles, "PAPER");
  464. this.answerDisabled = this.isDisabled(examFiles, "ANSWER");
  465. this.onlineDisabled = this.isDisabled(
  466. examFiles,
  467. "COMPUTERTEST_PACKAGE"
  468. );
  469. this.$http
  470. .get(
  471. QUESTION_API + "/findExportStructure/" + this.exportModel.examId
  472. )
  473. .then(response => {
  474. this.exportModel.exportType = response.data
  475. ? response.data.exportType
  476. : "NORMAL";
  477. this.structureDisabled = !response.data;
  478. if (this.exportModel.exportWay == "SINGLE") {
  479. this.structureDisabled = this.isDisabled(
  480. examFiles,
  481. "PAPER_STRUCTURE_OBJECTIVE"
  482. );
  483. }
  484. });
  485. } else {
  486. this.resetDisabled();
  487. }
  488. });
  489. },
  490. isDisabled(examFiles, fileType) {
  491. return (
  492. _.filter(examFiles, function(examFile) {
  493. return examFile.examFileType == fileType;
  494. }).length == 0
  495. );
  496. },
  497. resetDisabled() {
  498. this.paperDisabled = true;
  499. this.answerDisabled = true;
  500. this.structureDisabled = true;
  501. this.onlineDisabled = true;
  502. },
  503. exportPaperInfo() {
  504. let examId = this.exportModel.examId;
  505. let courseId = this.exportModel.courseId;
  506. let exportWay = this.exportModel.exportWay;
  507. if (!examId) {
  508. this.$notify({
  509. message: "请选择考试",
  510. type: "error"
  511. });
  512. return false;
  513. }
  514. if (this.exportModel.exportContentList.length == 0) {
  515. this.$notify({
  516. message: "请选择导出内容",
  517. type: "error"
  518. });
  519. return false;
  520. }
  521. if (this.printExamPackagePassword.length > 0) {
  522. var reg = /^[0-9A-Za-z]{6,12}$/;
  523. if (!reg.test(this.printExamPackagePassword)) {
  524. this.$notify({
  525. message: "加密密码请输入6至12位的数字或字母!",
  526. type: "error"
  527. });
  528. return false;
  529. }
  530. }
  531. let exportContentList = this.exportModel.exportContentList.toString();
  532. var key = this.user.key;
  533. var token = this.user.token;
  534. this.$http
  535. .get(
  536. QUESTION_API +
  537. "/exportBatchExamPaperInfoCheck/" +
  538. exportWay +
  539. "/" +
  540. examId +
  541. "?$key=" +
  542. key +
  543. "&$token=" +
  544. token
  545. )
  546. .then(
  547. response => {
  548. console.log(response);
  549. if (response.data) {
  550. this.$notify({
  551. message: response.data.desc,
  552. type: "error"
  553. });
  554. } else {
  555. var key = this.user.key;
  556. var token = this.user.token;
  557. if (exportWay == "SINGLE") {
  558. window.location.href =
  559. QUESTION_API +
  560. "/exportSingleExamPaperInfo/" +
  561. this.user.rootOrgName +
  562. "/" +
  563. exportWay +
  564. "/" +
  565. examId +
  566. "/" +
  567. courseId +
  568. "/" +
  569. exportContentList +
  570. "/" +
  571. this.user.displayName +
  572. "?psw=" +
  573. this.printExamPackagePassword +
  574. "&$key=" +
  575. key +
  576. "&$token=" +
  577. token;
  578. } else if (exportWay == "BATCH") {
  579. window.location.href =
  580. QUESTION_API +
  581. "/exportBatchExamPaperInfo/" +
  582. this.user.rootOrgName +
  583. "/" +
  584. exportWay +
  585. "/" +
  586. examId +
  587. "/" +
  588. exportContentList +
  589. "/" +
  590. this.user.displayName +
  591. "?$key=" +
  592. key +
  593. "&$token=" +
  594. token;
  595. }
  596. }
  597. },
  598. error => {
  599. console.log("aaa");
  600. this.$notify({
  601. message: error.body.desc,
  602. type: "error"
  603. });
  604. }
  605. );
  606. },
  607. removeItem() {
  608. sessionStorage.removeItem("extract_paper_currentPage");
  609. sessionStorage.removeItem("extract_paper_examId");
  610. sessionStorage.removeItem("extract_paper_courseNo");
  611. },
  612. //查询所有课程
  613. getCourses(query) {
  614. query = query.trim();
  615. console.log("query:", query);
  616. if (query) {
  617. if (!(query.indexOf("(") > -1 && query.indexOf(")") > -1)) {
  618. this.courseLoading = true;
  619. this.$http
  620. .get(CORE_API + "/course/query?name=" + query + "&enable=true")
  621. .then(response => {
  622. this.courseList = response.data;
  623. console.log("this.courseList:", this.courseList);
  624. this.courseLoading = false;
  625. });
  626. }
  627. } else {
  628. this.courseList = [];
  629. }
  630. },
  631. //查询考试
  632. getExams(query) {
  633. query = query.trim();
  634. this.$http
  635. .get(
  636. EXAM_WORK_API + "/exam/queryByNameLike?name=" + query + "&enable=true"
  637. )
  638. .then(response => {
  639. this.examList = response.data;
  640. });
  641. },
  642. //清空课程列表
  643. getExamCourses() {
  644. this.formSearch.courseNo = "";
  645. },
  646. initVue() {
  647. this.isClear = this.$route.params.isClear;
  648. if (this.isClear == 0 || !this.isClear) {
  649. this.removeItem();
  650. //查询所有考试
  651. this.getExams("");
  652. this.formSearch = {
  653. examId: "",
  654. courseNo: "",
  655. courseName: ""
  656. };
  657. } else {
  658. this.formSearch.courseNo =
  659. sessionStorage.getItem("extract_paper_courseNo") == "null"
  660. ? ""
  661. : sessionStorage.getItem("extract_paper_courseNo");
  662. this.formSearch.courseName =
  663. sessionStorage.getItem("extract_paper_courseName") == "null"
  664. ? ""
  665. : sessionStorage.getItem("extract_paper_courseName");
  666. this.formSearch.examId =
  667. sessionStorage.getItem("extract_paper_examId") == ""
  668. ? ""
  669. : parseInt(sessionStorage.getItem("extract_paper_examId"));
  670. this.currentPage =
  671. sessionStorage.getItem("extract_paper_currentPage") == null
  672. ? 1
  673. : parseInt(sessionStorage.getItem("extract_paper_currentPage"));
  674. if (this.formSearch.examId) {
  675. this.initialize(this.formSearch.examId);
  676. }
  677. if (this.formSearch.courseName) {
  678. this.getCourses(this.formSearch.courseName);
  679. }
  680. }
  681. }
  682. },
  683. computed: {
  684. ...mapState({ user: state => state.user }),
  685. courseInfoSelect() {
  686. var courseList = [];
  687. for (let course of this.courseList) {
  688. var courseInfo = course.name + "(" + course.code + ")";
  689. courseList.push({
  690. courseNo: course.code,
  691. courseName: course.name,
  692. courseInfo: courseInfo
  693. });
  694. }
  695. return courseList;
  696. }
  697. },
  698. watch: {
  699. $route: "initVue"
  700. },
  701. created() {
  702. this.initVue();
  703. }
  704. };
  705. </script>
  706. <style scoped src="../styles/Common.css"></style>