Browse Source

兼容跨品种分析图

Karsa 1 year ago
parent
commit
4528452f8a

+ 57 - 0
src/api/crossVarietyChart.js

@@ -0,0 +1,57 @@
+/* 跨品种分析 */
+import { get,post } from "./index";
+export default {
+  
+    /**
+     * 图表详情
+     * @param {*} params  ChartInfoId
+     * @returns 
+     */
+    chartDetail: params => {
+      return get('/cross_variety/chart_info/detail',params)
+    },
+
+    /**
+     * 设置英文
+     * @param {*} params  ChartInfoId ChartNameEn
+     */
+    editChartEn: params => {
+      return post('/cross_variety/chart_info/en/edit',params)
+    },
+
+    /**
+     * 图表搜索
+     * @param {*} params Keyword
+     * @returns 
+     */
+    searchChart: params => {
+      return get('/cross_variety/chart_info/search_by_es',params)
+    },
+
+    /**
+     * 刷新图表
+     * @param {*} params ChartInfoId
+     * @returns 
+     */
+    refreshChart: params => {
+      return get('/cross_variety/chart_info/refresh',params)
+    },
+
+    /**
+     * 图表另存为
+     * @param {*} params ChartInfoId ChartName
+     * @returns 
+     */
+    saveOtherChart: params => {
+      return post('/cross_variety/chart_info/copy',params)
+    },
+    
+    /**
+     * 编辑英文名称
+     * @param {*} params 
+     * @returns 
+     */
+    editChartEn: params => {
+      return post('/cross_variety/chart_info/en/edit',params)
+    }
+}

+ 9 - 0
src/api/statisticFeatureChart.js

@@ -17,6 +17,15 @@ export default {
     chartInfoEditEn(params){
         return post('/line_feature/chart_info/en/edit',params)
     },
+
+    /**
+     * 图表搜索
+     * @param {*} params Keyword IsShowMe CurrentIndex
+     * @returns 
+   */
+    searchChart: params => {
+        return get('/line_feature/chart_info/search_by_es',params)
+    },
     /**
      * 分类列表
      */

+ 127 - 20
src/hooks/chart/render.js

@@ -55,6 +55,19 @@ export function useChartRender(){
     }
 }
 
+/**备注一下 越多越乱 
+ * @params
+ * Source 1 ; chartType只在source:1用到 1曲线 2季节 3面积 4堆积柱 5散点 6组合 7柱形 8截面散点
+ * 2 商品价格
+ * 3 相关性
+ * 4 滚动相关性
+ * 5 商品利润
+ * 6 拟合方程
+ * 7 统计特征/标准差
+ * 8 统计特征/百分位
+ * 9 统计特征/频率
+ * 10 跨品种分析
+ */
 export function chartRender({data,renderId,lang='zh',changeLangIsCheck,showChartTitle=true}){
     // 初始化掉极值数据
     axisLimitState.leftIndex=-1
@@ -81,26 +94,6 @@ export function chartRender({data,renderId,lang='zh',changeLangIsCheck,showChart
     RenderDomId.value=renderId
     chartData.value=data
 
-    // if([1,3,4,5,6].includes(data.ChartInfo.ChartType)){
-    //     const chartSetMap = {
-    //         1: setSplineOpt,
-    //         3: setStackOrCombinChart,
-    //         4: setStackOrCombinChart,
-    //         5: setScatterOptions,
-    //         6: setStackOrCombinChart
-    //     };
-    //     chartOpt=chartSetMap[data.ChartInfo.ChartType](data)
-    // }else if(data.ChartInfo.ChartType ===2 ) {
-    //     chartOpt=setSeasonOpt(data)
-    // }else if(data.ChartInfo.ChartType ===7){//奇怪柱形图依赖数据
-    //     chartOpt=initBarData(data);
-    // }else if(data.ChartInfo.ChartType ===8){//商品价格曲线
-    //     chartOpt=initCommodityData(data);
-    // }else if(data.ChartInfo.ChartType ===9){//相关性图
-    //     chartOpt=initRelevanceChart(data);
-    // }else if(data.ChartInfo.ChartType ===10){//截面散点图
-    //     chartOpt=setSectionScatterChart(data);
-    // }
     if(data.ChartInfo.Source===1){
         const chartSetMap = {
             1: setSplineOpt,
@@ -121,6 +114,8 @@ export function chartRender({data,renderId,lang='zh',changeLangIsCheck,showChart
         chartOpt=setSplineOpt(data);
     }else if([9].includes(data.ChartInfo.Source)){//统计频率
         chartOpt=setStatisticFrequency(data);
+    }else if(data.ChartInfo.Source===10) {
+        chartOpt = setCrossVarietyChart(data)
     }
 
 
@@ -1809,3 +1804,115 @@ function setSectionScatterChart({DataResp}) {
         tooltip
     }
 }
+
+/* 跨品种分析 */
+function setCrossVarietyChart({DataResp,EdbInfoList}) {
+    axisLimitState.leftIndex=-1
+    axisLimitState.rightIndex=-1
+    axisLimitState.rightTwoIndex=-1
+
+    const { DataList,XName,YName,XNameEn,YNameEn,XMaxValue,XMinValue,YMaxValue,YMinValue } = DataResp;
+
+     //y轴
+     let yAxis = {
+        ...basicYAxis,
+        title: {
+          text: YName,
+          textCh:YName,// 中文
+          textEn:YNameEn||YName,
+          align: 'middle',
+        },
+        opposite: false,
+        reversed: false,
+        min: Number(YMinValue),
+        max: Number(YMaxValue),
+        tickWidth: 1,
+      }
+
+      // x轴
+      let xAxis = {
+        ...scatterXAxis,
+        title: {
+          text: XName,
+          textCh:XName,// 中文
+          textEn:XNameEn || XName,
+          align: 'middle',
+        },
+        min: Number(XMinValue),
+        max: Number(XMaxValue),
+      }
+
+       //数据列
+      let series = [];
+      DataList.forEach(item => {
+        //数据列
+        let series_item = {
+          data: [],
+          type: 'scatter',
+          name: item.Name,
+          nameCh: item.Name,
+          nameEn: item.NameEn||item.Name,
+          color: item.Color,
+          lineWidth: 0,
+          chartType: 'linear',
+          zIndex:1
+        }
+        item.CoordinatePointData.forEach(_ => {
+          series_item.data.push({x: _.X,y: _.Y,})
+        })
+        series.push(series_item);
+      })
+
+      let tooltip = {
+        formatter: function() {
+          let series_obj = DataList.find(_ => _.Name === this.series.name);
+          let ponit_obj = series_obj.CoordinatePointData.find(_ => _.X ===this.x && _.Y===this.y);
+          
+          let xEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.XEdbInfoId);
+          let yEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.YEdbInfoId);
+
+          let str=`<b>${ this.series.name }</b>`;
+          str += `<br><span style="color:${this.color}">\u25CF</span>${xEdbInfo.EdbName}: ${this.x} ${ponit_obj.XDate}<br>`;
+          str += `<span style="color:${this.color}">\u25CF</span>${yEdbInfo.EdbName}: ${this.y} ${ponit_obj.YDate}`;
+
+          return str
+        },
+        formatterCh: function() {
+          let series_obj = DataList.find(_ => _.Name === this.series.name);
+          let ponit_obj = series_obj.CoordinatePointData.find(_ => _.X ===this.x && _.Y===this.y);
+          
+          let xEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.XEdbInfoId);
+          let yEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.YEdbInfoId);
+
+          let str=`<b>${ this.series.name }</b>`;
+          str += `<br><span style="color:${this.color}">\u25CF</span>${xEdbInfo.EdbName}: ${this.x} ${ponit_obj.XDate}<br>`;
+          str += `<span style="color:${this.color}">\u25CF</span>${yEdbInfo.EdbName}: ${this.y} ${ponit_obj.YDate}`;
+
+          return str
+          
+        },
+        formatterEn: function() {
+          let series_obj = DataList.find(_ => _.NameEn === this.series.name);
+          let ponit_obj = series_obj.CoordinatePointData.find(_ => _.X ===this.x && _.Y===this.y);
+          
+          let xEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.XEdbInfoId);
+          let yEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.YEdbInfoId);
+
+          let str=`<b>${ this.series.name }</b>`;
+          str += `<br><span style="color:${this.color}">\u25CF</span>${xEdbInfo.EdbNameEn}: ${this.x} ${ponit_obj.XDate}<br>`;
+          str += `<span style="color:${this.color}">\u25CF</span>${yEdbInfo.EdbNameEn}: ${this.y} ${ponit_obj.YDate}`;
+
+          return str
+        }
+      }
+
+      return {
+        title: {
+          text:''
+        },
+        series,
+        yAxis: [yAxis],
+        xAxis,
+        tooltip
+      }
+}

+ 6 - 3
src/views/myETA/ChartDetail.vue

@@ -5,6 +5,7 @@ import apiFutureChart from '@/api/futureChart'
 import apiCorrelationChart from '@/api/correlationChart'
 import apiLineEquationChart from '@/api/lineEquationChart'
 import apiStatisticFeatureChart from '@/api/statisticFeatureChart'
+import apiCrossVarietyChart from '@/api/crossVarietyChart'
 import apiMyETAChart from '@/api/myETA'
 import apiDataEDB from '@/api/dataEDB'
 import { useRoute, useRouter } from 'vue-router'
@@ -524,6 +525,8 @@ async function handleChartRefresh(){
         res=await apiLineEquationChart.refreshChart({ ChartInfoId })
     }else if([7,8,9].includes(Source)) {
         res=await apiStatisticFeatureChart.refreshChart({ ChartInfoId })
+    }else if(Source===10) {
+        res=await apiCrossVarietyChart.refreshChart({ ChartInfoId })
     }
     if(res.Ret!==200)return
     showToast('刷新成功')
@@ -723,7 +726,7 @@ const isShowAddToMyETADialog=ref(false)
                 >{{chartState.startTime?chartState.startTime+'~'+(chartState.endTime?chartState.endTime:'至今'):'请选择时间段'}}</span>
             </div>
             <div class="right-action-box">
-                <div class="item" @click="handleShowAxisLimitOpt" v-if="![3,4,6,7,8,9].includes(chartInfo.Source)&&checkAuthBtn(myETABtn.myChart_editLimit)">
+                <div class="item" @click="handleShowAxisLimitOpt" v-if="[1,2,5].includes(chartInfo.Source)&&checkAuthBtn(myETABtn.myChart_editLimit)">
                     <img src="@/assets/imgs/myETA/icon_limit2.png" alt="">
                     <span>上下限设置</span>
                 </div>
@@ -785,7 +788,7 @@ const isShowAddToMyETADialog=ref(false)
                 <img class="icon" style="transform: rotate(180deg);" src="@/assets/imgs/icon_arrow.png" alt="">
                 <div>下一张</div>
             </div>
-            <div class="item" @click="handleShowAxisLimitOpt" v-if="![3,4,6,7,8,9].includes(chartInfo.Source)&&checkAuthBtn(myETABtn.myChart_editLimit)">
+            <div class="item" @click="handleShowAxisLimitOpt" v-if="[1,2,5].includes(chartInfo.Source)&&checkAuthBtn(myETABtn.myChart_editLimit)">
                 <img class="icon" src="@/assets/imgs/myETA/icon_limit.png" alt="">
                 <div>上下限</div>
             </div>
@@ -947,7 +950,7 @@ const isShowAddToMyETADialog=ref(false)
             <div class="item" @click.stop="handleChartShare" v-if="!chartInfo.Disabled&&checkAuthBtn(myETABtn.myChart_share)">
                 分享
             </div>
-            <div class="item" @click.stop="handleChartSave" v-if="![3,4,6,7,8,9].includes(chartInfo.Source)&&checkAuthBtn(myETABtn.myChart_save)">
+            <div class="item" @click.stop="handleChartSave" v-if="[1,2,5].includes(chartInfo.Source)&&checkAuthBtn(myETABtn.myChart_save)">
                 保存
             </div>
             <div class="item" @click.stop="handleRemoveChart" v-if="$route.query.iscommon!='true'&&checkAuthBtn(myETABtn.myChart_move)">

+ 9 - 1
src/views/myETA/components/ChartSaveOther.vue

@@ -5,6 +5,7 @@ import apiCorrelation from '@/api/correlationChart'
 import apiFuture from '@/api/futureChart'
 import apiLineEquationChart from '@/api/lineEquationChart'
 import apiStatisticFeatureChart from '@/api/statisticFeatureChart'
+import apiCrossVarietyChart from '@/api/crossVarietyChart'
 import { showToast } from 'vant'
 import { useWindowSize } from '@vueuse/core'
 
@@ -92,7 +93,7 @@ function getTreeData(topNode={}){
     })
 }
 
-let activeIds=ref('')//选中的分类
+let activeIds=ref(0)//选中的分类
 const activeIndex=ref(0)
 let activeTab=ref(0)
 
@@ -112,6 +113,8 @@ async function handleConfirmSave(){
         res=await apiLineEquationChart.chartSaveOther(params)
     }else if([7,8,9].includes(props.source)){
         res=await apiStatisticFeatureChart.chartSaveOther(params)
+    }else if(props.source===10){
+        res=await apiCrossVarietyChart.saveOtherChart(params)
     }else{
         res=await apiETAChart.ETAChartSaveOther(params)
     }
@@ -145,6 +148,11 @@ async function handleConfirmSave(){
                         >{{item.ChartClassifyName}}</li>
                     </ul>
                 </template>
+                <template v-else-if="source===10">
+                    <div class="item">
+                        图表名称: {{chartInfo.ChartName+'(1)'}}
+                    </div>
+                </template>
                 <template v-else>
                     <!-- <van-tree-select
                         v-model:active-id="activeIds"

+ 19 - 14
src/views/report/components/reportInsert/ETAChart.vue

@@ -4,13 +4,15 @@ import apiChart from '@/api/chart'
 import apiFutureChart from '@/api/futureChart'
 import apiCorrelationChart from '@/api/correlationChart'
 import apiLineEquationChart from '@/api/lineEquationChart'
+import apiStatisticFeatureChart from '@/api/statisticFeatureChart'
+import apiCrossVarietyChart from '@/api/crossVarietyChart'
 import { showToast } from 'vant'
 import { vInfiniteScroll } from '@vueuse/components'
 
 const emits=defineEmits(['update'])
 
 const searchVal=ref('')
-const typeActive=ref('ETA图库')
+const typeActive=ref(1)
 const onlyMe=ref(false)
 
 const listState=reactive({
@@ -29,17 +31,18 @@ async function getChartList(){
         IsShowMe:onlyMe.value
     }
     listState.loading=true
-    let res=null
-    if(typeActive.value==='ETA图库'){
-        res=await apiChart.ETAChartListByES(params)
-    }else if(typeActive.value==='商品价格曲线'){
-        res=await apiFutureChart.searchChartList(params)
-    }else if(typeActive.value==='相关性图表'){
-        res=await apiCorrelationChart.searchChartList(params)
-    }else if(typeActive.value==='拟合方程曲线'){
-        res=await apiLineEquationChart.searchChartList(params)
+
+    const apiMap = {
+        1: apiChart.ETAChartListByES,
+        2: apiFutureChart.searchChartList,
+        3: apiCorrelationChart.searchChartList,
+        6: apiLineEquationChart.searchChartList,
+        7: apiStatisticFeatureChart.searchChart,
+        10: apiCrossVarietyChart.searchChart,
     }
     
+    let res = await apiMap[typeActive.value](params)
+    
     listState.loading=false
     if(res.Ret===200){
         const arr=res.Data.List||[]
@@ -96,10 +99,12 @@ watch(
         <div class="sticky-box">
             <van-search v-model="searchVal" shape="round" placeholder="请输入图表名称" @search="handleRefreshList" @clear="handleRefreshList" />
             <van-tabs v-model:active="typeActive" line-width="16px" title-active-color="#0052D9" @change="handleRefreshList">
-                <van-tab title="ETA图库" name="ETA图库"></van-tab>
-                <van-tab title="商品价格曲线" name="商品价格曲线"></van-tab>
-                <van-tab title="相关性图表" name="相关性图表"></van-tab>
-                <van-tab title="拟合方程曲线" name="拟合方程曲线"></van-tab>
+                <van-tab title="ETA图库" :name="1"></van-tab>
+                <van-tab title="商品价格曲线" :name="2"></van-tab>
+                <van-tab title="相关性图表" :name="3"></van-tab>
+                <van-tab title="拟合方程曲线" :name="6"></van-tab>
+                <van-tab title="统计特征" :name="7"></van-tab>
+                <van-tab title="跨品种分析" :name="10"></van-tab>
             </van-tabs>
             <van-checkbox v-model="onlyMe" @change="handleRefreshList">只看我的</van-checkbox>
         </div>