Przeglądaj źródła

Merge branch 'master' into cygx_12.8.1

bding 1 rok temu
rodzic
commit
ccb0e74e1e
1 zmienionych plików z 111 dodań i 40 usunięć
  1. 111 40
      src/views/hzyb/chart/Detail.vue

+ 111 - 40
src/views/hzyb/chart/Detail.vue

@@ -193,7 +193,7 @@ const handleConfirmDate=()=>{
 
 const actionSheetShow=ref(false)
 const actions=computed(()=>{
-    return canSave.value&&![3,4,6,7,8,9].includes(chartSource)?[{ name: '刷新' },{ name: '保存' },{ name: '生成海报' }]:
+    return canSave.value&&[1,2,5].includes(chartSource)?[{ name: '刷新' },{ name: '保存' },{ name: '生成海报' }]:
                             [{ name: '刷新' },{ name: '生成海报' }]
 })
 const onActionSelect=(action,index)=>{
@@ -319,10 +319,8 @@ const getChartInfo=async (type)=>{
     // resData.value=null
     loading.value=true
 
-    //相关性图表 统计频率图
-    if([3,4,6,7,8,9].includes(chartSource)) return getRelevanceDetail();
-    //商品价格曲线调另外的接口
-    else if([2,5].includes(chartSource)) return getCommordityDetail();
+    //通用类根据code获取详情
+    if(chartSource!==1) return getCommonChartDetail();
 
     let res=null
     // 如果是从我的图库中来的
@@ -411,44 +409,17 @@ const getChartInfo=async (type)=>{
         nodata.value=true
     }
 }
-//获取商品价格曲线数据
-const getCommordityDetail = async() => {
-    const res = await apiCommonChartDetail({ChartInfoId})
-    loading.value=false
-    if(res.code===200){
-        resData.value=res.data
-        
-        relevanceChartData.value=res.data
-        initCommodityData(res.data);
 
-        // 向小程序发送分享数据
-        let postData = {
-            params:{
-                chartInfoId:ChartInfoId,
-                searchVal:decodeURIComponent(route.query.searchVal)||'',
-                chartSource,
-                MyChartId:route.query.MyChartId||'',
-                MyChartClassifyId:route.query.MyChartClassifyId||'',
-            },
-            title: res.data.ChartInfo.ChartName,
-            shareImg:res.data.ChartInfo.ChartImage
-        };
-        wx.miniProgram.postMessage({ data: postData });
-
-    }else if(res.code==403){
-        noauth.value=true
-        noAuthData.value=res.data
-    }
-
-}
-//获取相关性图表
-const getRelevanceDetail=async ()=>{
+//获取图表详情 除source:1外
+const getCommonChartDetail=async ()=>{
     const res = await apiCommonChartDetail({ChartInfoId})
     loading.value=false
     if(res.code===200){
         resData.value=res.data
-        
-        if([3].includes(res.data.ChartInfo.Source)) { //相关性
+
+        if([2,5].includes(res.data.ChartInfo.Source)) {//商品价格曲线 利润曲线
+            initCommodityData(res.data);
+        }else if([3].includes(res.data.ChartInfo.Source)) { //相关性
             relevanceChartData.value=res.data
             initRelevanceChart(res.data);
         }else if([4,6,7,8].includes(res.data.ChartInfo.Source)) { //滚动相关性 拟合方程曲线 标准差 百分比
@@ -456,7 +427,10 @@ const getRelevanceDetail=async ()=>{
         }else if(res.data.ChartInfo.Source===9) { //统计频率
             statisticFrequencyData.value = res.data.DataResp;
             setStatisticFrequency();
+        }else if(res.data.ChartInfo.Source===10) { //跨品种分析
+            initCrossVarietyChartData(res.data)
         }
+
         // 向小程序发送分享数据
         let postData = {
             params:{
@@ -1046,6 +1020,103 @@ const setStatisticFrequency = () => {
     }
 }
 
+/* 跨品种分析 */
+const crossVarietyChartData = ref({})
+const initCrossVarietyChartData = ({DataResp,ChartInfo,EdbInfoList}) => {
+    crossVarietyChartData.value = DataResp;
+
+    hasLeftAxis.value=false;
+
+    axisLimitData.leftMin=Number(DataResp.YMinValue)
+    axisLimitData.leftMax=Number(DataResp.YMaxValue)
+    axisLimitData.xMin=Number(DataResp.XMinValue)
+    axisLimitData.xMax=Number(DataResp.XMaxValue)
+
+    setCrossVarietyChart()
+}
+const setCrossVarietyChart = () => {
+    const { EdbInfoList } = resData.value;
+    
+    const { leftMin,leftMax,xMin,xMax }  = axisLimitData;
+
+    const { DataList,XName,YName } = crossVarietyChartData.value;
+
+    //y轴
+    let yAxis = {
+        ...basicYAxis,
+        title: {
+            text: YName,
+            align: 'middle',
+        },
+        opposite: false,
+        reversed: false,
+        min: Number(leftMin),
+        max: Number(leftMax),
+        tickWidth: 1,
+    }
+
+    // x轴
+    let xAxis = {
+        ...scatterXAxis,
+        title: {
+            text: XName,
+            align: 'middle',
+        },
+        min: Number(xMin),
+        max: Number(xMax),
+    }
+
+    //数据列
+    let series = [];
+    DataList.forEach(item => {
+        //数据列
+        let series_item = {
+            data: [],
+            type: 'scatter',
+            name: item.Name,
+            color: item.Color,
+            lineWidth: 0,
+            chartType: 'linear',
+            zIndex:1,
+            visible: true
+        }
+        item.CoordinatePointData.forEach(_ => {
+            series_item.data.push({x: _.X,y: _.Y,})
+        })
+        series.push(series_item);
+    })
+
+    let tooltip = {
+        formatter: function() {
+
+            let that = this;
+            let str = '';
+
+            let series_obj = DataList.find(_ => _.Name === that.series.name);
+            let ponit_obj = series_obj.CoordinatePointData.find(_ => _.X ===that.x && _.Y===that.y);
+            
+            let xEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.XEdbInfoId);
+            let yEdbInfo = EdbInfoList.find(_ => _.EdbInfoId===ponit_obj.YEdbInfoId);
+
+            str=`<b>${ that.series.name }</b>`;
+            str += `<br><span style="color:${that.color}">\u25CF</span>${xEdbInfo.EdbName}: ${that.x} ${ponit_obj.XDate}<br>`;
+            str += `<span style="color:${that.color}">\u25CF</span>${yEdbInfo.EdbName}: ${that.y} ${ponit_obj.YDate}`;
+
+            return str
+        }
+    }
+
+    chartData.value = {
+        title: {
+            text:''
+        },
+        series,
+        yAxis: [yAxis],
+        xAxis,
+        tooltip
+    }
+}
+
 
 
 // 路由改变 解决从搜索页返回数据不刷新问题
@@ -2163,7 +2234,7 @@ const setChartParams = () => {
 // 刷新图表
 const handleRefreshChart=async ()=>{
     let res=null 
-    if([1,6,7,8,9].includes(resData.value.ChartInfo.Source)){
+    if([1,6,7,8,9,10].includes(resData.value.ChartInfo.Source)){
         res=await apiChartRefresh({ChartInfoId:Number(ChartInfoId)})
     }else if([2,5].includes(resData.value.ChartInfo.Source)){
         res=await apiCommonChartRefresh({ChartInfoId:Number(ChartInfoId)})
@@ -2345,7 +2416,7 @@ const myChartPageChange=(type)=>{
                 <span :class="calendarType==='农历'&&'active'" @click="calendarTypeChange('农历')">农历</span>
                 <span :class="calendarType==='公历'&&'active'" @click="calendarTypeChange('公历')">公历</span>
             </div>
-            <span style="color:#E3B377;flex:1;text-align:right" @click="showLimit=true" v-if="![3,4,6,7,8,9].includes(resData.ChartInfo.Source)">上下限设置</span>
+            <span style="color:#E3B377;flex:1;text-align:right" @click="showLimit=true" v-if="[1,2,5].includes(resData.ChartInfo.Source)">上下限设置</span>
         </div>
         <div :class="['source-box',{'un-coll-sty':sourceColl,'coll-sty': !sourceColl}]">
             <span class="source-item">来源:{{resData&&resData.ChartInfo.ChartSource}}</span>