From 16c398f1dd39a87ae1681eef200fe80e80c2c7b1 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 12 五月 2026 11:26:49 +0800
Subject: [PATCH] 浪潮 1.附件预览、下载修改

---
 src/views/salesManagement/opportunityManagement/fileList.vue |    2 +-
 src/plugins/download.js                                      |   12 +++++++++++-
 src/components/filePreview/index.vue                         |   14 +++++++-------
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/components/filePreview/index.vue b/src/components/filePreview/index.vue
index ddc8429..d8720c3 100644
--- a/src/components/filePreview/index.vue
+++ b/src/components/filePreview/index.vue
@@ -78,9 +78,9 @@
   transformData: (workbookData) => workbookData,
 });
 
-// 璁$畻灞炴�� - 鍒ゆ柇鏂囦欢绫诲瀷
+// 璁$畻灞炴�� - 鍒ゆ柇鏂囦欢绫诲瀷锛堟敮鎸乁RL甯︽煡璇㈠弬鏁帮級
 const isImage = computed(() => {
-  const state = /\.(jpg|jpeg|png|gif)$/i.test(fileUrl.value);
+  const state = /\.(jpg|jpeg|png|gif)(\?.*)?$/i.test(fileUrl.value);
   if (state) {
     imgUrl.value = fileUrl.value.replaceAll('word', 'img');
   }
@@ -89,23 +89,23 @@
 
 const isPdf = computed(() => {
   console.log(fileUrl.value)
-  return /\.pdf$/i.test(fileUrl.value);
+  return /\.pdf(\?.*)?$/i.test(fileUrl.value);
 });
 
 const isDoc = computed(() => {
-  return /\.(doc|docx)$/i.test(fileUrl.value);
+  return /\.(doc|docx)(\?.*)?$/i.test(fileUrl.value);
 });
 
 const isXls = computed(() => {
-  const state = /\.(xls|xlsx)$/i.test(fileUrl.value);
+  const state = /\.(xls|xlsx)(\?.*)?$/i.test(fileUrl.value);
   if (state) {
-    options.value.xls = /\.(xls)$/i.test(fileUrl.value);
+    options.value.xls = /\.(xls)(\?.*)?$/i.test(fileUrl.value);
   }
   return state;
 });
 
 const isZipOrRar = computed(() => {
-  return /\.(zip|rar)$/i.test(fileUrl.value);
+  return /\.(zip|rar)(\?.*)?$/i.test(fileUrl.value);
 });
 
 const isSupported = computed(() => {
diff --git a/src/plugins/download.js b/src/plugins/download.js
index 2705310..e59d41a 100644
--- a/src/plugins/download.js
+++ b/src/plugins/download.js
@@ -1,4 +1,4 @@
-锘縤mport axios from "axios";
+import axios from "axios";
 import { ElLoading, ElMessage } from "element-plus";
 import { saveAs } from "file-saver";
 import { getToken } from "@/utils/auth";
@@ -82,6 +82,16 @@
   saveAs(text, name, opts) {
     saveAs(text, name, opts);
   },
+  byUrl(url, filename) {
+    // 灏哢RL涓殑preview鏇挎崲鎴恉ownload
+    const downloadUrl = url.replace(/preview/g, 'download')
+    const link = document.createElement('a')
+    link.href = downloadUrl
+    link.download = filename || ''
+    document.body.appendChild(link)
+    link.click()
+    document.body.removeChild(link)
+  },
   async printErrMsg(data) {
     const resText = await data.text();
     const rspObj = JSON.parse(resText);
diff --git a/src/views/salesManagement/opportunityManagement/fileList.vue b/src/views/salesManagement/opportunityManagement/fileList.vue
index 6ed631a..cfc4662 100644
--- a/src/views/salesManagement/opportunityManagement/fileList.vue
+++ b/src/views/salesManagement/opportunityManagement/fileList.vue
@@ -38,7 +38,7 @@
 }
 
 const downLoadFile = (row) => {
-  proxy.$download.name(row.url);
+  proxy.$download.byUrl(row.url, row.originalFilename);
 }
 
 const lookFile = (row) => {

--
Gitblit v1.9.3