ExtractPaperRule.vue 22 KB

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