From 36ca85c695cc3d6a6a645aca796d36b718249aee Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 26 二月 2025 15:03:35 +0800
Subject: [PATCH] 修改高低温、功率试验单位

---
 src/components/tool/file-preview.vue |   37 +++++++++++++++++++++++++++++++------
 1 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/src/components/tool/file-preview.vue b/src/components/tool/file-preview.vue
index 37705f8..08d1757 100644
--- a/src/components/tool/file-preview.vue
+++ b/src/components/tool/file-preview.vue
@@ -1,17 +1,17 @@
 <template>
   <div>
     <div v-if="isImage">
-      <img :src="fileUrl" alt="Image Preview" />
+      <img :src="imgUrl" alt="Image Preview" />
     </div>
     <div v-if="isPdf">
-      <object :data="fileUrl" type="application/pdf" width="100%" height="600px">
+      <object :data="fileUrl" type="application/pdf" width="100%" height="750px">
         <p>鎮ㄧ殑娴忚鍣ㄤ笉鏀寔 PDF 棰勮銆�<a :href="fileUrl">涓嬭浇 PDF 鏂囦欢</a></p>
       </object>
     </div>
     <div v-if="isDoc">
       <p v-if="!isDocShow">鏂囨。鏃犳硶鐩存帴棰勮锛岃涓嬭浇鏌ョ湅銆�</p>
       <a :href="fileUrl" v-if="!isDocShow">涓嬭浇鏂囦欢</a>
-      <vue-office-docx
+      <vue-office-docx v-else
           :src="fileUrl"
           style="height: 100vh;"
           @rendered="renderedHandler"
@@ -21,7 +21,7 @@
     <div v-if="isXls">
       <p v-if="!isDocShow">鏂囨。鏃犳硶鐩存帴棰勮锛岃涓嬭浇鏌ョ湅銆�</p>
       <a :href="fileUrl" v-if="!isDocShow">涓嬭浇鏂囦欢</a>
-      <vue-office-excel
+      <vue-office-excel v-else
         :src="fileUrl"
         :options="options"
         style="height: 100vh;"
@@ -95,11 +95,17 @@
         transformData: (workbookData) => {return workbookData}, //灏嗚幏鍙栧埌鐨別xcel鏁版嵁杩涜澶勭悊涔嬪悗涓旀覆鏌撳埌椤甸潰涔嬪墠锛屽彲閫氳繃transformData瀵瑰嵆灏嗘覆鏌撶殑鏁版嵁鍙婃牱寮忚繘琛屼慨鏀癸紝姝ゆ椂姣忎釜鍗曞厓鏍肩殑text鍊煎氨鏄嵆灏嗘覆鏌撳埌椤甸潰涓婄殑鍐呭
       },
       csvList:[],//csv鏂囦欢鏁版嵁
+      imgUrl:''
     }
   },
   computed: {
     isImage() {
-      return /\.(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')
+      }
+      return state;
     },
     isPdf() {
       return /\.pdf$/i.test(this.fileUrl);
@@ -108,7 +114,15 @@
       return /\.(doc|docx)$/i.test(this.fileUrl);
     },
     isXls(){
-      return /\.(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
+        }
+      }
+      return state;
     },
     isZipOrRar() {
       return /\.(zip|rar)$/i.test(this.fileUrl);
@@ -129,6 +143,7 @@
     renderedHandler() {
         console.log("娓叉煋瀹屾垚")
         this.isDocShow = true
+        this.resetStyle()
     },
     errorHandler() {
         console.log("娓叉煋澶辫触")
@@ -146,6 +161,7 @@
             column:[]
           }
           obj.tableData = this.formatCSVToTable(m.content.replaceAll('null',' '))
+          // .replaceAll('MIN','=MIN').replaceAll('MAX','=MAX').replaceAll('AVERAGE','=AVERAGE')
           for (let item in obj.tableData[0]) {
             obj.column.push({
               label: item,
@@ -196,6 +212,15 @@
       }
       return result
     },
+    resetStyle(){
+      const elements = document.querySelectorAll('[style*="pt"]');
+      for (const element of elements) {
+        const style = element.getAttribute('style');
+        if (!!style) {
+          element.setAttribute('style', style.replace(/pt/g, 'px'));
+        }
+      }
+    },
   }
 }
 </script>

--
Gitblit v1.9.3