Jelajahi Sumber

feat: 印刷任务导出pdf

zhangjie 1 tahun lalu
induk
melakukan
6bc1cfe2f5

+ 1 - 1
src/modules/admin/views/SchoolManage.vue

@@ -42,7 +42,7 @@
 
     <div class="part-box part-box-pad">
       <el-table ref="TableList" :data="dataList">
-        <el-table-column type="index" label="序号" width="70"></el-table-column>
+        <el-table-column prop="id" label="Id" width="80"></el-table-column>
         <el-table-column
           prop="name"
           label="学校名称"

+ 5 - 0
src/modules/exam/views/PdfBuildManage.vue

@@ -123,6 +123,11 @@
             scope.row.examEndTime | timestampFilter
           }}</span>
         </el-table-column>
+        <el-table-column prop="updateTime" label="完成时间" width="170">
+          <span slot-scope="scope">{{
+            scope.row.updateTime | timestampFilter
+          }}</span>
+        </el-table-column>
         <el-table-column
           class-name="action-column"
           label="操作"

+ 8 - 0
src/modules/print/api.js

@@ -138,3 +138,11 @@ export const printTaskTemplateView = (printPlanId) => {
 export const printTaskNormal = ({ id, normal }) => {
   return $post("/api/admin/exam/print/task_normal", { id, normal });
 };
+export const getPrintTaskWholePdf = (datas) => {
+  // examId,courseId,paperNumber
+  return $postParam("/api/admin/exam/print/get_whole_pdf", datas);
+};
+export const createPrintTaskWholePdf = (datas) => {
+  // examId,courseId,paperNumber
+  return $postParam("/api/admin/exam/print/create_whole_pdf", datas);
+};

+ 67 - 1
src/modules/print/views/PrintTaskManage.vue

@@ -122,7 +122,18 @@
         </el-form-item>
       </el-form>
       <div class="box-justify">
-        <div></div>
+        <div>
+          <el-button
+            v-if="checkPrivilege('button', 'CreateWholePdf')"
+            icon="el-icon-document"
+            :disabled="!searchfilter.paperNumber"
+            :loading="pdfLoading"
+            :type="wholePdfInfo.status === 'RUNNING' ? 'default' : 'success'"
+            @click="toViewWholePdf"
+          >
+            {{ wholePdfBtnName }}
+          </el-button>
+        </div>
         <div>
           <el-button
             v-if="checkPrivilege('button', 'BatchEnd')"
@@ -475,6 +486,8 @@ import {
   downloadPrintTaskPdf,
   rebuildPrintTaskPdf,
   printTaskNormal,
+  getPrintTaskWholePdf,
+  createPrintTaskWholePdf,
 } from "../api";
 import { PRINT_TASK_STATUS } from "@/constants/enumerate";
 import pickerOptions from "@/constants/datePickerOptions";
@@ -529,12 +542,29 @@ export default {
       actionType: "view",
       // view-template
       curTask: {},
+      // whole pdf
+      wholePdfInfo: {
+        status: "INIT",
+        url: "",
+      },
+      pdfLoading: false,
       // date-picker
       createTime: [],
       printTime: [],
       pickerOptions,
     };
   },
+  computed: {
+    wholePdfBtnName() {
+      if (this.wholePdfInfo.status === "RUNNING") {
+        return "生成pdf中...";
+      }
+      if (this.wholePdfInfo.status === "FINISH" && this.wholePdfInfo.url) {
+        return "查看合并PDF";
+      }
+      return "生成合并PDF";
+    },
+  },
   mounted() {
     // this.search();
   },
@@ -576,7 +606,9 @@ export default {
     search() {
       this.toPage(1);
       this.getTotalInfo();
+      this.fetchWholePdf();
     },
+
     printPlanChange() {
       this.filter.paperNumber = "";
       this.filter.courseId = "";
@@ -599,6 +631,40 @@ export default {
     handleSelectionChange(val) {
       this.multipleSelection = val.map((item) => item.examDetailId);
     },
+    async fetchWholePdf() {
+      if (!this.filter.paperNumber) {
+        this.wholePdfInfo = { status: "INIT", url: "" };
+        return;
+      }
+      this.wholePdfInfo = await getPrintTaskWholePdf({
+        examId: this.filter.examId,
+        courseId: this.filter.courseId,
+        paperNumber: this.filter.paperNumber,
+      });
+    },
+    async toViewWholePdf() {
+      if (this.wholePdfInfo.status === "RUNNING") {
+        return;
+      }
+      if (this.wholePdfInfo.url && this.wholePdfInfo.status === "FINISH") {
+        window.open(this.wholePdfInfo.url);
+        return;
+      }
+
+      if (this.pdfLoading) return;
+      this.pdfLoading = true;
+
+      const res = await createPrintTaskWholePdf({
+        examId: this.filter.examId,
+        courseId: this.filter.courseId,
+        paperNumber: this.filter.paperNumber,
+      }).catch(() => {});
+      this.pdfLoading = false;
+
+      if (!res) return;
+      this.$message.success("生成任务已经提交");
+      this.wholePdfInfo.status = "RUNNING";
+    },
     toPreview(row) {
       this.curTask = row;
       this.$refs.PreviewPrintTaskTemplate.open();