areagroup.vue 10.3 KB
<template>
    <div class="customgroup-wrapper">
        <el-header height="70px">
            <span class="behavior-title">{{ repTitle }}{{$t('Behavior.AreaGroup')}}</span>
            <span class="more-option-wrapper" @click="showCollapse">
                <span class="more-option-text">{{$t('Behavior.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>
        <!-- <behavior-option v-show="moreOptVisible"></behavior-option> @emitTitle="getTitle" -->
        <test-option v-show="moreOptVisible" @emitParams="getPatams" @startLoading="startLoad" ref="searchRef"></test-option>
        <!-- <el-main>Main</el-main> -->
        <div class="element-main behavior-main">
            <!-- main -->
            <!-- <router-view></router-view> -->
           <!-- 区域人脸客流统计详情 -->
            <div class="asis-table-wrapper">
                <h3 class="asis-table-header">
                    <!-- {{ DayCountingYoY_title }} -->
                    <span class="asis-table-title">{{ i18nFormatter(zfDetailTitle) }}</span>
                    <span class="asis-table-download" @click="dealExport('domFeaDayCounting', i18nFormatter(zfDetailTitle))">{{$t('allPages.load')}}</span>
                </h3>
                <div class="asis-table-content">
                    <common-tab v-loading="loading" :tableData="zfDetailOps" id="domFeaDayCounting" :headData="zfDetailHead" :tabHeight="''"></common-tab>
                </div>
            </div>
            <el-row class="chartRow" :gutter="12">
                <el-col :span="12" class="download-parent">
                    <!-- 顾客性别对比 -->
                    <common-chart id="areaChart" class="age-wrapper" :options="zfGenderOps" chartType="horFgBar"></common-chart>
                    <span class="ehcarts-title">{{ i18nFormatter(zfGenderTitle) }}</span>
                    <span class="download-text" @click="exportDataHandle('areaChart',i18nFormatter(zfGenderTitle),'faceZoneGenderRatio')">{{$t('allPages.load')}}</span>
                </el-col>
                <el-col :span="12" class="download-parent">
                    <!-- 顾客性别对比 -->
                    <common-chart id="areaAgeChart" class="age-wrapper" :options="zfAgeOps" chartType="areaAge"></common-chart>
                    <span class="ehcarts-title">{{ i18nFormatter(zfAgeTitle) }}</span>
                    <span class="download-text" @click="exportDataHandle('areaAgeChart',i18nFormatter(zfAgeTitle),'faceZoneAgeRatio')">{{$t('allPages.load')}}</span>
                </el-col>
            </el-row>
        </div>
        <export-data-dialog ref="exportDialog"></export-data-dialog>
    </div>
</template>

<script>
import testOption from './common/option/areagroupOps'
import defaultImg from '@/assets/img/behavior/default.png'
import commonTable from '../public/tableCommon'
import commonChart from './common/chart'
export default {
    data () {
        return {
            moreOptVisible: false,
            tableData: [],
            defaultImg: defaultImg,
            // picApiUrl: window._vionConfig.apiUrl + '/faceRecognitions/face/',
            currentPage: 1,
            pageArr: [10, 50, 100],
            pageSize: 10,
            totalPage: null,
            // popoverVisible: false,
            // hoverPic: '',
            // popPosition: {},
            repTitle: '',
            loading: true,
            tableHeight: 0,
            zfDetailHead: [],
            zfDetailOps: [],
            zfDetailTitle: '',
            zfAgeOps: [],
            zfAgeTitle: '',
            zfGenderOps: [],
            zfGenderTitle: '',
            tableKeyToId: {},
            tableIds: '',
            emitData:{},
        }
    },
    components: {
        'test-option': testOption,
        'common-tab': commonTable,
        'common-chart':commonChart,
    },
    created() {
        window.addEventListener('resize', () => {
            try {
                let timeHeatEChartsUtil = {
                    chart1: $('#areaChart')[0],
                    chart2: $('#areaAgeChart')[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) { }
        })
    },
    methods: {
        showCollapse() {
            // 获取上面元素的高度
            let headerH = '', titleH = '', collapseH = '', mt = '';
                headerH = this.getStyleFn('.el-header', 'height');
                titleH = this.getStyleFn('.customgroup-wrapper .el-header', 'height');
            if(this.moreOptVisible) {
                this.moreOptVisible = false;
                mt = titleH + 'px';
                $('.behavior-main').animate({ marginTop: mt });
            } else {
                this.moreOptVisible = true;
                setTimeout(() => {
                    collapseH = this.getStyleFn('.behavior-more-option', 'height');
                    mt = titleH + collapseH + 'px';
                    $('.behavior-main').animate({ marginTop: mt });
                }, 100);
            }
        },
        getTableId() {
            this.tableKeyToId = {};
            this.tableIds = '';
            this.$api.baseReport.reportChart({
                report: 'trafficAnalyze',
                // _t: Date.parse(new Date()) / 1000
            })
                .then(res => {
                    let tableItem = res.data.data;
                    tableItem.forEach((item, index) => {
                        this.tableKeyToId[item.key] = item.id;
                        if (index == tableItem.length - 1) {
                            this.tableIds += item.id;
                        } else {
                            this.tableIds += item.id + ',';
                        }
                    });
                    this.getTableData(this.tableIds);
                })
        },
        getTableData(tableIds) {
            if(!tableIds) return;
            let apiUrl = '', param = {};
            apiUrl = '/report/trafficAnalyze/zone';
            param = {
                orgIds: this.emitData.orgIds,
                startDate: this.emitData.startDate,
                endDate:this.emitData.endDate,
                chartIds: this.tableIds,
                // _t: Date.parse(new Date()) / 1000
            }
            this.$api.flowReport.trafficAnalyze(param)
                .then(res => {
                    setTimeout(() => {
                        this.loading = false;
                        // this.overflowBar(true);
                    }, 500);
                    let result = res.data;
                    // 区域人脸客流统计详情
                    let zoneDetail_head = result.data.body.faceZoneTrafficDetail.xaxis.data;
                        // zoneDetail_head.unshift('order')
                    this.zfDetailHead = this.autoComplateHead(null, zoneDetail_head);
                    this.zfDetailTitle = 'faceZoneTrafficDetail';
                    let zoneDetail_series = result.data.body.faceZoneTrafficDetail.series;
                    this.zfDetailOps = this.dealData(zoneDetail_series, this.zfDetailHead);
                    let zoneGender = result.data.body.faceZoneGenderRatio;
                        zoneGender['color'] = ['#3BB8FF', '#FFC62E', '#6e6fc1'];
                    this.zfGenderOps = zoneGender;
                    this.zfGenderTitle = 'faceZoneGenderRatio';
                    let zoneAge = result.data.body.faceZoneAgeRatio;
                        zoneAge['color'] = ['#6e6fc1', '#33bafe', '#fec62b', '#ff9c01', '#38d4be', '#79ce4c'];
                    this.zfAgeOps = zoneAge;
                    this.zfAgeTitle = 'faceZoneAgeRatio';
                })
                .catch(err => {
                    this.catchErrorHandle(err)
                    // console.log('areagroup err:', err.message, err)
                });
                // this.overflowBar(true);
        },
        startLoad(isCurrentPage) {
            if(isCurrentPage === 'areagroup') {
                this.zfDetailHead = [];
                this.zfDetailTitle = 'faceZoneTrafficDetail';
                this.zfDetailOps = [];
                this.zfGenderOps = {};
                this.zfGenderTitle = 'faceZoneGenderRatio';
                this.zfAgeOps = {};
                this.zfAgeTitle = 'faceZoneAgeRatio';
            }
        },
        getPatams(param) {
            this.emitData = param;
            this.repTitle = param.title;
            if(this.tableIds) {
                this.getTableData(this.tableIds);
            } else {
                this.getTableId();
            }
        },
        getTitle(tit) {
            this.repTitle = tit;
        },
        exportDataHandle(domId, title, chartKey) {
            // 
            let chartId = this.chartKeyToId[chartKey];
            let exportNeed = {
                domId: domId,
                title: title,
                data: {
                    url: window._vionConfig.apiUrl + '/report/trafficAnalyze/zone' + '/' + chartId + '/excel',
                    params: 'orgIds=' + this.emitData.orgIds + '&startDate=' + this.emitData.startDate + '&endDate=' + this.emitData.endDate 
                }
            }
            // console.log('areagroup exportNeed', exportNeed)
            this.$refs.exportDialog.dialogInit(exportNeed);
        },
    }
}
</script>

<style scoped>
    .customgroup-wrapper {
        width: 100%;
    }

    .gender-wrapper,
    .age-wrapper {
        height: 700px;
        background: #fff;
    } 

    @media only screen and (max-width: 1680px) {
        .gender-wrapper, .age-wrapper {
            height: 560px;
        }
    }
    @media only screen and (max-width: 1440px) {
        .gender-wrapper, .age-wrapper {
            height: 560px;
        }
    }
    @media only screen and (max-width: 1366px) {
        .gender-wrapper, .age-wrapper {
            height: 560px;
        }
    }
    @media only screen and (max-width: 1280px) {
        .gender-wrapper, .age-wrapper {
            height: 560px;
        }
    }
</style>