Browse Source

Merge branch 'ETA_1.9.0'

zwxi 8 months ago
parent
commit
18afe1a0d2

+ 1 - 0
controllers/chart.go

@@ -278,6 +278,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key string) (
 		errMsg = "获取主题信息失败,Err:" + err.Error()
 		return
 	}
+
 	chartInfo.ChartThemeStyle = chartTheme.Config
 	chartInfo.ChartThemeId = chartTheme.ChartThemeId
 

+ 5 - 4
controllers/excel_info.go

@@ -131,8 +131,8 @@ func (this *ExcelInfoController) GetTableDetail() {
 			br.ErrMsg = "自定义表格数据获取失败,Err:" + err.Error()
 			return
 		}
-		excelInfo.ExcelSource = strings.Join(sourceNameList, ",")
-		excelInfo.ExcelSourceEn = strings.Join(sourceNameEnList, ",")
+		resp.ExcelSource = strings.Join(sourceNameList, ",")
+		resp.ExcelSourceEn = strings.Join(sourceNameEnList, ",")
 	case utils.MIXED_TABLE:
 		var result request.MixedTableReq
 		err = json.Unmarshal([]byte(excelInfo.Content), &result)
@@ -174,8 +174,8 @@ func (this *ExcelInfoController) GetTableDetail() {
 			br.ErrMsg = "自定义表格数据获取失败,Err:" + err.Error()
 			return
 		}
-		excelInfo.ExcelSource = strings.Join(sourceNameList, ",")
-		excelInfo.ExcelSourceEn = strings.Join(sourceNameEnList, ",")
+		resp.ExcelSource = strings.Join(sourceNameList, ",")
+		resp.ExcelSourceEn = strings.Join(sourceNameEnList, ",")
 	}
 
 	tableData = excel.HandleTableCell(tableData)
@@ -202,6 +202,7 @@ func (this *ExcelInfoController) GetTableDetail() {
 	resp.ExcelImage = excelInfo.ExcelImage
 	resp.UniqueCode = excelInfo.UniqueCode
 	resp.Config = config
+	resp.SourcesFrom = excelInfo.SourcesFrom
 
 	if utils.Re == nil {
 		data, _ := json.Marshal(resp)

+ 84 - 0
models/data_manage/chart_theme/chart_theme.go

@@ -149,3 +149,87 @@ func GetSystemChartTheme(chartThemeTypeId int) (item *ChartTheme, err error) {
 
 	return
 }
+
+type ColorsOptions []string
+
+type LegendOptions struct {
+	VerticalAlign string `json:"verticalAlign"`
+	ItemStyle     struct {
+		Color        string `json:"color"`
+		FontSize     int    `json:"fontSize"`
+		Cursor       string `json:"cursor"`
+		FontWeight   string `json:"fontWeight"`
+		TextOverflow string `json:"textOverflow"`
+	} `json:"itemStyle"`
+}
+
+type TitleOptions struct {
+	Align string `json:"align"`
+	Style struct {
+		Color    string `json:"color"`
+		FontSize int    `json:"fontSize"`
+	} `json:"style"`
+}
+
+type MarkerOptions struct {
+	Style struct {
+		Color    string `json:"color"`
+		FontSize int    `json:"fontSize"`
+	} `json:"style"`
+}
+
+type AxisOptions struct {
+	Style struct {
+		Color    string `json:"color"`
+		FontSize int    `json:"fontSize"`
+	} `json:"style"`
+}
+
+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"`
+	LegendOptions  interface{}        `json:"legendOptions"`
+	TitleOptions   interface{}        `json:"titleOptions"`
+	MarkerOptions  interface{}        `json:"markerOptions"`
+	XAxisOptions   interface{}        `json:"xAxisOptions"`
+	YAxisOptions   interface{}        `json:"yAxisOptions"`
+	DrawOption     interface{}        `json:"drawOption"`
+	LineOptionList []LineStyleOptions `json:"lineOptionList"`
+}
+
+type NewChartOptions struct {
+	OldChartOptions
+	LineOptionList []NewLineOptions `json:"lineOptionList"`
+}
+
+type NewLineOptions struct {
+	LineOptions
+	Color     string `json:"color"`
+	DataMark  string `json:"dataMark"`
+	MarkType  string `json:"markType"`
+	MarkSize  int    `json:"markSize"`
+	MarkColor string `json:"markColor"`
+}
+
+type LineStyleOptions struct {
+	DashStyle string `json:"dashStyle"`
+	Color     string `json:"color"`
+	LineWidth int    `json:"lineWidth"`
+	LineType  string `json:"lineType"`
+	Radius    int    `json:"radius"`
+	DataMark  string `json:"dataMark"`
+	MarkType  string `json:"markType"`
+	MarkSize  int    `json:"markSize"`
+	MarkColor string `json:"markColor"`
+}

+ 1 - 2
models/excel_info.go

@@ -171,8 +171,7 @@ type ExcelInfoView struct {
 	IsDelete        int       `description:"是否删除,0:未删除,1:已删除" json:"-"`
 	ModifyTime      time.Time `description:"最近修改日期"`
 	CreateTime      time.Time `description:"创建日期"`
-	ExcelSource     string    `description:"表格来源str"`
-	ExcelSourceEn   string    `description:"表格来源(英文)"`
+	SourcesFrom     string    `description:"图表来源"`
 }
 
 // GetExcelInfoByClassifyIdAndName 根据分类id和表格名获取表格信息

+ 10 - 7
models/response/excel_info.go

@@ -10,13 +10,16 @@ import (
 // ExcelTableDetailResp  excel表格详情
 type ExcelTableDetailResp struct {
 	//ChartInfo   *ChartInfo
-	UniqueCode string `description:"表格唯一code"`
-	Source     int    `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
-	ExcelType  int    `description:"表格类型,1:指标列,2:日期列,默认:1"`
-	ExcelImage string `description:"表格截图"`
-	ExcelName  string `description:"表格名称"`
-	TableInfo  excel.TableData
-	Config     ExcelTableDetailConfigResp
+	UniqueCode    string `description:"表格唯一code"`
+	Source        int    `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+	ExcelType     int    `description:"表格类型,1:指标列,2:日期列,默认:1"`
+	ExcelImage    string `description:"表格截图"`
+	ExcelName     string `description:"表格名称"`
+	SourcesFrom   string `description:"图表来源"`
+	ExcelSource   string `description:"表格来源str"`
+	ExcelSourceEn string `description:"表格来源(英文)"`
+	TableInfo     excel.TableData
+	Config        ExcelTableDetailConfigResp
 }
 
 // ExcelTableDetailConfigResp

+ 47 - 0
services/data/chart_theme.go

@@ -1,6 +1,7 @@
 package data
 
 import (
+	"encoding/json"
 	"eta/eta_chart_lib/models/data_manage/chart_theme"
 	"eta/eta_chart_lib/utils"
 )
@@ -24,6 +25,11 @@ func GetChartThemeConfig(chartThemeId, source, chartType int) (chartTheme *chart
 
 	// 如果找到了,那么就返回
 	if chartTheme != nil {
+		// 兼容历史数据,加入新字段LineOptionList
+		//newConfig, e := ConvertOldChartOptions(chartTheme.Config)
+		//if e == nil {
+		//	chartTheme.Config = newConfig
+		//}
 		return
 	}
 
@@ -45,11 +51,52 @@ func GetChartThemeConfig(chartThemeId, source, chartType int) (chartTheme *chart
 
 	// 如果找到了,那么就返回
 	if chartTheme != nil {
+		// 兼容历史数据,加入新字段LineOptionList
+		//newConfig, e := ConvertOldChartOptions(chartTheme.Config)
+		//if e == nil {
+		//	chartTheme.Config = newConfig
+		//}
 		return
 	}
 
 	// 如果还是没找到,那就系统的主题id
 	chartTheme, err = chart_theme.GetSystemChartTheme(chartThemeType.ChartThemeTypeId)
 
+	// 兼容历史数据,加入新字段LineOptionList
+	//newConfig, e := ConvertOldChartOptions(chartTheme.Config)
+	//if e == nil {
+	//	chartTheme.Config = newConfig
+	//}
 	return
 }
+
+
+// 兼容历史数据,加入新字段LineOptionList
+func ConvertOldChartOptions(config string) (newConfig string, err error) {
+	var oldTheme chart_theme.OldChartOptions
+
+	var newTheme chart_theme.NewChartOptions
+	err = json.Unmarshal([]byte(config), &oldTheme)
+	if err != nil {
+		return
+	}
+	if oldTheme.LineOptionList != nil && len(oldTheme.LineOptionList) > 0 {
+		newConfig = config
+		return
+	}
+	newTheme.OldChartOptions = oldTheme
+	for i := 0; i < 10; i++ {
+		newLineOption := chart_theme.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
+}