Sfoglia il codice sorgente

fix:文件预览增加一个fileType

lazy 6 mesi fa
parent
commit
003b102ac6
1 ha cambiato i file con 10 aggiunte e 5 eliminazioni
  1. 10 5
      src/components/Upload/index.vue

+ 10 - 5
src/components/Upload/index.vue

@@ -170,7 +170,8 @@ export default {
             originalName: data.originalName,
             path: data.path,
             absolutePath: data.absolutePath,
-            type: data.type
+            type: data.type,
+            fileType: data.fileType
           }
         } else {
           return item
@@ -184,7 +185,7 @@ export default {
       handler(newV) {
         if (newV.length) {
           this.fileLists = newV.map(item => {
-            const { id, path, originalName, absolutePath, type } = item
+            const { id, path, originalName, absolutePath, type, fileType } = item
             return {
               id,
               url: path,
@@ -192,7 +193,8 @@ export default {
               originalName,
               path,
               absolutePath,
-              type
+              type,
+              fileType
             }
           })
         } else {
@@ -429,24 +431,27 @@ export default {
       var name = ''
       var absolutePath = ''
       var type = ''
+      var fileType = ''
       if (file.response) {
         const { response: { data }} = file
         idNum = data.id
         name = data.originalName || data.name
         absolutePath = data.absolutePath
         type = data.type
+        fileType = data.fileType
       } else {
         idNum = file.id
         name = file.name
         absolutePath = file.absolutePath
         type = file.type
+        fileType = file.fileType
       }
       // window.open(`#/perview?fileId=${idNum}&name=${name}&absolutePath=${absolutePath}`)
       const imgType = ['.jpg', '.png', '.jpeg', '.gif', '.bmp']
-      if (imgType.includes(type.toLowerCase())) {
+      if ((type && imgType.includes(type.toLowerCase())) || imgType.includes(fileType?.toLowerCase())) {
         window.open(`#/perview?fileId=${idNum}&name=${name}&absolutePath=${absolutePath}`)
       } else {
-        window.open(`${process.env.VUE_APP_BASE_API}/system/fileStorage/preview?fileId=${idNum}`)
+        window.open(`${process.env.VUE_APP_BASE_API}/system/fileStorage/preview?fileId=${idNum}&resource=${fileType ? 0 : 1}`)
       }
     },
     downloadClick(row) {