<template>
  <div class="layouts flex flexc aic">
    <Header></Header>
    <!-- <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item
          ><a :href="portalUrl + '/#/home/dataManagement/dataAdmin'"
            >政务一体化平台</a
          ></el-breadcrumb-item
        >
        <el-breadcrumb-item
          ><a :href="portalUrl + '/#/home/siteArrange'"
            >站点编排</a
          ></el-breadcrumb-item
        >
        <el-breadcrumb-item
          v-for="bread in breads"
          :key="bread.title"
          :to="bread.to"
          >{{ bread.title }}</el-breadcrumb-item
        >
      </el-breadcrumb>
    </div> -->
    <div class="out-box flex1">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
import Header from "./components/Header.vue";
import { getdeptList } from "@/api/department";
import { mapMutations } from "vuex";
import local from "@/utils/local";
export default {
  components: {
    Header,
  },
  data() {
    return {
      portalUrl: process.env.VUE_APP_API_portal_URL,
      breads: [],
    };
  },
  created() {
    this.calcBreads();
    this.getdeptList();
  },
  watch: {
    "$route.path"() {
      this.calcBreads();
    },
  },
  computed: {},
  methods: {
    ...mapMutations(["SET_deptList"]),
    // 计算面包屑
    calcBreads() {
      let temp = [{ to: "/basicsset", title: "数字样表系统" }];
      //  过滤出路由数据
      let r = this.$route.matched
        .filter((v) => v.meta.title)
        .map((v) => {
          return { to: v.path, title: v.meta.title };
        });
      // 赋值给面包屑渲染
      this.breads = [...temp, ...r];
    },

    // 获取部门列表
    async getdeptList() {
      let res = await getdeptList({
        siteId: local.getLocal("sampleSiteId")
          ? local.getLocal("sampleSiteId")
          : "",
        page: 1,
        size: -1,
      });
      let { code, data } = res.data;
      if (code === 1) {
        this.SET_deptList(data.data);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.layouts {
  width: 100%;
  min-width: 1500px;
  height: 100%;
  padding-bottom: 10px;
  // .crumbs {
  //   margin: 10px 0px;
  //   width: 98%;
  // }
  .out-box {
    width: 98%;
    margin-top: 10px;
    border-radius: 4px;
    background-color: #fff;
    overflow-y: auto;
  }
}
</style>