zwxi 8 月之前
父節點
當前提交
73a36817f8

+ 18 - 2
controllers/data_manage/chart_info.go

@@ -1508,7 +1508,14 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 		br.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
 
 	dateType := chartInfo.DateType
@@ -2660,7 +2667,16 @@ 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

+ 10 - 0
controllers/data_manage/chart_theme.go

@@ -52,6 +52,16 @@ func (c *ChartThemeController) List() {
 		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 = "获取成功"

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

@@ -229,6 +229,7 @@ func (c *ExcelInfoController) Add() {
 		IsDelete:        0,
 		ModifyTime:      time.Now(),
 		CreateTime:      time.Now(),
+		SourcesFrom:     req.SourcesFrom,
 	}
 
 	excelEdbMappingList := make([]*excel3.ExcelEdbMapping, 0)
@@ -732,13 +733,14 @@ func (c *ExcelInfoController) Edit() {
 	excelInfo.ExcelClassifyId = req.ExcelClassifyId
 	excelInfo.ExcelImage = req.ExcelImage
 	excelInfo.Content = content
+	excelInfo.SourcesFrom = req.SourcesFrom
 
 	// 自动保存时不会传缩略图,也就不更新这个字段
 	var updateExcelInfoParams []string
 	if req.ExcelImage != "" {
-		updateExcelInfoParams = []string{"ModifyTime", "ExcelName", "ExcelType", "ExcelClassifyId", "ExcelImage", "Content"}
+		updateExcelInfoParams = []string{"ModifyTime", "ExcelName", "ExcelType", "ExcelClassifyId", "ExcelImage", "Content", "SourcesFrom"}
 	} else {
-		updateExcelInfoParams = []string{"ModifyTime", "ExcelName", "ExcelType", "ExcelClassifyId", "Content"}
+		updateExcelInfoParams = []string{"ModifyTime", "ExcelName", "ExcelType", "ExcelClassifyId", "Content", "SourcesFrom"}
 	}
 
 	excelEdbMappingList := make([]*excel3.ExcelEdbMapping, 0)
@@ -1347,11 +1349,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

+ 85 - 0
models/data_manage/chart_theme/request/theme.go

@@ -28,3 +28,88 @@ type SetDefaultThemeReq struct {
 	ChartThemeId     int `description:"主题id"`
 	ChartThemeTypeId int `description:"主题类型id"`
 }
+
+
+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 - 0
models/data_manage/excel/excel_info.go

@@ -31,6 +31,7 @@ type ExcelInfo struct {
 	UpdateUserRealName string    `description:"更新人真实姓名"`
 	RelExcelInfoId     int       `description:"平衡表里静态表关联的动态表excel id"`
 	VersionName        string    `description:"静态表版本名称"`
+	SourcesFrom        string    `description:"图表来源"`
 }
 
 // Update 更新 excel表格基础信息

+ 2 - 0
models/data_manage/excel/request/excel_info.go

@@ -23,6 +23,7 @@ type AddExcelInfoReq struct {
 	ExcelClassifyId int         `description:"分类id"`
 	Content         string      `description:"Excel表格内容"`
 	TableData       interface{} `description:"自定义表格的数据内容"`
+	SourcesFrom     string      `description:"图表来源"`
 }
 
 // EditExcelInfoReq 编辑表格请求
@@ -34,6 +35,7 @@ type EditExcelInfoReq struct {
 	ExcelClassifyId int         `description:"分类id"`
 	Content         string      `description:"Excel表格内容"`
 	TableData       interface{} `description:"自定义表格的数据内容"`
+	SourcesFrom     string      `description:"图表来源"`
 }
 
 // SetExcelInfoImageReq 设置excel表格图片请求

+ 7 - 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
@@ -82,6 +83,7 @@ type ExcelInfoDetail struct {
 	UpdateUserId       int                          `description:"更新人id"`
 	UpdateUserRealName string                       `description:"更新人真实姓名"`
 	RelExcelInfoId     int                          `description:"平衡表里静态表关联的动态表excel id"`
+	SourcesFrom        string                       `description:"图表来源"`
 }
 
 // ExcelInfoDetailButton 操作按钮

+ 32 - 0
services/data/chart_theme.go

@@ -5,6 +5,7 @@ import (
 	"errors"
 	"eta/eta_mobile/models/data_manage"
 	"eta/eta_mobile/models/data_manage/chart_theme"
+	"eta/eta_mobile/models/data_manage/chart_theme/request"
 	"eta/eta_mobile/utils"
 	"fmt"
 	"github.com/shopspring/decimal"
@@ -609,3 +610,34 @@ 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
+	}
+	if oldTheme.LineOptionList != nil && len(oldTheme.LineOptionList) > 0 {
+		newConfig = config
+		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
+}

+ 1 - 0
services/data/excel/excel_info.go

@@ -99,6 +99,7 @@ func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang stri
 		CreateTime:      excelInfo.CreateTime,
 		TableData:       nil,
 		HaveOperaAuth:   haveOperaAuth,
+		SourcesFrom:     excelInfo.SourcesFrom,
 	}
 
 	// 无权限,不需要返回数据