HTML
<el-button type="primary" @click="handleDownload()" >
<el-icon :size="12"><i-ep-download /> </el-icon>{ $t('common.toolbar.exportExcel') }}
</el-button >
js
// 选中下载
const handleDownload = () => {
// 格式化table 参数
const tmpArr = tableOptions
.map((option) => {
return {
key: option.prop,
title: option.label,
slot: option.slot
}
})
.filter((item2) => item2.slot == undefined)
const loading = ElLoading.service({
// 打开遮罩层
lock: true,
text: '请稍等...',
background: 'rgba(255, 255, 255, 0.5)'
})
let list = JSON.stringify(selectedData.value)
list = formatExportData(JSON.parse(list))
// table2Excel(state.exportConfig, list, '多语言配置名称') state.exportConfig导出表格配置,list导出数据列表,“多语言配置名称”:导出文件名称
table2Excel(tmpArr, list, $t('productionEntry.listName'))
loading.close() // 关闭遮罩层
search()
}
const formatExportData = (list) => {
list.forEach((item) => {
// state.formatColumns.forEach((i) => {
// item[i.prop] = i.option[item[i.prop]]
// })
// for (let key in item) {
// if (!item[key] && item[key] == null) {
// item[key] = ''
// }
// }
})
return list
}