content.vue 5.14 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="lineChart" id="lineChart" 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:{
                    tooltip:{
                        trigger:'axis'
                    },
                    color:["#3BB8FF", "#FFC62E"],
                    xAxis: {
                        type: 'category',
                        data:[],
                        axisLabel:{
                            show:false
                        },
                        axisLine:{
                            show:false
                        },
                        axisTick:{
                            show:false
                        }
                    },
                    yAxis: [
                        {
                            type:'value',
                            name:''
                        },
                        {
                            type:'value',
                            name:''
                        }
                    ],
                    series: [
                        {
                            data: [],
                            type: 'line',
                            smooth: true
                        },
                        {
                            data: [],
                            type: 'line',
                            smooth: true,
                            yAxisIndex:1
                        }
                    ]
                }
            };
        },
        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['lineChart']);  
        },
        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.getCustomerExperience(param).then(res => {
                    let resData = res.data.data;
                    this.loading = false;
                    this.chartData = resData
                    this.option.xAxis.data = resData.xaxis.data
                    resData.series.forEach((item,index)=>{
                        this.option.yAxis[index].name=item.name
                        this.option.series[index].data=item.data
                        this.option.series[index].name=item.name
                    })
                    this.myChart.setOption(this.option,true)
                })
            },
            downloadData() {
                let exportNeed = {
                  domId: "lineChart",
                  title: this.chartData.title,
                  data: {
                    url: `/report/account/customer/experience/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>