浏览代码

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(() => {