<template>
  <!-- <div v-if="dataLoad" class="empty-box">数据加载中...</div> -->
  <div class="cccc">
    <ul class="rankingBox" v-if="list.length > 0">
      <li v-for="item in list" :key="item.yj_rysfzh">
        <div class="leftBox">
          <div class="top">
            <span class="dian blue"></span
            ><span @click="routerPush(item)" class="name text_title"
              >{{ item.yj_ryxm }}（{{ item.yj_rysfzh }}）</span>
          </div>

          <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>
    <van-empty description="暂无数据" v-if="list.length === 0" />
  </div>
</template>

<script setup>
import { dateFormat } from "../../../../utils/tools.js";
import { getManRankYj } from "../../../../api/yjxx.js";
import { ref, reactive, watch, onMounted, defineProps } from "vue";
import router from "../../../../router/index.js";
import { getRecentDay } from "../../../../utils/tools";
const props = defineProps({
  type: {
    type: Number,
    default: 0,
  }
});
watch(()=> props.type, (val)=>{
  getList()
})
const list = ref([]);
const totalWidth = ref(0);
const dataLoad = ref(true);
function getList() {
  getManRankYj({
    kssj: getRecentDay(props.type, 'ymd'),
    jssj: dateFormat(),
  })
    .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;
    });
}
function routerPush(row){
  router.push({
    path:'/yyzx/yjtjInfo/ryyjinfo',
    query:row
  })
}
onMounted(() => {
  getList();
});
</script>

<style lang="scss" scoped>
.cccc {
  height: 55vw;
  overflow: auto;
  margin-top: 1.5vw;
}
ul.rankingBox {
  height: 100%;
  overflow: auto;
  li {
    display: flex;
    justify-content: space-between;
    padding-top: 8px;
    .leftBox {
      flex: 1;
      .top {
        height: 28px;
        .name {
          font-size: 14px;
          vertical-align: middle;
        }
      }
      .jdtBox {
        height: 7px;
        background: #dbdbdb;
        border-radius: 4px;
        overflow: hidden;
        .jdt {
          background: #00c0fa;
          height: 100%;
          border-radius: 4px;
        }
      }
    }
    .rightBox {
      width: 68px;
      text-align: right;
      color: #4896ff;
      font-size: 14px;
      line-height: 50px;
      height: 34px;
      .numb {
        font-size: 14px;
        color: #333;
      }
    }
  }
}
</style>
