Vue导出Excel

后端调了下载直接打开 

<a v-if="$permission(['客服绩效', '客服绩效', '导出'])" :href="protocol +'//'+hostname + '/index.php?接口地址' + '&teacher_id=' + searchForm.teacher_id +'&date=' + searchForm.date +'&is_new=' + searchForm.is_new +'&is_refund=' + searchForm.is_refund +'&check_teacher_id=' + searchForm.check_teacher_id +'&product_id=' + searchForm.product_id +'&appcode=' + appcode + '&admin_name=' + admin_name + '&admin_id=' + admin_id + '&institution_id=' + institution_id + '&company_id=' + company_id + '&key='+ key" target="_blank" class="el-button el-button--primary" style="margin-bottom: 20px;">导出</a>


protocol:'',
hostname:'',
key:sessionStorage.getItem('key'),
admin_id:sessionStorage.getItem('admin_id'),
admin_name:sessionStorage.getItem('admin_name'),
institution_id:sessionStorage.getItem('institution_id'),
company_id:sessionStorage.getItem('company_id'),
appcode:sessionStorage.getItem('appcode'),


this.protocol= window.location.protocol
this.hostname= window.location.hostname

后端没调下载

exportExcel(){
  const _send = JSON.parse(JSON.stringify(this.formInline))
  const extractedValues = [];
  for (let i = 0; i < _send.category_ids.length; i++) {
    extractedValues.push(_send.category_ids[i][1]);
  }
  const result = extractedValues.join(',');
  _send.category_ids = result
  community.exportlistAPI({
    ..._send,
    type:'1',
  }).then((res)=>{
    if(res.code === 1) {
      if (window.location.protocol == 'https:') {
        res.data = res.data.replace('http:','https:')
      }else if (window.location.protocol == 'http:') {
        res.data = res.data.replace('https:','http:')
      }
      fetch(res.data)
      .then(response => response.blob())
      .then(blob => {
        const url = window.URL.createObjectURL(new Blob([blob]));
        const link = document.createElement('a');
        link.href = url;
        let filename = decodeURIComponent(res.data.substr(res.data.lastIndexOf('/')+1))
        link.setAttribute('download', filename);
        document.body.appendChild(link);
        link.click();
        link.parentNode.removeChild(link);
      });
    } else {
      this.$common.notifyError(res.message)
    }         
  })
},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值