<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">
          <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>
          <fuelEchart :listStatistics="listStatistics" />
        </div>
      </div>
    </div>
  </div>
</template>

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

<style lang="less" scoped>
.fuel {
  width: 443px;
  height: 50px;
  background: url('../../../assets/vehicle/tj.png') no-repeat;
  margin-top: 15px;
}
.list {
  width: 443px;
  height: 387px;
  border: 1px solid #00aaff;
  margin-top: 10px;
  cursor:pointer;
  .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;
    }
  }
}
.active{
  color:#fff;
}
</style>
