export function downloadCsv(val, key, name, keyName) {
if (val.length) {
let str = []
str.push(keyName.join(',') + '
')
val.map((item) => {
let temp = []
key.map((key) => {
temp.push(item[key])
})
str.push(temp.join(',') + '
')
})
let url = 'data:text/csv;charset=utf-8,ufeff' + encodeURIComponent(str.join(''))
let downloadLink = document.createElement('a')
downloadLink.href = url
downloadLink.download = `${name}.csv`
document.body.appendChild(downloadLink)
downloadLink.click()
document.body.removeChild(downloadLink)
}
}