vline.vue 4.49 KB
<!-- 近期客流趋势 -->
<template>
    <div>
        <!-- 顶部区域 S-->
        <div class="ipage_top">
            <div class="tit"><img v-if="icon!='empty'" :src="bindIcon()"/>{{title||chartData.title}}</div>
            <div class="acts">
                <el-tabs v-model="timeLevel" @tab-click="handleTimeChange" v-if="level.length">
                    <el-tab-pane v-if="level.includes('MONTH')" :label="$t('iPage.monthOver')" name="MONTH"></el-tab-pane>
                    <el-tab-pane v-if="level.includes('WEEK')" :label="$t('iPage.weekOver')" name="WEEK"></el-tab-pane>
                    <el-tab-pane v-if="level.includes('DAY')" :label="$t('iPage.dayOver')" name="DAY"></el-tab-pane>
                    <el-tab-pane v-if="level.includes('HOUR')" :label="$t('iPage.hourOver')" name="HOUR"></el-tab-pane>
                    <el-tab-pane v-if="level.includes('MINUTE')" :label="$t('iPage.minuteOver')" name="MINUTE"></el-tab-pane>
                </el-tabs>
                <slot name="action"></slot>
            </div>
        </div>
        <div class="ichart">
            <line-chart ref="chart" :cdata="chartData"></line-chart>
        </div>
    </div>
</template>

<script>
import _ from 'underscore';
import mixin from './mixin';
import mallData from '@/components/Echarts/data';
/**********************************************************/
let chartsConfig;
/*******************************************************/
export default {
    mixins: [mixin],
    props: {
        level: {
          type: Array,
          default: () => []
        },
        selected:{
            type:Object,
            default: () => {}
        }
    },
    watch:{
        level:{
            handler(newVal) {
                this.timeLevel = newVal[0]||'';
                this.loadChartData();
            },
            deep: true
        },
        selected: {
          handler(newVal) {
             this.filterSeries(newVal)
          },
          deep: true
        }
    },
    data() {
        return {
            timeLevel:'',
            configObj:{},
        }
    },
    created() {
        chartsConfig = {
            mall_gate_passenger_flow_trends:{   //客流走势
                otherConf:{
                    usePercent:true,
                    yAxisLineHide:true,
                    grid:{left:60,top:20,right:20,bottom:20},
                }
            },
            recent_passenger_flow_trends:{   //近期客流趋势
                otherConf:{
                _color:['#ffb4cc','#4992FF','#FF6D43','#F5D090','#63DAAB'],
                barWidth:26,
                yAxisLineHide:true,
                grid:{left:70,top:40,right:0,bottom:20},
                yAxisName:painter.$t('format.perTime')
                }
            },
            detention_comparison:{
                otherConf:{
                    yAxisLineHide:true,
                    legendShow:true,
                    yAxisName:painter.$t('format.perNum'),
                    grid:{left:70,top:40,right:0,bottom:60}
                }
            },
            default:{ //默认
                otherConf:{
                    yAxisLineHide:true,
                    //usePercent:true,
                //_color:['#FFA2C0','#FF6D43','#F5D090','#63DAAB','#4992FF']
                }
            }
        }
    },
    methods: {
        getChartsConfig(){
            return chartsConfig;
        },
        filterSeries(seriList){
            if(!this.chartData.series)return;
            this.configObj.otherConf.legendSelected = seriList;
            this.chartData = Object.assign({},this.chartData,{
                otherConf:this.configObj.otherConf||{}
            });
        },
        handleTimeChange(){
            this.loadChartData();
        },
        loadChartData(params){
            if(this.ckey=='mall_gate_passenger_flow_trends'){
                if(!this.timeLevel)return false;
                this.params.timeLevel = this.timeLevel;
            }
            this.chartId = this.getChartId(this.ckey);
            if(this.chartId){
               this.ajaxModuleData().then(data=>{
                  this.setChartData(data);
               });
            }else{
               this.setChartData(); 
            }
        },
        setChartData(data){
            this.configObj.otherConf._color = this.configObj.otherConf._color||this.getSeriesColor();
            this.chartData = Object.assign({},data,{
                otherConf:this.configObj.otherConf||{}
            });
        }
    }
}
</script>

<style  lang="less">

</style>