<template>
  <div class="table-container">
    <table>
      <thead>
        <tr>
          <th>车牌号</th>
          <th>当前总里程</th>
          <th>当月用氢量</th>
          <th>当月行驶里程</th>
          <th>当月碳排放</th>
        </tr>
      </thead>
    </table>
    <div class="scroll-wrapper">
      <vue-seamless-scroll :data="tableData" :class-option="scrollOptions" class="scroll-container">
        <table>
          <tbody>
            <tr v-for="(item, index) in tableData" :key="index">
              <td>{{ item.plateNumber }}</td>
              <td>{{ item.totalMileage }}km</td>
              <td>{{ item.dayHydrogen }}kg</td>
              <td>{{ item.dayMileage }}km</td>
              <td>{{ item.dayCarbon }}kg</td>
            </tr>
          </tbody>
        </table>
      </vue-seamless-scroll>
    </div>
  </div>
</template>

<script>
import vueSeamlessScroll from "vue-seamless-scroll";
import { currentGET } from 'api/modules'
export default {
  components: { vueSeamlessScroll },
  data() {
    return {
      scrollOptions: {
        step: 0.3, // 滚动速度
        limitMoveNum: 5, // 限制单步滚动的条数
        hoverStop: true, // 鼠标悬停是否暂停
        direction: 1, // 方向（1：向上滚动）
      },
      tableData: [],
            
    };
  },
  mounted() {
    this.getExchangeData(); 
  },
  methods: {    
    getExchangeData() {
      currentGET("big12").then(res => {
        console.log("当月汇总数据：");
        console.log(res.data);
        this.tableData = res.data;
      });
    },
  },
};
</script>

<style scoped>
.table-container {
  width: 100%;
  border-radius: 5px;
  overflow: hidden;
  padding-top: 10px; /* 添加顶部内边距 */
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: center; /* 修改为居中对齐 */
}

th {
  padding: 12px;
  color: #000000;
  font-size: 14px;
  width: 20%;
  text-align: center; /* 确保单元格内容居中 */
}
td {
  padding: 12px;
  color:rgb(0, 255, 204);
  font-size: 14px;
  width: 20%;
  text-align: center; /* 确保单元格内容居中 */
}

thead {
  background: #013f6a;
  padding: 10%;
}

.scroll-wrapper {
  height: 250px; /* 适配大屏，数据较多可增加高度 */
  overflow: hidden;
}

.scroll-container table {
  width: 100%;
}

tr {
  border-bottom: 1px solid #0a2a4a;
}

tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}
</style>
