Przeglądaj źródła

update 预览pdf

linweizeng 2 lat temu
rodzic
commit
8feb6c97e3
1 zmienionych plików z 21 dodań i 5 usunięć
  1. 21 5
      src/components/ibps-file-viewer/index.vue

+ 21 - 5
src/components/ibps-file-viewer/index.vue

@@ -6,7 +6,7 @@
             :url-list="[url]"
             :on-close="closeDialog"
         />
-        <!-- <template v-if="fileType !== 'image' && fileType">
+        <template v-if="fileType !== 'image' && fileType">
             <el-dialog
                 :visible.sync="dialogVisible"
                 :title="title"
@@ -25,7 +25,7 @@
                 />
                 <div v-else class="lc-fixed-navbar">不支持预览的类型</div>
             </el-dialog>
-        </template> -->
+        </template>
     </div>
 </template>
 <script>
@@ -44,6 +44,7 @@
     // import AudioViewer from './audio' //xianyifan
     // import VideoViewer from './video' //xianyifan
     // import TxtViewer from './txt'
+    import pdfViewer from './pdf/index'
     import { officeType, pdfType, txtType, imageType, audioType, videoType } from './constants'
     import PopupManager from '@/utils/popup'
     import editor from '@/business/platform/file/attachment/editFile/editor.vue'
@@ -54,7 +55,8 @@
             // AudioViewer,
             // VideoViewer,
             // TxtViewer,
-            editor
+            editor,
+            pdfViewer
         },
         props: {
             visible: {
@@ -74,6 +76,10 @@
             optionFile: {
                 type: Object,
                 default: () => {}
+            },
+            file:{
+                type: String,
+                require: ''
             }
         },
         data() {
@@ -99,7 +105,7 @@
             }
         },
         watch: {
-            visible: {
+            optionFile: {
                 handler: function (val, oldVal) {
                     this.dialogVisible = this.visible
                     this.loadViewer()
@@ -120,17 +126,27 @@
                 return PopupManager.getZIndex()
             },
             loadViewer() {
+                var flag = true;
+                if (/Mobi|Android|iPhone|iPad/i.test(navigator.userAgent)) {
+                    flag = false
+                }
                 if (imageType.includes(this.fileExt)) {
                     this.dialogVisible = false
                     this.zIndex = this.fixZIndex()
                     this.fileUrl = this.url
                     this.fileType = 'image'
+                } else if(flag && pdfType.includes(this.fileExt)){
+                    this.fileType = 'pdf'
+                    this.$nextTick(() => {
+                        this.$refs.viewer.load(this.url)
+                    })
+
                 } else {
                     this.openDialog() // 先初始化调用参数
                     this.openWindow() // 打开外部预览页面
                     this.closeDialog() // 关闭当前
                     // this.fileType = 'FILE'
-                } 
+                }
                 // else if (
                 //     officeType.includes(this.fileExt) ||
                 //     pdfType.includes(this.fileExt)