<template>
<a-col :span="5" class="set-line">
<a-button
type="primary"
:disabled="disabled"
class="set-loading-btn"
:loading="loading"
>
<download-excel
:fields="exportColumns"
type="xls"
:data="exportmemberList"
name="列表报表.xls"
:before-generate="exportData"
:before-finish="finishDownload"
>
导出</download-excel
>
</a-button>
<span class="add-padding-left" v-if="loading"
>正在导出请勿退出该页面...</span
>
</a-col>
</template>
<script>
export default {
name: "",
data() {
return {
exportColumns: {
订单编号: {
field: "no",
callback: (value) => {
return " " + value;
},
},
完成时间: "finished_at",
},
exportmemberList: [],
exportLastPage: null,
times: 1,
loading: false,
}
},
methods:{
async exportData() {
this.loading = true;
await this.getExportData(this.times);
},
finishDownload() {
this.exportmemberList.length = 0;
},
async getExportData(exportPage) {
return await this.$http
.post("/admin/Order?size=50&page=" + exportPage, this.params)
.then((res) => {
if (res.data.data.length != 0) {
this.exportmemberList.push(...res.data.data);
}
if (exportPage == 1) {
this.exportLastPage = res.data.last_page;
}
if (this.times >= this.exportLastPage) {
this.loading = false;
this.times = 1;
} else {
this.times++;
return this.getExportData(this.times);
}
});
},
}
}
</script>
|