Browse Source

fix:审批列表接口新增返回布局方式字段

Roc 8 months ago
parent
commit
84baf87de1

+ 31 - 0
controllers/report_approve/report_approve.go

@@ -317,6 +317,26 @@ func (this *ReportApproveController) List() {
 		ormList = list
 	}
 
+	cnReportIdList := make([]int, 0)
+	for _, v := range ormList {
+		if v.ReportType == report_approve.FlowReportTypeChinese {
+			cnReportIdList = append(cnReportIdList, v.ReportId)
+		}
+	}
+
+	reportLayoutMap := make(map[int]int8)
+	if len(cnReportIdList) > 0 {
+		layoutList, e := models.GetReportLayoutByReportIdList(cnReportIdList)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "GetReportLayoutByReportIdList err: " + e.Error()
+			return
+		}
+		for _, v := range layoutList {
+			reportLayoutMap[v.Id] = v.ReportLayout
+		}
+	}
+
 	// 格式化列表
 	for _, v := range ormList {
 		t := report_approve.FormatReportApproveOrm2Item(v)
@@ -333,6 +353,17 @@ func (this *ReportApproveController) List() {
 			}
 			t.ReportClassify = reportClassify
 		}
+
+		// 布局方式
+		{
+			t.ReportLayout = 1
+			if v.ReportType == report_approve.FlowReportTypeChinese {
+				if layout, ok := reportLayoutMap[v.ReportId]; ok {
+					t.ReportLayout = layout
+				}
+			}
+		}
+
 		respList = append(respList, t)
 	}
 

+ 26 - 0
models/report.go

@@ -1449,3 +1449,29 @@ func InsertMultiReport(items []*Report) (err error) {
 
 	return
 }
+
+// ReportLayout
+// @Description: 报告布局
+type ReportLayout struct {
+	Id           int
+	ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
+}
+
+// GetReportLayoutByReportIdList
+// @Description: 根据报告id获取报告的布局列表
+// @author: Roc
+// @datetime 2024-07-15 14:38:10
+// @param reportIdList []int
+// @return items []ReportLayout
+// @return err error
+func GetReportLayoutByReportIdList(reportIdList []int) (items []ReportLayout, err error) {
+	num := len(reportIdList)
+	if num <= 0 {
+		return
+	}
+	o := orm.NewOrmUsingDB("rddp")
+
+	sql := `SELECT id, report_layout  FROM report  WHERE id in (` + utils.GetOrmInReplace(num) + `) `
+	_, err = o.Raw(sql, reportIdList).QueryRows(&items)
+	return
+}

+ 1 - 0
models/report_approve/report_approve.go

@@ -199,6 +199,7 @@ type ReportApproveItem struct {
 	HandleTime            string `description:"处理时间"`
 	CreateTime            string `description:"创建时间"`
 	ModifyTime            string `description:"修改时间"`
+	ReportLayout          int8   `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
 }
 
 // FormatReportApproveOrm2Item 格式化报告审批