<template>
    <div>
        <van-nav-bar
            style="position: fixed; top: 0; width: 100%"
            :title="title"
            left-arrow
            @click-left="onClickLeft"
        />
        <keep-alive>
            <router-view v-if="$route.meta.keepAlive" style="margin-top: 45px"></router-view>
        </keep-alive>
        <router-view v-if="!$route.meta.keepAlive" style="margin-top: 45px"></router-view>
    </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
    name: 'Report',
    data() {
        return {}
    },
    computed: {
        ...mapGetters(['title'])
    },
    watch: {},
    mounted() {
        this.$store.dispatch('layout/init', {})
    },
    methods: {
        onClickLeft: function () {
            this.$store.dispatch('layout/pre', {}).then(res => {
                if (res < 0) {
                    this.$router.push('/')
                } else {
                    this.$router.push('/report')
                }
            })
        }
    }
}
</script>
