<template>
  <div class="tags">
    <el-breadcrumb v-if="isShowTag" class="breadcrumb" separator="">
      <el-breadcrumb-item>
        <div>当前位置 :</div>
      </el-breadcrumb-item>
      <el-breadcrumb-item>
        <span class="g-xs" @click="onToParent(route.meta.parent, route)" :class="{ active: !route.meta.parent }">{{
          route.meta.parent || route.meta.title
        }}</span>
      </el-breadcrumb-item>
      <el-breadcrumb-item v-if="route.meta.parent">
        <Right />
      </el-breadcrumb-item>
      <el-breadcrumb-item v-if="route.meta.parent">
        <span class="g-xs active">{{ route.meta.title }}</span>
      </el-breadcrumb-item>
      <el-breadcrumb-item v-if="route.meta.son">
        <span class="g-xs active">{{ '：' + sidebar.equipmentName }}</span>
      </el-breadcrumb-item>
    </el-breadcrumb>
  </div>
</template>

<script setup lang="ts">
  import Right from '@/components/pro-icon/right.vue'
  import { useSidebarStore } from '@/store/sidebar'
  const route = useRoute()
  const router = useRouter()
  const sidebar = useSidebarStore()
  const isShowTag = ref(true)
  onMounted(() => {
    if (route.path.includes('equipment-center') && !route.path.includes('list')) {
      isShowTag.value = false
    } else {
      isShowTag.value = true
    }
  })
  const onToParent = (e: any, route: any) => {
    if (e == '设备中心') {
      router.push('/equipment-center/list')
      sidebar.setIsEquipment(false)
    }
  }
</script>

<style lang="less" scoped>
  .tags {
    display: flex;
    align-items: center;
    font-weight: bold;
    z-index: 999;
    .el-breadcrumb {
      display: flex;
      align-items: center;
      font-weight: bold;
    }

    position: relative;
    height: 41px;
    background-color: pink;
    font-weight: bold;
    font-size: 14px;
    background: #fff;
    padding: 0 21px;
    line-height: 41px;
  }
  :deep(.breadcrumb) {
    .el-breadcrumb__separator {
      margin: 0 5px;
    }
    .el-breadcrumb-item {
      cursor: pointer;
    }
  }
  .active {
    font-weight: bold;
    font-size: 14px;
    color: #5f7cd6;
  }
</style>
