From a3d3fccd33ce1db87c4a9f15af8d98f85389663f Mon Sep 17 00:00:00 2001
From: zlwu <704541015@qq.com>
Date: Sun, 7 Sep 2025 20:54:52 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../xg/domain/vo/XgStudentStatisticsVo.java | 11 +++++-
web/src/views/xg/studentStatistics/index.vue | 35 ++++++++++++++++++-
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentStatisticsVo.java b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentStatisticsVo.java
index ed59ba95..a8a30042 100644
--- a/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentStatisticsVo.java
+++ b/backend/ruoyi-modules/ruoyi-xg/src/main/java/org/dromara/xg/domain/vo/XgStudentStatisticsVo.java
@@ -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;
}
diff --git a/web/src/views/xg/studentStatistics/index.vue b/web/src/views/xg/studentStatistics/index.vue
index c9223a15..1edb434c 100644
--- a/web/src/views/xg/studentStatistics/index.vue
+++ b/web/src/views/xg/studentStatistics/index.vue
@@ -99,6 +99,7 @@
@@ -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);