moveLine.vue 7.45 KB
<template>
    <div class="base-analysis">
        <el-header height="70px">
            <span class="asis-title">{{ asisName }}&nbsp;{{$t('asis.MoveLine')}}</span>
            <span class="more-option-wrapper" @click="showCollapse">
                <span class="more-option-text">{{$t('asis.moreOp')}}</span>
                <i :class="moreOptVisible ? 'el-icon-arrow-down more-option-arrow' : 'el-icon-arrow-down more-option-arrow more-option-up'"></i>
            </span>
        </el-header>
        <moveline-option v-show="moreOptVisible" ref="init" :mallData="mallData" @reportTime="reportHandler" @initData="initTab"></moveline-option>
        <div class="element-main base-main">
            <!-- ref="takeTime" -->
            <router-view :propparam="propParams"></router-view>
        </div>
    </div> 
</template>

<script>
import mlOption from '../common/option/mlMoreOption'
export default {
    data() {
        return {
            moreOptVisible: false,
            mallData: [],
            asisName: '',
            asisLevel: '',
            propParams: {}
        }
    },
    components: {
        'moveline-option': mlOption,
    },
    created() {
        window.addEventListener('resize', () => {
            try {
                let timeHeatEChartsUtil = {
                    chart1: $('#cusGraphChart')[0],
                    chart2: $('#mGraphChart')[0],
                    chart3: $('#graphChart')[0],
                    chart4: $('#wGraphChart')[0],
                    chart5: $('#yGraphChart')[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();
        this.showCollapse();
        // $('.element-main').niceScroll();
    },
    methods: {
        showCollapse() {
            // 获取上面元素的高度
            let headerH = '', titleH = '', collapseH = '', mt = '';
                headerH = this.getStyleFn('.el-header', 'height');
                titleH = this.getStyleFn('.analysis-wrapper .el-header', 'height');
            if(this.moreOptVisible) {
                this.moreOptVisible = false;
                mt = headerH + titleH + 8 + 'px';
                $('.base-main').animate({ marginTop: mt })
            } else {
                this.moreOptVisible = true;
                setTimeout(() => {
                    collapseH = this.getStyleFn('.analysis-option-wrapper', 'height');
                    mt = headerH + titleH + collapseH + 8 + 'px';
                    $('.base-main').animate({ marginTop: mt });
                }, 100);
            }
        },
        getMallOpt() {
            this.$api.base.mall({
                accountId: this.$cookie.get('accountId'),
                status: 1,
                // _t: Date.parse(new Date()) / 1000
            }).then(res => {
                let titleName = '', refMallId = null;
                if(res.data.data.length >= 1) {
                    let localMallId = window.sessionStorage.getItem('mallId');
                    localMallId ? Number(localMallId) : false;
                    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('/customer/trafficeline/daily');
                    this.propParams = {
                        dateType: '/trafficeline/daily',
                        data: data
                    };
                    break;
                case 'week':
                    this.$router.push('/customer/trafficeline/weekly')
                    this.propParams = {
                        dateType: '/trafficeline/weekly',
                        data: data
                    };
                    break;
                case 'month':
                    this.$router.push('/customer/trafficeline/monthly')
                    this.propParams = {
                        dateType: '/trafficeline/monthly',
                        data: data
                    };
                    break;
                case 'year':
                    this.$router.push('/customer/trafficeline/yearly')
                    this.propParams = {
                        dateType: '/trafficeline/yearly',
                        data: data
                    };
                    break;
                case 'custom':
                    this.$router.push('/customer/trafficeline/customly')
                    this.propParams = {
                        dateType: '/trafficeline/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('/customer/trafficeline/daily');
                    this.propParams = {
                        dateType: '/trafficeline/daily',
                        data: emitData
                    };
                    break;
                case 'week':
                    this.$router.push('/customer/trafficeline/weekly');
                    this.propParams = {
                        dateType: '/trafficeline/weekly',
                        data: emitData
                    };
                    break;
                case 'month':
                    this.$router.push('/customer/trafficeline/monthly');
                    this.propParams = {
                        dateType: '/trafficeline/monthly',
                        data: emitData
                    };
                    break;
                case 'year':
                    this.$router.push('/customer/trafficeline/yearly');
                    this.propParams = {
                        dateType: '/trafficeline/yearly',
                        data: emitData
                    };
                    break;
                case 'custom':
                    this.$router.push('/customer/trafficeline/customly');
                    this.propParams = {
                        dateType: '/trafficeline/customly',
                        data: emitData
                    };
                    break;
                default:
                    break;
            }
            // setTimeout(() => {
            //     this.$refs.takeTime.refreshHandle(emitData);
            // }, 200);
        }
    },
}
</script>

<style scoped>
</style>