提交
This commit is contained in:
1 parent
3e3a503fff
commit
a3d3fccd33
2 files changed
+44
-2
No files matched your search
+10
-1
@@ -1,5 +1,6 @@
|
||||
package org.dromara.xg.domain.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@@ -69,48 +70,56 @@ public class XgStudentStatisticsVo {
|
||||
@Data
|
||||
public static class StatisticsDetailData {
|
||||
/**
|
||||
* ID
|
||||
* ID (不导出到Excel)
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@ExcelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 上级名称(如学院下的专业名称显示学院名)
|
||||
*/
|
||||
@ExcelProperty(value = "上级")
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 宿舍扣分总数
|
||||
*/
|
||||
@ExcelProperty(value = "宿舍扣分总数")
|
||||
private Integer dormDeductionCount;
|
||||
|
||||
/**
|
||||
* 宿舍违纪记录总数
|
||||
*/
|
||||
@ExcelProperty(value = "宿舍违纪记录总数")
|
||||
private Integer dormViolationCount;
|
||||
|
||||
/**
|
||||
* 宿舍违纪记录扣分总数
|
||||
*/
|
||||
@ExcelProperty(value = "宿舍违纪记录扣分总数")
|
||||
private Double dormViolationDeduction;
|
||||
|
||||
/**
|
||||
* 教学区违纪记录总数
|
||||
*/
|
||||
@ExcelProperty(value = "教学区违纪记录总数")
|
||||
private Integer teachingViolationCount;
|
||||
|
||||
/**
|
||||
* 教学区违纪记录扣分总数
|
||||
*/
|
||||
@ExcelProperty(value = "教学区违纪记录扣分总数")
|
||||
private Double teachingViolationDeduction;
|
||||
|
||||
/**
|
||||
* 合计扣分
|
||||
*/
|
||||
@ExcelProperty(value = "违纪合计扣分")
|
||||
private Double totalDeduction;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>明细数据</span>
|
||||
<el-button type="success" icon="Download" @click="handleExport" :loading="exportLoading">导出Excel</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<el-table :data="statisticsData.detailData" style="width: 100%" border>
|
||||
@@ -286,9 +287,41 @@ const resetQuery = () => {
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
if (!statisticsData.value) {
|
||||
ElMessage.warning('暂无数据可导出');
|
||||
return;
|
||||
}
|
||||
|
||||
exportLoading.value = true;
|
||||
try {
|
||||
await exportStatistics(queryParams);
|
||||
const response = await exportStatistics(queryParams);
|
||||
|
||||
let blobData: Blob;
|
||||
if (response instanceof Blob) {
|
||||
blobData = response;
|
||||
} else if (response.data instanceof Blob) {
|
||||
blobData = response.data;
|
||||
} else {
|
||||
throw new Error('无效的响应数据格式');
|
||||
}
|
||||
|
||||
// 创建下载链接
|
||||
const url = window.URL.createObjectURL(blobData);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
|
||||
// 生成文件名
|
||||
const now = new Date();
|
||||
const dateStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
||||
const timeStr = `${String(now.getHours()).padStart(2, '0')}_${String(now.getMinutes()).padStart(2, '0')}_${String(now.getSeconds()).padStart(2, '0')}`;
|
||||
link.download = `学生统计数据_${dateStr}_${timeStr}.xlsx`;
|
||||
|
||||
link.style.display = 'none';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
|
||||
ElMessage.success('导出成功');
|
||||
} catch (error) {
|
||||
console.error('导出失败:', error);
|
||||
|
||||
Reference in new issue
Block a user