<template>
  <el-container class="wms-home">
    <el-header class="header">
      <div class="icon-img">
        <el-image :src="icon_img_url" :fit="'fill'" />
      </div>
      <div class="title">
        <span>WMS仓库管理系统</span>
      </div>
      <div class="user">{{ userName }}</div>
    </el-header>
    <el-container class="content">
      <el-aside class="aside">
        <el-scrollbar style="max-height: 95%;">
          <sideMenu></sideMenu>
        </el-scrollbar>
        <div :class="$route.path === '/location' ? 'locationsSel' : 'locations'" @click="openLocations">
          <el-icon>
            <View />
          </el-icon>
          <span>库位监控</span>
        </div>
      </el-aside>
      <el-container>
        <el-header class="tag">
          <appTag></appTag>
        </el-header>
        <el-main>
          <!-- 路由占位符 -->
          <el-scrollbar>
            <router-view v-slot="{ Component }">
              <!-- // TODO keepAlive配置 -->
              <keep-alive>
                <component :is="Component" />
              </keep-alive>
            </router-view>
          </el-scrollbar>
        </el-main>
        <el-footer class="footer">© 1970-2023 江苏菲达宝开电气股份有限公司</el-footer>
      </el-container>
    </el-container>
  </el-container>
</template>

<script setup>
// @ is an alias to /src
import sideMenu from '@/components/sideMenu.vue'
import appTag from '@/components/appTag.vue'
const icon_img_url = require('@/assets/fdbk_log.png')
</script>

<script>
export default {
  name: 'HomeView',
  components: {
    sideMenu,
    appTag
  },
  computed: {
    userName() {
      return this.$store.state.user.userName
    }
  },
  methods: {
    openLocations() {
      this.$store.commit('mutationSelectTags', {
        id: '25',
        labelName: '库位监控',
        path: '/location'
      })
      this.$router.push('/location')
    }
  }
}
</script>

<style scoped>
.wms-home {
  height: 100%;
  background-color: #CCCCCC;
}

.content {
  height: 95%;
  background-color: #FFFFFF;
}

.header {
  /* background-color: #66CCFF; */
  background-color: #D9E3EE;
  display: flex;
  align-items: center;
  height: 5%;
  /* font-size: 15px; */
}

.aside {
  background-color: #fff;
  height: 100%;
  width: 10%;
  border-right: 1px solid #66CCFF;
}

.footer {
  background-color: #F0FFFF;
  display: flex;
  justify-content: center;
  flex-direction: column;
  height: 3%;
}

.tag {
  padding-left: 1px;
  display: flex;
  align-items: center;
  height: 30px;
  border-bottom: solid 1px;
}

.icon-img {
  height: 100%;
  width: 3%;
}

.icon-img .el-image {
  height: 100%;
  width: 100%;
}

.title {
  margin-left: 2px;
}

.user {
  margin-left: auto;
}

.locations {
  padding: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 3.8%;
  border-top: solid 1px;
  cursor: pointer;
  color: #5A9CF8;
}

.locationsSel {
  padding: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 3.8%;
  border-top: solid 1px;
  cursor: pointer;
  background-color: #5A9CF8;
  color: #000;
}

.locations:hover {
  background-color: #5A9CF8;
  color: #000;
}
</style>
