zwxi 9 hónapja
szülő
commit
b969f19ce3

+ 10 - 1
controllers/data_manage/chart_info.go

@@ -5,6 +5,7 @@ import (
 	"eta/eta_api/controllers"
 	"eta/eta_api/models"
 	"eta/eta_api/models/data_manage"
+	"eta/eta_api/models/data_manage/chart_theme/request"
 	"eta/eta_api/models/data_manage/response"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services"
@@ -2655,7 +2656,15 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 		errMsg = "获取主题信息失败,Err:" + err.Error()
 		return
 	}
-	chartInfo.ChartThemeStyle = chartTheme.Config
+
+	// 兼容历史数据,加入新字段LineOptionList
+	newConfig, e := data.ConvertOldChartOptions(chartTheme.Config)
+	if e != nil {
+		chartInfo.ChartThemeStyle = chartTheme.Config
+	} else {
+		chartInfo.ChartThemeStyle = newConfig
+	}
+
 	chartInfo.ChartThemeId = chartTheme.ChartThemeId
 
 	chartInfoId := chartInfo.ChartInfoId

+ 15 - 14
controllers/data_manage/chart_theme.go

@@ -52,23 +52,14 @@ func (c *ChartThemeController) List() {
 		br.ErrMsg = "获取图表样式类型信息失败,Err:" + err.Error()
 		return
 	}
-	var oldTheme request.OldChartOptions
+
+	// 兼容历史数据,加入新字段LineOptionList
 	for i, v := range list {
-		var newTheme request.NewChartOptions
-		err = json.Unmarshal([]byte(v.Config), &oldTheme)
-		if err != nil {
+		newConfig, e := data.ConvertOldChartOptions(v.Config)
+		if e != nil {
 			continue
 		}
-		newTheme.OldChartOptions = oldTheme
-		for i := 0; i < 10; i++ {
-			newLineOption := request.NewLineOptions{
-				LineOptions: oldTheme.LineOptions,
-				Color:       oldTheme.ColorsOptions[i],
-			}
-			newTheme.LineOptionList = append(newTheme.LineOptionList, newLineOption)
-		}
-		newThemeStr, _ := json.Marshal(newTheme)
-		list[i].Config = string(newThemeStr)
+		list[i].Config = newConfig
 	}
 
 	br.Ret = 200
@@ -679,6 +670,16 @@ func (c *ChartThemeController) ListBySource() {
 		return
 	}
 
+	// 兼容历史数据,加入新字段LineOptionList
+	for i, v := range list {
+		newConfig, e := data.ConvertOldChartOptions(v.Config)
+		if e != nil {
+			continue
+		}
+		list[i].Config = newConfig
+	}
+
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 7 - 6
controllers/data_manage/excel/excel_info.go

@@ -248,7 +248,7 @@ func (c *ExcelInfoController) Add() {
 		ParentId:           req.ParentId,
 		UpdateUserId:       sysUser.AdminId,
 		UpdateUserRealName: sysUser.RealName,
-		SourcesFrom:     req.SourcesFrom,
+		SourcesFrom:        req.SourcesFrom,
 	}
 
 	excelEdbMappingList := make([]*excel3.ExcelEdbMapping, 0)
@@ -1561,11 +1561,12 @@ func (c *ExcelInfoController) GetExcelTableData() {
 	}
 
 	resp := response.ExcelTableDetailResp{
-		UniqueCode: excelInfo.UniqueCode,
-		ExcelImage: excelInfo.ExcelImage,
-		ExcelName:  excelInfo.ExcelName,
-		TableInfo:  tableData,
-		Config:     config,
+		UniqueCode:  excelInfo.UniqueCode,
+		ExcelImage:  excelInfo.ExcelImage,
+		ExcelName:   excelInfo.ExcelName,
+		TableInfo:   tableData,
+		Config:      config,
+		SourcesFrom: excelInfo.SourcesFrom,
 	}
 	br.Ret = 200
 	br.Success = true

+ 12 - 8
models/data_manage/chart_theme/request/theme.go

@@ -31,13 +31,6 @@ type SetDefaultThemeReq struct {
 
 type ColorsOptions []string
 
-type LineOptions struct {
-	DashStyle string  `json:"dashStyle"`
-	LineWidth int     `json:"lineWidth"`
-	LineType  string  `json:"lineType"`
-	Radius    float64 `json:"radius"`
-}
-
 type LegendOptions struct {
 	VerticalAlign string `json:"verticalAlign"`
 	ItemStyle     struct {
@@ -75,6 +68,13 @@ type DrawOption struct {
 	PlotBackgroundColor string `json:"plotBackgroundColor"`
 }
 
+type LineOptions struct {
+	DashStyle string  `json:"dashStyle"`
+	LineWidth int     `json:"lineWidth"`
+	LineType  string  `json:"lineType"`
+	Radius    float64 `json:"radius"`
+}
+
 type OldChartOptions struct {
 	ColorsOptions []string    `json:"colorsOptions"`
 	LineOptions   LineOptions `json:"lineOptions"`
@@ -93,5 +93,9 @@ type NewChartOptions struct {
 
 type NewLineOptions struct {
 	LineOptions
-	Color string `json:"color"`
+	Color     string `json:"color"`
+	DataMark  string `json:"dataMark"`
+	MarkType  string `json:"markType"`
+	MarkSize  int    `json:"markSize"`
+	MarkColor string `json:"markColor"`
 }

+ 6 - 5
models/data_manage/excel/response/excel_info.go

@@ -22,11 +22,12 @@ type ExcelListResp struct {
 
 // ExcelTableDetailResp  excel表格详情
 type ExcelTableDetailResp struct {
-	UniqueCode string `description:"表格唯一code"`
-	ExcelImage string `description:"表格截图"`
-	ExcelName  string `description:"表格名称"`
-	TableInfo  excel.TableData
-	Config     ExcelTableDetailConfigResp
+	UniqueCode  string `description:"表格唯一code"`
+	ExcelImage  string `description:"表格截图"`
+	ExcelName   string `description:"表格名称"`
+	TableInfo   excel.TableData
+	Config      ExcelTableDetailConfigResp
+	SourcesFrom string `description:"图表来源"`
 }
 
 // ExcelTableDetailConfigResp

+ 27 - 0
services/data/chart_theme.go

@@ -5,6 +5,7 @@ import (
 	"errors"
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/models/data_manage/chart_theme"
+	"eta/eta_api/models/data_manage/chart_theme/request"
 	"eta/eta_api/utils"
 	"fmt"
 	"github.com/shopspring/decimal"
@@ -609,3 +610,29 @@ func GetChartThemeConfig(chartThemeId, source, chartType int) (chartTheme *chart
 
 	return
 }
+
+// 兼容历史数据,加入新字段LineOptionList
+func ConvertOldChartOptions(config string) (newConfig string, err error) {
+	var oldTheme request.OldChartOptions
+
+		var newTheme request.NewChartOptions
+		err = json.Unmarshal([]byte(config), &oldTheme)
+		if err != nil {
+			return
+		}
+		newTheme.OldChartOptions = oldTheme
+		for i := 0; i < 10; i++ {
+			newLineOption := request.NewLineOptions{
+				LineOptions: oldTheme.LineOptions,
+				Color:       oldTheme.ColorsOptions[i],
+				DataMark:    "none",
+				MarkType:    "square",
+				MarkSize:    5,
+				MarkColor:   oldTheme.ColorsOptions[i],
+			}
+			newTheme.LineOptionList = append(newTheme.LineOptionList, newLineOption)
+		}
+		newThemeStr, _ := json.Marshal(newTheme)
+		newConfig = string(newThemeStr)
+		return
+}