文件流格式的文件下载
templateDownload(param).then((res) => {
const blob = new Blob([res.data], { type: 'application/octet-stream;charset=utf-8' })
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
res.filename = decodeURI(res.filename)
if (res.filename) {
const lastIndex = res.filename.lastIndexOf('.')
let name = ''
let suffix = ''
if (lastIndex !== -1) {
name = res.filename.slice(0, lastIndex)
suffix = res.filename.slice(lastIndex + 1)
link.setAttribute('download', `${name}.${suffix}`)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
} else {
this.$message.error('未选择合同,或所选合同无合同模板')
}
})