<template>

  <div class="system">
  
    <!-- 导航 -->
    <div class="navs">
  
      <div
        v-for="(item, x) in navs"
        :class="['x-nav', { 'act': act === item.key }]"
        :key="item.key"
        @click="navChange(item)"
      >
        {{ item.text }}({{ summary[['faciility', 'equipment'][x]] }})
      </div>
  
      <div :style="slideStyle" class="slide"></div>
  
    </div>

    <div v-show="act === 'type_1'">
      <FacilityList @facility-async="facilityAsync" />
    </div>

    <div v-show="act === 'type_2'">
      <EquipmentList @equipment-aysnc="equipmentAsync" :facilities/>
    </div>
  
  </div>
  
  </template>
  
  <script lang='ts' setup>

  import FacilityList from './components/FacilityList/index.vue'
  import EquipmentList from './components/EquipmentList/index.vue'
  
  import { ref, computed } from 'vue'
  
  const navs = ref([
    { text: '设施模型', key: 'type_1' },
    { text: '设备模型', key: 'type_2' }
  ])

  const facilities = ref<any>([])
  const summary = reactive({
    faciility: 0,
    equipment: 0
  })
  
  const act = ref('type_1')

  // 设施模型公共化
  const facilityAsync = (res) => {
    facilities.value = res.list
    summary.faciility = res.total
  }

  // 信息汇总
  const equipmentAsync = (total) => {
    summary.equipment = total
  }

  // 导航动画
  const slideStyle = computed(() => {
    const x = navs.value.findIndex(item => item.key === act.value)
    return {
      transform: `translateX(${x * (130 + 12)}px)`
    }
  })
  
  // 方向切换
  const navChange = (e) => {
    act.value = e.key
  }
  
  
  </script>
  
  <style lang='scss' scoped>
  
  $car-url: '@/assets/images/cars/';
  
  .navs {
    margin: 16px 40px 0;
    border-bottom: 1px solid #203A60;
    height: 48px;
    position: relative;
    .x-nav {
      font-size: 18px;
      font-weight: 600;
      width: 130px;
      height: 48px;
      display: inline-block;
      border: 1px solid #203A60;
      box-sizing: border-box;
      color: #ffffff;
      margin-right: 12px;
      border-radius: 12px 12px 0 0;
      text-align: center;
      line-height: 48px;
      cursor: pointer;
      position: relative;
      z-index: 2;
    }
  
    .slide {
      position: absolute;
      width: 130px;
      height: 48px;
      background: #0073E6;
      left: 0;
      top: 0;
      border-radius: 12px 12px 0 0;
      transition-property: all;
      transition-duration: 0.3s;
      transition-timing-function: ease-out;
    }
  
  }
  
  </style>
  
  <style lang="scss">
  .cancelButtonClass {
  background: #ffffff;
  color: #606266;
  border: 1px solid #909399;
  // border-color: #606266;
}
  .system {

    .el-input__inner,
    .el-select__input {
      color: #FFFFFF;
    }
    .el-input__wrapper {
      border-radius: 0;
      background: transparent;
      box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
    }
    .el-select {
      display: block;
      .el-select__selected-item {
        color: #FFFFFF;
      }
    }
    .el-form-item__label {
      color: #FFFFFF;
      width: 120px;
    }
    .el-form-item__content {
      width: 400px;
    }

    .el-radio {
      color: white;
      height: 26px;
      .el-radio__inner {
        background: transparent;
        border-color: rgba($color: #ffffff, $alpha: 0.3);
        &::after {
          background-color: #007DFA;
        }
      }
    }

  }
  
  .el-table {
    &.car-table {
      --el-table-bg-color: transparent;
      --el-table-tr-bg-color: transparent;
      --el-table-header-bg-color: transparent;
      --el-table-border: 0px solid transparent;
      --el-table-border-color: transparent;
      --el-table-text-color: rgba(240, 245, 255, 0.95);
      --el-table-header-text-color: rgba(240, 245, 255, 0.95);
      // --el-table-row-hover-bg-color: rgba(69, 116, 182, 0.1);
      // --el-fill-color-lighter: rgba(69, 116, 182, 0.2);
      .car-row {
        height: 44px;
      }
      .stripe-row {
        background: rgba(69, 116, 182, 0.2);
      }
      .el-table__row:hover {
        .el-table__cell {
          background: rgba(69, 116, 182, 0);
        }
        
      }
    }
  }
  
  .el-pagination {
    &.car-pages {
      --el-pagination-bg-color: rgba(32, 58, 96, 0.6);
      --el-pagination-button-color: white;
      --el-pagination-button-disabled-bg-color: rgba(32, 58, 96, 0.4);
      --el-pagination-button-disabled-color: rgba(255, 255, 255, 0.5);
      .number {
        margin: 0 4px;
        &.is-active {
          background: #007DFA;
          color: white;
        }
      }
    }
  }
  
  </style>