<template>
  <div id="app" v-cloak>
    <div class="role-list fl">
      <el-menu
        :default-active="defaultActive"
        class="el-menu-vertical-demo"
        :default-openeds="['/caixiao365', '/caixiaopingtai', '/516pingtai']"
        router
        @open="handleOpen"
        @close="handleClose"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
      >
        <template v-for="(si, sii) in menuTableData">
          <el-submenu
            :key="sii + si.id"
            v-if="si.children && si.children.length > 0"
            :index="'/' + si.path"
          >
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>{{ si.label }}</span>
            </template>
            <el-menu-item
              v-for="(skey, skeyi) in si.children"
              :key="sii + si.id + '-' + skeyi"
              :index="'/' + skey.path"
            >
              {{ skey.label }}
            </el-menu-item>
          </el-submenu>
          <el-menu-item v-else :key="sii + si.id" :index="'/' + si.path">
            <i class="el-icon-menu"></i>
            <span slot="title">{{ si.label }}</span>
          </el-menu-item>
        </template>
      </el-menu>
    </div>
    <div class="rule-view fr">
      <router-view />
    </div>
  </div>
</template>
<script>
export default {
  name: "commission",
  watch: {
    $route() {
      const { path } = this.$route;
      this.defaultActive = path;
    },
  },
  data() {
    return {
      defaultActive: null,
      menuTableData: [
        {
          id: "3",
          label: "采销365平台",
          level: "1",
          path: "caixiao365",
 
        },
        {
          id: "2",
          label: "采销平台",
          level: "1",
          path: "caixiaopingtai",
          children: [
            {
              id: "21",
              level: "2",
              path: "caixiaopingtai-21",
              label: "业绩达成报表(销售)",
            },
            {
              id: "22",
              level: "2",
              path: "caixiaopingtai-22",
              label: "其他报表",
            },
         
          ],
        },
        {
          id: "1",
          label: "516平台",
          level: "1",
          path: "516pingtai",
          children: [
            {
              id: "11",
              level: "2",
              path: "516pingtai-11",
              label: "业绩达成报表(销售)",
            },
            {
              id: "12",
              level: "2",
              path: "516pingtai-12",
              label: "其他报表",
            },
           
          ],
        },
      ],
    };
  },
  mounted() {},
  methods: {
    handleNodeClick(data) {
      const { level, id } = data;
      if (Number(level) === 2) {
        this.keyId = id;
      }
      console.log();
    },
  },
};
</script>
<style lang="scss">
.fl {
  float: left !important;
}
.fr {
  float: right !important;
}
* {
  box-sizing: border-box;
}
@mixin layout-dev {
  position: fixed;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
html {
  @include layout-dev;

  body {
    @include layout-dev;
    text-align: left;
  }
  .clear::after,
  .clear::before {
    content: "";
    display: block;
    clear: both;
  }

  #app {
    @include layout-dev;
    padding: 0;
    min-width: 1200px !important;
    position: relative;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;

    .role-list {
      height: 100%;
      overflow-y: auto;
      width: 220px;
      padding: 8px 0;
      min-height: 100%;
      flex-shrink: 0;
      margin: 0;
      background: #545c64;
      // border-right: 2px solid #dfe6ec;
      // @include scrollBar();
      &::after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        height: 100%;
        // width: 2px;
        // background-color: #e4e7ed;
        z-index: 1;
      }
      .role-list__title {
        color: #b4b6c0;
        line-height: 32px;
      }
      .role-list__item {
        position: relative;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        height: 32px;
        line-height: 32px;
        padding-left: 8px;
        color: rgb(48, 49, 51);
        cursor: pointer;
        i {
          position: absolute;
          right: 0;
          line-height: 32px;
        }
      }
      .role-list__item.active {
        color: #6954f0;
        background: #f7f7f7;
      }
    }
    //右侧
    .rule-view {
      height: 100%;
      margin: 0;
      //calc(100% - 50px);
      width: calc(100% - 220px);
      overflow-y: auto;
      padding: 16px;
      // @include scrollBar();
      .rule-list {
        border-right: 1px solid #dfe6ec;
        .title {
          padding: 18px 18px 12px 18px;
          border-bottom: 1px dashed #dfe6ec;
          font-size: 15px;
          color: #000;
        }
        .main {
          padding: 18px 18px 12px 18px;
          border-bottom: 1px solid #dfe6ec;
        }
        .main-title {
          width: 80px;
        }
        .main-item {
          width: calc(100% - 80px);
        }
      }
    }
    .el-table__fixed-right {
      height: 100% !important;
    }
    .el-table__fixed-left {
      height: 100% !important;
    }
    .commission {
      padding: 16px 16px !important;
      box-sizing: border-box !important;
      height: 100%;
    }

    .ml10 {
      margin-left: 10px !important;
    }
  }
}
</style>
