|
@@ -0,0 +1,292 @@
|
|
|
+<template>
|
|
|
+ <div class="chart-box" v-if="compData" ref="compRef" v-loading="loading">
|
|
|
+ <div class="top-title-box">
|
|
|
+ <div class="title" @click="goDetail">{{ chartInfo.ChartName }}</div>
|
|
|
+ <div class="opt-box">
|
|
|
+ <img
|
|
|
+ class="icon"
|
|
|
+ src="~@/assets/img/icons/refresh_blue_new.png"
|
|
|
+ alt=""
|
|
|
+ @click="refreshHandle"
|
|
|
+ />
|
|
|
+ <slot name="drag"></slot>
|
|
|
+ <slot name="delete"></slot>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 无权限 -->
|
|
|
+ <div class="nodata" v-if="chartInfo.HaveOperaAuth === false">
|
|
|
+ <noDataAuth :text="$t('MsgPrompt.no_chart_auth')" />
|
|
|
+ </div>
|
|
|
+ <div class="chart-render-wrap" v-else>
|
|
|
+ <Chart
|
|
|
+ minHeight="480px"
|
|
|
+ height="480px"
|
|
|
+ :options="options"
|
|
|
+ :chartInfo="chartInfo"
|
|
|
+ :index="compData.BiDashboardDetailId"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import Chart from '@/views/dataEntry_manage/components/chart';
|
|
|
+import { chartSetMixin } from '@/views/dataEntry_manage/mixins/chartPublic'
|
|
|
+import { dataBaseInterface } from '@/api/api.js';
|
|
|
+import chartRelevanceApi from '@/api/modules/chartRelevanceApi';
|
|
|
+import apiIntervalAnalysis from '@/api/modules/intervalAnalysis'
|
|
|
+import { fittingEquationInterface,statisticFeatureInterface,crossVarietyInterface } from '@/api/modules/chartRelevanceApi';
|
|
|
+export default {
|
|
|
+ components: { Chart },
|
|
|
+ mixins: [chartSetMixin],
|
|
|
+ props: {
|
|
|
+ compData: null
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ tableData: {
|
|
|
+ handler(newval) {
|
|
|
+ newval.length && !this.chartInfo.WarnMsg && [1, 11].includes(this.chartInfo.Source) && this.setChartOptionHandle(newval);
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: true,
|
|
|
+ observer: null,
|
|
|
+ isVisible: false, // 是否可见
|
|
|
+
|
|
|
+ chartInfo: {},
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ console.log('图表组件挂载');
|
|
|
+ this.createObserver();
|
|
|
+ },
|
|
|
+ beforeUnmount() {
|
|
|
+ if (this.observer) {
|
|
|
+ this.observer.disconnect();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /* 一键刷新 超长等待..*/
|
|
|
+ async refreshHandle() {
|
|
|
+ // 清除缓存配置项
|
|
|
+ this.loading = true;
|
|
|
+ const { Source, ChartInfoId, } = this.chartInfo;
|
|
|
+
|
|
|
+ let res = null
|
|
|
+ if (Source === 1) {
|
|
|
+ res = await dataBaseInterface.chartRefresh({ ChartInfoId })
|
|
|
+ } else if ([3].includes(Source)) {
|
|
|
+ res = await chartRelevanceApi.refreshChart({ ChartInfoId })
|
|
|
+ } else if (Source === 6) {
|
|
|
+ res = await fittingEquationInterface.refreshChart({ ChartInfoId })
|
|
|
+ } else if ([7].includes(Source)) {
|
|
|
+ res = await statisticFeatureInterface.refreshChart({ ChartInfoId })
|
|
|
+ } else if (Source === 10) {
|
|
|
+ res = await crossVarietyInterface.refreshChart({ ChartInfoId })
|
|
|
+ } else if (Source === 12) {
|
|
|
+ res = await apiIntervalAnalysis.chartRefresh({ ChartInfoId })
|
|
|
+ }
|
|
|
+
|
|
|
+ this.loading = false;
|
|
|
+ if (res.Ret !== 200) return
|
|
|
+ this.$message.success(res.Msg);
|
|
|
+
|
|
|
+ this.handleGetChartData()
|
|
|
+ },
|
|
|
+
|
|
|
+ goDetail() {
|
|
|
+ const pathMap = new Map([
|
|
|
+ [1, '/chartsetting'],
|
|
|
+ [3, '/chartrelevance'],
|
|
|
+ [6, '/fittingEquationList'],
|
|
|
+ [7, '/statisticFeatureList'],
|
|
|
+ [10, '/crossVarietyChartList'],
|
|
|
+ [12, '/rangeAnalysis']
|
|
|
+ ])
|
|
|
+ const href = this.$router.resolve({
|
|
|
+ path: pathMap.get(this.chartInfo.Source),
|
|
|
+ query: {
|
|
|
+ code: this.chartInfo.UniqueCode,
|
|
|
+ id: this.chartInfo.ChartInfoId
|
|
|
+ }
|
|
|
+ }).href
|
|
|
+ window.open(href, "_blank")
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取图表数据
|
|
|
+ async handleGetChartData() {
|
|
|
+ const res = await dataBaseInterface.getChartByCode({ UniqueCode: this.compData.UniqueCode })
|
|
|
+ this.loading = false
|
|
|
+ if (res.Ret !== 200) return;
|
|
|
+ this.chartInfo = res.Data.ChartInfo;
|
|
|
+
|
|
|
+ this.chartInfo.SeasonExtraConfig && (this.SeasonExtraConfig = JSON.parse(this.chartInfo.SeasonExtraConfig))
|
|
|
+
|
|
|
+ if (!this.chartInfo.HaveOperaAuth) return
|
|
|
+
|
|
|
+ if ([1, 11, 12].includes(this.chartInfo.Source)) {
|
|
|
+ //季节性图处理SeasonAverageConfig,SeasonRightEdbConfig
|
|
|
+ if (this.chartInfo.ChartType === 2) {
|
|
|
+ const { MaxMinLimits, SamePeriodAverage, SamePeriodStandardDeviation, RightAxis } = res.Data.DataResp
|
|
|
+ this.chartInfo.SeasonAverageConfig = { MaxMinLimits, SamePeriodAverage, SamePeriodStandardDeviation }
|
|
|
+ this.chartInfo.SeasonRightConfig = RightAxis
|
|
|
+ }
|
|
|
+ this.tableData = res.Data.EdbInfoList;
|
|
|
+ //初始化上下限
|
|
|
+ this.setLimitData(this.tableData)
|
|
|
+
|
|
|
+ this.chartInfo.ChartType === 7 && this.initBarData(res.Data);
|
|
|
+
|
|
|
+ //截面散点图
|
|
|
+ this.chartInfo.ChartType === 10 && this.initSectionScatterData(res.Data);
|
|
|
+
|
|
|
+ //雷达图
|
|
|
+ this.chartInfo.ChartType === 11 && this.initRadarData(res.Data);
|
|
|
+
|
|
|
+ // 截面组合图
|
|
|
+ this.chartInfo.ChartType === 14 && this.initSectionalCombinationChart(res.Data);
|
|
|
+
|
|
|
+ // 区间分析
|
|
|
+ this.chartInfo.Source === 12 && this.initIntervalAnalysisChartData(res.Data)
|
|
|
+
|
|
|
+ } else if ([2, 5].includes(this.chartInfo.Source)) {
|
|
|
+ // this.tableData = [res.Data.EdbInfoList[0]];
|
|
|
+ this.tableData = res.Data.EdbInfoList.filter(_e => _e.Source)
|
|
|
+ this.chartInfo = res.Data.ChartInfo.Source === 5 ? {
|
|
|
+ ...res.Data.ChartInfo,
|
|
|
+ ProfitNameEn: res.Data.DataResp.ProfitNameEn,
|
|
|
+ ProfitName: res.Data.DataResp.ProfitName,
|
|
|
+ } : res.Data.ChartInfo;
|
|
|
+ //商品价格图
|
|
|
+ this.initCommodityData(res.Data);
|
|
|
+ } else if ([3].includes(this.chartInfo.Source)) {//相关性 滚动相关性
|
|
|
+
|
|
|
+ this.relevanceChartData = {
|
|
|
+ ChartInfo: res.Data.ChartInfo,
|
|
|
+ EdbInfoList: res.Data.EdbInfoList,
|
|
|
+ XEdbIdValue: res.Data.XEdbIdValue,
|
|
|
+ CorrelationChartInfo: res.Data.CorrelationChartInfo,
|
|
|
+ YDataList: [
|
|
|
+ {
|
|
|
+ Value: res.Data.YDataList[0].Value,
|
|
|
+ Color: '#00f',
|
|
|
+ Name: res.Data.YDataList[0].Name || res.Data.ChartInfo.ChartName,
|
|
|
+ NameEn: res.Data.YDataList[0].NameEn || res.Data.ChartInfo.ChartNameEn
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ //多因子
|
|
|
+ if (res.Data.CorrelationChartInfo.AnalysisMode === 1) {
|
|
|
+ this.relevanceChartData.YDataList = res.Data.YDataList
|
|
|
+ }
|
|
|
+
|
|
|
+ this.initRelevanceChartData()
|
|
|
+ this.tableData = res.Data.EdbInfoList
|
|
|
+ } else if (this.chartInfo.Source === 4) {//滚动相关性换成曲线图绘图
|
|
|
+ this.tableData = res.Data.EdbInfoList
|
|
|
+ this.relevanceChartData = {
|
|
|
+ CorrelationChartInfo: res.Data.CorrelationChartInfo
|
|
|
+ }
|
|
|
+ this.setDefaultChart([res.Data.DataResp]);
|
|
|
+
|
|
|
+ } else if ([6, 7, 8].includes(this.chartInfo.Source)) {//拟合方程 标准差 百分比
|
|
|
+ this.tableData = res.Data.EdbInfoList;
|
|
|
+
|
|
|
+ this.setDefaultChart([res.Data.DataResp]);
|
|
|
+ } else if (this.chartInfo.Source === 9) { //统计频率
|
|
|
+ this.tableData = res.Data.EdbInfoList;
|
|
|
+ this.statisticFrequencyData = res.Data.DataResp;
|
|
|
+ this.setStatisticFrequency();
|
|
|
+ } else if (this.chartInfo.Source === 10) { //跨品种分析
|
|
|
+ this.tableData = res.Data.EdbInfoList;
|
|
|
+ this.crossVarietyChartData = res.Data.DataResp;
|
|
|
+
|
|
|
+ /* 历史数据chartInfo里全是空 兼容下历史数据不崩 */
|
|
|
+ this.chartLimit = {
|
|
|
+ min: res.Data.ChartInfo.LeftMin ? Number(res.Data.ChartInfo.LeftMin) : Number(res.Data.DataResp.YMinValue),
|
|
|
+ max: res.Data.ChartInfo.LeftMax ? Number(res.Data.ChartInfo.LeftMax) : Number(res.Data.DataResp.YMaxValue),
|
|
|
+ x_min: res.Data.ChartInfo.XMin ? Number(res.Data.ChartInfo.XMin) : Number(res.Data.DataResp.XMinValue),
|
|
|
+ x_max: res.Data.ChartInfo.XMax ? Number(res.Data.ChartInfo.XMax) : Number(res.Data.DataResp.XMaxValue),
|
|
|
+ }
|
|
|
+ this.setCrossVarietyChart();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 利用判断是否进入可视区域 来加载数据
|
|
|
+ // 如果加载过了就不用再加载了
|
|
|
+ createObserver() {
|
|
|
+ const options = {
|
|
|
+ root: null, // 使用浏览器可视区域为根
|
|
|
+ threshold: 0.1, // 当至少10%的内容进入可视区时触发回调
|
|
|
+ };
|
|
|
+
|
|
|
+ this.observer = new IntersectionObserver(this.handleIntersect, options);
|
|
|
+ this.observer.observe(this.$refs.compRef); // 监听组件
|
|
|
+ },
|
|
|
+ handleIntersect(entries) {
|
|
|
+ if (this.isVisible) return
|
|
|
+ entries.forEach(entry => {
|
|
|
+ // 判断是否在可视范围内
|
|
|
+ if (entry.isIntersecting) {
|
|
|
+ this.isVisible = true;
|
|
|
+ console.log('Component is visible');
|
|
|
+ // 在这里你可以执行其他操作,比如懒加载数据或图片等
|
|
|
+ this.handleGetChartData()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.chart-box {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ padding: 20px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ .top-title-box {
|
|
|
+ display: flex;
|
|
|
+ margin-bottom: 10px;
|
|
|
+ .title {
|
|
|
+ font-size: 20px;
|
|
|
+ font-weight: bold;
|
|
|
+ flex: 1;
|
|
|
+ display: -webkit-box;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ -webkit-line-clamp: 1;
|
|
|
+ line-break: anywhere;
|
|
|
+ -webkit-box-orient: vertical;
|
|
|
+ &::before {
|
|
|
+ content: "";
|
|
|
+ display: inline-block;
|
|
|
+ width: 4px;
|
|
|
+ height: 20px;
|
|
|
+ background-color: #0052d9;
|
|
|
+ position: relative;
|
|
|
+ top: 2px;
|
|
|
+ margin-right: 5px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .opt-box {
|
|
|
+ flex-shrink: 0;
|
|
|
+ margin-left: 10px;
|
|
|
+ .icon {
|
|
|
+ width: 24px;
|
|
|
+ height: 24px;
|
|
|
+ margin-left: 5px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .chart-render-wrap {
|
|
|
+ width: 100%;
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|