<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 style="margin-top: 20px" v-if="listStatistics.length > 0">
          <fuelEchart :listStatistics="listStatistics" />
        </div>
        <img class="null-imgs" v-if="listStatistics.length == 0" src="../../../assets/vehicle/null-img.png" alt="" />
      </div>
    </div>
  </div>
</template>

<script>
import fuelEchart from './fuelEchart'
import { getFuelConsumptionStatistics } from '@/api/vehicle.js'
export default {
  components: { fuelEchart },
  props: { itemsTime: String,selt:Number },
  data() {
    return {
      type: 'CURRENT_YEAR',
      listStatistics: [],
      categoryId:3
    }
  },
  watch: {
    itemsTime: {
      handler(val) {
        this.type = val
        this.funFuelConsumptionRanking()
      },
      immediate: true,
      deep: true,
    },
    selt:{
      handler(val) {
        this.categoryId = val
        this.funFuelConsumptionRanking()
      },
      immediate: true,
      deep: true,
    }
  },
  methods: {
    // changeType(val){
    //   this.type=val
    //   this.funFuelConsumptionRanking()
    // },
    // addClass(ev){
    //   return ev==this.type ? "active"
    //     : "";
    // },
    funFuelConsumptionRanking() {
      getFuelConsumptionStatistics({ type: this.type,categoryId:this.categoryId}).then((res) => {
        let list = res.data.some((item) => item.value > 0)
        if (list) {
          this.listStatistics = res.data
        } else {
          this.listStatistics = []
        }
      })
    },
  },
  // created() {
  //   this.funFuelConsumptionRanking()
  // },
}
</script>

<style lang="less" scoped>
.fuel {
  width: 443px;
  height: 50px;
  // background: url('../../../assets/vehicle/tj.png') no-repeat;
  background: url('../../../assets/vehicle/jyje.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;
}
.null-imgs {
  display: inline-block;
  width: 160px;
  height: 160px;
  margin: 100px 0 0 140px;
}
</style>
