Browse Source

merge fix

scorpio 2 years ago
parent
commit
8444b3da32
1 changed files with 15 additions and 22 deletions
  1. 15 22
      src/views/home/component/dash.vue

+ 15 - 22
src/views/home/component/dash.vue

@@ -441,17 +441,7 @@ export default {
           this.$message.error(res.msg)
           return
         }
-        const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.ms-excel' }))
-        const link = document.createElement('a')
-        link.style.display = 'none'
-        link.href = url
-        const excelName = new Date().getTime() + '.xlsx'
-        link.setAttribute('download', excelName)
-        document.body.appendChild(link)
-        link.click()
-        link.remove()
-        this.diaType = -1
-        this.$message.success('导出成功')
+        this.download(res)
       })
     },
     exportExcelTotal (item) {
@@ -462,18 +452,21 @@ export default {
           return
         }
         console.log(res)
-        const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.ms-excel' }))
-        const link = document.createElement('a')
-        link.style.display = 'none'
-        link.href = url
-        const excelName = new Date().getTime() + '.xlsx'
-        link.setAttribute('download', excelName)
-        document.body.appendChild(link)
-        link.click()
-        link.remove()
-        this.diaType = -1
-        this.$message.success('导出成功')
+        this.download(res)
       })
+    },
+    download (res) {
+      const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.ms-excel' }))
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = url
+      const excelName = new Date().getTime() + '.xlsx'
+      link.setAttribute('download', excelName)
+      document.body.appendChild(link)
+      link.click()
+      link.remove()
+      this.diaType = -1
+      this.$message.success('导出成功')
     }
   }
 }