CourseStatistic.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  1. <template>
  2. <section class="content" style="margin-top: 20px;">
  3. <div class="box box-info">
  4. <!-- 正文信息 -->
  5. <div class="box-body">
  6. <el-form
  7. :model="formSearch"
  8. :inline="true"
  9. label-position="right"
  10. label-width="100px"
  11. style="border-bottom: 1px solid rgb(221, 221, 221);margin-bottom: 10px"
  12. >
  13. <el-form-item label="学校">
  14. <el-select
  15. v-model="formSearch.orgId"
  16. placeholder="请选择"
  17. @change="loadExamList(formSearch.orgId)"
  18. >
  19. <el-option
  20. v-for="item in orgList"
  21. :label="item.orgName"
  22. :value="item.orgId"
  23. :key="item.orgId"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="考试">
  28. <el-select
  29. v-model="formSearch.examId"
  30. @change="searchRecords(1)"
  31. placeholder="请选择"
  32. >
  33. <el-option
  34. v-for="item in examList"
  35. :label="item.examName"
  36. :value="item.examId"
  37. :key="item.examId"
  38. ></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item label="试卷状态">
  42. <el-select
  43. v-model="formSearch.paperStatus"
  44. clearable
  45. placeholder="请选择"
  46. >
  47. <el-option label="请选择" value=""></el-option>
  48. <el-option
  49. v-for="item in coursePaperStatusList"
  50. :label="item.label"
  51. :value="item.value"
  52. :key="item.value"
  53. ></el-option>
  54. </el-select>
  55. </el-form-item>
  56. <el-form-item label="课程名称">
  57. <el-select
  58. v-model="formSearch.courseId"
  59. placeholder="请选择"
  60. filterable
  61. clearable
  62. remote
  63. :remote-method="loadCourseList"
  64. >
  65. <el-option label="请选择" value=""></el-option>
  66. <el-option
  67. v-for="item in courseList"
  68. :label="item.name"
  69. :value="item.id"
  70. :key="item.id"
  71. ></el-option>
  72. </el-select>
  73. </el-form-item>
  74. <el-form-item label="试卷名称">
  75. <el-input
  76. v-model="formSearch.paperName"
  77. style="width: 221px"
  78. clearable
  79. ></el-input>
  80. </el-form-item>
  81. <el-form-item style="padding-left: 30px">
  82. <el-button
  83. size="small"
  84. type="primary"
  85. icon="el-icon-search"
  86. @click="searchRecords(1)"
  87. >查询
  88. </el-button>
  89. <el-button
  90. size="small"
  91. icon="el-icon-refresh"
  92. @click="resetSearchForm"
  93. >
  94. 重置
  95. </el-button>
  96. </el-form-item>
  97. </el-form>
  98. <div style="margin-bottom: 5px;">
  99. 批量操作:
  100. <el-button
  101. size="small"
  102. type="primary"
  103. icon="el-icon-menu"
  104. @click="openAllotAllDialog"
  105. :disabled="!hasPermit"
  106. >分配待指定试卷
  107. </el-button>
  108. <el-button
  109. size="small"
  110. type="primary"
  111. icon="el-icon-download"
  112. @click="openExportAllDialog"
  113. >整体导出
  114. </el-button>
  115. <el-button
  116. size="small"
  117. type="primary"
  118. icon="el-icon-download"
  119. :disabled="selectElements.length == 0"
  120. @click="openExportDialog"
  121. >批量导出
  122. </el-button>
  123. <el-button
  124. size="small"
  125. type="primary"
  126. icon="el-icon-refresh"
  127. :disabled="selectElements.length == 0"
  128. @click="refreshStatistic"
  129. >统计刷新
  130. </el-button>
  131. </div>
  132. <!-- 数据列表 -->
  133. <el-table
  134. v-loading="loading"
  135. :data="tableData"
  136. element-loading-text="数据加载中"
  137. style="width:100%;"
  138. border
  139. stripe
  140. @selection-change="handleSelection"
  141. >
  142. <el-table-column type="selection" width="35px"> </el-table-column>
  143. <el-table-column label="课程名称" prop="courseName" sortable />
  144. <el-table-column
  145. width="140px"
  146. label="课程代码"
  147. prop="courseCode"
  148. sortable
  149. />
  150. <el-table-column
  151. width="102px"
  152. label="试卷类型"
  153. prop="paperType"
  154. sortable
  155. />
  156. <el-table-column width="102px" label="试卷状态" sortable>
  157. <template slot-scope="scope">
  158. <span
  159. @click="openAllotDialog(scope.row)"
  160. style="cursor: pointer"
  161. >{{ scope.row.paperStatusName }}</span
  162. >
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="试卷名称" prop="paperName" sortable />
  166. <el-table-column
  167. width="102px"
  168. label="试卷P数"
  169. prop="paperP"
  170. sortable
  171. />
  172. <el-table-column
  173. width="102px"
  174. label="考生人数"
  175. prop="totalStudent"
  176. sortable
  177. />
  178. <el-table-column width="180px" label="操作" :context="_self">
  179. <template slot-scope="scope">
  180. <el-button
  181. size="mini"
  182. type="primary"
  183. icon="el-icon-download"
  184. :disabled="scope.row.paperStatus <= 1"
  185. @click="openExportDialog(scope.row)"
  186. plain
  187. >下载
  188. </el-button>
  189. <el-dropdown style="margin-left: 10px;">
  190. <el-button
  191. size="mini"
  192. type="primary"
  193. :disabled="scope.row.paperStatus == 0"
  194. plain
  195. >
  196. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  197. </el-button>
  198. <el-dropdown-menu slot="dropdown">
  199. <el-dropdown-item>
  200. <el-button
  201. size="mini"
  202. type="primary"
  203. icon="el-icon-view"
  204. :disabled="scope.row.paperStatus <= 1"
  205. @click="preview(scope.row)"
  206. plain
  207. >试卷预览
  208. </el-button>
  209. </el-dropdown-item>
  210. <el-dropdown-item>
  211. <el-button
  212. size="mini"
  213. type="primary"
  214. icon="el-icon-menu"
  215. :disabled="!hasPermit"
  216. @click="openAllotDialog(scope.row)"
  217. plain
  218. >试卷指定
  219. </el-button>
  220. </el-dropdown-item>
  221. </el-dropdown-menu>
  222. </el-dropdown>
  223. </template>
  224. </el-table-column>
  225. </el-table>
  226. <!-- 分页 -->
  227. <div class="page pull-right">
  228. <el-pagination
  229. @current-change="handlePagerNo"
  230. :current-page="formSearch.pageNo"
  231. @size-change="handlePagerSize"
  232. :page-size="formSearch.pageSize"
  233. :page-sizes="[10, 20, 50, 100]"
  234. :total="totalElements"
  235. layout="total, sizes, prev, pager, next, jumper"
  236. ></el-pagination>
  237. </div>
  238. </div>
  239. <el-dialog
  240. title="试卷指定"
  241. width="380px"
  242. :visible.sync="allotDialog"
  243. @close="closeAllotDialog"
  244. >
  245. <el-form
  246. :model="allotForm"
  247. ref="allotForm"
  248. :rules="rules"
  249. label-position="right"
  250. label-width="80px"
  251. inline-message
  252. >
  253. <el-form-item label="课程名称" prop="courseName">
  254. <el-input
  255. v-model="allotForm.courseName"
  256. :disabled="true"
  257. class="w220"
  258. >
  259. {{ allotForm.courseName }}</el-input
  260. >
  261. </el-form-item>
  262. <el-form-item label="试卷类型" prop="paperType">
  263. <el-input
  264. v-model="allotForm.paperType"
  265. :disabled="true"
  266. class="w220"
  267. >
  268. {{ allotForm.paperType }}</el-input
  269. >
  270. </el-form-item>
  271. <el-form-item label="试卷名称" prop="coursePaperId">
  272. <el-select
  273. v-model="allotForm.coursePaperId"
  274. placeholder="请选择"
  275. class="w220"
  276. >
  277. <el-option
  278. v-for="item in coursePaperList"
  279. :value="item.coursePaperId"
  280. :key="item.coursePaperId"
  281. :label="item.paperName"
  282. ></el-option>
  283. </el-select>
  284. </el-form-item>
  285. <div style="text-align: center">
  286. <el-button type="primary" @click="saveAllot">确 定</el-button>
  287. <el-button @click="closeAllotDialog">取 消</el-button>
  288. </div>
  289. </el-form>
  290. </el-dialog>
  291. <el-dialog
  292. title="试卷整体分配"
  293. width="400px"
  294. :visible.sync="allotAllDialog"
  295. @close="closeAllotAllDialog"
  296. >
  297. <el-form
  298. :model="allotAllForm"
  299. ref="allotAllForm"
  300. :rules="rules"
  301. label-position="right"
  302. label-width="80px"
  303. inline-message
  304. >
  305. <el-form-item label="学校名称" prop="orgId">
  306. <el-select
  307. v-model="allotAllForm.orgId"
  308. @change="loadAllotExamList(allotAllForm.orgId)"
  309. placeholder="请选择"
  310. class="w220"
  311. >
  312. <el-option
  313. v-for="item in orgList"
  314. :label="item.orgName"
  315. :value="item.orgId"
  316. :key="item.orgId"
  317. ></el-option>
  318. </el-select>
  319. </el-form-item>
  320. <el-form-item label="考试名称" prop="examId">
  321. <el-select
  322. v-model="allotAllForm.examId"
  323. placeholder="请选择"
  324. class="w220"
  325. >
  326. <el-option
  327. v-for="item in allotExamList"
  328. :label="item.examName"
  329. :value="item.examId"
  330. :key="item.examId"
  331. ></el-option>
  332. </el-select>
  333. </el-form-item>
  334. <div style="text-align: center">
  335. <p style="color: red;">
  336. 警告:确定后当前考试中“未指定试卷”的课程会在已有的试卷中随机选取一套试卷分配关联,是否确定执行?
  337. </p>
  338. <el-button
  339. type="primary"
  340. @click="saveAllotAll"
  341. :disabled="allotAllForm.examId == ''"
  342. >确 定</el-button
  343. >
  344. <el-button @click="closeAllotAllDialog">取 消</el-button>
  345. </div>
  346. </el-form>
  347. </el-dialog>
  348. <el-dialog
  349. title="导出"
  350. width="450px"
  351. :visible.sync="exportDialog"
  352. @close="closeExportDialog"
  353. >
  354. <el-form
  355. :model="exportForm"
  356. ref="exportForm"
  357. :rules="rules"
  358. label-position="right"
  359. label-width="90px"
  360. inline-message
  361. >
  362. <el-form-item label="导出内容" prop="types">
  363. <el-checkbox-group v-model="exportForm.types">
  364. <el-checkbox label="1">试卷</el-checkbox>
  365. <el-checkbox label="2">答案</el-checkbox>
  366. <el-checkbox label="3">试卷结构</el-checkbox>
  367. </el-checkbox-group>
  368. </el-form-item>
  369. <div style="text-align: center">
  370. <el-button
  371. type="primary"
  372. @click="doExport"
  373. :disabled="exportForm.types.length == 0"
  374. >确定</el-button
  375. >
  376. <el-button @click="closeExportDialog">取 消</el-button>
  377. </div>
  378. </el-form>
  379. </el-dialog>
  380. <el-dialog
  381. title="试卷整体导出"
  382. width="430px"
  383. :visible.sync="exportAllDialog"
  384. @close="closeExportAllDialog"
  385. >
  386. <el-form
  387. :model="exportAllForm"
  388. ref="exportAllForm"
  389. :rules="rules"
  390. label-position="right"
  391. label-width="90px"
  392. inline-message
  393. >
  394. <el-form-item label="学校名称" prop="orgId">
  395. <el-select
  396. v-model="exportAllForm.orgId"
  397. @change="loadExportExamList(exportAllForm.orgId)"
  398. placeholder="请选择"
  399. class="w245"
  400. >
  401. <el-option
  402. v-for="item in orgList"
  403. :label="item.orgName"
  404. :value="item.orgId"
  405. :key="item.orgId"
  406. ></el-option>
  407. </el-select>
  408. </el-form-item>
  409. <el-form-item label="考试名称" prop="examId">
  410. <el-select
  411. v-model="exportAllForm.examId"
  412. @change="loadExamCoursePaperTotal"
  413. placeholder="请选择"
  414. class="w245"
  415. >
  416. <el-option
  417. v-for="item in exportExamList"
  418. :label="item.examName"
  419. :value="item.examId"
  420. :key="item.examId"
  421. ></el-option>
  422. </el-select>
  423. </el-form-item>
  424. <el-form-item label="导出内容" prop="types">
  425. <el-checkbox-group v-model="exportAllForm.types">
  426. <el-checkbox label="1">试卷</el-checkbox>
  427. <el-checkbox label="2">答案</el-checkbox>
  428. <el-checkbox label="3">试卷结构</el-checkbox>
  429. </el-checkbox-group>
  430. </el-form-item>
  431. <el-form-item label="试卷总数" prop="allNum">
  432. {{ exportAllForm.allNum }}
  433. </el-form-item>
  434. <el-form-item label="已有试卷数" prop="existNum">
  435. {{ exportAllForm.existNum }}
  436. </el-form-item>
  437. <el-form-item label="缺少试卷数" prop="missNum">
  438. {{ exportAllForm.missNum }}
  439. </el-form-item>
  440. <div style="text-align: center">
  441. <el-button
  442. type="primary"
  443. @click="doExportAll"
  444. :disabled="exportAllForm.existNum == 0"
  445. >确定</el-button
  446. >
  447. <el-button @click="closeExportAllDialog">取 消</el-button>
  448. </div>
  449. </el-form>
  450. </el-dialog>
  451. </div>
  452. </section>
  453. </template>
  454. <script>
  455. import { CORE_API, PRINT_API } from "@/constants/constants";
  456. import { coursePaperStatusList } from "../constants/constants.js";
  457. import { mapState } from "vuex";
  458. import { checkEmptyStr, checkEmptyNumber } from "../utils/common.js";
  459. export default {
  460. data() {
  461. return {
  462. formSearch: {
  463. orgId: "",
  464. examId: "",
  465. courseId: "",
  466. paperStatus: "",
  467. paperName: "",
  468. pageNo: 1,
  469. pageSize: 10
  470. },
  471. curUserRole: {},
  472. hasPermit: false,
  473. totalElements: 0,
  474. loading: false,
  475. tableData: [],
  476. orgList: [],
  477. examList: [],
  478. courseList: [],
  479. coursePaperList: [],
  480. coursePaperStatusList: coursePaperStatusList,
  481. allotExamList: [],
  482. allotDialog: false,
  483. allotForm: {
  484. id: "",
  485. coursePaperId: "",
  486. courseName: "",
  487. paperType: ""
  488. },
  489. allotAllDialog: false,
  490. allotAllForm: {
  491. orgId: "",
  492. examId: ""
  493. },
  494. selectElements: [],
  495. exportExamList: [],
  496. exportDialog: false,
  497. exportForm: {
  498. ids: [],
  499. types: []
  500. },
  501. exportAllDialog: false,
  502. exportAllForm: {
  503. orgId: "",
  504. examId: "",
  505. types: [],
  506. allNum: 0,
  507. existNum: 0,
  508. missNum: 0
  509. },
  510. rules: {
  511. orgId: [
  512. { required: true, message: "学校不能为空!", trigger: "change" }
  513. ],
  514. examId: [
  515. { required: true, message: "考试不能为空!", trigger: "change" }
  516. ],
  517. coursePaperId: [
  518. { required: true, message: "试卷不能为空!", trigger: "change" }
  519. ],
  520. courseName: [
  521. { required: true, message: "课程不能为空!", trigger: "change" }
  522. ],
  523. paperType: [
  524. { required: true, message: "试卷类型不能为空!", trigger: "change" }
  525. ],
  526. types: [
  527. { required: true, message: "请选择导出内容!", trigger: "change" }
  528. ]
  529. }
  530. };
  531. },
  532. methods: {
  533. handleSelection(elements) {
  534. /* 处理选中记录 */
  535. this.selectElements = elements;
  536. },
  537. handlePagerNo(pageNo) {
  538. /* 处理分页 */
  539. this.searchRecords(pageNo);
  540. },
  541. handlePagerSize(pageSize) {
  542. /* 处理每页条数 */
  543. this.formSearch.pageSize = pageSize;
  544. this.searchRecords(1);
  545. },
  546. resetSearchForm() {
  547. this.formSearch.courseId = "";
  548. this.formSearch.paperStatus = "";
  549. this.formSearch.paperName = "";
  550. //this.searchRecords(1);
  551. },
  552. searchRecords(pageNo) {
  553. this.formSearch.pageNo = pageNo;
  554. /* 查询记录列表 */
  555. let orgId = this.formSearch.orgId;
  556. if (checkEmptyNumber(orgId)) {
  557. this.$notify({
  558. title: "提示",
  559. message: "请选择学校!",
  560. type: "warning"
  561. });
  562. return;
  563. }
  564. let examId = this.formSearch.examId;
  565. if (checkEmptyNumber(examId)) {
  566. this.$notify({
  567. title: "提示",
  568. message: "请选择考试!",
  569. type: "warning"
  570. });
  571. return;
  572. }
  573. this.loading = true;
  574. let url = PRINT_API + "/course/statistic/list";
  575. this.$http.post(url, this.formSearch).then(
  576. response => {
  577. this.tableData = response.data.content;
  578. this.totalElements = response.data.totalElements;
  579. this.loading = false;
  580. },
  581. error => {
  582. console.log(error);
  583. this.loading = false;
  584. }
  585. );
  586. },
  587. selectDefault() {
  588. if (this.orgList.length > 0) {
  589. let firstOrgId = this.orgList[0].orgId;
  590. this.formSearch.orgId = firstOrgId;
  591. this.loadExamList(firstOrgId);
  592. }
  593. },
  594. loadOrgList() {
  595. /* 查询学校列表 */
  596. let url = PRINT_API + "/printing/project/org/list";
  597. this.$http.post(url).then(
  598. response => {
  599. this.orgList = response.data;
  600. this.selectDefault();
  601. },
  602. error => {
  603. console.log(error.response);
  604. // ignore
  605. }
  606. );
  607. },
  608. loadExamList(orgId) {
  609. /* 查询考试列表 */
  610. this.formSearch.examId = "";
  611. this.examList = [];
  612. this.tableData = [];
  613. if (checkEmptyNumber(orgId)) {
  614. return;
  615. }
  616. let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
  617. this.$http.post(url).then(response => {
  618. this.examList = response.data;
  619. if (this.examList.length > 0) {
  620. this.formSearch.examId = this.examList[0].examId;
  621. this.searchRecords(1);
  622. }
  623. });
  624. },
  625. loadAllotExamList(orgId) {
  626. /* 查询考试列表 */
  627. this.allotAllForm.examId = "";
  628. this.allotExamList = [];
  629. if (!checkEmptyNumber(orgId)) {
  630. let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
  631. this.$http.post(url).then(response => {
  632. this.allotExamList = response.data;
  633. });
  634. }
  635. },
  636. loadExportExamList(orgId) {
  637. /* 查询考试列表 */
  638. this.exportAllForm.examId = "";
  639. this.exportExamList = [];
  640. if (!checkEmptyNumber(orgId)) {
  641. let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
  642. this.$http.post(url).then(response => {
  643. this.exportExamList = response.data;
  644. });
  645. }
  646. },
  647. loadCourseList(query) {
  648. /* 查询课程列表 */
  649. this.courseList = [];
  650. let url = CORE_API + "/course/query?enable=true";
  651. let orgId = this.formSearch.orgId;
  652. if (!checkEmptyNumber(orgId)) {
  653. url += "&rootOrgId=" + orgId;
  654. }
  655. if (!checkEmptyStr(query)) {
  656. url += "&name=" + query;
  657. }
  658. this.$http.get(url).then(response => {
  659. this.courseList = response.data;
  660. });
  661. },
  662. refreshStatistic() {
  663. let checkUrl = PRINT_API + "/course/statistic/refresh/check";
  664. this.$http.get(checkUrl).then(response => {
  665. if (response.data.data) {
  666. this.$notify({
  667. title: "提示",
  668. message: "尚有课程统计任务正在刷新中,请稍后再刷新!",
  669. type: "warning"
  670. });
  671. } else {
  672. /* 刷新当前统计信息 */
  673. this.$confirm("刷新当前统计信息?", "提示", {
  674. confirmButtonText: "确定",
  675. cancelButtonText: "取消",
  676. type: "warning"
  677. })
  678. .then(() => {
  679. if (this.selectElements.length == 0) {
  680. this.$notify({
  681. title: "提示",
  682. message: "请选择要刷新的项!",
  683. type: "warning"
  684. });
  685. return;
  686. }
  687. let params = {};
  688. params.orgId = this.selectElements[0].orgId;
  689. params.examId = this.selectElements[0].examId;
  690. params.couses = [];
  691. this.selectElements.forEach(element => {
  692. params.couses.push({
  693. courseId: element.courseId,
  694. paperType: element.paperType
  695. });
  696. });
  697. let url = PRINT_API + "/course/statistic/refresh";
  698. this.$http.post(url, params).then(
  699. () => {
  700. this.$notify({
  701. title: "提示",
  702. type: "success",
  703. message: "刷新成功!"
  704. });
  705. this.searchRecords(this.formSearch.pageNo);
  706. },
  707. error => {
  708. console.log(error.response);
  709. this.$notify({
  710. title: "错误",
  711. type: "error",
  712. message: error.response.data.desc
  713. });
  714. }
  715. );
  716. })
  717. .catch(() => {
  718. //ignore
  719. });
  720. }
  721. });
  722. },
  723. preview(row) {
  724. /* 预览试卷PDF */
  725. let url = row.paperPdfUrl;
  726. if (!url) {
  727. this.$notify({
  728. title: "提示",
  729. message: "当前试卷不存在!",
  730. type: "warning"
  731. });
  732. return;
  733. }
  734. this.$confirm("确定预览?", "提示", {
  735. confirmButtonText: "确定",
  736. cancelButtonText: "取消",
  737. type: "warning"
  738. })
  739. .then(() => {
  740. window.open(url);
  741. })
  742. .catch(() => {
  743. /*ignore*/
  744. });
  745. },
  746. openAllotDialog(row) {
  747. /* 试卷状态为"已有"时,打开试卷指定弹窗 */
  748. if (!this.hasPermit) {
  749. console.log("no permit.");
  750. return;
  751. }
  752. if (row.paperStatus > 0) {
  753. this.allotDialog = true;
  754. this.allotForm.id = row.id;
  755. this.allotForm.coursePaperId = row.coursePaperId;
  756. this.allotForm.courseName = row.courseName;
  757. this.allotForm.paperType = row.paperType;
  758. let params = {
  759. orgId: row.orgId,
  760. examId: row.examId,
  761. courseId: row.courseId
  762. };
  763. let url = PRINT_API + "/course/paper/list";
  764. this.$http.post(url, params).then(
  765. response => {
  766. this.coursePaperList = response.data;
  767. },
  768. error => {
  769. console.log(error);
  770. }
  771. );
  772. }
  773. },
  774. closeAllotDialog() {
  775. /* 关闭试卷指定弹窗 */
  776. this.allotDialog = false;
  777. },
  778. saveAllot() {
  779. /* 保存试卷指定 */
  780. this.$refs.allotForm.validate(valid => {
  781. if (!valid) {
  782. return false;
  783. }
  784. let curLoading = this.$loading({
  785. lock: true,
  786. text: "数据保存中!"
  787. });
  788. let url =
  789. PRINT_API +
  790. "/course/paper/allot/" +
  791. this.allotForm.id +
  792. "/" +
  793. this.allotForm.coursePaperId;
  794. this.$http.post(url).then(
  795. () => {
  796. curLoading.close();
  797. this.$notify({
  798. title: "提示",
  799. message: "试卷指定成功!",
  800. type: "success"
  801. });
  802. this.allotDialog = false;
  803. this.searchRecords(this.formSearch.pageNo);
  804. },
  805. error => {
  806. console.log(error.response);
  807. curLoading.close();
  808. this.$notify({
  809. title: "错误",
  810. type: "error",
  811. message: error.response.data.desc
  812. });
  813. }
  814. );
  815. });
  816. },
  817. openAllotAllDialog() {
  818. /* 打开试卷整体分配弹窗 */
  819. this.allotAllDialog = true;
  820. },
  821. closeAllotAllDialog() {
  822. /* 关闭试卷整体分配弹窗 */
  823. this.allotAllDialog = false;
  824. },
  825. saveAllotAll() {
  826. /* 保存试卷整体分配 */
  827. this.$refs.allotAllForm.validate(valid => {
  828. if (!valid) {
  829. return false;
  830. }
  831. let curLoading = this.$loading({
  832. lock: true,
  833. text: "数据保存中!"
  834. });
  835. let url =
  836. PRINT_API +
  837. "/course/paper/allot/all/" +
  838. this.allotAllForm.orgId +
  839. "/" +
  840. this.allotAllForm.examId;
  841. this.$http.post(url).then(
  842. () => {
  843. curLoading.close();
  844. this.$notify({
  845. title: "提示",
  846. message: "试卷整体分配成功!",
  847. type: "success"
  848. });
  849. this.allotAllDialog = false;
  850. this.searchRecords(this.formSearch.pageNo);
  851. },
  852. error => {
  853. console.log(error.response);
  854. curLoading.close();
  855. this.$notify({
  856. title: "提示",
  857. type: "warning",
  858. message: error.response.data.desc
  859. });
  860. }
  861. );
  862. });
  863. },
  864. openExportDialog(row) {
  865. /* 打开批量导出弹窗 */
  866. this.exportDialog = true;
  867. this.exportForm.ids = [];
  868. if (row.id) {
  869. this.exportForm.ids.push(row.id);
  870. }
  871. },
  872. closeExportDialog() {
  873. /* 关闭批量导出弹窗 */
  874. this.exportDialog = false;
  875. },
  876. doExport() {
  877. /* 批量导出 */
  878. let ids = [];
  879. if (this.exportForm.ids.length > 0) {
  880. ids = this.exportForm.ids;
  881. } else {
  882. if (this.selectElements.length == 0) {
  883. this.$notify({
  884. title: "提示",
  885. message: "请选择要导出的项!",
  886. type: "warning"
  887. });
  888. return;
  889. }
  890. this.selectElements.forEach(element => {
  891. if (element.paperStatus > 1) {
  892. ids.push(element.id);
  893. }
  894. });
  895. }
  896. this.$refs.exportForm.validate(valid => {
  897. if (!valid) {
  898. return false;
  899. }
  900. if (ids.length == 0) {
  901. this.$notify({
  902. title: "提示",
  903. message: "包含未被指定试卷的课程则不可导出!",
  904. type: "warning"
  905. });
  906. return;
  907. }
  908. this.closeExportDialog();
  909. let url =
  910. PRINT_API +
  911. "/course/paper/export/batch?ids=" +
  912. ids.join(",") +
  913. "&types=" +
  914. this.exportForm.types.join(",");
  915. //console.log(url);
  916. window.location.href = url;
  917. });
  918. },
  919. openExportAllDialog() {
  920. /* 打开整体导出弹窗 */
  921. this.exportAllDialog = true;
  922. },
  923. closeExportAllDialog() {
  924. /* 关闭整体导出弹窗 */
  925. this.exportAllDialog = false;
  926. },
  927. doExportAll() {
  928. /* 整体导出 */
  929. this.$refs.exportAllForm.validate(valid => {
  930. if (!valid) {
  931. return false;
  932. }
  933. this.closeExportAllDialog();
  934. let url =
  935. PRINT_API +
  936. "/course/paper/export/all?orgId=" +
  937. this.exportAllForm.orgId +
  938. "&examId=" +
  939. this.exportAllForm.examId +
  940. "&types=" +
  941. this.exportAllForm.types.join(",");
  942. //console.log(url);
  943. window.location.href = url;
  944. });
  945. },
  946. loadExamCoursePaperTotal() {
  947. /* 查询考试的试卷数量情况 */
  948. let url =
  949. PRINT_API +
  950. "/course/paper/total/" +
  951. this.exportAllForm.orgId +
  952. "/" +
  953. this.exportAllForm.examId;
  954. this.$http.post(url).then(
  955. response => {
  956. let data = response.data;
  957. this.exportAllForm.allNum = data.allNum;
  958. this.exportAllForm.existNum = data.existNum;
  959. this.exportAllForm.missNum = data.missNum;
  960. },
  961. error => {
  962. console.log(error);
  963. }
  964. );
  965. }
  966. },
  967. computed: {
  968. ...mapState({ user: state => state.user })
  969. },
  970. created() {
  971. this.loadOrgList();
  972. this.loadUserRole(this.user);
  973. if (this.curUserRole.isSuperLeader || this.curUserRole.isPM) {
  974. this.hasPermit = true;
  975. } else {
  976. this.hasPermit = false;
  977. }
  978. }
  979. };
  980. </script>
  981. <style scoped>
  982. .page {
  983. margin-top: 10px;
  984. }
  985. .pull-right {
  986. float: right;
  987. }
  988. .pull-left {
  989. float: left;
  990. }
  991. .w220 {
  992. width: 220px;
  993. }
  994. .w245 {
  995. width: 245px;
  996. }
  997. </style>