PrintTaskManage.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. <template>
  2. <div class="print-task-manage">
  3. <div class="part-box part-box-filter">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <template v-if="checkPrivilege('condition', 'condition')">
  6. <el-form-item label="学期:">
  7. <semester-select
  8. v-model.trim="filter.semesterId"
  9. placeholder="学期"
  10. default-select
  11. ></semester-select>
  12. </el-form-item>
  13. <el-form-item label="考试:">
  14. <exam-select
  15. v-model="filter.examId"
  16. :semester-id="filter.semesterId"
  17. default-select
  18. @default-selected="search"
  19. ></exam-select>
  20. </el-form-item>
  21. <el-form-item label="印刷计划:">
  22. <print-plan-select
  23. v-model.trim="filter.printPlanId"
  24. placeholder="印刷计划"
  25. clearable
  26. :semester-id="filter.semesterId"
  27. :exam-id="filter.examId"
  28. @change="printPlanChange"
  29. ></print-plan-select>
  30. </el-form-item>
  31. <el-form-item label="课程(代码):" label-width="110px">
  32. <course-select
  33. v-model.trim="filter.courseId"
  34. :semester-id="filter.semesterId"
  35. :exam-id="filter.examId"
  36. :print-plan-id="filter.printPlanId"
  37. placeholder="课程(代码)"
  38. clearable
  39. ></course-select>
  40. </el-form-item>
  41. <el-form-item label="试卷编号:">
  42. <paper-number-select
  43. ref="PaperNumberSelect"
  44. v-model="filter.paperNumber"
  45. :semester-id="filter.semesterId"
  46. :exam-id="filter.examId"
  47. :print-plan-id="filter.printPlanId"
  48. :course-id="filter.courseId"
  49. placeholder="试卷编号"
  50. clearable
  51. ></paper-number-select>
  52. </el-form-item>
  53. <el-form-item label="印刷室:">
  54. <print-room-select
  55. v-model.trim="filter.printHouseId"
  56. placeholder="印刷室"
  57. clearable
  58. ></print-room-select>
  59. </el-form-item>
  60. <el-form-item label="印刷状态:">
  61. <status-select
  62. v-model="filter.status"
  63. type="EXAM_DETAIL_STATUS_ENUM"
  64. placeholder="印刷状态"
  65. style="width: 120px"
  66. clearable
  67. >
  68. </status-select>
  69. </el-form-item>
  70. <el-form-item label="考点:" label-width="55px">
  71. <place-select
  72. v-model.trim="filter.examPlace"
  73. :exam-id="filter.examId"
  74. :print-plan-id="filter.printPlanId"
  75. placeholder="考点"
  76. clearable
  77. ></place-select>
  78. </el-form-item>
  79. <el-form-item label="考场:" label-width="55px">
  80. <room-select
  81. v-model.trim="filter.examRoom"
  82. :exam-id="filter.examId"
  83. :print-plan-id="filter.printPlanId"
  84. placeholder="考场"
  85. clearable
  86. ></room-select>
  87. </el-form-item>
  88. <el-form-item label="班级:" label-width="55px">
  89. <el-input
  90. v-model.trim="filter.classDesc"
  91. placeholder="请输入班级"
  92. :maxlength="50"
  93. clearable
  94. ></el-input>
  95. </el-form-item>
  96. <el-form-item label="考试日期:">
  97. <el-date-picker
  98. v-model="createTime"
  99. type="daterange"
  100. :picker-options="pickerOptions"
  101. range-separator="至"
  102. start-placeholder="考试开始日期"
  103. end-placeholder="考试结束日期"
  104. value-format="timestamp"
  105. align="right"
  106. unlink-panels
  107. >
  108. </el-date-picker>
  109. </el-form-item>
  110. <el-form-item label="打印时间:">
  111. <el-date-picker
  112. v-model="printTime"
  113. type="datetimerange"
  114. :picker-options="pickerOptions"
  115. range-separator="至"
  116. start-placeholder="打印开始时间"
  117. end-placeholder="打印结束时间"
  118. value-format="timestamp"
  119. align="right"
  120. unlink-panels
  121. >
  122. </el-date-picker>
  123. </el-form-item>
  124. </template>
  125. <el-form-item label-width="0px">
  126. <el-button
  127. v-if="checkPrivilege('button', 'select')"
  128. type="primary"
  129. @click="search"
  130. >查询</el-button
  131. >
  132. </el-form-item>
  133. </el-form>
  134. <div class="box-justify">
  135. <div>
  136. <el-button
  137. v-if="checkPrivilege('button', 'CreateWholePdf')"
  138. icon="el-icon-document"
  139. :disabled="!searchfilter.paperNumber"
  140. :loading="pdfLoading"
  141. :type="wholePdfInfo.status === 'RUNNING' ? 'default' : 'success'"
  142. @click="toViewWholePdf"
  143. >
  144. {{ wholePdfBtnName }}
  145. </el-button>
  146. <el-button
  147. v-if="checkPrivilege('button', 'BatchEnd')"
  148. icon="el-icon-finished"
  149. type="success"
  150. :disabled="searchfilter.status !== 'WAITING'"
  151. @click="toBatchCancelOrSubmit('finish')"
  152. >
  153. 批量完成
  154. </el-button>
  155. <el-button
  156. v-if="checkPrivilege('button', 'BatchEnd')"
  157. icon="el-icon-bottom-left"
  158. type="danger"
  159. :disabled="searchfilter.status !== 'WAITING'"
  160. @click="toBatchCancelOrSubmit('cancel')"
  161. >
  162. 批量撤回
  163. </el-button>
  164. <el-button
  165. v-if="checkPrivilege('button', 'BatchEnd')"
  166. icon="el-icon-top-right"
  167. type="primary"
  168. :disabled="searchfilter.status !== 'READY'"
  169. @click="toBatchCancelOrSubmit('submit')"
  170. >
  171. 批量提交
  172. </el-button>
  173. <el-button
  174. v-if="checkPrivilege('button', 'BatchDownload')"
  175. icon="el-icon-download"
  176. type="primary"
  177. :disabled="loading"
  178. @click="toExport"
  179. >
  180. 批量下载PDF
  181. </el-button>
  182. <el-button
  183. v-if="checkPrivilege('button', 'BatchDownload')"
  184. type="primary"
  185. icon="el-icon-s-order"
  186. @click="toDataTask"
  187. >下载结果查询</el-button
  188. >
  189. </div>
  190. <div>
  191. <el-button
  192. v-if="checkPrivilege('button', 'Verify')"
  193. type="primary"
  194. icon="el-icon-s-order"
  195. @click="toBarCheck"
  196. >校验</el-button
  197. >
  198. </div>
  199. </div>
  200. </div>
  201. <div class="part-box part-box-pad box-justify">
  202. <p>
  203. <span class="mr-4"
  204. >科次总计:<i class="color-primary">{{ totalInfo.totalSubjects }}</i>
  205. 科次</span
  206. >
  207. <span class="mr-4"
  208. >试卷总计:<i class="color-primary">{{ totalInfo.paperCount }}</i>
  209. 套</span
  210. >
  211. <span class="mr-4"
  212. >卷袋总计:<i class="color-primary">{{ totalInfo.packageCount }}</i>
  213. 个</span
  214. >
  215. <span
  216. >总印量:<i class="color-primary">{{
  217. totalInfo.paperPages + totalInfo.cardPages
  218. }}</i>
  219. 张</span
  220. >
  221. <span
  222. >(试卷:<i class="color-primary">{{ totalInfo.paperPages }}</i>
  223. 张,</span
  224. >
  225. <span
  226. >题卡:<i class="color-primary">{{ totalInfo.cardPages }}</i>
  227. 张)</span
  228. >
  229. </p>
  230. <p>
  231. <span
  232. >剩余印量:<i class="color-danger">{{
  233. totalInfo.paperPagesLeft + totalInfo.cardPagesLeft
  234. }}</i>
  235. 张</span
  236. >
  237. <span
  238. >(试卷:<i class="color-danger">{{ totalInfo.paperPagesLeft }}</i>
  239. 张,</span
  240. >
  241. <span
  242. >题卡:<i class="color-danger">{{ totalInfo.cardPagesLeft }}</i>
  243. 张)</span
  244. >
  245. </p>
  246. </div>
  247. <div class="part-box part-box-pad">
  248. <el-table
  249. ref="TableList"
  250. :data="dataList"
  251. @selection-change="handleSelectionChange"
  252. >
  253. <el-table-column
  254. type="selection"
  255. fixed="left"
  256. width="55"
  257. align="center"
  258. ></el-table-column>
  259. <el-table-column
  260. type="index"
  261. label="序号"
  262. width="60"
  263. :index="indexMethod"
  264. ></el-table-column>
  265. <!-- <el-table-column
  266. prop="semesterName"
  267. label="学期"
  268. min-width="210"
  269. ></el-table-column>
  270. <el-table-column
  271. prop="examName"
  272. label="考试"
  273. min-width="160"
  274. ></el-table-column> -->
  275. <el-table-column
  276. prop="printPlanName"
  277. label="印刷计划"
  278. min-width="240"
  279. ></el-table-column>
  280. <el-table-column
  281. prop="courseNameCode"
  282. label="课程(代码)"
  283. min-width="260"
  284. >
  285. </el-table-column>
  286. <el-table-column
  287. prop="paperNumber"
  288. label="试卷编号"
  289. width="160"
  290. ></el-table-column>
  291. <el-table-column
  292. prop="classDesc"
  293. label="班级"
  294. width="160"
  295. ></el-table-column>
  296. <el-table-column
  297. prop="examDate"
  298. label="考试日期"
  299. width="100"
  300. ></el-table-column>
  301. <el-table-column
  302. prop="examTime"
  303. label="考试时间"
  304. width="100"
  305. ></el-table-column>
  306. <el-table-column
  307. prop="packageCode"
  308. label="卷袋编号"
  309. width="160"
  310. ></el-table-column>
  311. <el-table-column
  312. prop="examPlace"
  313. label="考点"
  314. min-width="160"
  315. ></el-table-column>
  316. <el-table-column
  317. prop="examRoom"
  318. label="考场"
  319. min-width="160"
  320. ></el-table-column>
  321. <el-table-column
  322. prop="printHouseName"
  323. label="印刷室"
  324. min-width="160"
  325. ></el-table-column>
  326. <!-- <el-table-column
  327. prop="singlePagesA3"
  328. label="单科次准印量A3(页)"
  329. width="80"
  330. ></el-table-column> -->
  331. <el-table-column
  332. prop="totalSubjects"
  333. label="科次"
  334. width="80"
  335. ></el-table-column>
  336. <!-- <el-table-column
  337. prop="pagesA3"
  338. label="A3准印量小计(页)"
  339. width="80"
  340. ></el-table-column>
  341. <el-table-column
  342. prop="pagesA4"
  343. label="A4准印量小计(页)"
  344. width="80"
  345. ></el-table-column> -->
  346. <el-table-column prop="statusDisplay" label="印刷状态" width="80">
  347. </el-table-column>
  348. <el-table-column prop="validate" label="是否校验" width="80">
  349. <span slot-scope="scope">{{ scope.row.validate ? "是" : "否" }}</span>
  350. </el-table-column>
  351. <el-table-column prop="printStartTime" label="打印开始时间" width="170">
  352. <span slot-scope="scope">{{
  353. scope.row.printStartTime | timestampFilter
  354. }}</span>
  355. </el-table-column>
  356. <el-table-column prop="printEndTime" label="打印完成时间" width="170">
  357. <span slot-scope="scope">{{
  358. scope.row.printEndTime | timestampFilter
  359. }}</span>
  360. </el-table-column>
  361. <el-table-column prop="normal" label="任务状态" width="80">
  362. <span slot-scope="scope">{{
  363. scope.row.normal ? "正常" : "作废"
  364. }}</span>
  365. </el-table-column>
  366. <el-table-column
  367. class-name="action-column"
  368. label="操作"
  369. width="160"
  370. fixed="right"
  371. >
  372. <template slot-scope="scope">
  373. <el-button
  374. v-if="
  375. checkPrivilege('link', 'download') &&
  376. (scope.row.status === 'READY' ||
  377. scope.row.status === 'WAITING' ||
  378. scope.row.status === 'PRINTING' ||
  379. scope.row.status === 'FINISH' ||
  380. scope.row.status === 'CANCEL')
  381. "
  382. class="btn-primary"
  383. type="text"
  384. @click="toActionPdf(scope.row, 'view')"
  385. >预览</el-button
  386. >
  387. <el-button
  388. v-if="
  389. checkPrivilege('link', 'createpdf') &&
  390. (scope.row.status === 'READY' ||
  391. scope.row.status === 'CANCEL' ||
  392. !scope.row.normal)
  393. "
  394. class="btn-primary"
  395. type="text"
  396. @click="toActionPdf(scope.row, 'build')"
  397. >重新生成</el-button
  398. >
  399. <el-button
  400. v-if="
  401. scope.row.status === 'READY' && checkPrivilege('link', 'submit')
  402. "
  403. class="btn-primary"
  404. type="text"
  405. @click="toSubmit(scope.row)"
  406. >提交</el-button
  407. >
  408. <!-- <el-button
  409. v-if="scope.row.status === 'PRINTING'"
  410. class="btn-primary"
  411. type="text"
  412. @click="toResubmit(scope.row)"
  413. >重新提交</el-button> -->
  414. <el-button
  415. v-if="
  416. scope.row.status === 'WAITING' && checkPrivilege('link', 'end')
  417. "
  418. class="btn-danger"
  419. type="text"
  420. @click="toCancel(scope.row)"
  421. >撤回</el-button
  422. >
  423. <el-button
  424. v-if="
  425. (scope.row.status === 'END' || scope.row.status === 'FINISH') &&
  426. checkPrivilege('link', 'normal')
  427. "
  428. :class="scope.row.normal ? 'btn-danger' : 'btn-primary'"
  429. type="text"
  430. @click="toNormal(scope.row)"
  431. >{{ scope.row.normal ? "作废" : "恢复" }}</el-button
  432. >
  433. <!-- <el-button
  434. class="btn-primary"
  435. type="text"
  436. @click="toPreview(scope.row)"
  437. >查看印品模板</el-button> -->
  438. </template>
  439. </el-table-column>
  440. </el-table>
  441. <div class="part-page">
  442. <el-pagination
  443. background
  444. layout="total, sizes, prev, pager, next, jumper"
  445. :pager-count="5"
  446. :current-page="current"
  447. :total="total"
  448. :page-size="size"
  449. @current-change="toPage"
  450. @size-change="pageSizeChange"
  451. >
  452. </el-pagination>
  453. </div>
  454. </div>
  455. <!-- PreviewPrintTaskTemplate-->
  456. <preview-print-task-template
  457. :instance="curTask"
  458. ref="PreviewPrintTaskTemplate"
  459. ></preview-print-task-template>
  460. <!-- pdf-view -->
  461. <el-dialog
  462. class="pdf-view-dialog"
  463. :visible.sync="padViewDialogVisible"
  464. title="请选择PDF类型"
  465. top="10vh"
  466. width="600px"
  467. :close-on-click-modal="false"
  468. :close-on-press-escape="false"
  469. append-to-body
  470. >
  471. <div class="text-center">
  472. <el-button
  473. v-if="actionType === 'build'"
  474. size="large"
  475. @click="actionPdf({ type: undefined })"
  476. >全部</el-button
  477. >
  478. <el-button
  479. v-for="item in pdfList"
  480. :key="item.name"
  481. type="primary"
  482. size="large"
  483. @click="actionPdf(item)"
  484. >{{ item.type | printPdfTypeFilter }}</el-button
  485. >
  486. </div>
  487. <div slot="footer"></div>
  488. </el-dialog>
  489. <!-- data-task-dialog -->
  490. <data-task-dialog
  491. v-if="checkPrivilege('button', 'BatchDownload')"
  492. ref="DataTaskDialog"
  493. task-type="PRINT_PDF_DOWNLOAD"
  494. ></data-task-dialog>
  495. <!-- PreviewFile -->
  496. <preview-file ref="PreviewFile" :data="curFile"></preview-file>
  497. <!-- BarCodeCheck -->
  498. <barCodeCheck
  499. v-if="checkPrivilege('button', 'BatchDownload')"
  500. ref="BarCodeCheck"
  501. :data="filter"
  502. ></barCodeCheck>
  503. </div>
  504. </template>
  505. <script>
  506. import {
  507. printTaskListPage,
  508. submitPrintTask,
  509. resubmitPrintTask,
  510. cancelPrintTask,
  511. batchCancelPrintTask,
  512. printTaskTotalInfo,
  513. getPrintTaskPdf,
  514. downloadPrintTaskPdf,
  515. rebuildPrintTaskPdf,
  516. printTaskNormal,
  517. getPrintTaskWholePdf,
  518. createPrintTaskWholePdf,
  519. } from "../api";
  520. import { PRINT_TASK_STATUS } from "@/constants/enumerate";
  521. import pickerOptions from "@/constants/datePickerOptions";
  522. import { parseTimeRangeDateAndTime } from "@/plugins/utils";
  523. import PreviewPrintTaskTemplate from "../components/PreviewPrintTaskTemplate";
  524. import PreviewFile from "@/components/PreviewFile.vue";
  525. import BarCodeCheck from "../components/BarCodeCheck.vue";
  526. const defaultTotalInfo = {
  527. totalSubjects: 0,
  528. packageCount: 0,
  529. paperCount: 0,
  530. paperPages: 0,
  531. cardPages: 0,
  532. pagesA4: 0,
  533. paperPagesLeft: 0,
  534. cardPagesLeft: 0,
  535. pagesA4Left: 0,
  536. };
  537. export default {
  538. name: "print-task-manage",
  539. components: { PreviewPrintTaskTemplate, PreviewFile, BarCodeCheck },
  540. data() {
  541. return {
  542. filter: {
  543. semesterId: "",
  544. examId: "",
  545. printPlanId: "",
  546. printHouseId: "",
  547. status: "",
  548. courseId: "",
  549. paperNumber: "",
  550. examPlace: "",
  551. examRoom: "",
  552. examStartTime: "",
  553. examEndTime: "",
  554. printStartTime: "",
  555. printEndTime: "",
  556. classDesc: "",
  557. },
  558. searchfilter: {},
  559. current: 1,
  560. size: this.GLOBAL.pageSize,
  561. total: 0,
  562. totalInfo: { ...defaultTotalInfo },
  563. dataList: [],
  564. curRow: {},
  565. multipleSelection: [],
  566. PRINT_TASK_STATUS,
  567. loading: false,
  568. // attachmentId preview
  569. curAttachmentId: "",
  570. // view-pdf
  571. padViewDialogVisible: false,
  572. pdfList: [],
  573. actionType: "view",
  574. // view-template
  575. curTask: {},
  576. // whole pdf
  577. wholePdfInfo: {
  578. status: "INIT",
  579. url: "",
  580. },
  581. pdfLoading: false,
  582. // date-picker
  583. createTime: [],
  584. printTime: [],
  585. pickerOptions,
  586. // preview file
  587. curFile: {
  588. id: "",
  589. type: "",
  590. },
  591. };
  592. },
  593. computed: {
  594. wholePdfBtnName() {
  595. if (this.wholePdfInfo.status === "RUNNING") {
  596. return "生成pdf中...";
  597. }
  598. if (this.wholePdfInfo.status === "FINISH" && this.wholePdfInfo.url) {
  599. return "查看合并PDF";
  600. }
  601. return "生成合并PDF";
  602. },
  603. },
  604. mounted() {
  605. // this.search();
  606. },
  607. methods: {
  608. async getList() {
  609. if (!this.checkPrivilege("list", "list")) return;
  610. const datas = {
  611. ...this.filter,
  612. pageNumber: this.current,
  613. pageSize: this.size,
  614. };
  615. if (this.createTime) {
  616. datas.examStartTime = this.createTime[0];
  617. datas.examEndTime = this.createTime[1];
  618. }
  619. if (this.printTime) {
  620. datas.printStartTime = this.printTime[0];
  621. datas.printEndTime = this.printTime[1];
  622. }
  623. const data = await printTaskListPage(datas);
  624. this.dataList = data.records.map((item) => {
  625. const { date, time } = parseTimeRangeDateAndTime(
  626. item.examStartTime,
  627. item.examEndTime
  628. );
  629. item.examDate = date || "--";
  630. item.examTime = time || "--";
  631. return item;
  632. });
  633. this.total = data.total;
  634. this.searchfilter = { ...this.filter };
  635. },
  636. toPage(page) {
  637. this.current = page;
  638. this.getList();
  639. this.multipleSelection = [];
  640. },
  641. search() {
  642. this.toPage(1);
  643. this.getTotalInfo();
  644. this.fetchWholePdf();
  645. },
  646. printPlanChange() {
  647. this.filter.paperNumber = "";
  648. this.filter.courseId = "";
  649. this.filter.examRoom = "";
  650. this.filter.examPlace = "";
  651. },
  652. async getTotalInfo() {
  653. const datas = {
  654. ...this.filter,
  655. pageNumber: this.current,
  656. pageSize: this.size,
  657. };
  658. if (this.createTime) {
  659. datas.examStartTime = this.createTime[0];
  660. datas.examEndTime = this.createTime[1];
  661. }
  662. const data = await printTaskTotalInfo(datas);
  663. this.totalInfo = data || { ...defaultTotalInfo };
  664. },
  665. handleSelectionChange(val) {
  666. this.multipleSelection = val.map((item) => item.examDetailId);
  667. },
  668. async fetchWholePdf() {
  669. if (!this.checkPrivilege("button", "CreateWholePdf")) return;
  670. if (!this.filter.paperNumber) {
  671. this.wholePdfInfo = { status: "INIT", url: "" };
  672. return;
  673. }
  674. this.wholePdfInfo = await getPrintTaskWholePdf({
  675. examId: this.filter.examId,
  676. courseId: this.filter.courseId,
  677. paperNumber: this.filter.paperNumber,
  678. });
  679. },
  680. async toViewWholePdf() {
  681. if (this.wholePdfInfo.status === "RUNNING") {
  682. return;
  683. }
  684. if (this.wholePdfInfo.url && this.wholePdfInfo.status === "FINISH") {
  685. this.curFile = {
  686. url: this.wholePdfInfo.url,
  687. type: "application/pdf",
  688. };
  689. this.$refs.PreviewFile.open();
  690. // window.open(this.wholePdfInfo.url);
  691. return;
  692. }
  693. if (this.pdfLoading) return;
  694. this.pdfLoading = true;
  695. const res = await createPrintTaskWholePdf({
  696. examId: this.filter.examId,
  697. courseId: this.filter.courseId,
  698. paperNumber: this.filter.paperNumber,
  699. }).catch(() => {});
  700. this.pdfLoading = false;
  701. if (!res) return;
  702. this.$message.success("生成任务已经提交");
  703. this.wholePdfInfo.status = "RUNNING";
  704. },
  705. toPreview(row) {
  706. this.curTask = row;
  707. this.$refs.PreviewPrintTaskTemplate.open();
  708. },
  709. toSubmit(row) {
  710. this.$confirm("确定提交该印刷任务吗?", "提示", {
  711. type: "warning",
  712. })
  713. .then(async () => {
  714. const data = await submitPrintTask(row.examDetailId);
  715. if (!data) return;
  716. this.$message.success("提交成功!");
  717. this.getList();
  718. })
  719. .catch(() => {});
  720. },
  721. toResubmit(row) {
  722. this.$confirm("确定重新提交该印刷任务吗?", "提示", {
  723. type: "warning",
  724. })
  725. .then(async () => {
  726. const data = await resubmitPrintTask({
  727. id: row.examDetailId,
  728. printPlanId: row.printPlanId,
  729. });
  730. if (!data) return;
  731. this.$message.success("提交成功!");
  732. this.getList();
  733. })
  734. .catch(() => {});
  735. },
  736. toCancel(row) {
  737. this.$confirm("确定撤回该印刷任务的提交吗?", "提示", {
  738. type: "warning",
  739. })
  740. .then(async () => {
  741. const data = await cancelPrintTask(row.examDetailId);
  742. if (!data) return;
  743. this.$message.success("撤回成功!");
  744. this.getList();
  745. })
  746. .catch(() => {});
  747. },
  748. toBatchCancelOrSubmit(type) {
  749. const names = {
  750. finish: "完成",
  751. submit: "提交",
  752. cancel: "撤回",
  753. };
  754. const name = names[type];
  755. if (!this.multipleSelection.length) {
  756. this.$message.error(`请选择要${name}的记录!`);
  757. return;
  758. }
  759. this.$confirm(`确定${name}选中的印刷任务的提交吗?`, "提示", {
  760. type: "warning",
  761. })
  762. .then(async () => {
  763. const data = await batchCancelPrintTask(
  764. this.multipleSelection.join(),
  765. type
  766. );
  767. if (!data) return;
  768. this.$message.success("操作成功!");
  769. this.getList();
  770. })
  771. .catch(() => {});
  772. },
  773. async toActionPdf(row, actionType) {
  774. this.curTask = row;
  775. this.actionType = actionType;
  776. this.pdfList = [];
  777. let result = true;
  778. const data = await getPrintTaskPdf(row.examDetailId).catch(() => {
  779. result = false;
  780. });
  781. if (!result) return;
  782. if (!data || !data.length) {
  783. this.$message.error("当前任务pdf还未生成好,请稍后再试!");
  784. return;
  785. }
  786. if (data.length === 1) {
  787. this.actionPdf(data[0]);
  788. } else {
  789. this.pdfList = data;
  790. if (actionType === "build")
  791. this.pdfList = this.pdfList.filter(
  792. (item) => item.type !== "MERGE_PDF"
  793. );
  794. this.padViewDialogVisible = true;
  795. }
  796. },
  797. actionPdf(item) {
  798. if (this.actionType === "view") {
  799. this.viewPdf(item);
  800. } else {
  801. this.rebuildPdf(item);
  802. }
  803. },
  804. async rebuildPdf(item) {
  805. const action = await this.$confirm(
  806. `确定要重新生成该印刷任务PDF吗?`,
  807. "提示",
  808. {
  809. type: "warning",
  810. }
  811. ).catch(() => {});
  812. if (action !== "confirm") return;
  813. const res = await rebuildPrintTaskPdf(
  814. this.curTask.examDetailId,
  815. item.type
  816. );
  817. if (!res) return;
  818. this.$message.success("操作成功!");
  819. this.padViewDialogVisible = false;
  820. this.getList();
  821. },
  822. viewPdf(item) {
  823. this.curFile = {
  824. url: item.url,
  825. type: "application/pdf",
  826. };
  827. this.$refs.PreviewFile.open();
  828. },
  829. async toExport() {
  830. if (this.loading) return;
  831. if (!this.multipleSelection.length) {
  832. this.$message.error("请选择要下载的记录!");
  833. return;
  834. }
  835. this.loading = true;
  836. const data = await downloadPrintTaskPdf({
  837. ids: this.multipleSelection,
  838. semesterId: this.filter.semesterId,
  839. examId: this.filter.examId,
  840. }).catch(() => {});
  841. this.loading = false;
  842. if (!data) return;
  843. this.$message.success("文件下载任务提交成功!");
  844. },
  845. toDataTask() {
  846. this.$refs.DataTaskDialog.open();
  847. },
  848. toBarCheck() {
  849. if (!this.filter.examId) {
  850. this.$message.error("请选择考试!");
  851. return;
  852. }
  853. this.$refs.BarCodeCheck.open();
  854. },
  855. async toNormal(row) {
  856. const typeName = row.normal ? "作废" : "恢复";
  857. const action = await this.$confirm(
  858. `确定${typeName}该印刷任务吗?`,
  859. "提示",
  860. {
  861. type: "warning",
  862. }
  863. ).catch(() => {});
  864. if (action !== "confirm") return;
  865. const data = await printTaskNormal({
  866. id: row.examDetailId,
  867. normal: !row.normal,
  868. });
  869. if (!data) return;
  870. row.normal = !row.normal;
  871. this.$message.success("撤回成功!");
  872. },
  873. },
  874. };
  875. </script>