exportFile (filePath, item) {
const b = {
method: 'get',
headers: {
'Content-Type': 'application/json'
},
responseType: 'blob',
url: url + ':9001/api/tHistoryData/downHistoryFile?filePath=' + filePath + '&fileName=' + item.fileName
}
axios(b).then(response => {
downloadFile(response, item.fileName)
})
},
export function downloadFile (res,fileName) {
const blob = new Blob([res.data])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
console.log(res)
var contentDisposition = decodeURI(res.headers['content-disposition'])
var result = patt.exec(contentDisposition)
console.log(patt,patt.exec(contentDisposition))
fileName = fileName.replace(/\"/g, '')
const name = fileName
downloadElement.href = href
downloadElement.download = name
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
}