export function getData(url) {
return request({
url,
method: 'get',
responseType: 'blob',
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
download (data,titName) {
if(!data){
return
}
const content = data
const blob = new Blob([content], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
const fileName = titName?titName: ''
if ('download' in document.createElement('a')) {
var downloadElement = document.createElement('a')
var href = window.URL.createObjectURL(blob)
var reg = /^["](.*)["]$/g
downloadElement.style.display = 'none'
downloadElement.href = href
downloadElement.download = decodeURI(filename.replace(reg, '$1'))
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
} else {
navigator.msSaveBlob(blob, fileName)
}
}