trendAccount.vue 4.68 KB
<!-- 客流总览 -->
<template>
    <div>
        <div class="iwraper">
            <div class="ipage_top" v-show="levels.length">
                <div class="tit"></div>
                <div class="wact">
                    <div class="acts" v-if="levels && levels.length > 1">
                        <el-tabs v-model="timeLevel" @tab-click="handleTimeChange">
                            <el-tab-pane v-if="levels.includes('MONTH')" :label="$t('iPage.monthOver')" name="MONTH">
                            </el-tab-pane>
                            <el-tab-pane v-if="levels.includes('WEEK')" :label="$t('iPage.weekOver')" name="WEEK">
                            </el-tab-pane>
                            <el-tab-pane v-if="levels.includes('DAY')" :label="$t('iPage.dayOver')" name="DAY">
                            </el-tab-pane>
                            <el-tab-pane v-if="levels.includes('HOUR')" :label="$t('iPage.hourOver')" name="HOUR">
                            </el-tab-pane>
                            <el-tab-pane v-if="levels.includes('MINUTE')" :label="$t('iPage.minuteOver')" name="MINUTE">
                            </el-tab-pane>
                        </el-tabs>
                    </div>
                    <span @click="exportBtn" class="asis-table-download">{{ $t('allPages.load') }}</span>
                </div>
            </div>
            <div class="ichart">
                <trent-chart ref="chart" chartId="trendChart1" :cdata="chartData"></trent-chart>
            </div>
        </div>
        <export-data-dialog ref="exportDialog"></export-data-dialog>
    </div>
</template>

<script>
import _ from 'underscore';
import mixin from "./mixin";
import exportData from '../../../public/exportData'
export default {
    components:{
        'export-data-dialog':exportData
    },
    mixins: [mixin],
    data() {
        return {
            curKey: '',
            timeLevel: "HOUR",
            level: [],
            levels: ['HOUR','MINUTE'],
            configObj: {},
        };
    },
    props: {
        mparam: {},
    },
    watch: {
        mparam: {
            handler(newVal) {
                this.newVal = newVal
                this.setCurLevel(newVal);
                newVal && this.loadChartData();
            },
            deep: true,
        },
    },
    created() {

    },
    methods: {
        setCurLevel(parmaObj) {
            let dateType = parmaObj.dateType;
            if (dateType == 'day') {
                this.levels = ['HOUR', 'MINUTE'];
                this.timeLevel = this.levels[0];
            }else if (dateType == 'month') {
                this.levels = ['WEEK', 'DAY', 'HOUR'];
                this.timeLevel = this.levels[1];
            } else if (dateType == 'year') {
                this.levels = ['MONTH', 'WEEK', 'DAY'];
                this.timeLevel = this.levels[0];
            }
        },
        handleTimeChange(v) {
            this.loadChartData();
        },
        loadChartData(params = this.mparam) {
            params = _.omit(Object.assign({}, this.params, params), 'level');
            params.timeLevel = this.timeLevel;
            this.$api.ipageReport.getAccountPassenger({
                orgId:params.accountIds,
                option:params.timeLevel.toLowerCase() ,
                startDate:params.startDate,
                endDate:params.endDate,
                type:'line',
            }).then(res => {
                let { data } = res.data;
                this.setChartData(data);
            })
        },
        setChartData(data) {
            let addConfig = {};
            if (this.timeLevel && this.timeLevel == "MINUTE") {
                addConfig.periodTime = true;
                addConfig.nextTimeNum = 10;
            }
            this.chartData = Object.assign({}, data, {
                otherConf: {
                    ...addConfig,
                    _color: ["#acc6f6", "#4BBEFF", "#87D14B", "#FFC62E", "#FF9631"],
                    perUnit: this.$t('format.perTime'),
                },
            });
        },
        exportBtn(){
            let exportNeed = {
              domId: "trendChart1",
              title: this.chartData.title,
              data: {
                url: `/report/account/passenger/export`,
                params: `orgId=${this.mparam.accountIds}&type=line&startDate=${this.mparam.startDate}&endDate=${this.mparam.endDate}&option=${this.timeLevel.toLowerCase()}`
              }
            };
            this.$refs.exportDialog.dialogInit(exportNeed);
        },
    },
};
</script>

<style scoped  lang="less">
.wact {
    display: flex;
    align-items: center;
}

.asis-table-download {
    float: none;
    margin-left: 20px;
}

.asis-table-download:after {
    top: 2px
}
</style>