1
This commit is contained in:
@@ -194,7 +194,7 @@ class Http {
|
||||
return promise
|
||||
}
|
||||
|
||||
async fileExport(url, param) {
|
||||
async fileExport(url, param, filename, is_down = true) {
|
||||
let formData = this.formatFormDataParam(param)
|
||||
|
||||
let config = {
|
||||
@@ -206,14 +206,19 @@ class Http {
|
||||
url: url,
|
||||
responseType: 'blob'
|
||||
}
|
||||
|
||||
let res = await axios.post(url, formData, config)
|
||||
const filename = res.headers.filename
|
||||
const a = document.createElement('a')
|
||||
const href = window.URL.createObjectURL(res.data)
|
||||
a.href = href
|
||||
a.download = filename
|
||||
a.click()
|
||||
window.URL.revokeObjectURL(url)
|
||||
filename = filename || res.headers['content-disposition'].split('filename=')[1].split(';')[0]
|
||||
|
||||
// 开头和结尾去掉 中间不去掉
|
||||
filename = filename.replace(/^[_-]+|[_-]+$/g, '')
|
||||
|
||||
// 直接下载
|
||||
if (is_down) {
|
||||
window.framework.uiTool.downloadFile(res.data, filename)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user