Parcourir la source

添加同期上下限/均线/标准差,季节性图预览

cxmo il y a 9 mois
Parent
commit
61db5237d3

+ 3 - 0
src/api/modules/chartApi.js

@@ -850,6 +850,9 @@ const dataBaseInterface = {
 	sectionScatterPreviewData: params => {
 		return http.post('/datamanage/chart_info/preview/time_section',params)
 	},
+	seasonPreviewData:params=>{
+		return http.post('/datamanage/chart_info/preview/season',params)
+	},
 
 	 /* 批量计算
 	 * @param {*} params 

+ 2 - 0
src/views/dataEntry_manage/addChart.vue

@@ -358,6 +358,8 @@
 						ref="markerSectionRef"
 						:chartInfo="chartInfo"
 						@update="setChartMarkerInfo"
+						@updateSeason="updateSeasonChart"
+						@previewSeason="previewSeasonChart"
 					/>
         </div>
 

+ 86 - 17
src/views/dataEntry_manage/components/addAverageDialog.vue

@@ -13,22 +13,38 @@
         :title="dialogTitle"
     >
         <div class="container">
-            <el-form>
-                <el-form-item label="倍数" v-if="averageType===3"></el-form-item>
-                <el-form-item v-if="averageType===1"
+            <el-form :model="averageForm" :rules="formRules" hide-required-asterisk
+                ref="averageFormRef"
+                label-position="right"
+                label-width="120px">
+                <el-form-item label="倍数" prop="Multiple" v-if="averageType===3">
+                    <el-input-number 
+                        v-model="averageForm.Multiple" 
+                        controls-position="right" 
+                        :min="1" step-strictly
+                        style="width: 90px"
+                        />
+                </el-form-item>
+                <el-form-item prop="Year"
                     :label="rangeLabelMap[averageType]" >
                     <span>过去</span>
-                    <el-input-number v-model="averageForm.Value" controls-position="right" :min="averageType===3?1:2"></el-input-number>
+                    <el-input-number 
+                        v-model="averageForm.Year" 
+                        controls-position="right" 
+                        :min="averageType===3?1:2" step-strictly
+                        style="width: 90px" 
+                        />
                     <span>年</span>
                 </el-form-item>
-                <el-form-item label="颜色及透明度">
+                <el-form-item label="颜色及透明度" prop="Color">
                     <el-color-picker
+                      style="width: 90px"
                       v-model="averageForm.Color"
-                      size="mini" show-alpha
+                      show-alpha
                       :predefine="predefineColors"
                     ></el-color-picker>
                 </el-form-item>
-                <el-form-item label="线型" v-if="averageType===2">
+                <el-form-item label="线型" prop="LineType" v-if="averageType===2">
                     <el-select v-model="averageForm.LineType">
                         <el-option v-for="lineItem in lineStylesOpts"
                             :key="lineItem.value"
@@ -40,10 +56,15 @@
                         </el-option>
                     </el-select>
                 </el-form-item>
-                <el-form-item label="粗细" v-if="averageType===3"></el-form-item>
-                    <el-input-number v-model="averageForm.LineWidth" controls-position="right" :min="1"></el-input-number>
-                <el-form-item label="图例">
-                    <el-input></el-input>
+                <el-form-item label="粗细" prop="LineWidth" v-if="averageType===2">
+                    <el-input-number 
+                        v-model="averageForm.LineWidth" 
+                        controls-position="right" 
+                        :min="1" step-strictly
+                        style="width: 90px"/>
+                </el-form-item>
+                <el-form-item label="图例" prop="Legend">
+                    <el-input v-model="averageForm.Legend"  style="width: 300px;"/>
                 </el-form-item>
             </el-form>
         </div>
@@ -66,11 +87,20 @@ export default {
         averageType:{
             type:Number,
             default:1, //1同期上下限 2同期均线 3同期标准差
+        },
+        formData:{
+            type:Object,
+            default:{}
         }
     },
     computed:{
         dialogTitle(){
-            return '添加同期上下限'
+            const titleMap = {
+                1:'添加同期上下限',
+                2:'添加同期均线',
+                3:'添加同期标准差'
+            }
+            return titleMap[this.averageType]
         },
         rangeLabelMap(){
             return {
@@ -78,15 +108,33 @@ export default {
                 2:'均线取数范围',
                 3:'取数范围'
             }
+        },
+        formRules(){ //方便英文翻译
+            return {
+                Legend:[{required:true,message:'请输入图例名称'}],
+                Year:[{required:true,message:'请输入年份'}],
+                LineWidth:[{required:true,message:'请选择线宽'}],
+                Multiple:[{required:true,message:'请选择倍数'}],
+            }
+        }
+    },
+    watch:{
+        isShow(newval){
+            if(newval){
+                Object.assign(this.averageForm,this.formData)
+                if(!this.averageForm.Legend){
+                    this.getLegend()
+                }
+            }
         }
     },
     data() {
         return {
             averageForm:{
                 Legend:'',//图例名称
-                Value:'',//上下限取数范围/均线取数范围/取数范围
+                Year:2,//上下限取数范围/均线取数范围/取数范围
                 Color:'#075EEE',//颜色及透明度
-                LineType:'',//线型
+                LineType:'Solid',//线型
                 LineWidth:1,//线宽
                 Multiple:1,//倍数
             },
@@ -95,11 +143,32 @@ export default {
         };
     },
     methods: {
-
+        getLegend(){
+            const nameMap = {
+                1:'年区间',
+                2:'年均值',
+                3:'年标准差'
+            }
+            this.averageForm.Legend = this.averageForm.Year+nameMap[this.averageType]
+        },
+        async confirmPerson(){
+            //校验
+            await this.$refs.averageFormRef.validate()
+            this.$emit('modify',{data:this.averageForm,type:this.averageType})
+        }
     },
 };
 </script>
 
-<style scoped lang="scss">
-
+<style lang="scss">
+.average-edit-dialog{
+    .container{
+        padding:0 60px;
+        .el-input{
+            width:100%;
+        }
+        .el-color-picker__trigger { width: 100%;padding: 0;border-radius: 4px; }
+        .number-input .el-input__inner { padding: 0 2px 0 10px; }
+    }
+}
 </style>

+ 106 - 2
src/views/dataEntry_manage/components/addRightEdbDialog.vue

@@ -13,7 +13,95 @@
         title="添加右轴指标"
     >
         <div class="container">
-            添加右轴指标
+           <div class="type-select">
+                <el-radio-group>
+                    <el-radio>左轴指标同比</el-radio>
+                    <el-radio>指标库</el-radio>
+                    <el-radio>预测指标</el-radio>
+                </el-radio-group>
+                <el-input placeholder="指标ID/指标名称"></el-input>
+           </div>
+           <div class="form-box">
+            <el-form>
+                <el-form-item label="生成样式">
+                    <el-select>
+                        <el-option label="柱形" value="column"></el-option>
+                        <el-option label="标记点" value="mark"></el-option>
+                    </el-select>
+                </el-form-item>
+                <!-- 如果选择标记点 -->
+                <el-form-item label="形状">
+                    <el-select>
+                        <el-option 
+                            v-for="markItem in markTypesOpts" 
+                            :key="markItem.value"
+                            :label="markItem.label"
+                            :value="markItem.value"
+                            >
+                            <div style="display: flex;align-items: center;justify-content: center;height: 100%;" v-html="markItem.svg">
+                            </div>
+                        </el-option>
+                    </el-select>
+                </el-form-item>
+                <!-- 柱形/标记点的 颜色及透明度 -->
+                <el-form-item label="颜色及透明度">
+                    <el-color-picker
+                      style="width: 90px"
+                      v-model="rightEdbForm.ChartColor"
+                      show-alpha
+                      :predefine="predefineColors"
+                    ></el-color-picker>
+                </el-form-item>
+                <!-- 如果选择标记点 -->
+                <el-form-item label="大小">
+                    <el-input-number 
+                        v-model="rightEdbForm.Size" 
+                        controls-position="right" 
+                        :min="1" 
+                        style="width: 90px"/>
+                </el-form-item>
+                <el-form-item label="图例名称"></el-form-item>
+                <!-- 如果选择左轴同比 -->
+                <el-form-item label="数字格式"></el-form-item>
+                <!-- 如果选择标记点 -->
+                <el-form-item label="连线" v-if="rightEdbForm.Style==='mark'">
+                    <el-radio-group>
+                        <el-radio :label="0">无</el-radio>
+                        <el-radio :label="1">有</el-radio>
+                    </el-radio-group>
+                </el-form-item>
+                <!-- 如果选择连线 -->
+                <template v-if="rightEdbForm.IsConnected">
+                    <el-form-item label="连线颜色">
+                        <el-color-picker
+                        style="width: 90px"
+                        v-model="rightEdbForm.LineColor"
+                        show-alpha
+                        :predefine="predefineColors"
+                        ></el-color-picker>
+                    </el-form-item>
+                    <el-form-item label="连线线型">
+                        <el-select v-model="rightEdbForm.LineStyle">
+                            <el-option v-for="lineItem in lineStylesOpts"
+                                :key="lineItem.value"
+                                :label="lineItem.label"
+                                :value="lineItem.value"
+                            >
+                                <svg width="60" height="10" viewBox="0 0 60 10" fill="none" xmlns="http://www.w3.org/2000/svg" v-html="lineItem.svg">
+                                </svg>
+                            </el-option>
+                        </el-select>
+                    </el-form-item>
+                    <el-form-item label="连线粗细">
+                        <el-input-number 
+                            v-model="rightEdbForm.LineWidth" 
+                            controls-position="right" 
+                            :min="1" 
+                            style="width: 90px"/>
+                    </el-form-item>
+                </template>
+            </el-form>
+           </div>
         </div>
         <div slot="footer" class="dialog-footer" style="text-align: center;">
             <el-button @click="$emit('close')">取消</el-button>
@@ -23,6 +111,8 @@
 </template>
 
 <script>
+import { defaultOpts } from '@/utils/defaultOptions';
+import { markTypesOpts,lineStylesOpts } from '@/views/system_manage/chartTheme/common/config'
 export default {
     props:{
         isShow:{
@@ -32,7 +122,21 @@ export default {
     },
     data() {
         return {
-
+            rightEdbForm:{
+                IndicatorType:1,//1左轴同比 2指标库 3预测指标
+                Style:'column',//生成样式 column/mark
+                Shape:'circle',//标记点形状
+                ChartColor:'',//颜色
+                Size:3,//标记点大小
+                Legend:'',//图例名称
+                NumFormat:1,//数值格式 1百分比 2小数
+                IsConnected:0,//连线 0无 1有
+                LineColor:'',//线条颜色
+                LineWidth:3,//线条粗细
+                LineStyle:'',//线条线型
+            },
+            markTypesOpts,lineStylesOpts,
+            predefineColors: defaultOpts.colors.slice(0, 2),
         };
     },
     methods: {

+ 92 - 26
src/views/dataEntry_manage/components/markersSection.vue

@@ -72,17 +72,17 @@
     <!-- 季节性图升级-同期上下限/均线/标准差-->
     <template v-if="chartInfo.ChartType===2">
         <div class="section-item">
-            <div class="average-item" v-if="averageList[1].isAdd">
-                <span>{{item.axisName}}: {{item.value}}</span>
+            <div class="average-item" v-if="averageArea.IsAdd">
+                <span>{{averageArea.Year||0}}年区间上下限</span>
                 <div style="flex-shrink:0">
-                    <i class="el-icon-view icon" :style="item.isShow?'color:#0052D9':'color:#999'" @click="item.isShow=!item.isShow;updateChartHandle()"/>
-                    <i class="el-icon-edit icon" style="margin:0 6px" @click="openAverageDialog(averageList[1],1)"/>
+                    <i class="el-icon-view icon" :style="averageArea.IsShow?'color:#0052D9':'color:#999'" @click="averageArea.IsShow=!averageArea.IsShow;previewSeason('updateSeason')"/>
+                    <i class="el-icon-edit icon" style="margin:0 6px" @click="openAverageDialog(averageArea,1,'edit')"/>
                     <i class="el-icon-delete icon" @click="deleteAverage(1)"/>
                 </div>
             </div>
-            <div
+            <div v-else
                 class="add-cont"
-                @click="openAverageDialog(averageList[1],1)"
+                @click="openAverageDialog(averageArea,1)"
             >
                 <img
                     src="~@/assets/img/set_m/add_ico.png"
@@ -93,9 +93,17 @@
             </div>
         </div>
         <div class="section-item">
-            <div
+            <div class="average-item" v-if="averageLine.IsAdd">
+                <span>{{averageLine.Year||0}}年区间均值</span>
+                <div style="flex-shrink:0">
+                    <i class="el-icon-view icon" :style="averageLine.IsShow?'color:#0052D9':'color:#999'" @click="averageLine.IsShow=!averageLine.IsShow;previewSeason('updateSeason')"/>
+                    <i class="el-icon-edit icon" style="margin:0 6px" @click="openAverageDialog(averageLine,1,'edit')"/>
+                    <i class="el-icon-delete icon" @click="deleteAverage(1)"/>
+                </div>
+            </div>
+            <div v-else
                 class="add-cont"
-                @click="openAverageDialog(averageList[2],2)"
+                @click="openAverageDialog(averageLine,2)"
             >
                 <img
                     src="~@/assets/img/set_m/add_ico.png"
@@ -106,9 +114,17 @@
             </div>
         </div>
         <div class="section-item">
-            <div
+            <div class="average-item" v-if="averageStd.IsAdd">
+                <span>{{averageStd.Year||0}}年区间标准差</span>
+                <div style="flex-shrink:0">
+                    <i class="el-icon-view icon" :style="averageStd.IsShow?'color:#0052D9':'color:#999'" @click="averageStd.IsShow=!averageStd.IsShow;previewSeason('updateSeason')"/>
+                    <i class="el-icon-edit icon" style="margin:0 6px" @click="openAverageDialog(averageStd,1,'edit')"/>
+                    <i class="el-icon-delete icon" @click="deleteAverage(1)"/>
+                </div>
+            </div>
+            <div v-else
                 class="add-cont"
-                @click="openAverageDialog(averageList[3],3)"
+                @click="openAverageDialog(averageStd,3)"
             >
                 <img
                     src="~@/assets/img/set_m/add_ico.png"
@@ -207,17 +223,33 @@
     <addAverageDialog 
         :isShow="isAddAverageDialogShow"
         :averageType="averageType"
+        :formData="averageForm"
+        @close="isAddAverageDialogShow=false"
+        @modify="addAverage"
     />
     <!-- 右轴指标弹窗 -->
-
+    <addRightEdbDialog 
+        :isShow="isAddRightEdbDialogShow"
+        @close="isAddRightEdbDialogShow=false"
+    />
   </div>  
 </template>
 <script>
 import addMarkerDialog from './addMarkerDialog.vue'
 import mDialog from '@/components/mDialog.vue'
 import addAverageDialog from './addAverageDialog.vue'
+import addRightEdbDialog from './addRightEdbDialog.vue'
+
+const baseAverageForm = {
+    Legend:'',//图例名称
+    Year:2,//上下限取数范围/均线取数范围/取数范围
+    Color:'#075EEE',//颜色及透明度
+    LineType:'',//线型
+    LineWidth:1,//线宽
+    Multiple:1,//倍数
+}
 export default {
-  components: { addMarkerDialog,mDialog, addAverageDialog },
+  components: { addMarkerDialog,mDialog, addAverageDialog, addRightEdbDialog },
   props: {
     chartInfo: {
       type: Object
@@ -251,11 +283,15 @@ export default {
       isAddAverageDialogShow:false,
       averageType:1,//1同期上下限 2同期均线 3同期标准差
       averageForm:{},//初始化和回显用
-      averageList:[
-        '',
-        {isAdd:false},//同期上下限
-        {isAdd:false},//同期均线
-        {isAdd:false}],//同期标准差
+      averageMap:{
+        0:'',
+        1:{name:'averageArea'},//同期上下限
+        2:{name:'averageLine'},//同期均线
+        3:{name:'averageStd'},//同期标准差
+      },
+      averageArea:{IsAdd:false,IsShow:false},
+      averageLine:{IsAdd:false,IsShow:false},
+      averageStd:{IsAdd:false,IsShow:false},
 
       /* 右轴指标弹窗 */
       isAddRightEdbDialogShow:false,
@@ -347,20 +383,41 @@ export default {
       };
     },
     //打开同期弹窗
-    openAverageDialog(data,type){
-        if(data.isAdd) return 
-        this.averageForm = data
+    openAverageDialog(data,type,openType='add'){
+        if(openType==='add'){
+            this.averageForm = {
+                ...baseAverageForm,
+                IsAdd:false,
+                IsShow:false
+            }
+        }else{
+            this.averageForm = data
+        }
         this.averageType = type
         this.isAddAverageDialogShow = true
-
     },
-    addAverage(data,type){
-        this.averageList[type] = data
-        this.averageList[type].isAdd = true
+    addAverage({data,type}){
+        Object.assign(this[this.averageMap[type].name],data)
+        this[this.averageMap[type].name].IsAdd = true
+        this[this.averageMap[type].name].IsShow = true
+        this.isAddAverageDialogShow=false
+        this.previewSeason('previewSeason')
     },
     deleteAverage(type){
-        this.averageList[type] = {}
-        this.averageList[type].isAdd = false
+        this[this.averageMap[type].name].IsAdd = false
+        this.previewSeason('previewSeason')
+    },
+    //更新季节性图 同期/右轴
+    //预览图表
+    previewSeason(eventName='previewSeason'){
+        this.$emit(eventName,{
+            SeasonAverageConfig:{
+                MaxMinLimits:this.averageArea,
+                SamePeriodAverage:this.averageLine,
+                SamePeriodStandardDeviation:this.averageStd
+            },
+            SeasonRightEdbConfig:{}
+        })
     }
   },
 }
@@ -380,6 +437,15 @@ export default {
         padding: 12px 15px;
       }
     }
+    .average-item{
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        padding: 12px 15px;
+        border: 1px solid #DCDFE6;
+        background: #F0F2F5;
+        margin-bottom: 15px;
+    }
     .icon {font-size: 18px;cursor: pointer;}
     .el-icon-delete{
       color: #f00;

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

@@ -365,6 +365,7 @@
 						:chartType="chartInfo.ChartType"
 						:chartInfo="chartInfo"
 						@update="setChartMarkerInfo"
+                        @preview="previewChart"
 					/>
         </div>
 			</div>

+ 47 - 0
src/views/dataEntry_manage/mixins/addOreditMixin.js

@@ -1076,6 +1076,53 @@ export default {
 				? chartTypeMap[this.chartInfo.ChartType]() 
 				: this.setChartOptionHandle(this.tableData);
 		},
+		//更新季节性图(不重新获取数据)
+		updateSeasonChart({SeasonAverageConfig,SeasonRightEdbConfig}){
+			if(this.chartInfo.SeasonAverageConfig){
+				const {MaxMinLimits,SamePeriodAverage,SamePeriodStandardDeviation} = SeasonAverageConfig
+				this.chartInfo.SeasonAverageConfig.MaxMinLimits.IsShow = MaxMinLimits.IsShow||false
+				this.chartInfo.SeasonAverageConfig.SamePeriodAverage.IsShow = SamePeriodAverage.IsShow||false
+				this.chartInfo.SeasonAverageConfig.SamePeriodStandardDeviation.IsShow = SamePeriodStandardDeviation.IsShow||false
+
+				this.reLoadChartOption()
+			}
+		},
+		//预览季节性图(请求接口)
+		previewSeasonChart({SeasonAverageConfig,SeasonRightEdbConfig}){
+			let db_arr = this.tableData.map(item => ({
+				ChartColor: item.ChartColor,
+				PredictChartColor: item.PredictChartColor,
+				ChartStyle: item.ChartStyle,
+				ChartWidth: Number(item.ChartWidth),
+				EdbInfoId: item.EdbInfoId,
+				EdbAliasName: item.EdbAliasName,
+				EdbInfoType: item.EdbInfoType,
+				IsAxis: item.IsAxis,
+				IsOrder: item.IsOrder,
+				LeadUnit: item.EdbInfoType ? '' : item.LeadUnit,
+				LeadValue: item.EdbInfoType ? 0 : Number(item.LeadValue),
+				MaxData: Number(item.MaxData),
+				MinData: Number(item.MinData)
+			}))
+			const ChartEdbInfoList = db_arr
+			const {MaxMinLimits,SamePeriodAverage,SamePeriodStandardDeviation} = SeasonAverageConfig
+			const SeasonExtraConfig = {
+				...this.SeasonExtraConfig,
+				MaxMinLimits:MaxMinLimits.IsAdd?SeasonAverageConfig.MaxMinLimits:{},
+				SamePeriodAverage:SamePeriodAverage.IsAdd?SamePeriodAverage:{},
+				SamePeriodStandardDeviation:SamePeriodStandardDeviation.IsAdd?SamePeriodStandardDeviation:{}
+			}
+			dataBaseInterface.seasonPreviewData({ChartEdbInfoList,SeasonExtraConfig}).then(res=>{
+				if(res.Ret!==200) return 
+				const {DataResp} = res.Data
+				const {MaxMinLimits,SamePeriodAverage,SamePeriodStandardDeviation} = DataResp
+				this.chartInfo.SeasonAverageConfig = {
+					MaxMinLimits,SamePeriodAverage,SamePeriodStandardDeviation
+				}
+				this.reLoadChartOption()
+			})
+
+		},
 		//获取图表全局设置
 		async getChartBaseSetting(){
 			//目前是用基本配置的接口,后续有多个配置再改

+ 43 - 1
src/views/dataEntry_manage/mixins/chartPublic.js

@@ -1115,7 +1115,7 @@ export const chartSetMixin = {
             maxLimit = this.chartLimit.max||0
         }
 
-      //数据列
+      //数据列-常规
       for (let index in chartDataHandle) {
         let j = chartDataHandle[index]
         // console.log(j,index);
@@ -1144,6 +1144,48 @@ export const chartSetMixin = {
         seasonData.push(serie_item);
       }
 
+      //数据列-同期上下限/均线/标准差
+      const {MaxMinLimits={},SamePeriodAverage={},SamePeriodStandardDeviation={}} = this.chartInfo.SeasonAverageConfig||{}
+      if(MaxMinLimits.IsShow&&MaxMinLimits.List&&MaxMinLimits.List.length){
+        let serieItem = {
+            type:'arearange',//上下限是一个范围
+            data:[],
+            name:MaxMinLimits.Legend||'同期上下限',
+            color:MaxMinLimits.Color||'#075EEE'
+        }
+        MaxMinLimits.List.forEach(item=>{
+            serieItem.data.push([item.DataTimestamp,item.MinValue,item.MaxValue])
+        })
+        seasonData.push(serieItem)
+      }
+      if(SamePeriodAverage.IsShow&&SamePeriodAverage.List){
+        let serieItem = {
+            type:'line',
+            data:[],
+            lineWidth:SamePeriodAverage.LineWidth,
+            dashStyle:SamePeriodAverage.LineType,
+            name:MaxMinLimits.Legend||'同期均值',
+            color:MaxMinLimits.Color||'#075EEE'
+        }
+        SamePeriodAverage.List.forEach(item=>{
+            serieItem.data.push([item.DataTimestamp,item.Value])
+        })
+        seasonData.push(serieItem)
+      }
+      if(SamePeriodStandardDeviation.IsShow&&SamePeriodStandardDeviation.List){
+        let serieItem = {
+            type:'arearange',//标准差也是一个范围
+            data:[],
+            name:SamePeriodStandardDeviation.Legend||'同期标准差',
+            color:SamePeriodStandardDeviation.Color||'#075EEE'
+        }
+        SamePeriodStandardDeviation.List.forEach(item=>{
+            serieItem.data.push([item.DataTimestamp,item.MinValue,item.MaxValue])
+        })
+        seasonData.push(serieItem)
+      }
+      //数据列-右轴
+
       //y轴
       const textZh = chartData.ConvertUnit||chartData.Unit
       const textEn = chartData.ConvertEnUnit||chartData.UnitEn||chartData.ConvertUnit||chartData.Unit