Kaynağa Gözat

Add - 企业信息详情文件链接下载完善

yhfu 2 hafta önce
ebeveyn
işleme
17c483b6d5

+ 6 - 16
src/components/companyProjectDialog/index.vue

@@ -32,16 +32,16 @@
             <img v-for="(e,idx) in info.attachPaths" :key="idx" :src="e" style="width: 100px;height: 100px;">
           </span>
         </div>
-        <div style="margin-top: 22%;">
+        <!-- <div style="margin-top: 22%;">
           <span>视频:</span>
           <span style="height: 200px;white-space: normal;overflow: hidden scroll;">
-            <span v-for="(e,idx) in info.imgList" :key="idx" @click="downloadImg(e.name,e.url)" :href="e.url" download>{{ e.name }}</span>
+            <span v-for="(e,idx) in info.imgList" :key="idx" @click="download(e.name,e.url)" :href="e.url" download>{{ e.name }}</span>
           </span>
-        </div> 
+        </div>  -->
         <div style="margin-top: 22%;">
           <span>附件:</span>
           <span style="height: 200px;white-space: normal;overflow: hidden scroll;">
-            <span v-for="(e,idx) in info.imgList" :key="idx" @click="downloadImg(e.name,e.url)" :href="e.url" download>{{ e.name }}</span>
+            <span v-for="(e,idx) in info.fileUrl" @click="download(e[1],e[0])" style="display: inline-block;width: 100%;">{{ e[1] }}</span>
           </span>
         </div>  
       </div>
@@ -68,18 +68,8 @@ export default{
         this.info = param
         this.dialogVisible = true
       },
-      downloadImg(name,url){
-        fetch(url)
-        .then(response => response.blob())
-        .then(blob => {
-            const anchor = document.createElement('a');
-            const url = window.URL.createObjectURL(blob);
-            anchor.href = url;
-            anchor.download = name;
-            anchor.click();
-            window.URL.revokeObjectURL(url);
-        })
-        .catch(error => console.error('下载图片失败', error));
+      download(name,url){
+        window.open(url);
       }
     }
 

+ 10 - 0
src/views/forest.vue

@@ -546,11 +546,21 @@
             if(res.data.attachPaths){
               attachPaths = res.data.attachPaths.split(",")
             }
+            // 处理附件路径
+            let fileUrl
+            if(res.data.fileUrl){
+              fileUrl = res.data.fileUrl.split(",")
+              fileUrl.forEach((e,idx) => {
+                fileUrl[idx] = e.split("+")
+              })
+            }
+            console.log('fileUrl',fileUrl)
             let detailInfo = {
               title:res.data.infoTitle || '',
               unit:res.data.infoTitle || '',
               content:res.data.infoContent || '',
               attachPaths,
+              fileUrl,
               videos:[],
               others:[]
             }