<template>
  <div class="wrapper"> 
    <!-- 权限系统 -->
    <headerAuth v-if="headerShowAuth()"/>
    <!-- 数据中心 -->
    <headerDatax v-if="headerShowDatax()" />
    <!-- 决策引擎系统 -->
    <headerEnginex v-if="headerShowEnginex()"/>
        <v-sidebar></v-sidebar>
        <div class="content-box" :class="{'content-collapse':collapse}">
            <v-tags></v-tags>
            <div class="content" >
                <transition name="move" mode="out-in">
                    <keep-alive :include="tagsList">
                        <router-view></router-view>
                    </keep-alive>
                </transition>
                <el-backtop target=".content"></el-backtop>
            </div>
        </div>
    </div>
</template>

<script>
import headerEnginex from './HeaderEnginex.vue';
import headerAuth from './HeaderAuth.vue'
import headerDatax from './HeaderDatax.vue'
import vSidebar from './Sidebar.vue';
import vTags from './Tags.vue';
import bus from './bus';
export default {
    data() {
        return {
            tagsList: [],
            collapse: false
        };
    },
    components: {
        headerAuth,  // 权限系统化header
        headerDatax, // 数据中心header
        headerEnginex, // 决策引擎系统
        vSidebar,
        vTags
    },
    created() {
        bus.$on('collapse-content', msg => {
            this.collapse = msg;
        });

        // 只有在标签页列表里的页面才使用keep-alive，即关闭标签之后就不保存到内存中了。
        bus.$on('tags', msg => {
            let arr = [];
            for (let i = 0, len = msg.length; i < len; i++) {
                msg[i].name && arr.push(msg[i].name);
            }
            this.tagsList = arr;
        });
    },
    methods: {
      // 权限系统
      headerShowAuth() {
        if (localStorage.getItem('platform') === 'Auth') {
          return true
        } else {
          return false
        }
      },
      // 数据中心
      headerShowDatax() {
        if (localStorage.getItem('platform') === 'DataX') {
          return true
        } else {
          return false
        }
      },
      // 决策引擎系统
      headerShowEnginex() {
        if (localStorage.getItem('platform') === 'Enginex') {
          return true
        } else {
          return false
        }
      }
    }
};
</script>
