Ver Fonte

switch branch

Karsa há 1 ano atrás
pai
commit
c6c898549f

+ 9 - 0
src/api/modules/chartThemeApi.js

@@ -61,4 +61,13 @@ export const setConfigTheme = params => {
  */
 export const previewChartData = params => {
   return http.get('/datamanage/chart/theme/preview_data',params)
+}
+
+/**
+ * 获取主题列表
+ * @param {*} params  ChartType  Source
+ * @returns 
+ */
+export const getThemeBySource = params => {
+  return http.get('/datamanage/chart/theme/list_by_source',params)
 }

+ 6 - 5
src/views/dataEntry_manage/addChart.vue

@@ -43,16 +43,16 @@
 
 					<el-form-item label="图表主题" prop="Theme">
 						<el-select
-							v-model="chartInfo.Theme"
+							v-model="chartInfo.ThemeId"
 							placeholder="请选择图表主题"
 							style="width: 90%"
-							@change="resetChartEdbDefault"
+							@change="changeThemeHandle"
 						>
 							<el-option
 								v-for="item in chartThemeArr"
-								:key="item.key"
-								:label="item.label"
-								:value="item.key"
+								:key="item.ChartThemeId"
+								:label="item.ChartThemeName"
+								:value="item.ChartThemeId"
 							>
 							</el-option>
 						</el-select>
@@ -789,6 +789,7 @@ export default {
 	},
   mounted() {
 		this.getMenu();
+		this.getThemeList();
 		window.addEventListener('resize', this.reloadRightWid);
 	},
 	destroyed() {

+ 2 - 1
src/views/dataEntry_manage/editChart.vue

@@ -51,7 +51,7 @@
 
 					<el-form-item label="图表主题" prop="Theme">
 						<el-select
-							v-model="chartInfo.Theme"
+							v-model="chartInfo.ThemeId"
 							placeholder="请选择图表主题"
 							style="width: 90%"
 						>
@@ -855,6 +855,7 @@ export default {
   mounted() {
 		this.getMenu();
 		this.getChartInfo();
+		this.getThemeList();
 		this.reloadRightWid();
 		window.addEventListener('resize', this.reloadRightWid);
 	},

+ 29 - 15
src/views/dataEntry_manage/mixins/addOreditMixin.js

@@ -14,7 +14,7 @@ export default {
 				Source:1,
 				Unit: '',
 				ChartName: '',
-				Theme: 0,
+				ThemeId: 0,
 				SourcesFrom: 'wind,ths',
 				SourcesFromVisible: 1,
 				Instructions: '图标说明是的货物以带回去五个一给我倭寇的贫困我的卡我极为强劲的的我吉庆街得我',
@@ -414,14 +414,14 @@ export default {
 
 		/* 添加指标时 配置默认颜色 线条等 */
 		setAddChartDefault() {
+
+			let themeOpt = JSON.parse(this.chartInfo.ChartThemeStyle);
+
 			this.tableData.forEach((item,index) => {
-				item.ChartColor = item.ChartColor || defaultOpts.colors[index];
-				item.PredictChartColor = item.PredictChartColor || defaultOpts.colors[index];
-				item.ChartStyle = item.ChartStyle || 'spline';
-				if (index === 0)
-					this.tableData[index].ChartWidth = this.tableData[index].ChartWidth || 3;
-				if (index >= 1)
-					this.tableData[index].ChartWidth = this.tableData[index].ChartWidth || 1;
+				item.ChartColor = item.ChartColor || themeOpt.colorsOptions[index];
+				item.PredictChartColor = item.PredictChartColor || themeOpt.colorsOptions[index];
+				item.ChartStyle = item.ChartStyle || (themeOpt.lineOptions.isSpline?'spline':'line');
+				this.tableData[index].ChartWidth = this.tableData[index].ChartWidth || themeOpt.lineOptions.lineWidth;
 			})
 		},
 
@@ -711,26 +711,40 @@ export default {
 			}
 		},
 
-		/* 重置指标相关样式 */
+		/* 重置指标相关样式 颜色 粗细 */
 		resetChartEdbDefault() {
 			if(!this.tableData.length) return
+
+			let themeOpt = JSON.parse(this.chartInfo.ChartThemeStyle);
 			this.tableData.forEach((item,index) => {
-				item.ChartColor = defaultOpts.colors[index];
-				item.PredictChartColor = defaultOpts.colors[index];
-				item.ChartStyle = item.ChartStyle || 'spline';
+				item.ChartColor = themeOpt.colorsOptions[index];
+				item.PredictChartColor = themeOpt.colorsOptions[index];
+				item.ChartStyle = themeOpt.lineOptions.isSpline?'spline':'line';
 				item.isAxis = item.isAxis||1;
 
-				this.tableData[index].ChartWidth = index === 0 ? 3 : 1;
+				this.tableData[index].ChartWidth = themeOpt.lineOptions.lineWidth;
 			})
 		},
 
 		/* 获取主题列表 */
 		async getThemeList() {
-			let res =  await chartThemeInterface.getThemeByType({ChartThemeTypeId: this.formData.chartType})
+			let res =  await chartThemeInterface.getThemeBySource({ChartType: this.chartInfo.ChartType,Source:1})
 
 			if(res.Ret !== 200) return
       this.chartThemeArr = res.Data || []
-      this.chartInfo.ThemeId = res.Data[0].DefaultChartThemeId
+      this.chartInfo.ThemeId = res.Data[0].DefaultChartThemeId;
+
+			if(!this.chartInfo.ChartThemeStyle) {
+				this.chartInfo.ChartThemeStyle = this.chartThemeArr.find(_ => _.ChartThemeId===this.chartInfo.ThemeId).Config
+			}
+		},
+
+		/* 改变主题时 */
+		changeThemeHandle() {
+			this.chartInfo.ChartThemeStyle = this.chartThemeArr.find(_ => _.ChartThemeId===this.chartInfo.ThemeId).Config;
+			this.resetChartEdbDefault()
+
+			this.setChartOptionHandle(this.tableData)
 		},
 
 		/* 更新图表标识区,标识线,图表说明 */