<template>
  <div>
    <div>
      <div class="fuel"></div>
      <div class="list">
        <div style="text-align: right; color: #8abfdc; font-size: 14px; margin: 10px 20px 10px 0;cursor:pointer;">
          <span @click="changeType('CURRENT_YEAR')" :class="addClass('CURRENT_YEAR')">年份</span>
          <span style="margin: 0 15px" @click="changeType('CURRENT_MONTH')" :class="addClass('CURRENT_MONTH')">月份</span>
          <span @click="changeType('CURRENT_WEEK')" :class="addClass('CURRENT_WEEK')">每周</span>
        </div>
        <!-- 表格 -->
        <div>
          <div class="row header">
            <span class="type">排名</span>
            <span class="count">所属单位</span>
            <span class="time"> 总油耗（升）</span>
            <span class="unit">名次</span>
          </div>
          <ul style="padding-left: 0">
            <li class="row textw" v-for="(item, index) in listStatistics" :key="index">
              <span class="type" style="text-align:center;width: 10px;margin-left: -15px;">{{ item.rank }}</span>
              <span class="count" style="text-align:center; width: 80px;margin-left: -26px;">{{ item.name }}</span>
              <span class="time" style="text-align:center; width: 30px;margin-left: -26px;">{{ item.value }}</span>
              <span class="unit" style="text-align:center; width: 40px;margin-right: -20px;">
                <img v-if="item.changeRank>0" src="../../../assets/vehicle/Vector (6).png" />
                <img v-else-if="item.changeRank<0" src="../../../assets/vehicle/Vector (5).png" />
                <span v-if="item.changeRank!=0">{{ Math.abs(item.changeRank) }}</span>
                <span v-if="item.changeRank==0">-</span>
              </span>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import fuelEchart from './fuelEchart'
import { getFuelConsumptionRanking } from '@/api/vehicle.js'
export default {
  components: { fuelEchart },
  data() {
    return {
      type: 'CURRENT_YEAR',
      listStatistics: [],
    }
  },
  methods: {
    changeType(val) {
      this.type = val
      this.funFuelConsumptionRankings()
    },
    addClass(ev){
      return ev==this.type ? "active"
        : "";
    },
    funFuelConsumptionRankings() {
      getFuelConsumptionRanking({ type: this.type }).then((res) => {
        this.listStatistics = res.data
      })
    },
  },
  created() {
    this.funFuelConsumptionRankings()
  },
}
</script>

<style lang="less" scoped>
.fuel {
  width: 443px;
  height: 50px;
  background: url('../../../assets/vehicle/yh.png') no-repeat;
}
.list {
  width: 443px;
  height: 434px;
  border: 1px solid #00aaff;
  margin-top: 10px;
  .header {
    color: #61dbff !important;
    height: 38px !important;
    background-color: rgba(66, 92, 108, 0.3) !important;
    margin-top: 2px;
    letter-spacing: 1px;
    line-height: 38px;
    display: flex;
    justify-content: space-around;
    padding: 0 !important;
    .is_notice {
      line-height: 19px;
      font-size: 10px;
    }
  }

  li.row > span {
    //   text-align: center;
    font-size: 14px;
    display: inline-block;
  }
  li.row.active {
    background-color: rgba(0, 213, 255, 0.2);
  }

  li.row {
    box-sizing: border-box;
  }

  .row,
  li {
    display: block;
    height: 46px;
    border-bottom: 1px dashed #1f2535;
    line-height: 46px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 14px;
    //   background-color: rgba(0, 0, 0, 0.2);
    color: #fff;
    margin-top: 5px;
    .unit {
      // display: flex;
      // justify-content: center;
      // align-items: center;
      // flex: 0.15;
      img {
        display: inline-block;
        width: 11px;
        height: 16px;
        margin-right:4px;
        //   margin-left: 5px;
      }
    }
    //   .type {
    //     flex: 0.15;
    //   }
    //   .count {
    //     text-align: center;
    //     display: inline-block;
    //     overflow: hidden;
    //     text-overflow: ellipsis !important; // 超出隐藏
    //     white-space: nowrap;
    //      flex: 0.35;
    //   }
    //   .time {
    //     color: #61dbff;
    //     flex: 0.35;
    //   }
  }
  // .textw:first-child{
  //   color: aqua;
  //  margin-right: 20px;
  // }
}
.active{
  color:#fff ;
  
}
</style>
