后端调了下载直接打开
<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)
}
})
},