customly.vue 4.92 KB
<template>
    <div class="customly">
        <div class="asis-table-wrapper heatmap-wrapper single-report-wrapper">
            <!-- <h3 class="heatmap-header">
                    <span class="heatmap-title">时间热力图</span>
                    <span class="heatmap-download">导出数据</span>
                </h3> -->
            <div class="heatmap-content download-parent">
                <!-- 时间热力图 -->
                <heatmap-chart id="customHeatmap" class="custom-heatmap-chart" :options="customHeatmap_ops" chartType="Heatmap"></heatmap-chart>
                <!-- <span class="chart-title">{{$t('asis.TimeHeat')}}</span> -->
                <span class="download-text" @click="exportDataHandle($t('asis.TimeHeat'),'TimeThermodynamic')">{{$t('allPages.load')}}</span>
            </div>
        </div>
        <export-data-dialog ref="exportDialog"></export-data-dialog>
    </div>
</template>

<script>
import exportData from '../../public/exportData'
import publicChart from '../common/publicChart'
export default {
    props: {
        propparam: Object
    },
    data() {
        return {
            customHeatmap_ops: {},
            chartKeyToId: {},
            chartIds: '',
            emitData: [],
            startTime:'',
            endTime:'',
        }
    },
    components: {
        'heatmap-chart': publicChart,
        'export-data-dialog': exportData,
    },
    watch: {
        propparam: {
            handler: 'refreshHandle',
            immediate: true
        }
    },
    mounted() {
    },
    methods: {
        refreshHandle(param) {
            if(param.dateType !== '/timeheat/customly') return;
            this.emitData = param.data;
            if (this.chartIds && JSON.stringify(this.chartKeyToId) !== '{}') {
                this.getChartData(this.chartIds);
            } else {
                this.getChartId();
            }
        },
        getChartId() {
            this.chartKeyToId = {};
            this.chartIds = '';
            this.$api.baseReport.reportChart({
                report: 'TimeThermodynamic',
                // _t: Date.parse(new Date()) / 1000
            })
                .then(res => {
                    let chartItem = res.data.data;
                    chartItem.forEach((item, index) => {
                        this.chartKeyToId[item.key] = item.id;
                        if (item.key === 'TimeThermodynamic') {
                            if (index == chartItem.length - 1) {
                                this.chartIds += item.id;
                            } else {
                                this.chartIds += item.id + ','
                            }
                        }
                    });
                    this.getChartData(this.chartIds);
                })
        },
        getChartData(chartIds) {
            if(!this.chartIds) return;
            this.customHeatmap_ops = {};
            let apiUrl = '', param = {};
            if (this.emitData.asis_time == '' || this.emitData.asis_time == undefined) {
                this.startTime = this.dayReduce(new Date(), 30)
                this.endTime = dateUnit.dateFormat(new Date(), 'yyyy-MM-dd');
            } else {
                this.startTime = this.emitData.asis_time[0];
                this.endTime = this.emitData.asis_time[1];
            }
            // 常规情况赋值
            // apiUrl = '/report/thermodynamic/' + this.emitData.asis_level;
            param = {
                orgIds: this.emitData.asis_org,
                chartIds: chartIds,
                startDate: this.startTime,
                endDate: this.endTime,
                // kpiType: this.emitData.asis_kpi,
                // formatIds: this.emitData.asis_format,
                // _t: Date.parse(new Date()) / 1000
            };
            this.$api.analysisReport.thermodynamicAnalysis(this.emitData.asis_level, param)
                .then(res => {
                    this.customHeatmap_ops = res.data.data.body.TimeThermodynamic;
                })
                .catch(err => { })
        },
        exportDataHandle(title, chartKey) {
            let chartId = this.chartIds;
		    let exportNeed = {
		        domId: 'customHeatmap',
		        title: title,
		        data: {
					url: `/report/thermodynamic/${this.emitData.asis_level}/${chartId}/excel`,
					params: `orgIds=${this.emitData.asis_org}&chartIds=${chartId}&startDate=${this.startTime}&endDate=${this.endTime}`
		        }
		    }
		    this.$refs.exportDialog.dialogInit(exportNeed);
		},
    }
}
</script>

<style scoped>
/* #weekHeatmap, */

.custom-heatmap-chart {
    height: 722px;
}

.download-text {
    right: 30px;
    top: 5px;
    padding-right: 0;
}

.download-text:after {
    content: none;
}
    @media only screen and (max-width: 1366px) {
        .custom-heatmap-chart {
            height: 500px;
        }
    }
    @media only screen and (max-width: 1280px) {
        .custom-heatmap-chart {
            height: 500px;
        }
    }
</style>