ExtractPaperInfo.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. <template>
  2. <section
  3. class="content"
  4. v-loading="loading"
  5. element-loading-text="保存调卷规则及生成试卷文件中..."
  6. >
  7. <LinkTitlesCustom :currentPaths="['考试管理', '调卷规则', '调卷详情']" />
  8. <!-- 正文信息 -->
  9. <div class="box-body">
  10. <el-form
  11. :inline="true"
  12. :model="extractConfig"
  13. ref="extractPaperForm"
  14. label-position="right"
  15. label-width="120px"
  16. >
  17. <el-row>
  18. <el-form-item label="考试名称">
  19. <el-select
  20. filterable
  21. clearable
  22. v-model="extractConfig.examId"
  23. @change="getExamCourses"
  24. placeholder="请选择"
  25. :remote-method="getExams"
  26. remote
  27. :disabled="isInsert"
  28. >
  29. <el-option
  30. v-for="item in examList"
  31. :key="item.id"
  32. :label="item.name"
  33. :value="item.id"
  34. >
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="课程名称">
  39. <el-select
  40. v-model="extractConfig.courseCode"
  41. filterable
  42. clearable
  43. @change="getPaperTypeList"
  44. placeholder="请选择"
  45. :disabled="isInsert"
  46. >
  47. <el-option
  48. v-for="item in courseInfoSelect"
  49. :key="item.courseNo"
  50. :label="item.courseInfo"
  51. :value="item.courseNo"
  52. >
  53. </el-option>
  54. </el-select>
  55. </el-form-item>
  56. </el-row>
  57. <el-tabs v-model="tabs">
  58. <el-tab-pane label="步骤一:调卷模式选择" name="first">
  59. <el-form-item prop="status">
  60. <el-radio-group
  61. class="pull_right_ss"
  62. v-model="extractConfig.callType"
  63. >
  64. <el-radio label="WHOLE_SET">成套调用</el-radio>
  65. <!-- <el-radio label="RESTRUCT">重组调用</el-radio> -->
  66. </el-radio-group>
  67. </el-form-item>
  68. </el-tab-pane>
  69. </el-tabs>
  70. <el-tabs v-model="tabs">
  71. <el-tab-pane label="步骤二:试卷抽取比例" name="first">
  72. <el-row>
  73. <el-col :span="24">
  74. <el-tag v-if="extractConfig.examType === 'TRADITION'"
  75. >传统考试</el-tag
  76. >
  77. <el-tag v-if="extractConfig.examType === 'ONLINE'"
  78. >在线考试</el-tag
  79. >
  80. <el-tag v-if="extractConfig.examType === 'PRACTICE'"
  81. >练习考试</el-tag
  82. >
  83. </el-col>
  84. </el-row>
  85. <el-row :key="num" v-for="(examPaper, num) in examPaperList">
  86. <el-col :span="24">
  87. <el-form-item label="试卷类型" class="pull-left">
  88. <el-input
  89. class="input_width_lg"
  90. placeholder="请输入试卷类型"
  91. v-model="examPaper.groupCode"
  92. disabled
  93. ></el-input>
  94. </el-form-item>
  95. <el-button
  96. type="primary"
  97. v-if="extractConfig.examType != 'TRADITION'"
  98. @click="addOnLinePaper(examPaper.groupCode)"
  99. ><i class="el-icon-plus"></i> 新增试卷
  100. </el-button>
  101. </el-col>
  102. <el-col
  103. :span="20"
  104. :offset="2"
  105. v-for="(paperInfo, index) in examPaper.paperInfoList"
  106. :key="paperInfo.selectedPaperId"
  107. >
  108. <el-form-item>
  109. <span>试卷选定</span>
  110. <el-select
  111. filterable
  112. v-model="paperInfo.paper.id"
  113. placeholder="请选择"
  114. @change="searchAudioTimeConfig"
  115. class="select_width_lg"
  116. >
  117. <el-option
  118. v-for="item in paperList"
  119. :label="item.name"
  120. :value="item.id"
  121. :key="item.id"
  122. >
  123. </el-option>
  124. </el-select>
  125. <span>选取几率</span>
  126. <span>
  127. <el-input
  128. class="input_width_sms"
  129. v-model="paperInfo.weight"
  130. :disabled="extractConfig.examType === 'TRADITION'"
  131. ></el-input
  132. >%
  133. <i
  134. class="el-icon-delete"
  135. v-if="index > 0"
  136. @click.prevent="
  137. removePaperInfo(examPaper.groupCode, paperInfo)
  138. "
  139. ></i>
  140. </span>
  141. <span :class="'errorMsg_' + num + '_' + index"></span>
  142. </el-form-item>
  143. </el-col>
  144. </el-row>
  145. </el-tab-pane>
  146. </el-tabs>
  147. <div>
  148. <el-tabs v-model="tabs">
  149. <el-tab-pane label="步骤三:随机设定" name="first">
  150. <el-form-item
  151. label="客观题小题乱序"
  152. prop="scrambling_the_question_order"
  153. >
  154. <el-radio-group
  155. class="pull_right_sm"
  156. v-model="extractConfig.scrambling_the_question_order"
  157. >
  158. <el-radio :label="1">开启</el-radio>
  159. <el-radio :label="0">关闭</el-radio>
  160. </el-radio-group>
  161. </el-form-item>
  162. <br />
  163. <el-form-item
  164. label="客观题选项乱序"
  165. prop="scrambling_the_option_order"
  166. >
  167. <el-radio-group
  168. class="pull_right_sm"
  169. v-model="extractConfig.scrambling_the_option_order"
  170. >
  171. <el-radio :label="1">开启</el-radio>
  172. <el-radio :label="0">关闭</el-radio>
  173. </el-radio-group>
  174. </el-form-item>
  175. </el-tab-pane>
  176. </el-tabs>
  177. </div>
  178. <div
  179. style="padding: 5px;"
  180. v-show="extractConfig.examType != 'PRACTICE'"
  181. >
  182. <el-tabs v-model="tabs">
  183. <el-tab-pane label="步骤四:音频播放次数设置" name="first">
  184. <el-row
  185. class="row_header_word"
  186. v-show="audioTimeConfigList.length > 0"
  187. >
  188. <el-col :span="4" :offset="1">试卷类型</el-col>
  189. <el-col :span="4">试卷名称</el-col>
  190. <el-col :span="3">大题号</el-col>
  191. <el-col :span="3">小题号</el-col>
  192. <el-col :span="4">播放次数</el-col>
  193. </el-row>
  194. <el-row
  195. v-for="(audioTimeConfig, index) in audioTimeConfigList"
  196. class="margin-top-10"
  197. :key="index"
  198. >
  199. <el-col :span="4" :offset="1">
  200. {{ audioTimeConfig.groupCode }}
  201. </el-col>
  202. <el-col :span="4"> {{ audioTimeConfig.paper.name }} </el-col>
  203. <el-col :span="3">
  204. {{ audioTimeConfig.paperDetailUnit.paperDetail.number }}
  205. </el-col>
  206. <el-col :span="3">
  207. {{ audioTimeConfig.paperDetailUnit.number }}
  208. </el-col>
  209. <el-col :span="4">
  210. <el-input
  211. class="input_width_ss"
  212. size="small"
  213. v-model="audioTimeConfig.playTime"
  214. >次
  215. </el-input>
  216. </el-col>
  217. </el-row>
  218. <el-row v-show="audioTimeConfigList.length == 0">
  219. <el-col :span="18" :offset="1"> 无音频试题 </el-col>
  220. </el-row>
  221. </el-tab-pane>
  222. </el-tabs>
  223. </div>
  224. <div>
  225. <el-tabs v-model="tabs">
  226. <el-row>
  227. <el-col>
  228. <el-form-item label="是否生成文件">
  229. <el-radio-group v-model="isbuildFile">
  230. <el-radio label="1">是</el-radio>
  231. <el-radio label="0">否</el-radio>
  232. </el-radio-group>
  233. </el-form-item>
  234. </el-col>
  235. </el-row>
  236. <el-row :gutter="20">
  237. <el-col :span="12" :offset="1">
  238. <el-button type="primary" @click="submitForm"> 保存 </el-button>
  239. <el-button type="primary" @click="back"
  240. ><i class="el-icon-arrow-left"></i> 返 回</el-button
  241. >
  242. </el-col>
  243. </el-row>
  244. </el-tabs>
  245. </div>
  246. </el-form>
  247. </div>
  248. </section>
  249. </template>
  250. <script>
  251. import { EXAM_WORK_API, QUESTION_API } from "@/constants/constants";
  252. import { mapState } from "vuex";
  253. import _ from "lodash";
  254. import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
  255. export default {
  256. components: { LinkTitlesCustom },
  257. data() {
  258. return {
  259. loading: false,
  260. extractConfig: {
  261. examId: "", //考试ID
  262. examName: "", //考试名称
  263. examType: "", //考试类型:网络考试、传统考试
  264. courseCode: "", //课程代码
  265. courseName: "", //课程名称
  266. callType: "WHOLE_SET", //调卷类型:默认成套调用
  267. examPaperList: [],
  268. scrambling_the_question_order: 0, //小题乱序 默认关闭
  269. scrambling_the_option_order: 0 //选项乱序 默认关闭
  270. },
  271. examPaperList: [],
  272. audioTimeConfig: {
  273. examId: "",
  274. examName: "",
  275. paper: {
  276. id: ""
  277. },
  278. groupCode: "",
  279. courseCode: "",
  280. playTime: ""
  281. },
  282. audioTimeConfigModelList: [],
  283. tabs: "first",
  284. paperList: [],
  285. isbuildFile: "0",
  286. audioTimeConfigList: [],
  287. paperName: "",
  288. examList: [],
  289. courseList: [],
  290. courseAll: [],
  291. isInsert: false
  292. };
  293. },
  294. methods: {
  295. //根据考务查询考试集合
  296. getExams(query) {
  297. query = query.trim();
  298. this.$http
  299. .get(
  300. EXAM_WORK_API + "/exam/queryByNameLike?name=" + query + "&enable=true"
  301. )
  302. .then(response => {
  303. this.examList = response.data;
  304. });
  305. },
  306. //根据考试查询课程
  307. getExamCourses() {
  308. if (!this.isInsert) {
  309. this.extractConfig.courseCode = "";
  310. this.courseList = [];
  311. if (this.extractConfig.examId) {
  312. //查询该考试下的课程
  313. this.$http
  314. .get(
  315. QUESTION_API +
  316. "/findCourseByExtractConfig/" +
  317. this.extractConfig.examId
  318. )
  319. .then(response => {
  320. this.courseList = response.data;
  321. });
  322. }
  323. //查询考试对象,获取考试类型:离线,在线,传统
  324. if (this.extractConfig.examId) {
  325. this.$http
  326. .get(EXAM_WORK_API + "/exam/" + this.extractConfig.examId)
  327. .then(response => {
  328. var exam = response.data;
  329. this.extractConfig.examType = exam.examType;
  330. this.extractConfig.examName = exam.name;
  331. });
  332. }
  333. }
  334. },
  335. //根据考试ID和课程code取出试卷类型集合
  336. getPaperTypeList() {
  337. if (!this.isInsert) {
  338. var id = "";
  339. for (let course of this.courseList) {
  340. if (this.extractConfig.courseCode == course.courseCode) {
  341. id = course.courseId;
  342. break;
  343. }
  344. }
  345. this.$http
  346. .get(
  347. EXAM_WORK_API +
  348. "/exam/queryExamCoursePaperTypeList?examId=" +
  349. this.extractConfig.examId +
  350. "&courseId=" +
  351. id
  352. )
  353. .then(response => {
  354. let examPaperArr = response.data;
  355. console.log("examPaperArr:", examPaperArr);
  356. if (examPaperArr && examPaperArr.length > 0) {
  357. let _examPaperList = [];
  358. for (let examPaper of examPaperArr) {
  359. let groupCode = examPaper.paperType;
  360. let weight =
  361. this.extractConfig.examType == "TRADITION" ? 100 : "";
  362. let examPaperListByGroupCode = this.getWeightFromExamPaperList(
  363. groupCode
  364. );
  365. if (examPaperListByGroupCode) {
  366. _examPaperList.push({
  367. groupCode: groupCode,
  368. paperInfoList: examPaperListByGroupCode
  369. });
  370. } else {
  371. _examPaperList.push({
  372. groupCode: groupCode,
  373. paperInfoList: [
  374. {
  375. weight: weight,
  376. paper: { id: "" }
  377. }
  378. ]
  379. });
  380. }
  381. }
  382. this.examPaperList = _examPaperList;
  383. }
  384. });
  385. this.getPaperList();
  386. }
  387. },
  388. //根据groupCode得到examPaper集合
  389. getWeightFromExamPaperList(groupCode) {
  390. let examPaperListByGroupCode = [];
  391. let examPaperList = this.extractConfig.examPaperList;
  392. if (!examPaperList || examPaperList.length == 0) {
  393. return null;
  394. }
  395. for (let examPaper of examPaperList) {
  396. if (examPaper.groupCode == groupCode) {
  397. examPaperListByGroupCode.push(examPaper);
  398. }
  399. }
  400. return examPaperListByGroupCode;
  401. },
  402. //根据课程,查询试卷集合
  403. getPaperList() {
  404. if (this.extractConfig.courseCode) {
  405. this.$http
  406. .get(
  407. QUESTION_API +
  408. "/getGenPaper?courseNo=" +
  409. this.extractConfig.courseCode
  410. )
  411. .then(response => {
  412. this.paperList = response.data;
  413. });
  414. }
  415. },
  416. //根据选择试卷集合查询音频题
  417. searchAudioTimeConfig() {
  418. this.audioTimeConfigModelList = [];
  419. //取到数组里面每个对象
  420. for (var i = 0; i < this.examPaperList.length; i++) {
  421. //定一个试卷的集合,用来去重
  422. var paperIds = [];
  423. for (var j = 0; j < this.examPaperList[i].paperInfoList.length; j++) {
  424. paperIds.push(this.examPaperList[i].paperInfoList[j].paper.id);
  425. }
  426. //对试卷集合进行去重
  427. console.log("paperIds:", paperIds);
  428. var ids = [];
  429. ids = _.uniq(paperIds);
  430. for (var k = 0; k < ids.length; k++) {
  431. //把对象添加到集合
  432. this.audioTimeConfigModelList.push({
  433. courseCode: this.extractConfig.courseCode,
  434. groupCode: this.examPaperList[i].groupCode,
  435. paper: {
  436. id: ids[k]
  437. },
  438. examId: this.extractConfig.examId,
  439. examName: this.extractConfig.examName
  440. });
  441. }
  442. }
  443. this.$http
  444. .post(
  445. QUESTION_API + "/audioTimeConfig/all",
  446. this.audioTimeConfigModelList
  447. )
  448. .then(response => {
  449. this.audioTimeConfigList = response.data;
  450. });
  451. },
  452. //增加在线考试试卷
  453. addOnLinePaper(groupCode) {
  454. let num = 0;
  455. for (let i = 0; i < this.examPaperList.length; i++) {
  456. if (this.examPaperList[i].groupCode == groupCode) {
  457. num = i;
  458. break;
  459. }
  460. }
  461. this.examPaperList[num].paperInfoList.push({
  462. weight: 0,
  463. paper: {
  464. id: ""
  465. }
  466. });
  467. },
  468. //删除试卷
  469. removePaperInfo(groupCode, item) {
  470. let num = 0;
  471. for (let i = 0; i < this.examPaperList.length; i++) {
  472. if (this.examPaperList[i].groupCode == groupCode) {
  473. num = i;
  474. break;
  475. }
  476. }
  477. let index = this.examPaperList[num].paperInfoList.indexOf(item);
  478. if (index !== -1) {
  479. this.examPaperList[num].paperInfoList.splice(index, 1);
  480. }
  481. if (this.extractConfig.examType != "PRACTICE") {
  482. //重新查询一次所有试卷的音频题数
  483. this.searchAudioTimeConfig();
  484. }
  485. },
  486. //保存提交
  487. submitForm() {
  488. this.saveExtractConfig();
  489. },
  490. //保存调卷规则
  491. saveExtractConfig() {
  492. if (!this.extractConfig.examId) {
  493. this.$notify({
  494. message: "请选择考试",
  495. type: "error"
  496. });
  497. return false;
  498. }
  499. if (!this.extractConfig.courseCode) {
  500. if (this.isInsert) {
  501. this.$notify({
  502. message:
  503. "考务数据中,该场考试下已经没有这门课程,无法保存调卷规则。",
  504. type: "error"
  505. });
  506. } else {
  507. this.$notify({
  508. message: "请选择课程",
  509. type: "error"
  510. });
  511. }
  512. return false;
  513. }
  514. if (this.extractConfig.examType != "PRACTICE") {
  515. for (let audioTimeConfig of this.audioTimeConfigList) {
  516. if (!this.checkValue(audioTimeConfig.playTime)) {
  517. this.$notify({
  518. message: "播放次数只能为整数",
  519. type: "error"
  520. });
  521. return false;
  522. }
  523. }
  524. }
  525. let myExamPaperList = this.verificationData();
  526. if (myExamPaperList.length > 0) {
  527. this.loading = true;
  528. this.extractConfig.examPaperList = myExamPaperList;
  529. this.$http
  530. .put(
  531. QUESTION_API + "/extractConfig" + "/" + this.isbuildFile,
  532. this.extractConfig
  533. )
  534. .then(
  535. () => {
  536. if (this.extractConfig.examType != "PRACTICE") {
  537. this.addAudioTimeConfig();
  538. }
  539. this.loading = false;
  540. this.$notify({ type: "success", message: "保存成功" });
  541. this.back();
  542. },
  543. error => {
  544. this.loading = false;
  545. this.$notify({
  546. type: "error",
  547. message: error.response.data.desc
  548. });
  549. }
  550. );
  551. }
  552. },
  553. //音频播放次数校验
  554. checkValue(val) {
  555. if (/(^[0-9]\d*$)/.test(val)) {
  556. return true;
  557. } else {
  558. return false;
  559. }
  560. },
  561. //新增音频播放次数
  562. addAudioTimeConfig() {
  563. if (!this.audioTimeConfigList || this.audioTimeConfigList.length == 0) {
  564. /* 未设置时则清理已存在的数据 */
  565. this.$http
  566. .post(
  567. QUESTION_API +
  568. "/deleteAudioTimeConfig/" +
  569. this.extractConfig.examId +
  570. "/" +
  571. this.extractConfig.courseCode
  572. )
  573. .then(() => {});
  574. } else {
  575. this.$http
  576. .post(QUESTION_API + "/addAudioTimeConfig", this.audioTimeConfigList)
  577. .then(() => {});
  578. }
  579. },
  580. //校验调卷规则数据
  581. verificationData() {
  582. let myExamPaperList = [];
  583. let examPaperList = this.examPaperList;
  584. for (let i = 0; i < examPaperList.length; i++) {
  585. let selectedPaperIds = []; //校验试卷重复性
  586. let weightCount = 0; //校验概率之和
  587. let _paperInfoList = examPaperList[i].paperInfoList;
  588. let groupCode = examPaperList[i].groupCode;
  589. if (!groupCode) {
  590. this.$notify({
  591. message: "试卷类型不能为空",
  592. type: "error",
  593. duration: 2000
  594. });
  595. break;
  596. }
  597. for (let j = 0; j < _paperInfoList.length; j++) {
  598. if (!_paperInfoList[j].paper.id) {
  599. myExamPaperList = [];
  600. // $(".errorMsg_" + i + "_" + j)
  601. // .text("试卷不能为空")
  602. // .show();
  603. document.getElementsByClassName(
  604. "errorMsg_" + i + "_" + j
  605. )[0].innerHTML = "试卷不能为空";
  606. document.getElementsByClassName(
  607. "errorMsg_" + i + "_" + j
  608. )[0].style.display = "block";
  609. break;
  610. } else {
  611. //$(".errorMsg_" + i + "_" + j).hide();
  612. document.getElementsByClassName(
  613. "errorMsg_" + i + "_" + j
  614. )[0].style.display = "none";
  615. }
  616. var reg = /^([1]?\d{1,2})$/;
  617. if (
  618. !reg.test(_paperInfoList[j].weight) ||
  619. _paperInfoList[j].weight == 0
  620. ) {
  621. myExamPaperList = [];
  622. // $(".errorMsg_" + i + "_" + j)
  623. // .text("请输入1-100的整数")
  624. // .show();
  625. document.getElementsByClassName(
  626. "errorMsg_" + i + "_" + j
  627. )[0].innerHTML = "请输入1-100的整数";
  628. document.getElementsByClassName(
  629. "errorMsg_" + i + "_" + j
  630. )[0].style.display = "block";
  631. break;
  632. } else {
  633. //$(".errorMsg_" + i + "_" + j).hide();
  634. if (document.getElementsByClassName("errorMsg_" + i + "_" + j)) {
  635. document.getElementsByClassName(
  636. "errorMsg_" + i + "_" + j
  637. )[0].style.display = "none";
  638. }
  639. weightCount += parseInt(_paperInfoList[j].weight);
  640. selectedPaperIds.push(_paperInfoList[j].paper.id);
  641. myExamPaperList.push({
  642. groupCode: groupCode,
  643. paper: {
  644. id: _paperInfoList[j].paper.id
  645. },
  646. weight: _paperInfoList[j].weight
  647. });
  648. }
  649. }
  650. if (myExamPaperList.length == 0) {
  651. break;
  652. } else {
  653. if (_.uniq(selectedPaperIds).length != selectedPaperIds.length) {
  654. myExamPaperList = [];
  655. this.$notify({
  656. message: "试卷选择不能重复",
  657. type: "error",
  658. duration: 2000
  659. });
  660. break;
  661. }
  662. if (weightCount != 100) {
  663. myExamPaperList = [];
  664. this.$notify({
  665. message: "试卷选取几率总和必须等于100",
  666. type: "error",
  667. duration: 2000
  668. });
  669. break;
  670. }
  671. }
  672. }
  673. return myExamPaperList;
  674. },
  675. //返回
  676. back() {
  677. if (this.isInsert) {
  678. this.$router.push({
  679. path: "/questions/extract_paper_rule/1"
  680. });
  681. } else {
  682. this.$router.push({
  683. path: "/questions/extract_paper_rule/0"
  684. });
  685. }
  686. },
  687. //修改调卷规则
  688. getExtractConfig(extractConfigId) {
  689. this.$http
  690. .get(QUESTION_API + "/extractConfig/" + extractConfigId)
  691. .then(response => {
  692. this.extractConfig = response.data;
  693. //查询该考试下的课程
  694. this.$http
  695. .get(
  696. EXAM_WORK_API +
  697. "/exam/queryExamCourseList?examId=" +
  698. this.extractConfig.examId +
  699. "&enable=true&name=" +
  700. this.extractConfig.courseCode
  701. )
  702. .then(response => {
  703. this.courseList = response.data;
  704. if (!this.courseList || this.courseList.length < 1) {
  705. this.$notify({
  706. message: "考务中,该场考试下面,没有设置课程!",
  707. type: "error"
  708. });
  709. } else {
  710. //根据考试ID和课程code取出试卷类型集合
  711. this.getPaperTypes();
  712. }
  713. });
  714. });
  715. },
  716. //根据考试ID和课程code取出试卷类型集合
  717. getPaperTypes() {
  718. var id = "";
  719. if (this.courseList && this.courseList.length > 0) {
  720. for (let course of this.courseList) {
  721. if (this.extractConfig.courseCode == course.courseCode) {
  722. id = course.courseId;
  723. break;
  724. }
  725. }
  726. if (id != "") {
  727. //查询该课程下的所有试卷
  728. this.getPaperList();
  729. this.$http
  730. .get(
  731. EXAM_WORK_API +
  732. "/exam/queryExamCoursePaperTypeList?examId=" +
  733. this.extractConfig.examId +
  734. "&courseId=" +
  735. id
  736. )
  737. .then(response => {
  738. let examPaperArr = response.data;
  739. if (examPaperArr && examPaperArr.length > 0) {
  740. let _examPaperList = [];
  741. for (let examPaper of examPaperArr) {
  742. let groupCode = examPaper.paperType;
  743. let weight =
  744. this.extractConfig.examType == "TRADITION" ? 100 : "";
  745. let examPaperListByGroupCode = this.getWeightFromExamPaperList(
  746. groupCode
  747. );
  748. if (examPaperListByGroupCode) {
  749. _examPaperList.push({
  750. groupCode: groupCode,
  751. paperInfoList: examPaperListByGroupCode
  752. });
  753. } else {
  754. _examPaperList.push({
  755. groupCode: groupCode,
  756. paperInfoList: [
  757. {
  758. weight: weight,
  759. paper: { id: "" }
  760. }
  761. ]
  762. });
  763. }
  764. }
  765. this.examPaperList = _examPaperList;
  766. if (this.extractConfig.examType != "PRACTICE") {
  767. this.searchAddAudioTimeConfig();
  768. }
  769. }
  770. });
  771. this.getPaperList();
  772. } else {
  773. this.$notify({
  774. message: "考务中,该场考试下面,没有设置该门课程!",
  775. type: "error"
  776. });
  777. }
  778. }
  779. },
  780. //存在调卷规则id,先查询
  781. searchAddAudioTimeConfig() {
  782. this.audioTimeConfigModelList = [];
  783. //取到数组里面每个对象
  784. for (var i = 0; i < this.examPaperList.length; i++) {
  785. //定一个试卷的集合,用来去重
  786. var paperIds = [];
  787. for (var j = 0; j < this.examPaperList[i].paperInfoList.length; j++) {
  788. paperIds.push(this.examPaperList[i].paperInfoList[j].paper.id);
  789. }
  790. //对试卷集合进行去重
  791. var ids = [];
  792. ids = _.uniq(paperIds);
  793. for (var k = 0; k < ids.length; k++) {
  794. //把对象添加到集合
  795. this.audioTimeConfigModelList.push({
  796. courseCode: this.extractConfig.courseCode,
  797. groupCode: this.examPaperList[i].groupCode,
  798. paper: {
  799. id: ids[k]
  800. },
  801. examId: this.extractConfig.examId,
  802. examName: this.extractConfig.examName
  803. });
  804. }
  805. }
  806. this.$http
  807. .post(
  808. QUESTION_API + "/audioTimeConfig/update",
  809. this.audioTimeConfigModelList
  810. )
  811. .then(response => {
  812. this.audioTimeConfigList = response.data;
  813. });
  814. }
  815. },
  816. computed: {
  817. ...mapState({ user: state => state.user }),
  818. courseInfoSelect() {
  819. var courseList = [];
  820. for (let course of this.courseList) {
  821. var courseInfo = course.courseName + "(" + course.courseCode + ")";
  822. courseList.push({
  823. courseNo: course.courseCode,
  824. courseName: course.courseName,
  825. courseInfo: courseInfo
  826. });
  827. }
  828. return courseList;
  829. }
  830. },
  831. //初始化
  832. created: function() {
  833. let extractConfigId = this.$route.params.extractConfigId;
  834. //1.查询考试集合
  835. this.getExams("");
  836. if (extractConfigId) {
  837. this.isInsert = true;
  838. //规则ID存在,表示是修改操作
  839. this.getExtractConfig(extractConfigId);
  840. }
  841. }
  842. };
  843. </script>
  844. <style scoped>
  845. .pull_right_ss {
  846. margin-left: 30px;
  847. }
  848. .paper_title_top {
  849. margin-top: -10px;
  850. }
  851. .input_width_sms {
  852. width: 80px;
  853. }
  854. .input_width_ss {
  855. width: 50px;
  856. }
  857. .el-icon-delete {
  858. cursor: pointer;
  859. }
  860. [class^="errorMsg_"] {
  861. color: #ff4949;
  862. display: none;
  863. }
  864. .margin-top-10 {
  865. margin-top: 10px;
  866. }
  867. .select_width_lg {
  868. width: 420px;
  869. }
  870. </style>
  871. <style scoped src="../styles/Common.css"></style>