Bläddra i källkod

兼容没有上下限的图表,兼容预测指标、ETA逻辑链接、图表配置-主题设置

cxmo 10 månader sedan
förälder
incheckning
8f7e00d3f3

+ 3 - 4
src/views/dataEntry_manage/addChart.vue

@@ -459,7 +459,7 @@
 								/>
 							</div> -->
 							<!-- 需求:曲线图、堆积柱状图、组合图加入新指标时上下限自动调整 -->
-							<template v-if="![7,10].includes(chartInfo.ChartType)">
+							<template v-if="![7,10,11].includes(chartInfo.ChartType)">
 								<div class="range-cont left" v-if="leftIndex !== -1">
 									<el-input
 										style="width: 60px; display: block"
@@ -697,7 +697,6 @@ import { dataBaseInterface } from '@/api/api.js';
 import { chartSetMixin } from './mixins/chartPublic';
 import {unitArr} from '@/utils/defaultOptions.js';
 import addOrEditMixn from './mixins/addOreditMixin';
-import changeLimit from './mixins/changeLimit';
 import Chart from './components/chart';
 import DateChooseDia from './components/DateChooseDia';
 import barOption from './components/barOptionSection.vue';
@@ -767,7 +766,7 @@ export default {
 			return localStorage.getItem('userName');
 		}
 	},
-	mixins: [chartSetMixin,addOrEditMixn,changeLimit],
+	mixins: [chartSetMixin,addOrEditMixn],
   data() {
     return {
 			isSlideLeft: false,
@@ -856,7 +855,7 @@ export default {
 								EndDate: this.year_select === 5 ? this.select_date[1] : '',
 							} 
 						: typePrams
-					if(![7,10].includes(this.chartInfo.ChartType)){
+					if(![7,10,11].includes(this.chartInfo.ChartType)){
 						params = {
 							...params,
 							LeftMin:this.leftLimitData[1]+'',

+ 5 - 9
src/views/dataEntry_manage/chartSetting.vue

@@ -861,7 +861,6 @@ import {
   copyOtherOptions
 } from '@/utils/defaultOptions';
 import { chartSetMixin } from './mixins/chartPublic'
-import changeLimit from './mixins/changeLimit';
 import mPage from '@/components/mPage';
 import Chart from './components/chart';
 import chartDialog from './components/chartDialog';
@@ -910,7 +909,7 @@ export default {
       };
     },
   },
-  mixins: [chartSetMixin,changeLimit],
+  mixins: [chartSetMixin],
   data() {
     return {
       showData: false,
@@ -1659,12 +1658,9 @@ export default {
 			this.setDefaultSourceFrom();
   
       this.tableData = res.Data.EdbInfoList;
-      //若没有手动改过上下限,则初始化上下限
-      if(!this.chartInfo.MinMaxSave){
-            this.calcYAxislimit()
-        }else{
-            this.setLimitData()
-        }
+      //初始化上下限
+      this.setLimitData(this.tableData)
+        
       // 设置起始日期和最新日期
       this.setExtremumDate()
 
@@ -1917,7 +1913,7 @@ export default {
               EndDate: this.year_select === 5 ? this.select_date[1] : '',
             }
           : typeChartParam;
-        if(![7,10].includes(this.selected_chartType)){
+        if(![7,10,11].includes(this.selected_chartType)){
             params = {
                 ...params,
                 LeftMin:this.leftLimitData[1]+'',

+ 4 - 5
src/views/dataEntry_manage/editChart.vue

@@ -456,7 +456,7 @@
 								/>
 							</div> -->
 							<!-- 需求:曲线图、堆积柱状图、组合图加入新指标时上下限自动调整 -->
-							<template v-if="![7,10].includes(chartInfo.ChartType)">
+							<template v-if="![7,10,11].includes(chartInfo.ChartType)">
 								<div class="range-cont left" v-if="leftIndex !== -1">
 									<el-input
 										style="width: 60px; display: block"
@@ -698,7 +698,6 @@ import { dataBaseInterface } from '@/api/api.js';
 import { chartSetMixin } from './mixins/chartPublic';
 import {unitArr} from '@/utils/defaultOptions.js'
 import addOrEditMixn from './mixins/addOreditMixin';
-import changeLimit from './mixins/changeLimit';
 import Chart from './components/chart';
 import DateChooseDia from './components/DateChooseDia';
 import SaveChartOther from './components/SaveChartOther';
@@ -757,7 +756,7 @@ export default {
       deep: true,
     },
 	},
-	mixins: [chartSetMixin,addOrEditMixn,changeLimit],
+	mixins: [chartSetMixin,addOrEditMixn],
   data() {
     return {
 			isSlideLeft: false,
@@ -824,7 +823,7 @@ export default {
 					this.chartInfo.ChartType === 11 && this.initRadarData(res.Data);
 					
 					this.getThemeList();
-					this.getLimitData()
+					this.setLimitData(this.tableData)
 
         });
 		},
@@ -963,7 +962,7 @@ export default {
 							height: 230,
 						}
 					});
-					if(![7,10].includes(this.chartInfo.ChartType)){
+					if(![7,10,11].includes(this.chartInfo.ChartType)){
 						params = {
 							...params,
 							LeftMin:this.leftLimitData[1]+'',

+ 2 - 31
src/views/dataEntry_manage/mixins/addOreditMixin.js

@@ -932,11 +932,11 @@ export default {
 				isShow:this.chartInfo.SourcesFromVisable
 			})
 		},
-		/* 指标切换左右轴*/
+		/* 图表轴发生变化:增加/删除指标,改变指标左右轴*/
 		EdbAxisChange(){
 			//若用户没有修改过,则计算y轴的上下限
 			if(!this.chartInfo.MinMaxSave){
-				this.calcYAxislimit()
+				this.calcYAxislimit(this.tableData)
 			}
 		},
 		//新增/编辑保存图表时-判断用户有没有手动更改过上下限
@@ -982,34 +982,5 @@ export default {
 			let limitSame = leftLimitSame&&rightLimitSame&&rightTwoLimitSame
 			return limitSame
 		},
-		//编辑图表-获取接口的上下限数据赋值
-		getLimitData(){
-			const {
-				//左右轴极值字段 
-				LeftMin=0,LeftMax=0,
-				RightMin=0,RightMax=0,
-				Right2Min=0,Right2Max=0,
-				MinMaxSave
-			} = this.chartInfo
-			if(MinMaxSave){
-				this.leftLimitData = [Number(LeftMin),Number(LeftMax)]
-				this.rightLimitData = [Number(RightMin),Number(RightMax)]
-				this.rightTwoLimitData = [Number(Right2Min),Number(Right2Max)]
-				//右二轴之前没存字段,需要单独处理下
-				//若右二轴的上下限均为0,则不管用户有没有修改过,都重新赋值
-				if(this.rightTwoLimitData[0]===0&&this.rightTwoLimitData[1]===0){
-					const rightTwoData = this.tableData.filter(i=>i.IsAxis===2).map(i=>[Number(i.MinData),Number(i.MaxData)])
-					if(rightTwoData.length){
-						const {Max,Min} = this.calcLimit(rightTwoData.flat())
-						this.rightTwoLimitData = [Max,Min]
-					}else{
-						this.rightTwoLimitData = [0,0]
-					}
-				}
-			}else{
-				this.EdbAxisChange()
-			}
-			
-		}
 	}
 }

+ 0 - 85
src/views/dataEntry_manage/mixins/changeLimit.js

@@ -1,85 +0,0 @@
-export default {
-    data() {
-        return {
-            leftLimitData:[0,0],//左轴上下限
-            rightLimitData:[0,0],//右轴上下限
-            rightTwoLimitData:[0,0],//右二轴上下限
-        }
-    },
-    methods: {
-        /* 计算y轴上下限 */
-        calcYAxislimit(type) {
-            //分组
-            const leftData = this.tableData.filter(i => i.IsAxis === 1).map(i => [Number(i.MinData), Number(i.MaxData)])
-            const rightData = this.tableData.filter(i => !i.IsAxis).map(i => [Number(i.MinData), Number(i.MaxData)])
-            const rightTwoData = this.tableData.filter(i => i.IsAxis === 2).map(i => [Number(i.MinData), Number(i.MaxData)])
-            //计算最大最小值
-            if (leftData.length) {
-                const {
-                    Max,
-                    Min
-                } = this.calcLimit(leftData.flat())
-                this.leftLimitData = [Max, Min]
-            } else {
-                this.leftIndex = -1
-                this.leftLimitData = [0, 0]
-            }
-            if (rightData.length) {
-                const {
-                    Max,
-                    Min
-                } = this.calcLimit(rightData.flat())
-                this.rightLimitData = [Max, Min]
-            } else {
-                this.rightIndex = -1
-                this.rightLimitData = [0, 0]
-            }
-            if (rightTwoData.length) {
-                const {
-                    Max,
-                    Min
-                } = this.calcLimit(rightTwoData.flat())
-                this.rightTwoLimitData = [Max, Min]
-            } else {
-                this.rightTwoIndex = -1
-                this.rightTwoLimitData = [0, 0]
-            }
-            console.table([{
-                    'y轴': '左轴',
-                    '最大值': this.leftLimitData[0],
-                    '最小值': this.leftLimitData[1]
-                },
-                {
-                    'y轴': '右轴',
-                    '最大值': this.rightLimitData[0],
-                    '最小值': this.rightLimitData[1]
-                },
-                {
-                    'y轴': '右二轴',
-                    '最大值': this.rightTwoLimitData[0],
-                    '最小值': this.rightTwoLimitData[1]
-                }
-            ])
-        },
-        calcLimit(arr) {
-            return {
-                Max: Math.max(...arr),
-                Min: Math.min(...arr)
-            }
-        },
-        changeAxisLimit() {
-            this.setAddChartDefault&&this.setAddChartDefault();
-            this.setChartOptionHandle(this.tableData);
-        },
-        setLimitData(){
-            this.leftLimitData[1] = this.chartInfo.LeftMin
-            this.leftLimitData[0] = this.chartInfo.LeftMax
-
-            this.rightLimitData[1] = this.chartInfo.RightMin
-            this.rightLimitData[0] = this.chartInfo.RightMax
-        
-            this.rightTwoLimitData[1] = this.chartInfo.Right2Min
-            this.rightTwoLimitData[0] = this.chartInfo.Right2Max
-        }
-    }
-}

+ 130 - 8
src/views/dataEntry_manage/mixins/chartPublic.js

@@ -38,7 +38,7 @@ const basicYAxis = {
 }
 /**备注一下 越多越乱
  * @params
- * Source 1 ; chartType 1曲线 2季节 3面积 4堆积柱 5散点 6组合 7柱形 8截面散点
+ * Source 1 ; chartType 1曲线 2季节 3面积 4堆积柱 5散点 6组合 7柱形 10截面散点 11雷达图
  * 2 商品价格
  * 3 相关性
  * 4 滚动相关性
@@ -134,6 +134,9 @@ export const chartSetMixin = {
       leftIndex: -1, //左侧上下限对应下标
       rightIndex: -1, //右侧上下限对应下标
       rightTwoIndex: -1,//右2上下限对应下标
+      leftLimitData:[0,0],//左轴上下限
+      rightLimitData:[0,0],//右轴上下限
+      rightTwoLimitData:[0,0],//右二轴上下限
       left_extreme: [],
       right_extreme: [],
       
@@ -590,15 +593,23 @@ export const chartSetMixin = {
         );
         
         //获取对应轴的上下限
+        //预测指标-走势图;图表配置-主题设置;不使用自定义上下限,剔除
+        const useTableLimit = ['/predictEdb','/chartThemeSet'].includes(this.$route.path)
         let minLimit = 0,maxLimit = 0
-        const limitMap = {
-            0:this.rightLimitData||[],
-            1:this.leftLimitData||[],
-            2:this.rightTwoLimitData||[]
+        if(useTableLimit){
+            minLimit = this.tableData[sameSideIndex].MinData
+            maxLimit = this.tableData[sameSideIndex].MaxData
+        }else{
+            const limitMap = {
+                0:this.rightLimitData||[],
+                1:this.leftLimitData||[],
+                2:this.rightTwoLimitData||[]
+            }
+            minLimit = limitMap[item.IsAxis][1]||0
+            maxLimit = limitMap[item.IsAxis][0]||0
         }
-        minLimit = limitMap[item.IsAxis][1]||0
-        maxLimit = limitMap[item.IsAxis][0]||0
-
+        
+        
         //y轴
         let yItem = {
           ...basicYAxis,
@@ -2609,5 +2620,116 @@ export const chartSetMixin = {
 				});
 			}
 		},
+    
+        /* 计算y轴上下限 */
+        calcYAxislimit(tableData=[]) {
+            //分组
+            const leftData = tableData.filter(i => i.IsAxis === 1).map(i => [Number(i.MinData), Number(i.MaxData)])
+            const rightData = tableData.filter(i => !i.IsAxis).map(i => [Number(i.MinData), Number(i.MaxData)])
+            const rightTwoData = tableData.filter(i => i.IsAxis === 2).map(i => [Number(i.MinData), Number(i.MaxData)])
+            //计算最大最小值
+            if (leftData.length) {
+                const {
+                    Max,
+                    Min
+                } = this.calcLimit(leftData.flat())
+                this.leftLimitData = [Max, Min]
+            } else {
+                this.leftIndex = -1
+                this.leftLimitData = [0, 0]
+            }
+            if (rightData.length) {
+                const {
+                    Max,
+                    Min
+                } = this.calcLimit(rightData.flat())
+                this.rightLimitData = [Max, Min]
+            } else {
+                this.rightIndex = -1
+                this.rightLimitData = [0, 0]
+            }
+            if (rightTwoData.length) {
+                const {
+                    Max,
+                    Min
+                } = this.calcLimit(rightTwoData.flat())
+                this.rightTwoLimitData = [Max, Min]
+            } else {
+                this.rightTwoIndex = -1
+                this.rightTwoLimitData = [0, 0]
+            }
+            console.table([{
+                    'y轴': '左轴',
+                    '最大值': this.leftLimitData[0],
+                    '最小值': this.leftLimitData[1]
+                },
+                {
+                    'y轴': '右轴',
+                    '最大值': this.rightLimitData[0],
+                    '最小值': this.rightLimitData[1]
+                },
+                {
+                    'y轴': '右二轴',
+                    '最大值': this.rightTwoLimitData[0],
+                    '最小值': this.rightTwoLimitData[1]
+                }
+            ])
+        },
+        calcLimit(arr) {
+            return {
+                Max: Math.max(...arr),
+                Min: Math.min(...arr)
+            }
+        },
+        //输入框改变上下限时触发
+        changeAxisLimit() {
+            this.setAddChartDefault&&this.setAddChartDefault();
+            this.setChartOptionHandle(this.tableData);
+        },
+        //图表详情-设置图表上下限
+        setLimitData(tableData=[]){
+            const {
+                //左右轴极值字段 
+                LeftMin=0,LeftMax=0,
+                RightMin=0,RightMax=0,
+                Right2Min=0,Right2Max=0,
+                MinMaxSave
+            } = this.chartInfo
+            if(MinMaxSave){
+                this.leftLimitData = [Number(LeftMax),Number(LeftMin)]
+                this.rightLimitData = [Number(RightMax),Number(RightMin)]
+                this.rightTwoLimitData = [Number(Right2Max),Number(Right2Min)]
+                //若轴的上下限均为0,则不管用户有没有修改过,都重新赋值
+                if(this.leftLimitData[0]===0&&this.leftLimitData[1]===0){
+                    const leftData = tableData.filter(i=>i.IsAxis===1).map(i=>[Number(i.MinData),Number(i.MaxData)])
+                    if(leftData.length){
+                        const {Max,Min} = this.calcLimit(leftData.flat())
+                        this.leftLimitData = [Max,Min]
+                    }else{
+                        this.leftLimitData = [0,0]
+                    }
+                }
+                if(this.rightLimitData[0]===0&&this.rightLimitData[1]===0){
+                    const rightData = tableData.filter(i => !i.IsAxis).map(i=>[Number(i.MinData),Number(i.MaxData)])
+                    if(rightData.length){
+                        const {Max,Min} = this.calcLimit(rightData.flat())
+                        this.rightLimitData = [Max,Min]
+                    }else{
+                        this.rightLimitData = [0,0]
+                    }
+                }
+                if(this.rightTwoLimitData[0]===0&&this.rightTwoLimitData[1]===0){
+                    const rightTwoData = tableData.filter(i=>i.IsAxis===2).map(i=>[Number(i.MinData),Number(i.MaxData)])
+                    if(rightTwoData.length){
+                        const {Max,Min} = this.calcLimit(rightTwoData.flat())
+                        this.rightTwoLimitData = [Max,Min]
+                    }else{
+                        this.rightTwoLimitData = [0,0]
+                    }
+                }
+            }else{
+                this.calcYAxislimit(tableData)
+            }
+        }
 	}
 }

+ 5 - 9
src/views/mychart_manage/components/chartDetailDia.vue

@@ -589,12 +589,11 @@ import DateChooseDia from '@/views/dataEntry_manage/components/DateChooseDia';
 import changeLang from "@/views/dataEntry_manage/components/changeLang"
 import setEnNameDia from "@/views/dataEntry_manage/components/setEnNameDia"
 import { chartSetMixin } from '@/views/dataEntry_manage/mixins/chartPublic'
-import changeLimit from '@/views/dataEntry_manage/mixins/changeLimit';
 import { copyFit } from '@/utils/svgToblob.js';
 
 export default {
   components: { Chart, DateChooseDia,SaveChartOther,changeLang,setEnNameDia },
-  mixins: [ chartSetMixin,changeLimit ],
+  mixins: [ chartSetMixin],
   directives: {
     'click-outside':{
       bind(el, binding) {
@@ -733,12 +732,9 @@ export default {
             this.setDefaultSourceFrom();
             
             this.tableData = res.Data.EdbInfoList;
-            //若没有手动改过上下限,则初始化上下限
-            if(!this.chartInfo.MinMaxSave){
-                this.calcYAxislimit()
-            }else{
-                this.setLimitData()
-            }
+            //初始化上下限
+            this.setLimitData(this.tableData)
+            
             //eta图
             this.setDefaultDateSelect(); //设置默认的日期选中
 
@@ -1205,7 +1201,7 @@ export default {
           }
         : typeChartParam;
         
-        if(![7,10].includes(this.selected_chartType)){
+        if(![7,10,11].includes(this.selected_chartType)){
             params = {
                 ...params,
                 LeftMin:this.leftLimitData[1]+'',

+ 2 - 1
src/views/sandbox_manage/sandFlowNew/components/addLInkDia.vue

@@ -388,7 +388,8 @@ import { dataBaseInterface,reportlist} from '@/api/api.js';
         if (res.Ret !== 200) return;
         this.chartInfo = res.Data.ChartInfo || {}
         this.edbData = res.Data.EdbInfoList|| []
-
+        //初始化上下限
+        this.setLimitData(this.edbData)
         const chartTypeMap = {
           7: this.initBarData, //柱形图
           10: this.initSectionScatterData //截面散点