Explorar o código

feat: pdf预览02

zhangjie hai 8 meses
pai
achega
8df908fd40

+ 27 - 2
src/modules/exam/components/ModifyTaskPaper.vue

@@ -278,6 +278,8 @@
       ref="PreviewAttachment"
       :attachment-ids="attachmentIds"
     ></preview-attachment>
+    <!-- PreviewFile -->
+    <preview-file ref="PreviewFile" :data="curFile"></preview-file>
   </div>
 </template>
 
@@ -286,7 +288,10 @@ import UploadPaperDialog from "./UploadPaperDialog";
 import ModifyCard from "../../card/components/ModifyCard";
 import CardPreviewDialog from "../../card/components/CardPreviewDialog.vue";
 import PreviewAttachment from "@/components/PreviewAttachment.vue";
+import PreviewFile from "@/components/PreviewFile.vue";
+
 import { taskApplyDetail, taskPaperApplyEdit, cardForSelectList } from "../api";
+import { attachmentPreview } from "../../login/api";
 import { COMMON_CARD_RULE_ID } from "@/constants/enumerate";
 import { copyCard } from "../../card/api";
 
@@ -318,6 +323,7 @@ export default {
     ModifyCard,
     CardPreviewDialog,
     PreviewAttachment,
+    PreviewFile,
   },
   props: {
     instance: {
@@ -381,6 +387,11 @@ export default {
       user: this.$ls.get("user", {}),
       // attachmentId preview
       attachmentIds: [],
+      // preview file
+      curFile: {
+        url: "",
+        type: "",
+      },
     };
   },
   methods: {
@@ -485,11 +496,25 @@ export default {
         this.paperAttachments.splice(index, 1, { ...attachment });
       }
     },
-    toViewAttachment(attachment) {
+    async toViewAttachment(attachment) {
       if (!attachment.jpgAttachmentId) {
-        this.$message.error("附件丢失!");
+        if (!attachment.attachmentId) {
+          this.$message.error("附件丢失!");
+          return;
+        }
+        const data = await attachmentPreview(attachment.attachmentId);
+        if (!data[0].url) {
+          this.$message.error("附件丢失!");
+          return;
+        }
+        this.curFile = {
+          url: data[0].url,
+          type: "application/pdf",
+        };
+        this.$refs.PreviewFile.open();
         return;
       }
+
       const datas = JSON.parse(attachment.jpgAttachmentId);
       this.attachmentIds = datas.map((item) => item.attachmentId);
       this.$refs.PreviewAttachment.open();

+ 33 - 3
src/modules/exam/components/taskApply/ModifyTaskApply.vue

@@ -49,6 +49,8 @@
       ref="PreviewAttachment"
       :attachment-ids="attachmentIds"
     ></preview-attachment>
+    <!-- PreviewFile -->
+    <preview-file ref="PreviewFile" :data="curFile"></preview-file>
   </div>
 </template>
 
@@ -67,6 +69,8 @@ import TaskPaper from "./TaskPaper.vue";
 import TaskPrint from "./TaskPrint.vue";
 import TaskFlow from "./TaskFlow.vue";
 import PreviewAttachment from "@/components/PreviewAttachment.vue";
+import PreviewFile from "@/components/PreviewFile.vue";
+import { attachmentPreview } from "@/modules/login/api";
 
 const initExamTask = {
   id: null,
@@ -138,7 +142,14 @@ const initTaskApply = {
 
 export default {
   name: "modify-task-apply",
-  components: { TaskInfo, TaskPaper, TaskFlow, TaskPrint, PreviewAttachment },
+  components: {
+    TaskInfo,
+    TaskPaper,
+    TaskFlow,
+    TaskPrint,
+    PreviewAttachment,
+    PreviewFile,
+  },
   props: {
     rowData: {
       type: Object,
@@ -188,6 +199,11 @@ export default {
       examRule: {},
       dataReady: false,
       attachmentIds: [],
+      // preview file
+      curFile: {
+        url: "",
+        type: "",
+      },
     };
   },
   created() {
@@ -284,11 +300,25 @@ export default {
       this.cancel();
       this.$emit("modified");
     },
-    toViewAttachment(attachment) {
+    async toViewAttachment(attachment) {
       if (!attachment.jpgAttachmentId) {
-        this.$message.error("附件丢失!");
+        if (!attachment.attachmentId) {
+          this.$message.error("附件丢失!");
+          return;
+        }
+        const data = await attachmentPreview(attachment.attachmentId);
+        if (!data[0].url) {
+          this.$message.error("附件丢失!");
+          return;
+        }
+        this.curFile = {
+          url: data[0].url,
+          type: "application/pdf",
+        };
+        this.$refs.PreviewFile.open();
         return;
       }
+
       const datas = JSON.parse(attachment.jpgAttachmentId);
       this.attachmentIds = datas.map((item) => item.attachmentId);
       this.$refs.PreviewAttachment.open();

+ 16 - 2
src/modules/mark/components/markParam/MarkParamSubjectiveAnswer.vue

@@ -41,6 +41,9 @@
       >
       <el-button @click="cancel">取消</el-button>
     </div>
+
+    <!-- PreviewFile -->
+    <preview-file ref="PreviewFile" :data="curFile"></preview-file>
   </div>
 </template>
 
@@ -51,10 +54,11 @@ import {
   markSubjectiveQuestionUpload,
 } from "../../api";
 import SelectFile from "@/components/SelectFile.vue";
+import PreviewFile from "@/components/PreviewFile.vue";
 
 export default {
   name: "mark-param-subjective-answer",
-  components: { SelectFile },
+  components: { SelectFile, PreviewFile },
   data() {
     return {
       modalIsShow: false,
@@ -62,6 +66,11 @@ export default {
       infos: { file: null, md5: null, errorMsg: null },
       fileFormat: ["pdf"],
       answerFileUrl: "",
+      // preview file
+      curFile: {
+        url: "",
+        type: "",
+      },
     };
   },
   computed: {
@@ -83,7 +92,12 @@ export default {
       this.answerFileUrl = res || "";
     },
     toViewAnswer() {
-      window.open(this.answerFileUrl);
+      // window.open(this.answerFileUrl);
+      this.curFile = {
+        url: this.answerFileUrl,
+        type: "application/pdf",
+      };
+      this.$refs.PreviewFile.open();
     },
     fileChange(data) {
       if (data.errorMsg) {

+ 26 - 3
src/modules/print/components/ModifyPlanPaper.vue

@@ -151,13 +151,17 @@
       ref="PreviewAttachment"
       :attachment-ids="attachmentIds"
     ></preview-attachment>
+    <!-- PreviewFile -->
+    <preview-file ref="PreviewFile" :data="curFile"></preview-file>
   </div>
 </template>
 
 <script>
 import { updatePlanLinkPaper, linkPaperNumberList } from "../api";
 import { taskApplyDetail } from "../../exam/api";
+import { attachmentPreview } from "../../login/api";
 import PreviewAttachment from "@/components/PreviewAttachment.vue";
+import PreviewFile from "@/components/PreviewFile.vue";
 
 const initModalForm = {
   id: null,
@@ -168,7 +172,7 @@ const initModalForm = {
 
 export default {
   name: "modify-plan-paper",
-  components: { PreviewAttachment },
+  components: { PreviewAttachment, PreviewFile },
   props: {
     instance: {
       type: Object,
@@ -215,6 +219,11 @@ export default {
       },
       // attachmentId preview
       attachmentIds: [],
+      // preview file
+      curFile: {
+        url: "",
+        type: "",
+      },
     };
   },
   methods: {
@@ -274,11 +283,25 @@ export default {
       );
       if (paper) this.paperTypes = paper.paperTypes;
     },
-    toViewAttachment(attachment) {
+    async toViewAttachment(attachment) {
       if (!attachment.jpgAttachmentId) {
-        this.$message.error("附件丢失!");
+        if (!attachment.attachmentId) {
+          this.$message.error("附件丢失!");
+          return;
+        }
+        const data = await attachmentPreview(attachment.attachmentId);
+        if (!data[0].url) {
+          this.$message.error("附件丢失!");
+          return;
+        }
+        this.curFile = {
+          url: data[0].url,
+          type: "application/pdf",
+        };
+        this.$refs.PreviewFile.open();
         return;
       }
+
       const datas = JSON.parse(attachment.jpgAttachmentId);
       this.attachmentIds = datas.map((item) => item.attachmentId);
       this.$refs.PreviewAttachment.open();

+ 22 - 4
src/modules/print/views/PrintTaskManage.vue

@@ -479,6 +479,9 @@
       ref="PreviewAttachment"
       :attachment-id="curAttachmentId"
     ></preview-attachment>
+
+    <!-- PreviewFile -->
+    <preview-file ref="PreviewFile" :data="curFile"></preview-file>
   </div>
 </template>
 
@@ -502,6 +505,7 @@ import pickerOptions from "@/constants/datePickerOptions";
 import { parseTimeRangeDateAndTime } from "@/plugins/utils";
 import PreviewPrintTaskTemplate from "../components/PreviewPrintTaskTemplate";
 import PreviewAttachment from "@/components/PreviewAttachment.vue";
+import PreviewFile from "@/components/PreviewFile.vue";
 
 const defaultTotalInfo = {
   totalSubjects: 0,
@@ -517,7 +521,7 @@ const defaultTotalInfo = {
 
 export default {
   name: "print-task-manage",
-  components: { PreviewPrintTaskTemplate, PreviewAttachment },
+  components: { PreviewPrintTaskTemplate, PreviewAttachment, PreviewFile },
   data() {
     return {
       filter: {
@@ -563,6 +567,11 @@ export default {
       createTime: [],
       printTime: [],
       pickerOptions,
+      // preview file
+      curFile: {
+        url: "",
+        type: "",
+      },
     };
   },
   computed: {
@@ -659,7 +668,12 @@ export default {
         return;
       }
       if (this.wholePdfInfo.url && this.wholePdfInfo.status === "FINISH") {
-        window.open(this.wholePdfInfo.url);
+        this.curFile = {
+          url: this.wholePdfInfo.url,
+          type: "application/pdf",
+        };
+        this.$refs.PreviewFile.open();
+        // window.open(this.wholePdfInfo.url);
         return;
       }
 
@@ -800,8 +814,12 @@ export default {
       this.getList();
     },
     viewPdf(item) {
-      // TODO:
-      window.open(item.url);
+      this.curFile = {
+        url: item.url,
+        type: "application/pdf",
+      };
+      this.$refs.PreviewFile.open();
+      // window.open(item.url);
       // this.padViewDialogVisible = false;
     },
     async toExport() {