comprehen.vue 6.76 KB
<template>
    <div class="comprehen-analysis">
        <el-header>
            <span class="asis-title">{{ asisName }}&nbsp;{{$t('asis.Comprehen')}}</span>
        </el-header>
        <comprehen-option ref="init" :mallData="mallData" @reportTime="reportHandler" @initData="initTab"></comprehen-option>
        <div class="element-main comprehen-main">
            <router-view :propparam="propParams"></router-view>
        </div>
    </div> 
</template>

<script>
import comprehenOption from '../common/option/comprehenMoreOption'
export default {
    data() {
        return {
            mallData: [],
            asisName: '',
            asisLevel: '',
            propParams: {}
        }
    },
    components: {
        'comprehen-option': comprehenOption,
    },
    created() {
        window.addEventListener('resize', () => {
            try {
                let timeHeatEChartsUtil = {
                    chart1: $('#dgenderChart')[0],
                    chart2: $('#dageChart')[0],
                    chart3: $('#dmomentChart')[0],
                    chart4: $('#dcumulativeChart')[0],
                    chart5: $('#dnearfifChart')[0],
                    chart6: $('#wgenderChart')[0],
                    chart7: $('#wageChart')[0],
                    chart8: $('#wnearfifChart')[0],
                    chart9: $('#mgenderChart')[0],
                    chart10: $('#mageChart')[0],
                    chart11: $('#mnearfifChart')[0],
                    chart12: $('#ygenderChart')[0],
                    chart13: $('#yageChart')[0],
                    chart14: $('#ynearfifChart')[0],
                    chart14: $('#cgenderChart')[0],
                    chart14: $('#cageChart')[0],
                    chart14: $('#cnearfifChart')[0],
                }
                for(let k in timeHeatEChartsUtil) {
                    if(timeHeatEChartsUtil.hasOwnProperty(k) && timeHeatEChartsUtil[k] != undefined) {
                        timeHeatEChartsUtil[k] = this.$echarts.init(timeHeatEChartsUtil[k]);
                        var element = timeHeatEChartsUtil[k];
                        element.resize();
                    }
                }
            } catch (err) { }
        })
    },
    mounted() {
        // this.router.push('/analysis/comprehenAnalysis/daily')
        this.getMallOpt();
    },
    methods: {
        getMallOpt() {
            this.$api.base.mall({
                accountId: this.$cookie.get('accountId'),
                status: 1,
                // _t: Date.parse(new Date()) / 1000
            }).then(res => {
                let titleName = '', refMallId = null;
                let localMallId = window.sessionStorage.getItem('mallId');
                    localMallId ? Number(localMallId) : false;
                if(res.data.data.length >= 1) {
                    res.data.data.forEach((item, index) => {
                        this.mallData.push(item);
                        if(localMallId) {
                            if(item.id == localMallId) {
                                titleName = item.name;
                            }
                        }
                    });
                    this.asisName = titleName ? titleName : res.data.data[0].name;
                    refMallId = localMallId ? Number(localMallId) : res.data.data[0].id;
                    this.$refs.init.initAsis(refMallId);
                }
            })
        },
        initTab(data) {
            switch (data.asis_date) {
                case 'day':
                    this.$router.push('/analysis/comprehen/daily')
                    this.propParams = {
                        dateType: '/comprehen/daily',
                        data: data
                    };
                    break;
                case 'week':
                    this.$router.push('/analysis/comprehen/weekly')
                    this.propParams = {
                        dateType: '/comprehen/weekly',
                        data: data
                    };
                    break;
                case 'month':
                    this.$router.push('/analysis/comprehen/monthly')
                    this.propParams = {
                        dateType: '/comprehen/monthly',
                        data: data
                    };
                    break;
                case 'year':
                    this.$router.push('/analysis/comprehen/yearly')
                    this.propParams = {
                        dateType: '/comprehen/yearly',
                        data: data
                    };
                    break;
                case 'custom':
                    this.$router.push('/analysis/comprehen/customly')
                    this.propParams = {
                        dateType: '/comprehen/customly',
                        data: data
                    };
                    break;
                default:
                    break;
            }
            // setTimeout(() => {
            //     this.$refs.takeTime.refreshHandle(data);
            // }, 1000);
        },
        reportHandler(emitData) {
            this.asisName = emitData.asis_tit;
            switch (emitData.asis_date) {
                case 'day':
                    this.$router.push('/analysis/comprehen/daily');
                    this.propParams = {
                        dateType: '/comprehen/daily',
                        data: emitData
                    };
                    break;
                case 'week':
                    this.$router.push('/analysis/comprehen/weekly');
                    this.propParams = {
                        dateType: '/comprehen/weekly',
                        data: emitData
                    };
                    break;
                case 'month':
                    this.$router.push('/analysis/comprehen/monthly');
                    this.propParams = {
                        dateType: '/comprehen/monthly',
                        data: emitData
                    };
                    break;
                case 'year':
                    this.$router.push('/analysis/comprehen/yearly');
                    this.propParams = {
                        dateType: '/comprehen/yearly',
                        data: emitData
                    };
                    break;
                case 'custom':
                    this.$router.push('/analysis/comprehen/customly');
                    this.propParams = {
                        dateType: '/comprehen/customly',
                        data: emitData
                    };
                    break;
                default:
                    break;
            }
            // setTimeout(() => {
            //     this.$refs.takeTime.refreshHandle(emitData);
            // }, 200);
        }
    },
}
</script>

<style scoped>
    .comprehen-analysis {
        width: 100%;
    }
</style>