zbar.vue 8.74 KB
<!-- 店铺客流综合指标 -->
<template>
    <div>
        <!-- 顶部区域 S-->
        <div class="ipage_top">
            <div class="tit"><img :src="bindIcon('shichang2')"/>{{title||chartData.title}}</div>
            <div class="acts">
                <template v-if="filterKeys.includes(ckey)">
                    <ul class="condition-box">
                      <!-- 选择店铺 S -->
                          <li class="condition-item">
                            <span class="condition-item-text">{{$t('asisTab.storeType')}}</span>
                            <div class="condition-item-option">
                              <el-select v-model="zoneTypeVal" filterable :placeholder="$t('pholder.zoneSelect')" class="floor-sel-box format-sel-box">
                                <el-option :label="$t('iPage.allZone')" value=""></el-option>
                                <el-option v-for="item in zoneTypeData" :key="item.id" :label="item.name" :value="item.id"></el-option>
                              </el-select>
                            </div>
                          </li> 
                          <!-- 选择店铺 E-->
                          <!-- 选择业态 S -->
                          <li class="condition-item">
                            <span class="condition-item-text">{{$t('asisTab.format')}}:</span>
                            <div class="condition-item-option">
                              <el-select v-model="formatVal" filterable :placeholder="$t('pholder.formateSelect')" class="floor-sel-box format-sel-box">
                                <el-option :label="$t('iPage.allFormat')" value=""></el-option>
                                <el-option v-for="item in formatData" :key="item.id" :label="item.name" :value="item.id"></el-option>
                              </el-select>
                            </div>
                          </li> 
                          <!-- 选择业态 E-->
                          <!-- 选择客群年龄性别 S -->
                          <li class="condition-item" v-if="ageSexKeys.includes(ckey)">
                            <span class="condition-item-text">{{$t('iPage.coutomerage')}}:</span>
                            <div class="condition-item-option">
                              <el-select v-model="genderVal" filterable :placeholder="$t('table.gender')" class="small-sel-box format-sel-box">
                                <el-option :label="$t('pholder.all')" value=""></el-option>
                                <el-option v-for="item in genderData" :key="item.value" :label="item.name" :value="item.value"></el-option>
                              </el-select>
                            </div>
                            <div class="condition-item-option" style="margin-left: 0;">
                              <el-select v-model="ageVal" filterable :placeholder="$t('table.age')" class="small-sel-box format-sel-box">
                                <el-option :label="$t('pholder.all')" value=""></el-option>
                                <el-option v-for="item in ageData" :key="item.value" :label="item.name" :value="item.value"></el-option>
                              </el-select>
                            </div>
                          </li> 
                          <!-- 选择客群年龄性别 E-->
                    </ul>
                    <el-tabs class="no_bar" v-model="sortVal">
                        <el-tab-pane :label="$t('iPage.trafficmax10')" name="desc"></el-tab-pane>
                        <el-tab-pane :label="$t('iPage.trafficmin10')" name="asc"></el-tab-pane>
                    </el-tabs>
                </template>
                <el-tabs v-else v-model="activeTab">
                    <!-- <el-tab-pane label="月汇总" name="month"></el-tab-pane>
                    <el-tab-pane label="周汇总" name="week"></el-tab-pane>
                    <el-tab-pane label="天汇总" name="day"></el-tab-pane> -->
                    <el-tab-pane :label="$t('iPage.hourOver')" name="hour"></el-tab-pane>
                    <el-tab-pane :label="$t('iPage.minuteOver')" name="minute"></el-tab-pane>
                </el-tabs>
                <slot name="action"></slot>
            </div>
        </div>
        <div class="ichart">
            <bar-chart ref="chart" :cdata="chartData"></bar-chart>
        </div>
    </div>
</template>

<script>
import mixin from './mixin';
import mallData from '@/components/Echarts/data';
/**********************************************************/
const chartsConfig = {
    zone_comprehensive_index_distribution:{   //店铺客流综合指标
        otherConf:{
            _color:['#57A7F6'],
            labelShow:true,
            usePercent:true,
            yAxisLineHide:true,
            //rotateVal:40,
            grid:{top: 40,right:20, bottom: 60, left: 70 },

        }
    },
    default:{ //默认
        otherConf:{
            _color:['#57A7F6'],
            labelShow:true,
            yAxisLineHide:true,
            grid:{top: 40,right:20, bottom: 60, left: 70 },
           // hasYaxisName:false,
        }
    }
};
/*******************************************************/
export default {
    mixins: [mixin],
    data() {
        return {
            filterKeys:['zone_comprehensive_index_distribution','zone_customer_ranking','floor_zone_passenger_flow_comparison'],
            ageSexKeys:['zone_customer_ranking','floor_zone_passenger_flow_comparison'],    
            configObj:{},
            zoneTypeVal:"", //店铺类型
            zoneTypeData:[{
                id:1,
                name:this.$t('dictionary.store')
              },{
                id:3,
                name:this.$t('dictionary.mainStore')
            }],
            formatVal:'',
            formatData:[],
            genderVal:'',
            ageVal:'',
            sortVal:'desc',
            activeTab:'hour',
            genderData:[{
                name: this.$t('dictionary.Male'),
                value: 1
            },{
                name: this.$t('dictionary.Female'),
                value: 0
            }/*,{
                name: this.$t('dictionary.unknow'),
                value: 2
            }*/],
            ageData: [
                {
                  name: this.$t('table.under'),
                  value: '0-18'
                },
                {
                  name: '18-24' + this.$t("table.ages"),
                  value: '18-24'
                },
                {
                  name: '25-34' + this.$t("table.ages"),
                  value: '25-34'
                },
                {
                  name: '35-44' + this.$t("table.ages"),
                  value: '35-44'
                },
                {
                  name: '45-54' + this.$t("table.ages"),
                  value: '45-54'
                },
                {
                  name: '55-64' + this.$t("table.ages"),
                  value: '55-64'
                },
                {
                  name: this.$t('table.over'),
                  value: '65-'
                }
            ],
        }
    },
    watch: {
        zoneTypeVal(newValue){
           
           this.loadChartData();
        },
        formatVal(newValue){
           
           this.loadChartData();
        },
        genderVal(){
           this.loadChartData();
        },
        ageVal(){
           this.loadChartData();
        },
        activeTab(){
           this.loadChartData();
        },
        sortVal(newValue){

           this.loadChartData();
        }
        
    },
    created() {
        this.getFormatList().then(res=>{
           let {data} = res.data;
           this.formatData = data;
        });
    },
    methods: {
        getChartsConfig(){
            return chartsConfig;
        },
        handleTimeChange(){
           this.loadChartData();
        },
        handleSortChange(){
           this.loadChartData();
        },
        loadChartData(params){
            this.chartId = this.getChartId(this.ckey);
            /**************************/
            this.params.sortType = this.sortVal;
            this.params.formatIds = this.formatVal;
            this.params.zoneType = this.zoneTypeVal;
            this.params.ageList = this.ageVal;
            this.params.gender = this.genderVal;
            /*******************************/
            if(this.chartId){
               this.ajaxModuleData(this.params).then(data=>{
                  this.setChartData(data);
               });
            }else{
               this.setChartData(); 
            }
        },
        setChartData(data){  
            this.chartData = Object.assign({},data/*mallData.body.retentionInAndOutLine*/,{
                otherConf:this.configObj.otherConf||{}
            });
        }
    }
}
</script>

<style  lang="less">
.small-sel-box{width: 90px;}
</style>