如何在限制请求头的情况下,去导出报告之类

使用流的方式:

    // 导出报告
    exportReport () {
        // window.open(`${baseUrl.baseUrl}/media/export?orderId=${this.searchItem}&promotionId=${this.currrentFormName}&activityId=${this.currrentFormActive}&starTime=${this.startTime}&endTime=${this.endTime}&status=${this.currrentOrderState}`)
        let token = getToken()
        return new Promise((resolve, reject) => {
          baseUrl.request({
            url: `${baseUrl.baseUrl}/media/export?orderId=${this.searchItem}&promotionId=${this.currrentFormName}&activityId=${this.currrentFormActive}&starTime=${this.startTime}&endTime=${this.endTime}&status=${this.currrentOrderState}`,
            headers: {
              Authorization: 'Bearer ' + token
            },
            responseType: 'blob'
          }).then(res => {
            console.log('this', this)
            console.log('res', res)
            let blob = new Blob([res.data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'})
            let link = document.createElement('a')
            link.href = window.URL.createObjectURL(blob)
            link.download = `订单媒介报告导出${formatTime2(new Date())}.xlsx`
            link.click()
          })
        })
    }

猜你喜欢

转载自www.cnblogs.com/xuhuang/p/9942612.html
今日推荐