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/reportLibrary/verificationRelease/components/approval/index.vue |   80 +++++++++++++++++++++------------------
 1 files changed, 43 insertions(+), 37 deletions(-)

diff --git a/laboratory/src/views/reportLibrary/verificationRelease/components/approval/index.vue b/laboratory/src/views/reportLibrary/verificationRelease/components/approval/index.vue
index 15cb70c..f8011cb 100644
--- a/laboratory/src/views/reportLibrary/verificationRelease/components/approval/index.vue
+++ b/laboratory/src/views/reportLibrary/verificationRelease/components/approval/index.vue
@@ -1,6 +1,6 @@
 <template>
-    <el-dialog :title="dialogTitle" :visible.sync="visible" width="90%" top="5vh" @open="open" po :close-on-click-modal="false"
-        @close="handleClose">
+    <el-dialog :title="dialogTitle" :visible.sync="visible" width="90%" top="5vh" @open="open" po
+        :close-on-click-modal="false" @close="handleClose">
         <div class="approval-dialog" :style="{ height: obj.isDetail ? '80vh' : '60vh' }">
             <!-- 左侧审批内容 -->
             <div class="approval-content">
@@ -63,11 +63,7 @@
                                 </div>
                             </div>
                             <el-form-item prop="feasibilityReportFiles" style="margin-top: -18px">
-                                <el-upload
-                                disabled
-                                :on-preview="handlePreview"
-                                    :file-list="fileList"
-                                />
+                                <el-upload disabled :on-preview="handlePreview" :file-list="fileList" />
                             </el-form-item>
 
                         </el-form>
@@ -118,7 +114,7 @@
 import ApprovalProcess from '@/components/approvalProcess'
 import AiEditor from '@/components/AiEditor'
 import { getDetail } from '../../service';
-import { customUploadRequest, getFullUrl } from "@/utils/utils";
+import { customUploadRequest, getFullUrl, getAllocateIp , downloadFileByUrl, isImageFile } from "@/utils/utils";
 import apiConfig from '@/utils/baseurl';
 
 
@@ -159,10 +155,10 @@
                 updateBy: "",
                 auditRemark: "",
                 auditPersonName: "",
-                feasibilityReportFiles:[],
+                feasibilityReportFiles: [],
                 auditTime: ""
             },
-            fileList:[],
+            fileList: [],
             tableData: [],
             rules: {},
             status: "2",
@@ -177,16 +173,26 @@
     methods: {
         getFullUrl,
         handlePreview(file) {
-            console.log('url', file)
-            if (file && file.url) {
-                if (file.url && file.url.startsWith(apiConfig.showImgUrl)) {
-                    window.open(file.url, '_blank');
-                }else{
-                    let newUrl=apiConfig.showImgUrl+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);
+        }
+      }
+    },
         open() {
             if (!this.obj.id) {
                 this.$message.error('缺少必要参数');
@@ -205,22 +211,22 @@
                     processData: []
                 };
                 if (
-            data.feasibilityReportFiles &&
-            data.feasibilityReportFiles.length > 0
-          ) {
-            this.fileList =
-              data.feasibilityReportFiles.map((file) => {
-                return {
-                  name: file.fileName,
-                  url: getFullUrl(file.fileUrl),
-                  uid: file.id,
-                };
-              });
-            this.form.feasibilityReportFiles =data.feasibilityReportFiles
-          } else {
-            this.fileList = [];
-            this.form.feasibilityReportFiles = [];
-          }
+                    data.feasibilityReportFiles &&
+                    data.feasibilityReportFiles.length > 0
+                ) {
+                    this.fileList =
+                        data.feasibilityReportFiles.map((file) => {
+                            return {
+                                name: file.fileName,
+                                url: getFullUrl(file.fileUrl),
+                                uid: file.id,
+                            };
+                        });
+                    this.form.feasibilityReportFiles = data.feasibilityReportFiles
+                } else {
+                    this.fileList = [];
+                    this.form.feasibilityReportFiles = [];
+                }
 
                 this.tableData = data.projectTeam ?
                     [{ ...data.projectTeam, staffName: data.staffNames || '' }] :
@@ -237,7 +243,7 @@
                     ]
                 });
 
-                if (data.status == 2 || data.status == 4|| data.status==3) {
+                if (data.status == 2 || data.status == 4 || data.status == 3) {
                     processData.push({
                         type: "primary",
                         mode: "list",

--
Gitblit v1.7.1