Browse Source

下载音频

jwyu 1 year ago
parent
commit
7954284972
1 changed files with 29 additions and 2 deletions
  1. 29 2
      src/views/smartReport/reportList.vue

+ 29 - 2
src/views/smartReport/reportList.vue

@@ -282,14 +282,22 @@
                         @click="openupload(scope.row.SmartReportId)"
                         @click="openupload(scope.row.SmartReportId)"
                         >音频上传</span
                         >音频上传</span
                         >
                         >
-                        <a
+                        <span 
+                            style="cursor: pointer; color: #4099ef;display:inline-block" 
+                            v-permission="permissionBtn.smartReportManageBtn.reportManage_audioDownload"
+                            v-if="scope.row.VideoUrl"
+                            @click="handleDownloadVoice(scope.row)"
+                        >
+                            音频下载
+                        </span>
+                        <!-- <a
                         v-permission="permissionBtn.smartReportManageBtn.reportManage_audioDownload"
                         v-permission="permissionBtn.smartReportManageBtn.reportManage_audioDownload"
                         :href="scope.row.VideoUrl"
                         :href="scope.row.VideoUrl"
                         v-if="scope.row.VideoUrl"
                         v-if="scope.row.VideoUrl"
                         :download="scope.row.VideoName"
                         :download="scope.row.VideoName"
                         style="cursor: pointer; color: #4099ef"
                         style="cursor: pointer; color: #4099ef"
                         >音频下载</a
                         >音频下载</a
-                        >
+                        > -->
                     </div>
                     </div>
                     </template>
                     </template>
                 </el-table-column>
                 </el-table-column>
@@ -753,6 +761,25 @@ export default {
                 this.uploadDialog = false;
                 this.uploadDialog = false;
             });
             });
         },
         },
+        // 下载音频
+        handleDownloadVoice(e){
+            const x = new window.XMLHttpRequest();
+            x.open('GET', e.VideoUrl, true);
+            x.responseType = 'blob';
+            x.onload = () => {
+                const url = window.URL.createObjectURL(x.response);
+                const a = document.createElement('a');
+                a.download = e.VideoName+'.mp3';
+                a.style.display = 'none'
+
+                let blob=new Blob([x.response])
+                a.href = URL.createObjectURL(blob);
+                a.target = '_blank'
+                document.body.append(a)
+                a.click();
+            };
+            x.send();
+        }
     },
     },
 
 
     created() {
     created() {