inout.vue 4.6 KB
<!-- 出入口客流分布 -->
<template>
    <div>
        <!-- 顶部区域 S-->
        <div class="ipage_top">
            <div class="tit"><img :src="bindIcon('zhuancang')"/>{{title||chartData.title}}</div>
            <div class="acts">
                <slot name="action"></slot>
                <!-- <el-tabs v-model="numPerVal" @tab-click="handlePerClick" class="no_bar">
                    <el-tab-pane label="人次" name="percent"></el-tab-pane>
                    <el-tab-pane label="人数" name="count"></el-tab-pane>
                </el-tabs> -->
            </div>
        </div>
        <div class="ichart">
            <div class="legend">
                <ul class="acea-row row-start">
                    <li v-for="(item,idx) in legendList" :class="item[1]?'':'hidden'" @click="legendBtn(item)" :key="idx">
                        <em :style="{backgroundColor:_color[idx]}"></em>
                        <span>{{item[0]}}</span>    
                    </li>
                </ul>
            </div>
            <el-row>
                <el-col :span="10">
                    <pie-chart ref="chart" :cdata="chartData"></pie-chart>
                </el-col>
                <el-col :span="14" class="split">
                    <vline ref="vline" icon="empty" :selected="selected" :ckey="vlineKey" :title="$t('iPage.coustomertrend')" :level="levels"></vline>
                </el-col>
            </el-row>
        </div>
    </div>
</template>
<script>
import mixin from './mixin';
import vline from './vline';
import _ from 'underscore';
/**********************************************************/
const chartsConfig = {
    default:{ //默认
        otherConf:{
            yAxisLineHide:true,
            isGraphic:true,
            labelName:true,
            radius:['50%','78%'],
            legendObj:{
                show:false,
                selected:{}
            },
            //_color:this._color
        }
    }
};
/*******************************************************/
export default {
    mixins: [mixin],
    data() {
        return {
            numPerVal:'percent',
            isEmpty:true,
            selected:{},
            configObj:{},
            legendList:[],
            _color:[],
            levels:[],
            vlineKey:''
        }
    },
    components:{
        vline
    },
    created() {
        if(this.ckey=='mall_gate_passenger_distribution'){
            this.vlineKey = 'mall_gate_passenger_flow_trends';
        }else if(this.ckey=='floor_gate_passenger_distribution'){ 
            this.vlineKey = 'floor_gate_passenger_flow_trends'
        }
    },
    methods: {
        setCurLevel(){
            let dateType = this.params.dateType;
            if(dateType=='day'){
              this.levels=['HOUR','MINUTE'];
            }else if(dateType=='month'){
              this.levels=['DAY','HOUR','MINUTE'];
            }else if(dateType=='year'){
              this.levels=['MONTH','DAY','HOUR','MINUTE'];
            }
            
        },
        getChartsConfig(params){
            this.setCurLevel();
            return chartsConfig;
        },
        handlePerClick(){

        },
        handleTimeChange(){

        },
        legendBtn(item){
            let name = item[0];
            let selected = this.configObj.otherConf.legendObj.selected;
            let isShow = item[1];
            selected[item[0]] = !isShow;
            this.selected = selected;
            item[1] = !isShow;
            this.$forceUpdate();
        },
        loadChartData(params){
            this.chartId = this.getChartId(this.ckey);
            if(this.chartId){
               this.ajaxModuleData().then(data=>{
                  this.setChartData(data);
               });
            }
            this.$refs.vline.loadModuleData(params,true);
        },
        setChartData(data){
            try{
                this._color = this.getSeriesColor();
                let legendSelect = {}
                data.series[0].data.forEach((item,index)=>{
                    legendSelect[item.name] = index<100?true:false;
                })
                this.selected = legendSelect;
                this.configObj.otherConf.legendObj.selected = legendSelect;
                this.configObj.otherConf._color = this._color;
                this.chartData = Object.assign({},data,this.configObj);
                this.legendList = _.pairs(legendSelect);
                this.isEmpty = false;
            }catch(err){
                this.chartData = {otherConf:{}};
                this.isEmpty = true;
                this.hideLoading();
            }
        }
    }
}
</script>

<style scoped  lang="less">

</style>