msreport.vue 4.86 KB
<template>
    <div class="daily">
        <!-- 主力店铺同环比报表 -->
        <div class="asis-table-wrapper mainstore-table-wrapper">
            <h3 class="asis-table-header mainstore-table-header">
                <!-- {{ DayCountingYoY_title }} -->
                <!-- <span class="asis-table-title">{{ i18nFormatter(feaDayCountingYoY_title) }}</span> -->
                <span class="asis-table-download" @click="dealExport('domFeaDayCounting', i18nFormatter(feaDayCountingYoY_title))">{{$t('allPages.load')}}</span>
            </h3>
            <div class="asis-table-content">
                <common-tab v-loading="loading" :tableData="feaDayCountingYoY_ops" id="domFeaDayCounting" :headData="feaDayCountingYoY_head" :tabHeight="''"></common-tab>
            </div>
        </div>
    </div>
</template>

<script>
import commonTable from '../../public/tableCommon'
export default {
    props: {
        propparam: Object
    },
    data() {
        return {
            loading: true,
            feaDayCountingYoY_head: [],
            feaDayCountingYoY_title: '',
            feaDayCountingYoY_ops: [],
            searchTime: '',
            tableKeyToId: {},
            tableIds: '',
            emitData: [],
            customLoading: undefined
        }
    },
    components: {
        'common-tab': commonTable
    },
    watch: {
        propparam: {
            handler: 'refreshHandle',
            immediate: true
        }
    },
    mounted() {
        // this.getTableId();
    },
    methods: {
        refreshHandle(param) {
            if(param.dateType !== '/mainstore/msreport') return;
            this.emitData = param.data;
            this.loading = true;
            if(this.tableIds && JSON.stringify(this.tableKeyToId) !== '{}') {
				this.getTableData(this.tableIds);
			} else {
				this.getTableId();
			}
        },
        getTableId() {
            this.tableKeyToId = {};
            this.tableIds = '';
            this.$api.baseReport.reportChart({
                report: 'mainZoneYOAnalysis',
                // _t: Date.parse(new Date()) / 1000
            })
            .then(res => {
                let tableItem = res.data.data;
                if(!tableItem.length){
                   this.loading = false; 
                }
                tableItem.forEach((item, index) => {
                    this.tableKeyToId[item.key] = item.id;
                    if(item.key === 'dayMainZoneYOAnalysis') {
                        this.tableIds = item.id;
                    }
                });
                this.getTableData(this.tableIds);
            })
        },
        getTableData(tableIds) {
            if (!this.emitData.asis_org) return
            let reportType = this.emitData.asis_date;
            tableIds = this.tableKeyToId[this.emitData.asis_date];
            if(!tableIds) return this.loading = false;
            this.feaDayCountingYoY_ops = [];
            this.DayCountingYoY_ops = [];
            this.DayAddYoY_ops = [];
            let apiUrl = '', param = {}, searchTime = '';
            if(this.emitData.asis_time) {
                if(typeof this.emitData.asis_time === 'string') {
                    searchTime = this.emitData.asis_time;
                } else {
                    searchTime = dateUnit.dateFormat(this.emitData.asis_time, 'yyyy-MM-dd');
                }
            } else {
                searchTime = dateUnit.dateFormat(new Date(), 'yyyy-MM-dd');
            }
            // apiUrl = '/report/mainZoneYOAnalysis/zone';
            param = {
                orgIds: this.emitData.asis_org,
                startDate: searchTime,
                chartIds: tableIds,
                // _t: Date.parse(new Date()) / 1000
            }
            this.$api.analysisReport.mainZoneYOAnalysis(param)
            .then(res => {
                if(!res.data.data.length){
                    this.loading = false;
                }
                setTimeout(() => {
                    this.loading = false;
                }, 500);
                let report = 'DayYoYMoM';
                this.feaDayCountingYoY_title =report + '15DayCountingYoY';
                let feaDayCountingYoY_series = res.data.data.body[reportType].series;
                let faeDayCountingYoY = res.data.data.body[reportType].xaxis.data;
                this.feaDayCountingYoY_head = this.autoComplateHead(reportType, faeDayCountingYoY);
                // 处理数据
                if(feaDayCountingYoY_series.length) {
                    this.feaDayCountingYoY_ops = this.dealData(feaDayCountingYoY_series, this.feaDayCountingYoY_head);
                }
            })
            .catch(err => {
                this.catchErrorHandle(err)
            })
        },
    }
}
</script>

<style scoped>
.mainstore-table-wrapper {
    padding: 5px 26px 12px 26px;
}
.mainstore-table-header {
    margin-bottom: 0px
}
    /* @import url(./public/css/common.css); */
</style>