<!--
 * @Author: SunTao 328867980@qq.com
 * @Date: 2024-10-18 10:31:31
 * @LastEditors: SunTao 328867980@qq.com
 * @LastEditTime: 2024-10-30 16:21:25
 * @FilePath: \znxjxt-ui\src\views\big-screen\disease-components\pic-rank.vue
 * @Description: 病害巡检-pic排名
-->

<template>
  <div class="content">
    <vue-seamless-scroll
      class="vue-scroll"
      :class-option="defaultOption"
      :data="picList"
      v-if="picList.length > 4"
    >
      <div
        class="pic-div"
        v-for="(item, index) in picList"
        :key="`pic-${index}`"
      >
        <div class="pic-top">
          <div class="pic-top-name">
            <a>{{ index + 1 }}</a
            >{{ item.roadName }}
          </div>
          <div class="pic-top-value">
            <span>{{ item.pci }}</span>
          </div>
        </div>
        <div class="pic-bottom">
          <div
            :style="{ width: `${item.pci}%` }"
            :class="`pic-bottom-${index}`"
          ></div>
        </div>
      </div>
    </vue-seamless-scroll>
    <template v-else>
      <div
        class="pic-div"
        v-for="(item, index) in picList"
        :key="`pic-${index}`"
      >
        <div class="pic-top">
          <div class="pic-top-name">
            <a>{{ index + 1 }}</a
            >{{ item.roadName }}
          </div>
          <div class="pic-top-value">
            <span>{{ item.pci }}</span>
          </div>
        </div>
        <div class="pic-bottom">
          <div
            :style="{ width: `${item.pci}%` }"
            :class="`pic-bottom-${index}`"
          ></div>
        </div>
      </div>
    </template>
  </div>
</template>
  
  <script>
import { roadPic } from "@/api/xj/screen/disease-screen";
import vueSeamlessScroll from "vue-seamless-scroll";
export default {
  name: "PicRank",
  components: { vueSeamlessScroll },
  data() {
    return {
      // 轮播配置
      defaultOption: {
        step: 0.2, // 数值越大速度滚动越快
        limitMoveNum: 1,
        hoverStop: true, // 是否开启鼠标悬停stop
        direction: 1, // 0向下 1向上 2向左 3向右
        openWatch: true, // 开启数据实时监控刷新dom
        singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动)direction => 0/1
        singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
        waitTime: 2000, // 单步运动停止的时间(默认值1000ms)
      },
      // 排名数据
      picList: [],
    };
  },
  created() {
    this.getPicData();
  },
  methods: {
    /* 获取数据 */
    getPicData() {
      roadPic().then(({ data, code }) => {
        if (code === 200) {
          this.picList = data.slice(0, 5);
        }
      });
    },
  },
};
</script>
  
  <style lang="scss" scoped>
.content {
  width: 100%;
  height: 100%;
  color: #c7daf2;
  overflow: hidden;

  .pic-div {
    width: calc(100% - 1rem);
    height: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(47, 120, 170, 0.4);

    .pic-top {
      display: flex;
      justify-content: space-between;

      .pic-top-name {
        display: flex;
        align-items: flex-end;
        font-size: 0.8rem;

        a {
          display: flex;
          width: 1rem;
          height: 1rem;
          margin-right: 0.5rem;
          justify-content: center;
          align-items: center;
          border: 1px solid rgba(47, 120, 170, 0.4);
        }
      }

      .pic-top-value {
        font-family: "DouYu";
        font-size: 1rem;
        background: linear-gradient(
          to bottom,
          #ffffff,
          #2773d0
        ); /*设置渐变的方向从左到右 颜色从ff0000到ffff00*/
        background-clip: text; /*将设置的背景颜色限制在文字中*/
        -webkit-text-fill-color: transparent; /*给文字设置成透明*/
      }
    }

    .pic-bottom {
      width: 100%;
      height: 0.3rem;
      background-color: rgba(2, 40, 88, 0.7);

      .pic-bottom-0 {
        height: 0.3rem;
        background: linear-gradient(
          90deg,
          rgba(3, 25, 56, 0.2) 0%,
          #ffc000 100%
        );
      }

      .pic-bottom-1 {
        height: 0.3rem;
        background: linear-gradient(
          90deg,
          rgba(3, 25, 56, 0.2) 0%,
          #00fcff 100%
        );
      }

      .pic-bottom-2 {
        height: 0.3rem;
        background: linear-gradient(
          90deg,
          rgba(3, 25, 56, 0.2) 0%,
          #22b5ff 100%
        );
      }

      .pic-bottom-3 {
        height: 0.3rem;
        background: linear-gradient(
          90deg,
          rgba(3, 25, 56, 0.2) 0%,
          #00fcff 100%
        );
      }

      .pic-bottom-4 {
        height: 0.3rem;
        background: linear-gradient(
          90deg,
          rgba(3, 25, 56, 0.2) 0%,
          #22b5ff 100%
        );
      }
    }
  }
}
</style>
  