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)