报名导出按钮
This commit is contained in:
parent
b06a058604
commit
245a15a5bc
@ -64,8 +64,6 @@ export const eventregistrationBatchauditPost = (data) => {
|
|||||||
/**
|
/**
|
||||||
* 导出报名
|
* 导出报名
|
||||||
* @param {Object} data - 导出参数
|
* @param {Object} data - 导出参数
|
||||||
* @param {number} [data.pageNo] - 当前页码
|
|
||||||
* @param {number} [data.pageSize] - 每页条数
|
|
||||||
* @param {number} [data.eventId] - 赛事ID
|
* @param {number} [data.eventId] - 赛事ID
|
||||||
* @param {number} [data.registrationMode] - 报名模式
|
* @param {number} [data.registrationMode] - 报名模式
|
||||||
* @param {string} [data.unitName] - 单位名称
|
* @param {string} [data.unitName] - 单位名称
|
||||||
@ -76,10 +74,12 @@ export const eventregistrationBatchauditPost = (data) => {
|
|||||||
* @param {number} [data.paymentStatus] - 支付状态
|
* @param {number} [data.paymentStatus] - 支付状态
|
||||||
* @param {string} [data.registrationTimeStart] - 报名开始时间
|
* @param {string} [data.registrationTimeStart] - 报名开始时间
|
||||||
* @param {string} [data.registrationTimeEnd] - 报名结束时间
|
* @param {string} [data.registrationTimeEnd] - 报名结束时间
|
||||||
* @returns {Promise<string>} - 返回导出文件URL
|
* @returns {Promise<Blob>} - 返回Excel文件流
|
||||||
*/
|
*/
|
||||||
export const eventregistrationExportPost = (data) => {
|
export const eventregistrationExportPost = (data) => {
|
||||||
return http.post('/eventregistration/export', data);
|
return http.post('/eventregistration/export', data, {
|
||||||
|
responseType: 'blob'
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -48,6 +48,12 @@
|
|||||||
@selectionChange="selection">
|
@selectionChange="selection">
|
||||||
<template #tools>
|
<template #tools>
|
||||||
<el-button v-auth="'event:add'" type="primary" @click="allSure"> 批量审核 </el-button>
|
<el-button v-auth="'event:add'" type="primary" @click="allSure"> 批量审核 </el-button>
|
||||||
|
<el-button type="primary" :loading="exportLoading" @click="handleExport">
|
||||||
|
<template #icon>
|
||||||
|
<el-icon><Download /></el-icon>
|
||||||
|
</template>
|
||||||
|
导出
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
<template #isUploadMaterial="props">
|
<template #isUploadMaterial="props">
|
||||||
<el-tag :type="props.row.isUploadMaterial ? 'success' : 'danger'">
|
<el-tag :type="props.row.isUploadMaterial ? 'success' : 'danger'">
|
||||||
@ -335,7 +341,7 @@ import { ElMessage, ElMessageBox } from 'element-plus';
|
|||||||
import { Check, View, Download, Rank, Warning } from '@element-plus/icons-vue';
|
import { Check, View, Download, Rank, Warning } from '@element-plus/icons-vue';
|
||||||
import { eventDetailGet } from '/@/api/match/event';
|
import { eventDetailGet } from '/@/api/match/event';
|
||||||
import { eventarrangementListGet, eventarrangementPut, eventarrangementExportPost, eventarrangementPreviewPost } from '/@/api/match/eventarrangement';
|
import { eventarrangementListGet, eventarrangementPut, eventarrangementExportPost, eventarrangementPreviewPost } from '/@/api/match/eventarrangement';
|
||||||
import { eventregistrationPagePost, eventregistrationBatchauditPost, eventregistrationMaterialurlsPost, eventregistrationStatsGet } from '/@/api/match/eventregistration';
|
import { eventregistrationPagePost, eventregistrationBatchauditPost, eventregistrationMaterialurlsPost, eventregistrationStatsGet, eventregistrationExportPost } from '/@/api/match/eventregistration';
|
||||||
import { eventscorePageathletePost, eventscorePagecoachleaderPost, eventscoreImportscorePost, eventscoreDownloadtemplateGet, eventscoreExportcertificatePost, eventscoreIssuecertificatePost, eventscoreGetCertificateDetailGet, eventscoreIssuepointsPost } from '/@/api/match/eventscore';
|
import { eventscorePageathletePost, eventscorePagecoachleaderPost, eventscoreImportscorePost, eventscoreDownloadtemplateGet, eventscoreExportcertificatePost, eventscoreIssuecertificatePost, eventscoreGetCertificateDetailGet, eventscoreIssuepointsPost } from '/@/api/match/eventscore';
|
||||||
import { certificateListGet } from '/@/api/match/certificate';
|
import { certificateListGet } from '/@/api/match/certificate';
|
||||||
import Step1BasicInfo from './Steps/Step1BasicInfo.vue';
|
import Step1BasicInfo from './Steps/Step1BasicInfo.vue';
|
||||||
@ -361,9 +367,11 @@ const previewDialogVisible = ref(false);
|
|||||||
const previewData = ref([]);
|
const previewData = ref([]);
|
||||||
const previewEventName = ref('赛事编排预览');
|
const previewEventName = ref('赛事编排预览');
|
||||||
const scoreFileInputRef = ref(null);
|
const scoreFileInputRef = ref(null);
|
||||||
|
const tableRef = ref();
|
||||||
const tableuu = ref();
|
const tableuu = ref();
|
||||||
const tableCoach = ref();
|
const tableCoach = ref();
|
||||||
const tableLeader = ref();
|
const tableLeader = ref();
|
||||||
|
const exportLoading = ref(false);
|
||||||
|
|
||||||
// 证书发放相关
|
// 证书发放相关
|
||||||
const certificateDialogVisible = ref(false);
|
const certificateDialogVisible = ref(false);
|
||||||
@ -919,6 +927,55 @@ const allSure = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
exportLoading.value = true;
|
||||||
|
const searchParams = tableRef.value?.searchParam || {};
|
||||||
|
const exportParams = {
|
||||||
|
eventId: initParam.value.eventId,
|
||||||
|
};
|
||||||
|
for (const key in searchParams) {
|
||||||
|
const val = searchParams[key];
|
||||||
|
if (val === '' || val === null || val === undefined) continue;
|
||||||
|
if (Array.isArray(val) && val.length === 2) {
|
||||||
|
let start = val[0];
|
||||||
|
let end = val[1];
|
||||||
|
if (start instanceof Date) {
|
||||||
|
start = `${start.getFullYear()}-${String(start.getMonth() + 1).padStart(2, '0')}-${String(start.getDate()).padStart(2, '0')}`;
|
||||||
|
}
|
||||||
|
if (end instanceof Date) {
|
||||||
|
end = `${end.getFullYear()}-${String(end.getMonth() + 1).padStart(2, '0')}-${String(end.getDate()).padStart(2, '0')}`;
|
||||||
|
}
|
||||||
|
exportParams[`${key}Start`] = start;
|
||||||
|
exportParams[`${key}End`] = end;
|
||||||
|
} else {
|
||||||
|
exportParams[key] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const data = await eventregistrationExportPost(exportParams);
|
||||||
|
if (data instanceof Blob) {
|
||||||
|
if (data.type && data.type.includes('application/json')) {
|
||||||
|
const text = await data.text();
|
||||||
|
const err = JSON.parse(text);
|
||||||
|
ElMessage.error(err.errors || err.message || '导出失败');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const blob = new Blob([data], {
|
||||||
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||||
|
});
|
||||||
|
downloadByBlob(blob, `报名信息_${new Date().getTime()}.xlsx`);
|
||||||
|
ElMessage.success('导出成功');
|
||||||
|
} else {
|
||||||
|
ElMessage.error('导出失败,未获取到文件');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('导出失败:', error);
|
||||||
|
ElMessage.error('导出失败,请稍后重试');
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//=================================成绩与证书==================================
|
//=================================成绩与证书==================================
|
||||||
const user = ref('运动员')
|
const user = ref('运动员')
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user