<template>
  <div class="abs-full title2">
    <div class="m-tt">
      <h4>隧道监测</h4>
    </div>
    <div class="m-body">
      <div class="bottom bottom-suidao">
        <div class="dt">
            <span>监测项</span> <span>最近更新时间</span> <span>监测数据</span>
          </div>
        <dl class="scrolling1">
          <!-- <dt>
            <span>检测项</span> <span>最近更新时间</span>
            <span>监测数据</span>
          </dt> -->
          <div class="list-wrap">
            <div class="list-content">
            <dd
                v-for="(item, index) in dataList"
                :key="index"
                class="suidao-item"
              >
                <span class="ellipsis">{{ item.monName }}时间框里东方红路水电费收快递费就</span>
                <span>{{ item.monDate }}</span>
                <span>{{ item.monNumber }}</span>
              </dd>
            </div>
          </div>
        </dl>
      </div>
    </div>
  </div>
</template>

<script>
import { getList } from "@/api/avoidanceSys/suidao";
export default {
  props: {
    dataList: {
      type: Array,
      default: () => [{ name: "测试1:", y: 6.3 }],
    },
    colors: {
      type: Array,
      default: () => [
        "#27BAFF",
        "#EEE485",
        "#25D8A9",
        "#008ADD",
        "#25D8A9",
        "#EEE485",
        "#27BAFF",
        "#008ADD",
      ],
    },
  },
  data() {
    return {
      dataList: [],
      // 应急预案
      interval4suidao: null,
      scrollPosition4suidao: 0,
      direction4suidao: 1, // 1 for down, -1 for up
      step4suidao: 1, // 每次滚动的像素
      intervalTime4suidao: 40, // 每次滚动的时间间隔（ms）
    };
  },

  watch: {},
  created() {},
  mounted() {
    this.getList();
    this.startScrolling(
      ".bottom-suidao .list-wrap",
      ".bottom-suidao .list-content",
      "suidao"
    );
  },

  methods: {
    /** 查询应急预案信息列表 */
    getList() {
      getList({
        pageNum: 1,
        pageSize: 99999,
      }).then((response) => {
        this.dataList = response.rows;
        this.startScrolling(
          ".bottom-suidao .list-wrap",
          ".bottom-suidao .list-content",
          "suidao"
        );
      });
    },
    startScrolling(containerClass, contentClass, type) {
      const container = document.querySelector(containerClass);
      const content = document.querySelector(contentClass);
      var affixHeight = 10;

      if (this["interval4" + type]) {
        clearInterval(this["interval4" + type]);
      }
      this["interval4" + type] = setInterval(() => {
        this["scrollPosition4" + type] +=
          this["step4" + type] * this["direction4" + type];
        if (
          this["scrollPosition4" + type] + container.clientHeight >=
            content.scrollHeight + affixHeight ||
          this["scrollPosition4" + type] <= 0
        ) {
          this["direction4" + type] *= -1; // 改变滚动方向
        }
        content.style.transform = `translateY(-${
          this["scrollPosition4" + type]
        }px)`;
      }, this["intervalTime4" + type]);
    },
  },
};
</script>

<style scoped lang="scss">
.ellipsis {
  width: 100%; /* 设置容器宽度 */
  white-space: nowrap; /* 防止文本换行 */
  overflow: hidden; /* 隐藏超出容器的文本 */
  text-overflow: ellipsis; /* 当文本溢出容器时显示省略号 */
}
.abs-full {
  position: relative;
  display: flex;
  flex-direction: column;

  &.title2 {
    height: 3.81rem;
    width: 4.76rem;
    background: no-repeat center center
      url("~@/assets/images/dpNew2/title2.png");
    background-size: 100% 100%;
  }
  background: linear-gradient(
    to right,
    rgba(0, 60, 144, 0.9),
    /* #003c90 - 90% 不透明度 */ rgba(0, 44, 106, 0.7)
      /* #002c6a - 70% 不透明度 */
  );

  .chart {
    position: relative;
  }
}
.m-tt {
  height: 0.48rem;
  width: 100%;

  position: absolute;
  top: 0.07rem;
  left: 0.2rem;
  h4 {
    height: 100%;
    line-height: 0.48rem;
    margin: 0;
    font-size: 0.22rem;
    letter-spacing: 0.01rem;
    padding-left: 0.4rem;
    font-family: Source Han Sans SC;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0px 3px 8px rgba(19, 80, 113, 0.48);
    background: linear-gradient(180deg, #ffffff 54.00390625%, #28caff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    //background-image:linear-gradient(to bottom,#fff,#f3fffc,#e4fff9);
    //-webkit-background-clip:text;-webkit-text-fill-color:transparent;
  }
}

.m-body {
  display: flex;
  flex-direction: column;
  padding: 0.2rem;
  padding-top: 0.5rem;
  .bottom {
    height: 2.8rem;
    overflow: hidden;
    margin-top: 0.1rem;
    .dt {
        height: 0.42rem;
        line-height: 0.42rem;
        color: #0adfff;
        display: grid;
        font-family: PingFang SC;
        font-weight: 500;
        font-size: 0.18rem;
        text-align: right;
        grid-template-columns: 1.4rem 1.8rem 1rem;

        border-radius: 4px 4px 0px 0px;
      }
    .scrolling1 {
      height:3.5rem;
      overflow-y: auto;
      border-radius: 4px 4px 0px 0px;
      border: 1px solid #0aabff;
      
      dd {
        height: 0.4rem;
        margin-left: 0;
        color: #d3dfeb;
        margin-right: 0px;
        display: grid;
        text-align: center;
        font-size: 0.14rem;
        align-items: center;
        border-bottom: 0.01rem solid #1f77c2;
      }
    }
  }
  .bottom-suidao {
    height: 3.5rem;
    .scrolling1 {
      position: relative;
      overflow: hidden;
      border: none;
      margin: 0;
      .list-wrap {
        position: relative;
        height: 2.7rem;
        overflow: hidden;
        // margin-top: 0.4rem;
      }
      .list-content {
        position: absolute; /* 绝对定位 */
        transition: transform 0.2s ease; /* 添加平滑过渡 */
      }
      dd {
        background-image: url("~@/assets/images/dpNew2/bg1.png");
        background-size: cover;
        padding-left: 0.9rem;
        position: relative;
        grid-template-columns: 1.2rem 1.5rem 0.9rem;
        margin-top: 0.1rem;
        height: 0.57rem;
        border: none;
        text-align: left;
        &::before {
          content: "";
          position: absolute;
          top: 0.1rem;
          left: 0.25rem;
          width: 0.36rem;
          height: 0.3rem;
          background-image: url("~@/assets/images/dpNew3/icon_1.png");
          background-repeat: no-repeat;
          background-size: cover;
        }
      }
    }
  }
}
</style>