Browse Source

导出数据提示

master
maziyang 6 days ago
parent
commit
6a7bed61fc
  1. 17
      src/views/VoteDetail/VoteDetail.vue
  2. 4
      src/views/test/test.vue

17
src/views/VoteDetail/VoteDetail.vue

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

4
src/views/test/test.vue

@ -18,7 +18,7 @@
<el-progress
class="left-progress"
:percentage="opt.count"
:format="() => opt.content + ' √'"
:format="() => opt.content "
:stroke-width="30"
:text-inside="true"
:color="colors[opt.id]"
@ -42,7 +42,7 @@ const totalStatus = () => {
const options = ref([
{ id: 1, content: '选择1', count: 20 ,status:0},
{ id: 2, content: '选择2', count: 30 ,status:0},
{ id: 3, content: '选择3', count: 40 ,status:0},
{ id: 3, content: '选择3', count: 50 ,status:0},
])
const colors = ref({})

Loading…
Cancel
Save