Commit da937d70 authored by hewenhao's avatar hewenhao

feat: 增加导出功能

parent 7caf7c4b
......@@ -42,6 +42,11 @@
</div>
</div>
</el-scrollbar>
<template #footer>
<el-button type="primary" @click="exportData">
导出数据
</el-button>
</template>
</art-dialog>
</template>
<script>
......@@ -106,6 +111,22 @@ export default {
})
.catch(() => {
})
},
// 导出为csv 文件
exportData () {
const data = [['奖项', '中奖人']]
this.resultList.forEach(item => {
item.value.forEach(subItem => {
data.push([item.name, subItem.name || subItem.index])
})
})
const csvContent = data.map(row => row.join(',')).join('\n')
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = 'result.csv'
a.click()
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment