From 30b96c334bf080ece9bdeac1a1b65f0e62bf9f87 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期一, 24 三月 2025 09:49:58 +0800
Subject: [PATCH] 下载,预览

---
 src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue |   32 +++++++++++-----
 src/components/Preview/filePreview.vue                                                |   36 +++++++++++++----
 src/views/structural/capabilityAndLaboratory/workshop/components/fileList.vue         |    4 +
 3 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/src/components/Preview/filePreview.vue b/src/components/Preview/filePreview.vue
index 7633c5e..4b0d62d 100644
--- a/src/components/Preview/filePreview.vue
+++ b/src/components/Preview/filePreview.vue
@@ -82,7 +82,7 @@
         minRowLength: 0,  // excel鏈�灏戞覆鏌撳灏戣锛屽鏋滄兂瀹炵幇鏍规嵁xlsx瀹為檯鍑芥暟娓叉煋锛屽彲浠ュ皢姝ゅ�艰缃负0.
         widthOffset: 10,  //濡傛灉娓叉煋鍑烘潵鐨勭粨鏋滄劅瑙夊崟鍏冩牸瀹藉害涓嶅锛屽彲浠ュ湪榛樿娓叉煋鐨勫垪琛ㄥ搴︿笂鍐嶅姞 Npx瀹�
         heightOffset: 10, //鍦ㄩ粯璁ゆ覆鏌撶殑鍒楄〃楂樺害涓婂啀鍔� Npx楂�
-        beforeTransformData: (workbookData) => { return workbookData }, //搴曞眰閫氳繃exceljs鑾峰彇excel鏂囦欢鍐呭锛岄�氳繃璇ラ挬瀛愬嚱鏁帮紝鍙互瀵硅幏鍙栫殑excel鏂囦欢鍐呭杩涜淇敼锛屾瘮濡傛煇涓崟鍏冩牸鐨勬暟鎹樉绀轰笉姝g‘锛屽彲浠ュ湪姝よ嚜琛屼慨鏀规瘡涓崟鍏冩牸鐨剉alue鍊笺��
+        beforeTransformData: (workbookData) => { return workbookData }, //搴曞眰閫氳繃exceljs鑾峰彇excel鏂囦欢鍐呭锛岄�氳繃璇ラ挬瀛愬嚱鏁帮紝鍙互瀵硅幏鍙栫殑excel鏂囦欢鍐呭杩涜淇敼锛屾瘮濡傛煇涓崟鍏冩牸鐨勬暟鎹樉绀轰笉姝g‘锛屽彲浠ヨ嚜琛屼慨鏀规瘡涓崟鍏冩牸鐨剉alue鍊笺��
         transformData: (workbookData) => { return workbookData }, //灏嗚幏鍙栧埌鐨別xcel鏁版嵁杩涜澶勭悊涔嬪悗涓旀覆鏌撳埌椤甸潰涔嬪墠锛屽彲閫氳繃transformData瀵瑰嵆灏嗘覆鏌撶殑鏁版嵁鍙婃牱寮忚繘琛屼慨鏀癸紝姝ゆ椂姣忎釜鍗曞厓鏍肩殑text鍊煎氨鏄嵆灏嗘覆鏌撳埌椤甸潰涓婄殑鍐呭
       },
       csvList: [],//csv鏂囦欢鏁版嵁
@@ -91,23 +91,41 @@
   },
   computed: {
     isImage() {
-      let state = /\.(jpg|jpeg|png|gif)$/i.test(this.fileUrl)
+      // let state = /\.(jpg|jpeg|png|gif)$/i.test(this.fileUrl)
+      // this.imgUrl = this.fileUrl
+      // if (state) {
+      //   this.imgUrl = this.fileUrl.replaceAll('word', 'img')
+      // }
+      // 浠� URL 鎴栨枃浠跺悕涓彁鍙栧疄闄呯殑鏂囦欢鍚�
+      const fileName = this.currentFile.fileName || this.fileUrl.split('/').pop().split('?')[0]
+      let state = /\.(jpg|jpeg|png|gif)$/i.test(fileName)
       this.imgUrl = this.fileUrl
-      if (state) {
-        this.imgUrl = this.fileUrl.replaceAll('word', 'img')
-      }
+      console.log("鏂囦欢鍚�:", fileName, "鏄惁鍥剧墖:", state)
       return state;
     },
     isPdf() {
-      return /\.pdf$/i.test(this.fileUrl);
+      // return /\.pdf$/i.test(this.fileUrl);
+      const fileName = this.currentFile.fileName || this.fileUrl.split('/').pop().split('?')[0]
+      return /\.pdf$/i.test(fileName);
     },
     isDoc() {
-      return /\.(doc|docx)$/i.test(this.fileUrl);
+      // return /\.(doc|docx)$/i.test(this.fileUrl);
+      const fileName = this.currentFile.fileName || this.fileUrl.split('/').pop().split('?')[0]
+      return /\.(doc|docx)$/i.test(fileName);
     },
     isXls() {
-      let state = /\.(xls|xlsx)$/i.test(this.fileUrl)
+      // let state = /\.(xls|xlsx)$/i.test(this.fileUrl)
+      // if (state) {
+      //   if (/\.(xlsx)$/i.test(this.fileUrl)) {
+      //     this.options.xls = false
+      //   } else {
+      //     this.options.xls = true
+      //   }
+      // }
+      const fileName = this.currentFile.fileName || this.fileUrl.split('/').pop().split('?')[0]
+      let state = /\.(xls|xlsx)$/i.test(fileName)
       if (state) {
-        if (/\.(xlsx)$/i.test(this.fileUrl)) {
+        if (/\.(xlsx)$/i.test(fileName)) {
           this.options.xls = false
         } else {
           this.options.xls = true
diff --git a/src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue b/src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue
index 0f43503..41174ef 100644
--- a/src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue
+++ b/src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue
@@ -103,16 +103,28 @@
     },
     // 涓嬭浇
     upload (row) {
-      let url = '';
-      if(row.type==1){
-        url = this.javaApi+'/img/'+row.fileUrl
-        file.downloadIamge(url,row.fileName)
-      }else{
-        url = this.javaApi+'/word/'+row.fileUrl
-        const link = document.createElement('a');
-        link.href = url;
-        link.download = row.fileName;
-        link.click();
+      const fileName = row.fileName; 
+      const fileUrl = row.fileUrl;  
+      try {
+          const response = axios({
+              method: 'get',
+              url: `${Vue.prototype.javaApi}/common/downloadMinio`,
+              params: {
+                fileUrl,
+                fileName
+              },
+              responseType: 'blob',
+              headers: { Authorization: 'Bearer ' + getToken() }
+          });
+  
+          if (blobValidate(response.data)) {
+              saveAs(new Blob([response.data]), fileName);
+              Message.success("涓嬭浇鎴愬姛");
+          } else {
+              this.printErrMsg(response.data);
+          }
+      } catch (error) {
+          Message.error("涓嬭浇澶辫触锛�" + error.message);
       }
     },
   }
diff --git a/src/views/structural/capabilityAndLaboratory/workshop/components/fileList.vue b/src/views/structural/capabilityAndLaboratory/workshop/components/fileList.vue
index 11287cd..6cdd690 100644
--- a/src/views/structural/capabilityAndLaboratory/workshop/components/fileList.vue
+++ b/src/views/structural/capabilityAndLaboratory/workshop/components/fileList.vue
@@ -11,7 +11,7 @@
     <lims-table :tableData="tableDataFile" :column="columnFile" height="500px" key="tableDataFile"
       :tableLoading="tableLoadingFile"></lims-table>
     <el-dialog title="鏌ョ湅闄勪欢" :visible.sync="lookDialogVisible" width="800px" top="5vh" fullscreen append-to-body>
-      <filePreview v-if="lookDialogVisible" :fileUrl="javaApi + '/word/' + currentInfo.fileUrl" :currentFile="{}"
+      <filePreview v-if="lookDialogVisible" :fileUrl="currentInfo.fileMinioUrl" :currentFile="currentInfo"
         style="max-height: 90vh;overflow-y: auto;" />
     </el-dialog>
   </div>
@@ -85,6 +85,7 @@
               name: '棰勮',
               type: 'text',
               clickFun: (row) => {
+                console.log('棰勮鏂囦欢淇℃伅:', row)
                 this.currentInfo = row
                 this.lookDialogVisible = true
               }
@@ -109,6 +110,7 @@
         this.tableLoadingFile = false
         if (res.code === 200) {
           this.tableDataFile = res.data
+          console.log('鏂囦欢鍒楄〃鏁版嵁:', this.tableDataFile)
         }
       }).catch(err => {
         this.tableLoadingFile = false

--
Gitblit v1.9.3