PrintTaskManage.vue 25 KB

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