
<template>
  <ul class="rankingBox noScollLine" v-if="list.length > 0">
    <li v-for="item in list" :key="item.yj_gzyid">
      <div class="leftBox">
        <el-tooltip effect="dark" :content="item.yj_gzymc" placement="top-start">
          <div class="top">
            <span class="dian blue"></span>
            <span class="name">{{ item.yj_gzymc }}</span>
          </div>
        </el-tooltip>
        <div class="jdtBox">
          <div class="jdt" :style="{ width: (parseInt(item.total) / totalWidth) * 100 + '%' }"></div>
        </div>
      </div>
      <div class="rightBox">
        <span class="numb">{{ item.total }}</span> 次
      </div>
    </li>
  </ul>
  <div v-if="list.length === 0" class="empty-box">暂无数据</div>
</template>

<script setup>
import { getGzyYj } from "@/api/yjCenter.js";
import { ref, reactive,defineProps,watchEffect } from "vue";
const props = defineProps({
  data:Object
})

const list = ref([]);
const totalWidth = ref(0);
const dataLoad = ref(true);

function getList() {
  getGzyYj(props.data).then((res) => {
    list.value = res;
    if (list.value && list.value.length > 0) {
      dataLoad.value = false;
      totalWidth.value = Math.max(...list.value.map((item) => item.total));
    }
  }).catch((err) => {
    dataLoad.value = false;
  });
}

watchEffect(()=>{
  getList();
})

</script>

<style lang="scss" scoped>
@import "@/assets/css/largeScreen.scss";
ul.rankingBox {
  height:100%;
  overflow: auto;
  padding:4px 10px;
  box-sizing: border-box;
  li {
    display: flex;
    justify-content: space-between;
    padding-top: 8px;
    .leftBox {
      flex: 1;
      width: 290px;
      .top {
        height: 28px;
        .name {
          display: inline-block;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          width: 240px;
          font-size: 14px;
          vertical-align: middle;
        }
      }
      .jdtBox {
        height: 7px;
        background: #092a4e;
        border-radius: 4px;
        overflow: hidden;
        .jdt {
          background: #00c0fa;
          height: 100%;
          border-radius: 4px;
        }
      }
    }
    .rightBox {
      width: 60px;
      text-align: right;
      color: #4896ff;
      font-size: 14px;
      line-height: 50px;
      height: 34px;
      .numb {
        font-size: 14px;
        color: #fff;
      }
    }
  }
}
</style>
