yuwandanmian 2 年之前
父节点
当前提交
110fca6c7c
共有 2 个文件被更改,包括 50 次插入26 次删除
  1. 13 5
      src/utils/request_blob.js
  2. 37 21
      src/views/searchSystem/components/BLSearch.vue

+ 13 - 5
src/utils/request_blob.js

@@ -1,19 +1,25 @@
 import axios from 'axios'
-import { Message } from 'element-ui'
+import { Message, Loading } from 'element-ui'
 import store from '@/store'
 import { getToken } from '@/utils/auth'
 
-// create an axios instance
-const service = axios.create({
-  timeout: 50000 // request timeout
-})
 
+// create an axios instance
+const service = axios.create()
+let loadingInstance
 // request interceptor
 service.interceptors.request.use(
   config => {
     if (store.getters.token) {
       config.headers['token'] = `${getToken()}`
     }
+    loadingInstance = Loading.service({
+      lock: false,
+      customClass: 'z-index999',
+      text: '加载中,请稍后...',
+      spinner: 'ui-icon-loading',
+      background: 'rgba(0, 0, 0, 0.7)'
+    })
     return config
   },
   error => {
@@ -35,9 +41,11 @@ service.interceptors.response.use(
    * You can also judge the status by HTTP Status Code
    */
   response => {
+    loadingInstance.close()
     return response
   },
   error => {
+    loadingInstance.close()
     console.log('err' + error) // for debug
     Message({
       message: error.message,

+ 37 - 21
src/views/searchSystem/components/BLSearch.vue

@@ -510,27 +510,43 @@ export default {
       })
     },
     highDownload(name) {
-      alert('api 有问题 todo ')
-      // const params = {
-      //   keyword: this.formData0.input
-      // }
-      // bassNormalSearchDownload(params).then(res => {
-      //   const content = res.data // 后台返回二进制数据
-      //   const blob = new Blob([content])
-      //   const fileName = `${name}.xlsx`
-      //   if ('download' in document.createElement('a')) { // 非IE下载
-      //     const elink = document.createElement('a')
-      //     elink.download = fileName
-      //     elink.style.display = 'none'
-      //     elink.href = URL.createObjectURL(blob)
-      //     document.body.appendChild(elink)
-      //     elink.click()
-      //     URL.revokeObjectURL(elink.href) // 释放URL 对象
-      //     document.body.removeChild(elink)
-      //   } else { // IE10+下载
-      //     navigator.msSaveBlob(blob, fileName)
-      //   }
-      // })
+      const pramse = {}
+      pramse.field = this.formData1.seniorList;
+      pramse.AAC01_start = this.formData1.startTime;
+      pramse.AAC01_end = this.formData1.endTime;
+
+      pramse.AAC04_start = this.formData1.AAC04_start;
+      pramse.AAC04_end = this.formData1.AAC04_end;
+      const { ageType1, ageType2 } = this.formData1
+      // ageType1 = 1 年龄
+      // ageType1 = 0 天数
+      if (ageType1) {
+        pramse.AAA04_start = this.formData1.AAA04_start;
+      } else {
+        pramse.AAA40_start =  this.formData1.AAA04_start
+      }
+      if (ageType2) {
+        pramse.AAA04_end = this.formData1.AAA04_end;
+      } else {
+        pramse.AAA40_end =  this.formData1.AAA04_end
+      }
+      bassHighSearchDownload(pramse).then(res => {
+        const content = res.data // 后台返回二进制数据
+        const blob = new Blob([content])
+        const fileName = `${name}.xlsx`
+        if ('download' in document.createElement('a')) { // 非IE下载
+          const elink = document.createElement('a')
+          elink.download = fileName
+          elink.style.display = 'none'
+          elink.href = URL.createObjectURL(blob)
+          document.body.appendChild(elink)
+          elink.click()
+          URL.revokeObjectURL(elink.href) // 释放URL 对象
+          document.body.removeChild(elink)
+        } else { // IE10+下载
+          navigator.msSaveBlob(blob, fileName)
+        }
+      })
     },
     onLockResult() {
       this.lock = true