CourseStatistic.vue 29 KB

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