|
|
@ -368,20 +368,26 @@ export default { |
|
|
|
if (this.searchType) params.type = this.searchType; |
|
|
|
if (this.searchUid) params.uid = this.searchUid; |
|
|
|
|
|
|
|
this.$http('GET', '/agentnew/export_order', params, { |
|
|
|
this.$http('GET', '/agentnew/export_order', params,{ |
|
|
|
returnFullResponse: true , |
|
|
|
headers: { |
|
|
|
'Auth': this.token |
|
|
|
'Auth': this.token, |
|
|
|
}, |
|
|
|
responseType: 'blob' |
|
|
|
}).then(response => { |
|
|
|
console.log(response) |
|
|
|
console.log(response.headers) |
|
|
|
const blob = new Blob([response], { type: 'application/force-download' }); |
|
|
|
}).then(response => { |
|
|
|
const { |
|
|
|
headers, // 响应头(headers) |
|
|
|
data, // 响应体数据 |
|
|
|
} = response; |
|
|
|
const filename = this.decodeRFC5987Filename(headers['content-disposition']); |
|
|
|
// console.log(headers,data,filename,'ajax_get_check_order_list====='); |
|
|
|
|
|
|
|
const blob = new Blob([data], { type: 'application/force-download' }); |
|
|
|
const downloadUrl = window.URL.createObjectURL(blob); |
|
|
|
|
|
|
|
const link = document.createElement('a'); |
|
|
|
link.href = downloadUrl; |
|
|
|
link.setAttribute('download', 'filename.xls'); |
|
|
|
link.setAttribute('download', filename); |
|
|
|
|
|
|
|
document.body.appendChild(link); |
|
|
|
link.click(); |
|
|
@ -409,14 +415,16 @@ export default { |
|
|
|
|
|
|
|
// location.href = url; |
|
|
|
}, |
|
|
|
// 从响应头解析文件名 |
|
|
|
getFilenameFromHeaders(headers) { |
|
|
|
const disposition = headers['content-disposition']; |
|
|
|
if (!disposition) return null; |
|
|
|
|
|
|
|
// 匹配形如:attachment; filename="example.txt" |
|
|
|
const matches = disposition.match(/filename="?([^"]+)"?/i); |
|
|
|
return matches && matches[1] ? matches[1] : null; |
|
|
|
decodeRFC5987Filename(header) { |
|
|
|
// 匹配 RFC 5987 编码的文件名(如 filename*=utf8''xxx) |
|
|
|
const match = header.match(/filename\*=(?:utf8|UTF-8)''([^;]+)/i); |
|
|
|
console.log(match,'match'); |
|
|
|
if (match) { |
|
|
|
return decodeURIComponent(match[1]); |
|
|
|
} |
|
|
|
// 回退到普通文件名(如 filename="xxx") |
|
|
|
const fallbackMatch = header.match(/filename="?([^"]+)"?/i); |
|
|
|
return fallbackMatch ? fallbackMatch[1] : 'download'; |
|
|
|
}, |
|
|
|
getPayImg(pay_type) { |
|
|
|
return require('@/assets/pay/pay_' + pay_type + '.svg'); |
|
|
|