<template>
  <el-container class="mta-Inframe" direction="vertical">
    <!-- header -->
    <mta-header></mta-header>
    <!-- main -->
    <el-container>
      <el-aside width="auto">
        <el-scrollbar class="Inframe-head-sidebar-scroll" wrap-class="scrollbar-wrapper">
          <el-menu
                  :default-active="$route.path"
                  class="el-menu-vertical-demo"
                  background-color="#fff"
                  text-color="#000"
                  :active-text-color="getThemeColor(0)"
                  :unique-opened="true"
                  :collapse="isCollapse"
                  ref="menuRef"
                  :collapse-transition="true"
                  :router="isRouter">

            <div class="mta-menu-btn-left" v-if="isCollapse" @click="changeStatus(1)"><i
                    class="el-icon-d-arrow-right"></i></div>
            <div class="mta-menu-btn-right" v-if="!isCollapse" @click="changeStatus(0)"><i
                    class="el-icon-d-arrow-left"></i></div>
            <mta-sidebar-item v-for="(child,index) in menuList" :sidebar="child"
                              :key="child.path" :stIndex="index"></mta-sidebar-item>

          </el-menu>

        </el-scrollbar>
      </el-aside>
      <el-main>
        <mta-transform>
          <router-view/>
        </mta-transform>
      </el-main>
    </el-container>
    <!--footer-->
    <mta-footer></mta-footer>
  </el-container>
</template>
<script>
  import {mapGetters} from 'vuex'
  import MtaHeader from '@/components/management/Layout/Header.vue'
  import MtaFooter from '@/components/management/Layout/Footer.vue'
  import MtaSidebarItem from '@/components/management/Layout/Sidebar/SidebarItem.vue'
  import MtaTransform from '@/components/management/Transform'
  import { initThemeColor } from '@/utils/theme';
  import * as Initialization from '@/utils/initializationConfig';


  export default {
    name: 'about',
    components: {
      MtaHeader,
      MtaFooter,
      MtaSidebarItem,
      MtaTransform,

    },
    data() {
      return {
        isCollapse: false,
        isRouter: true,
        activeIndex:    '',
        defaultOpeneds: [],
        headerArr:      [
          [
            {
              content:  '首页',
              keyPath:  '/a/main',
              children: [
                /*{
                    content: '试题添加编辑',
                    keyPath: '/a/kaoshi/shitiAdd2',
                },*/
              ],
            },
          ],
          [
            {
              content:  '角色管理',
              keyPath:  '/a/inframe/roleManagement',
              children: [
                /*{
                    content: '试题添加编辑',
                    keyPath: '/a/kaoshi/shitiAdd2',
                },*/
              ],
            },
            {
              content:  '租户配置',
              keyPath:  '/a/inframe/tenantManagement',
              children: [
                /*{
                    content: '试题添加编辑',
                    keyPath: '/a/kaoshi/shitiAdd2',
                },*/
              ],
            },
            {
              content:  '菜单角色绑定',
              keyPath:  '/a/inframe/menuRoleManagement',
              children: [
                /*{
                    content: '试题添加编辑',
                    keyPath: '/a/kaoshi/shitiAdd2',
                },*/
              ],
            },
            {
              content:  '菜单管理',
              keyPath:  '/a/inframe/menuManagement',
              children: [
                /*{
                    content: '试题添加编辑',
                    keyPath: '/a/kaoshi/shitiAdd2',
                },*/
              ],
            },
            {
              content:  '用户管理',
              keyPath:  '/a/inframe/userManagement',
              children: [
                /*{
                    content: '试题添加编辑',
                    keyPath: '/a/kaoshi/shitiAdd2',
                },*/
              ],
            },
            {
              content:  '帮助中心',
              keyPath:  '/a/inframe/inner',
              children: [
                /*{
                    content: '试题添加编辑',
                    keyPath: '/a/kaoshi/shitiAdd2',
                },*/
              ],
            },
          ],
        ],
      }
    },
    computed: {
      menuList() {
        return this.dealMenuList(this.getAuth.menuList, 0);
      },
      ...mapGetters(['getAuth', 'getThemeColor']),
    },
    methods: {
      changeStatus(status) {
        if (status === 0) {
          this.isCollapse = true;
        } else {
          this.isCollapse = false;
        }
      },
      dealMenuList(data, pId) {
        const ret = [];
        for (const o of data) {
          if (o.parentId === pId) {
            o.children = this.dealMenuList(data, o.menuId);
            o.children.sort((a, b) => {
              /*if (a.number === b.number) {
                  return a.menuId - b.menuId;
              }  */
              return a.number - b.number;
            });
            ret.push(o);
          }
        }
        return ret;
      },
    },
    watch:      {
    },
    created() {
      initThemeColor();
      // 初始化 页面标签meta ico图标
      Initialization.initializationPageConfig();
    },
  }
</script>
<style lang="scss" scoped>
  .mta-Inframe {
    flex: 1;

    .el-container {
      height: calc(100vh - 120px)
    }


    .el-main {
      display: flex;
      flex-direction: column;
      background-color: #f0f0f0;
    }


    .el-aside {
      background: #FFF;
      display: flex;
    }

    .mta-footer {
      height: 50px;
      background: -webkit-gradient(linear, left top, left bottom, from(rgba(11, 0, 56, .95)), to(#333));
      background: linear-gradient(rgba(11, 0, 56, .95), #333);
      line-height: 50px;
      text-align: center;
      color: #ccc;
      font-size: 13px;
    }

    .mta-menu-btn-left {
      width: 64px;
      text-align: center;
      font-size: 22px;
      padding-right: 21px;
    }

    .mta-menu-btn-right {
      width: 220px;
      text-align: right;
      font-size: 22px;
      padding-right: 18px;
    }

    .Inframe-head-sidebar-scroll {
       height: calc(100vh - 126px);
    }

  }

</style>
<style lang="scss">
  .mta-Inframe {

    .el-aside {

      .el-menu-vertical-demo:not(.el-menu--collapse) {
        width: 240px;
        min-height: 400px;
      }

      .el-scrollbar__wrap.el-scrollbar__wrap {
        overflow-x: hidden; // 待定
        width: auto;
      }

      .sidebar-container {
        flex: 1;
        min-width: 64px;
      }
    }

    .scrollbar-wrapper {
      .el-scrollbar__view {
        height: 100%;

        .el-menu-vertical-demo {
          height: 100%;
        }
      }

      i {
        color: inherit !important; // 控制icon样式
      }
    }

    .mta-footer {
      p {
        margin: 0;
      }
    }

    .el-menu-vertical-demo {
      i {
        display: inline-block;
        width: 30px;
        height: 22px;
        text-align: center;
        vertical-align: middle;
        font-size: 22px;
      }

      span {
        /*font-size: 18px;*/
        font-size: 15px;
        font-weight: bold;
      }
    }
  }

  .mta-menu-span {
    padding-left: 16px;
  }

  .el-menu--vertical {
    .fa:before {
      display: inline-block;
      vertical-align: middle;
    }
  }

  .fa:before {
    width: 22px;
    height: 22px;
    content: "";
    display: block;
  }

  .fa-bank:before {
    background-image: url("../../assets/images/icons/fa-bank.svg");
  }

  .fa-bars:before {
    background-image: url("../../assets/images/icons/fa-bar.svg");
  }


  .fa-handshake-o:before {
    background-image: url("../../assets/images/icons/fa-bars.svg");
  }


  .fa-user:before {
    background-image: url("../../assets/images/icons/fa-user.svg");
  }

  .fa-users:before {
    background-image: url("../../assets/images/icons/fa-users.svg");
  }


  .fa-user-circle:before {
    background-image: url("../../assets/images/icons/fa-user-circle.svg");
  }


  .fa-user-o:before {
    background-image: url("../../assets/images/icons/fa-user-o.svg");
  }

  .el-menu-item.is-active .fa-user-o:before {
    background-image: url("../../assets/images/icons/fa-user-o-a.svg");
  }

  .fa-lightbulb-o:before {
    background-image: url("../../assets/images/icons/fa-lightbulb-o.svg");
  }

  .el-menu-item.is-active .fa-lightbulb-o:before {
    background-image: url("../../assets/images/icons/fa-lightbulb-o-a.svg");
  }

  .fa-sitemap:before {
    background-image: url("../../assets/images/icons/Organizational.svg");
  }

  .el-menu-item.is-active .fa-sitemap:before {
    background-image: url("../../assets/images/icons/Organizational_a.svg");
  }
  .fa-tongji:before {
    background-image: url("../../assets/images/icons/fa-tongji.svg");
  }
  .el-menu-item.is-active .fa-tongji:before {
    background-image: url("../../assets/images/icons/fa-tongji-a.svg");
  }
  .fa-tongji-pingtai:before {
    background-image: url("../../assets/images/icons/fa-tongji-pingtai.svg");
  }
  .fa-tongji-zuhu:before {
    background-image: url("../../assets/images/icons/fa-tongji-zuhu.svg");
  }
  .fa-support:before {
    background-image: url("../../assets/images/icons/fw-manager.svg");
  }
</style>
