ExtractPaperRule.vue 19 KB

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