<template>
  <div class="flex h-full w-full flex-col">
    <Header></Header>
    <div
      :class="[
        'out-box',
        'flex-1',
        'overflow-auto',
        {
          'not-home': $route.path != '/home',
        },
      ]"
    >
      <keep-alive>
        <!-- 需要缓存的视图组件 -->
        <router-view v-if="$route.meta.keepAlive"> </router-view>
      </keep-alive>
      <!-- 不需要缓存的视图组件 -->
      <router-view v-if="!$route.meta.keepAlive"> </router-view>
    </div>
  </div>
</template>

<script>
import { mapMutations, mapActions } from "vuex";
import Header from "./components/Header.vue";
import { getSiteTree } from "@/api/site";
import storage from "@/utils/storage";
export default {
  components: {
    Header,
  },
  data() {
    return {
      siteId: storage.get(2, "siteId"),
    };
  },
  created() {
    this.getSiteTree();
    this.getBusiness(this.siteId);
    this.getDeptList(this.siteId);
    this.getWindowList(this.siteId);
  },
  methods: {
    ...mapMutations("user", ["SET_areaTree"]),
    ...mapActions("user", ["getBusiness", "getDeptList", "getWindowList"]),
    // 获取个人站点树
    async getSiteTree() {
      let res = await getSiteTree({
        page: 1,
        size: -1,
      });
      if (res.data.code == 1) {
        let { siteTree } = res.data.data;
        this.SET_areaTree(siteTree);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.not-home {
  padding: 24px 50px;
}
</style>
