From e8e51ffed8ba7ef5f4bbdf6d43c5380448189bd4 Mon Sep 17 00:00:00 2001 From: chenlin Date: Sun, 27 Apr 2025 10:39:29 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=8E=86=E5=8F=B2=E6=B1=87=E6=80=BB?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=E5=AF=BC=E5=87=BAexcel?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/apis/migumanage/migu_admin.go | 14 ++++++++++++++ app/admin/models/migu.go | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/admin/apis/migumanage/migu_admin.go b/app/admin/apis/migumanage/migu_admin.go index 7514629..32a4914 100644 --- a/app/admin/apis/migumanage/migu_admin.go +++ b/app/admin/apis/migumanage/migu_admin.go @@ -3232,6 +3232,20 @@ func (e MiGuDeployService) HistoricalSummaryListNewByCatch(c *gin.Context) { return summaries[i].Date > summaries[j].Date }) + // 判断是否导出Excel + if req.IsExport == 1 { + // 调用导出Excel函数 + url, err := models.ExportHistoricalSummaryToExcel(summaries, e.Orm) + if err != nil { + response.Error(c, http.StatusInternalServerError, err, "导出失败") + return + } + + // 返回导出文件的URL地址 + response.OK(c, map[string]string{"export_url": url}, "导出成功") + return + } + // 4. 分页 total := len(summaries) start := (req.PageNum - 1) * req.PageSize diff --git a/app/admin/models/migu.go b/app/admin/models/migu.go index 88bca9f..4eccdbd 100644 --- a/app/admin/models/migu.go +++ b/app/admin/models/migu.go @@ -1449,7 +1449,7 @@ func ExportHistoricalSummaryToExcel(data []MgHistoricalSummary, db *gorm.DB) (st for i, record := range data { row := i + 2 productName := productMap[record.ProductID] // 获取产品名称 - file.SetCellValue(sheet, "A"+strconv.Itoa(row), record.Date) + file.SetCellValue(sheet, "A"+strconv.Itoa(row), record.Date[:10]) file.SetCellValue(sheet, "B"+strconv.Itoa(row), productName) file.SetCellValue(sheet, "C"+strconv.Itoa(row), record.ChannelCode) file.SetCellValue(sheet, "D"+strconv.Itoa(row), record.SubmissionCount)