|
@ -7,7 +7,7 @@ |
|
|
<el-button type="danger" @click="fetchVoteData"> |
|
|
<el-button type="danger" @click="fetchVoteData"> |
|
|
搜索 |
|
|
搜索 |
|
|
</el-button> |
|
|
</el-button> |
|
|
<el-button type="danger" @click="exportDataFrontend"> |
|
|
|
|
|
|
|
|
<el-button type="danger" @click="exportDataFrontend" :loading="buttonLoading"> |
|
|
导出数据 |
|
|
导出数据 |
|
|
</el-button> |
|
|
</el-button> |
|
|
|
|
|
|
|
@ -41,14 +41,15 @@ |
|
|
import { useVoteDetailStore } from '@/stores/voteDetail' |
|
|
import { useVoteDetailStore } from '@/stores/voteDetail' |
|
|
import { ref, onMounted, reactive } from 'vue' |
|
|
import { ref, onMounted, reactive } from 'vue' |
|
|
import { useRoute } from 'vue-router'; |
|
|
import { useRoute } from 'vue-router'; |
|
|
|
|
|
|
|
|
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
|
|
const buttonLoading = ref(false) |
|
|
const route = useRoute(); |
|
|
const route = useRoute(); |
|
|
// const voteId = ref(route.params.voteId); |
|
|
// const voteId = ref(route.params.voteId); |
|
|
const voteInfo = reactive({ |
|
|
const voteInfo = reactive({ |
|
|
// voteId: Number(route.query.voteId), |
|
|
// voteId: Number(route.query.voteId), |
|
|
voteId: route.query.voteId, |
|
|
voteId: route.query.voteId, |
|
|
voteTitle: route.query.voteTitle, |
|
|
voteTitle: route.query.voteTitle, |
|
|
articleTitle:route.query.articleTitle, |
|
|
|
|
|
|
|
|
articleTitle: route.query.articleTitle, |
|
|
}) |
|
|
}) |
|
|
const tableData = ref([]) |
|
|
const tableData = ref([]) |
|
|
const totalCount = ref(0) |
|
|
const totalCount = ref(0) |
|
@ -105,6 +106,9 @@ const handleCurrentChange = async (newPage) => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const exportDataFrontend = async () => { |
|
|
const exportDataFrontend = async () => { |
|
|
|
|
|
buttonLoading.value = true |
|
|
|
|
|
// ElMessage.info('开始导出,请稍候…') |
|
|
|
|
|
try { |
|
|
let exportData = ref([]) |
|
|
let exportData = ref([]) |
|
|
let params = reactive({ |
|
|
let params = reactive({ |
|
|
voteId: voteInfo.voteId, |
|
|
voteId: voteInfo.voteId, |
|
@ -140,6 +144,13 @@ const exportDataFrontend = async () => { |
|
|
document.body.appendChild(link) |
|
|
document.body.appendChild(link) |
|
|
link.click() |
|
|
link.click() |
|
|
document.body.removeChild(link) |
|
|
document.body.removeChild(link) |
|
|
|
|
|
ElMessage.success('已生成文件并下载') |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
ElMessage.error('导出失败,请重试') |
|
|
|
|
|
} finally { |
|
|
|
|
|
buttonLoading.value = false |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
<style scoped> |
|
|
<style scoped> |
|
|