export: add project name to CSV filename format
Update filename format to include both project and quotation names: YYYY-MM-DD (PROJECT-NAME) QUOTATION-NAME BOM.csv Changes: - Add ProjectName field to ExportRequest (optional) - Update ExportCSV: use project_name if provided, otherwise fall back to name - Update ExportConfigCSV: use config name for both project and quotation Example filenames: 2026-02-09 (OPS-1957) config1 BOM.csv 2026-02-09 (MyProject) MyQuotation BOM.csv Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ func NewExportHandler(
|
|||||||
|
|
||||||
type ExportRequest struct {
|
type ExportRequest struct {
|
||||||
Name string `json:"name" binding:"required"`
|
Name string `json:"name" binding:"required"`
|
||||||
|
ProjectName string `json:"project_name"`
|
||||||
Items []struct {
|
Items []struct {
|
||||||
LotName string `json:"lot_name" binding:"required"`
|
LotName string `json:"lot_name" binding:"required"`
|
||||||
Quantity int `json:"quantity" binding:"required,min=1"`
|
Quantity int `json:"quantity" binding:"required,min=1"`
|
||||||
@@ -54,7 +55,11 @@ func (h *ExportHandler) ExportCSV(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set headers before streaming
|
// Set headers before streaming
|
||||||
filename := fmt.Sprintf("%s (%s) BOM.csv", time.Now().Format("2006-01-02"), req.Name)
|
projectName := req.ProjectName
|
||||||
|
if projectName == "" {
|
||||||
|
projectName = req.Name
|
||||||
|
}
|
||||||
|
filename := fmt.Sprintf("%s (%s) %s BOM.csv", time.Now().Format("2006-01-02"), projectName, req.Name)
|
||||||
c.Header("Content-Type", "text/csv; charset=utf-8")
|
c.Header("Content-Type", "text/csv; charset=utf-8")
|
||||||
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
|
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
|
||||||
|
|
||||||
@@ -124,7 +129,8 @@ func (h *ExportHandler) ExportConfigCSV(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set headers before streaming
|
// Set headers before streaming
|
||||||
filename := fmt.Sprintf("%s (%s) BOM.csv", config.CreatedAt.Format("2006-01-02"), config.Name)
|
// For config export, use config name for both project and quotation name
|
||||||
|
filename := fmt.Sprintf("%s (%s) %s BOM.csv", config.CreatedAt.Format("2006-01-02"), config.Name, config.Name)
|
||||||
c.Header("Content-Type", "text/csv; charset=utf-8")
|
c.Header("Content-Type", "text/csv; charset=utf-8")
|
||||||
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
|
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user