瀏覽代碼

pdf查看

lsc 3 年之前
父節點
當前提交
f5aba27082
共有 1 個文件被更改,包括 17 次插入2 次删除
  1. 17 2
      src/components/study.vue

+ 17 - 2
src/components/study.vue

@@ -1447,7 +1447,7 @@
               </div>
               <input
                 type="file"
-                accept="application/.ppt, .pptx, .xlsx, .xls, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, image/png, image/gif, image/jpeg"
+                accept="application/pdf, application/.ppt, .pptx, .xlsx, .xls, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, image/png, image/gif, image/jpeg"
                 style="display: none"
                 @change="beforeUpload1($event, 1)"
               />
@@ -1705,7 +1705,13 @@
       :before-close="handleClose"
       class="dialog_diy"
     >
+      <pdf
+        v-if="showPDF"
+        :pdfUrl="pptImgUrl"
+        style="width: 100%; height: 520px; overflow: auto"
+      ></pdf>
       <iframe
+        v-else
         :src="pptImgUrl"
         frameborder="0"
         width="100%"
@@ -1926,6 +1932,7 @@ export default {
       timer: null,
       showType: 0,
       fileType: 0,
+      showPDF: false,
     };
   },
   methods: {
@@ -2751,13 +2758,21 @@ export default {
     },
     openFile(f) {
       this.pptImgUrl = "";
-      var a = ["PPT", "PPTX", "PDF", "XLSX", "XLS", "DOC", "DOCX"];
+      var a = ["PPT", "PPTX", "XLSX", "XLS", "DOC", "DOCX"];
       if (
         a.indexOf(f.split(".")[f.split(".").length - 1].toLocaleUpperCase()) !=
         -1
       ) {
         this.pptImgUrl =
           "https://view.officeapps.live.com/op/view.aspx?src=" + f;
+        this.showPDF = false;
+        this.dialogVisible3 = true;
+      } else if (
+        f.split(".")[f.split(".").length - 1].toLocaleUpperCase() ==
+        "PDF"
+      ) {
+        this.pptImgUrl = f;
+        this.showPDF = true;
         this.dialogVisible3 = true;
       }
     },