From 10638dc89f1cd2a20c4035383a66192da5dfbccd Mon Sep 17 00:00:00 2001
From: 董国庆 <364620639@qq.com>
Date: 星期三, 17 十二月 2025 11:04:34 +0800
Subject: [PATCH] 修改文件图片回显

---
 culture/src/views/strainReportLibrary/reportLibraryOneFour/components/approval/index.vue |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/culture/src/views/strainReportLibrary/reportLibraryOneFour/components/approval/index.vue b/culture/src/views/strainReportLibrary/reportLibraryOneFour/components/approval/index.vue
index f348780..f612516 100644
--- a/culture/src/views/strainReportLibrary/reportLibraryOneFour/components/approval/index.vue
+++ b/culture/src/views/strainReportLibrary/reportLibraryOneFour/components/approval/index.vue
@@ -58,7 +58,8 @@
                             </el-form-item>
 
                             <el-form-item prop="name" style="margin-top: 38px">
-                                <el-upload action="#" :file-list="fileList" disabled list-type="text" :on-preview="handlePreview">
+                                <el-upload action="#" :file-list="fileList" disabled list-type="text"
+                                    :on-preview="handlePreview">
                                     <el-button size="small" type="primary">点击上传</el-button>
                                     <div slot="tip" class="el-upload__tip">支持任意格式文件上传</div>
                                 </el-upload>
@@ -153,6 +154,7 @@
 import ApprovalProcess from '@/components/approvalProcess'
 import AiEditor from '@/components/AiEditor'
 import { getDetail } from '../../service';
+import { getAllocateIp, downloadFileByUrl, isImageFile } from '@/utils/utils';
 
 
 export default {
@@ -197,7 +199,7 @@
                 auditPersonName: "",
                 auditTime: ""
             },
-            fileList:[],
+            fileList: [],
             assessmentTable: [
                 {
                     category: '1.该分题的菌种专业知识',
@@ -252,10 +254,24 @@
     },
     methods: {
         handlePreview(file) {
-            if (file.url) {
-                window.open(file.url, '_blank');
-            } else {
-                this.$message.warning('无可预览地址');
+            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() {
@@ -272,7 +288,7 @@
                     processData: []
                 };
 
-                let arr = (data.evaluate||'').split(',')
+                let arr = (data.evaluate || '').split(',')
                 this.fileList = (data.enclosureUrl ? JSON.parse(data.enclosureUrl) : [])
                 this.assessmentTable = this.assessmentTable.map((item, index) => {
                     item.selectedScore = Number(arr[index])

--
Gitblit v1.7.1