소스 검색

feat: (dashborad) 增加export

gemercheung 2 년 전
부모
커밋
b7cf35f922
1개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. 13 1
      src/views/dashboard/analysis/index.vue

+ 13 - 1
src/views/dashboard/analysis/index.vue

@@ -166,7 +166,19 @@
   });
 
   async function handleExport() {
-    await bulletChatExportApi(searchInfo);
+    const data = await bulletChatExportApi(searchInfo);
+    const downloadBlob = new Blob([data], {
+      type: 'application/msexcel',
+    });
+    const url = URL.createObjectURL(downloadBlob);
+    const a: HTMLAnchorElement = document.createElement('a');
+    document.body.appendChild(a);
+    a.style.display = 'none';
+    a.href = url;
+    const name = new Date().getTime();
+    a.download = `${name}.csv`;
+    a.click();
+    window.URL.revokeObjectURL(url);
   }
 
   setTimeout(() => {