ExtractPaperRule.vue 22 KB

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