From fe6509e66e6852f6b5d740385bdae4fd0a11da77 Mon Sep 17 00:00:00 2001
From: 董国庆 <364620639@qq.com>
Date: 星期二, 21 十月 2025 14:55:05 +0800
Subject: [PATCH] 修改问题

---
 laboratory/src/views/chemistQa/productApproval/components/approval/index.vue |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/laboratory/src/views/chemistQa/productApproval/components/approval/index.vue b/laboratory/src/views/chemistQa/productApproval/components/approval/index.vue
index 88dc505..dbe3b34 100644
--- a/laboratory/src/views/chemistQa/productApproval/components/approval/index.vue
+++ b/laboratory/src/views/chemistQa/productApproval/components/approval/index.vue
@@ -112,7 +112,7 @@
 import AiEditor from '@/components/AiEditor'
 import { getDetail, audit } from '../../service'
 import apiConfig from '@/utils/baseurl';
-import { getAllocateIp } from '@/utils/utils'
+import { getAllocateIp, downloadFileByUrl, isImageFile  } from '@/utils/utils'
 
 export default {
     name: "ApprovalDialog",
@@ -176,16 +176,26 @@
     },
     methods: {
         handlePreview(file) {
-            console.log('url', file)
-            if (file && file.url) {
-                if (file.url && file.url.startsWith(getAllocateIp())) {
-                    window.open(file.url, '_blank');
-                } else {
-                    let newUrl = getAllocateIp() + file.url;
-                    window.open(newUrl, '_blank');
-                }
-            }
-        },
+      if (file && file.url) {
+        // 判断是否为图片文件
+        const isImage = isImageFile(file.url);
+        
+        if (isImage) {
+          // 图片文件:使用 window.open 预览
+          if (file.url && file.url.startsWith(getAllocateIp())) {
+            console.log('图片链接', file.url)
+            window.open(file.url, '_blank');
+          } else {
+            let newUrl = getAllocateIp() + file.url;
+            console.log('图片链接', newUrl)
+            window.open(newUrl, '_blank');
+          }
+        } else {
+          // 非图片文件:使用下载方式
+          downloadFileByUrl(file.url, file.name);
+        }
+      }
+    },
         getDetail() {
             getDetail(this.data.id).then(res => {
                 if (res) {

--
Gitblit v1.7.1