<template>
  <div class="right_top">
    <div class="right_top-title flex">
      <div class="flex items-center">
        <img src="@/assets/img/home/title_arrow.png" alt="">
        近30天高频事项预警
      </div>
    </div>
    <div class="scroll" v-loading="loading">
      <vue3-seamless-scroll :list="list" hover :singleHeight="100">
        <div class="scroll-item" v-for="item in list" :key="item.id">
          <span class="scroll-item-area">{{ item.areaName }}</span>
          <el-tooltip placement="top">
            <template #content> {{ item.title }}</template>
            <span class="scroll-item-title">{{ item.title }}</span>
          </el-tooltip>
          <span class="scroll-item-hotspot">{{ item.hotspotName }}</span>
          <span class="scroll-item-num"> <CountUp :endVal="item.sumCount " :duration="2"/>次</span>
        </div>
      </vue3-seamless-scroll>
    </div>
  </div>
</template>
<script setup lang="ts">
import {onMounted, ref} from "vue";
import {Vue3SeamlessScroll} from "vue3-seamless-scroll";
import CountUp from "@/components/count-up";
import {highFrequency} from "@/api/home";

const list = ref<any>([]);
const loading = ref(false);
const getData = async () => {
  loading.value = true;
  try {
    const {result} = await highFrequency();
    list.value = result;
    loading.value = false;
  } catch (e) {
    console.log(e);
    loading.value = false;
  }
}
onMounted(() => {
  getData();
})
</script>
<style scoped lang="scss">
.right_top {
  padding: 0 30px;
  font-size: 15px;

  &-title {
    font-size: 20px;
    color: #fff;
    justify-content: space-between;
    align-items: center;
  }


  .scroll {
    height: 280px;
    overflow: hidden;
    margin-top: 10px;

    &-item {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: #D2D4D5;
      margin-bottom: 15px;

      &-area {
        display: inline-block;
        background-color: #69BBF6;
        padding: 0 6px;
        color: #333;
        border-radius: 4px;
        white-space: nowrap;
      }

      &-title {
        width: 50%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-left: 10px;
      }

      &-hotspot {
        width: 30%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
      }
    }
  }
}

.count-up-wrap {
  display: inline-block;
}
</style>