<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <CostumeHeader>
    <template #select>
      <!-- 填写空的div以覆盖默认的选择框 -->
      <div></div>
    </template>
    <div class="w-200px flex flex-items-center">
      <RightCircleOutlined class="w-30px" />
      <div class="flex-grow-1">
        网络断开
        <span> {{ warns.length }}条 </span>
      </div>
    </div>
  </CostumeHeader>
  <div class="timeline">
    <div v-for="(item, i) in warns" :key="`svvhccdw-${i}`" class="flex items-center timeline-item">
      <div class="timeline-item__icon" :class="`timeline-item__icon_${item.color}`"></div>
      <div class="timeline-item__dot"></div>
      <div class="timeline-item__label">{{ item.label }}</div>
      <div :class="`timeline-item__value_${item.color}`">{{ item.count }}</div>
    </div>
    <div class="position-absolute timeline-component"></div>
  </div>
</template>
<script lang="ts" setup>
  import { onMounted, ref } from 'vue';
  // import { list as cfgList } from '@/views/vent/deviceManager/configurationTable/configuration.api';
  // import { list } from '@/views/vent/deviceManager/deviceTable/device.api';
  import CostumeHeader from './CostumeHeader.vue';
  import { RightCircleOutlined } from '@ant-design/icons-vue';
  // import MiniBoard from './MiniBoard.vue';
  // import mapComponent from './components/3Dmap/index.vue';

  // 设备类别，是个枚举 TODO: 将手动换为自动获取类别
  // const devicekind = 'fanlocal';

  // const configs = ref<{ prop: string; label: string }[]>([]);
  // function fetchConfig() {
  //   cfgList({
  //     deviceType: 'devicekind',
  //   }).then(({ records }) => {
  //     const moduleData = JSON.parse(records[0]?.moduleData);
  //     configs.value = Object.keys(moduleData).map((k) => {
  //       return {
  //         prop: k,
  //         label: moduleData[k],
  //       };
  //     });
  //   });
  // }

  const warns = ref([
    {
      label: 'test',
      count: 0,
      color: 'red',
    },
    {
      label: 'test',
      count: 0,
      color: 'orange',
    },
    {
      label: 'test',
      count: 0,
      color: 'yellow',
    },
    {
      label: 'test',
      count: 0,
      color: 'green',
    },
    {
      label: 'test',
      count: 0,
      color: 'blue',
    },
  ]);
  // 获取全部局扇的数据，并以选项格式返回给 Header 消费
  // function fetchOptions() {
  //   return list({
  //     devicekind,
  //   }).then(({ records }) => {
  //     devices.value = records;
  //     selectDeviceByID(records[0]?.id);
  //     return records.map((e) => {
  //       return {
  //         label: e.strinstallpos,
  //         key: e.id,
  //       };
  //     });
  //   });
  // }

  onMounted(() => {
    // fetchConfig();
  });
</script>
<style lang="less" scoped>
  @import '@/design/vent/color.less';

  .timeline-item {
    height: 20%;
  }
  .timeline-item__icon_red {
    background-image: url('@/assets/images/home-container/configurable/warn_icon_5.png');
  }
  .timeline-item__icon_orange {
    background-image: url('@/assets/images/home-container/configurable/warn_icon_4.png');
  }
  .timeline-item__icon_yellow {
    background-image: url('@/assets/images/home-container/configurable/warn_icon_3.png');
  }
  .timeline-item__icon_green {
    background-image: url('@/assets/images/home-container/configurable/warn_icon_2.png');
  }
  .timeline-item__icon_blue {
    background-image: url('@/assets/images/home-container/configurable/warn_icon_1.png');
  }
  .timeline-item__icon {
    width: 54px;
    height: 45px;
    margin: 0 50px 0 50px;
    background-repeat: no-repeat;
  }
  .timeline-item__dot {
    position: absolute;
    width: 10px;
    height: 10px;
    left: 7px;
    background-color: @vent-gas-primary-bg;
    border-radius: 5px;
    position: relative;
  }
  .timeline-item__dot::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    width: 16px;
    height: 16px;
    border-radius: 8px;
    border: 1px solid @vent-gas-tab-border;
  }
  .timeline-item__label {
    width: 100px;
    margin-left: 100px;
  }
  .timeline-item__value_red {
    color: red;
  }
  .timeline-item__value_orange {
    color: orange;
  }
  .timeline-item__value_yellow {
    color: yellow;
  }
  .timeline-item__value_green {
    color: yellowgreen;
  }
  .timeline-item__value_blue {
    color: lightblue;
  }

  .timeline {
    height: 220px;
    padding: 5px;
    position: relative;
  }
  .timeline-component {
    width: 2px;
    height: 180px;
    top: 20px;
    left: 170px;
    background-image: @vent-configurable-home-timeline;
  }
</style>
