<a-button
class="mar_r10"
icon="download"
type="primary"
@click="exportData"
>
导出
</a-button>
methods:{
// 导出
exportData (type) {
// g_exportXlsform({headId: '82cde47f4aad4ca2973cb683b6a898c9',paramsStr: {}})
// 获取导出数据
this.$message.loading({ content: '导出中', key: 'updatable' });
const paramsStr = JSON.stringify({})
g_exportXlsform({ headId: '82cde47f4aad4ca2973cb683b6a898c9', paramsStr: { paramsStr: paramsStr } }).then((res) => {
const data = res.data;
//----------------------------------重要部分start-------------------------------------------------
if (!data || data.size === 0) {
this.$message.warning('文件下载失败')
return
}
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(new Blob([data]), '采购订单' + '.xls')
} else {
const url = window.URL.createObjectURL(new Blob([data]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', '采购订单' + '.xls')
document.body.appendChild(link)
link.click()
document.body.removeChild(link) // 下载完成移除元素
window.URL.revokeObjectURL(url) // 释放掉blob对象
}
//----------------------------------重要部分end-------------------------------------------------
})
},
}
网友评论