content.vue 4.83 KB
<template>
    <div class="daily">
        <div class="asis-table-wrapper">
            <h3 class="asis-table-header single-report-header tf-table-header">
                <span class="asis-table-download" @click="downloadData">{{$t('allPages.load')}}</span>
            </h3>
            <div class="asis-table-content" v-loading="loading">
                <el-row>
                    <div ref="scatterChart" id="scatterChart" class="chart" :style="{ height: tableHeight + 'px' }"></div>
                </el-row>
            </div>
        </div>
        <export-data-dialog ref="exportDialog"></export-data-dialog>
    </div>
</template>

<script>
    import exportData from "../../public/exportData";
    import echarts from 'echarts'
    export default {
        props: {
            propparam: {
                type: Object,
                default: () => {}
            }
        },
        components: {
            "export-data-dialog": exportData,
        },
        data() {
            return {
                loading: false,
                trafficFlow_title: "competitivePassengerFlowData", //报表
                emitData: {},
                chartData: {}, // 图数据
                option:{
                    xAxis: {
                        name:this.$t('head.perSquare'),
                        splitLine: {
                            lineStyle: {
                              type: 'dashed'
                            }
                        }
                    },
                    yAxis: {
                        name:this.$t('head.humanEffect'),
                        splitLine: {
                            lineStyle: {
                                    type: 'dashed'
                            }
                        },
                        scale: true
                    },
                    series: [
                        {
                            symbolSize: 20,
                            data: [],
                            type: 'scatter'
                        }
                    ]
                }
            };
        },
        computed:{
            tableHeight() {
              let windowHeight = window.innerHeight,
                scale = 0.34
              
              scale = windowHeight <= 720
                ? 0.4
                : windowHeight <= 768
                  ? 0.38
                  : windowHeight <= 900
                    ? 0.36
                    : windowHeight <= 1080
                      ? 0.34
                      : 0.34
              return windowHeight - windowHeight * scale
            }
        },
        watch: {
            propparam: {
                handler: "refreshHandle",
                // immediate: true,
                deep: true
            },
            emitData: {
                handler() {
                },
                immediate: true,
                deep: true
            }
        },
        mounted() {
          this.myChart = echarts.init(this.$refs['scatterChart']);  
        },
        methods: {
            refreshHandle(param) {
                if (param) {
                    this.emitData = param
                    this.getData();
                }
            },
            getData() {
                this.loading = true;
                let param = {
                    orgId: this.$cookie.get('accountId'),
                    startDate: this.emitData.startDate,
                    endDate: this.emitData.endDate,
                }
                this.$api.businessAnalysisApi.getCostAnalysis(param).then(res => {
                    let resData = res.data.data;
                    this.loading = false;
                    this.chartData = resData
                    this.option.series = resData.series
                    this.option.series[0].emphasis = {
                        focus: 'series',
                        label: {
                          show: true,
                          formatter: function (param) {
                            return param.data[2];
                          },
                          position: 'top'
                        }
                    }
                    this.option.series[0].symbolSize =20
                    this.myChart.setOption(this.option,true)
                })
            },
            downloadData() {
                let exportNeed = {
                  domId: "scatterChart",
                  title: this.chartData.title,
                  data: {
                    url: `/report/account/cost/analysis/export`,
                    params: `orgId=${this.$cookie.get('accountId')}&startDate=${this.emitData.startDate}&endDate=${this.emitData.endDate}`
                  }
                };
                this.$refs.exportDialog.dialogInit(exportNeed);
            },
        }
    };
</script>

<style scoped>
    .asis-table-wrapper {
        position: relative;
    }
</style>