<script>
import CoreData from "@/components/common/coreData.vue";
import ElectricityUseChart from "@/components/dashboard/portrait/electricity/electricityUseChart.vue";
import ElectricityDistributionChart from "@/components/dashboard/portrait/electricity/electricityDistributionChart.vue";
import api from "@/api/dashboard/apiDashboard";
export default {
  data() {
    return {
      coreData: [
        {
          type: 0,
          title: '月总用电量(kWh)',
          num: 0,
          historyDesc: '同比',
          historyNum: 0
        },
        {
          type: 0,
          title: '今日用电量(kWh)',
          num: 0,
          historyDesc: '同比',
          historyNum: 0
        },
        {
          type: 0,
          title: '今日用电趋势',
          num: 0,
          showTrendIcon: true,
          historyDesc: '同比',
        },
        {
          type: 0,
          title: '人均用电成本(元/天)',
          num: 0,
          historyDesc: '同比',
          historyNum: 0
        },
        {
          type: 1,
          showStar: true,
          title: '值得关注',
          content: ''
        },
      ]
    }
  },
  props: {
    chartHeight: Number
  },
  components: {
    CoreData,
    ElectricityUseChart,
    ElectricityDistributionChart,
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.getCoreData()
    },
    getCoreData() {
      api.getElectricityCoreData().then(res=>{
        this.coreData[0].num = res.list[0].value
        this.coreData[0].historyNum = res.list[0].compare
        this.coreData[1].num = res.list[1].value
        this.coreData[1].historyNum = res.list[1].compare
        this.coreData[2].num = res.list[2].value
        this.coreData[2].historyNum = res.list[2].compare
        this.coreData[3].num = res.list[3].value
        this.coreData[3].historyNum = res.list[3].compare
        this.coreData[4].content = res.worthAttention
      })
    },
  }
}
</script>

<template>
  <div class="supermarketPortrait">
    <div class="portrait-coreData">
      <CoreData :data-list="coreData"></CoreData>
    </div>
    <div style="padding: 15px">
      <a-row>
        <a-col :span="16">
          <ElectricityUseChart :height="chartHeight"></ElectricityUseChart>
        </a-col>
        <a-col :span="8">
          <ElectricityDistributionChart :height="chartHeight"></ElectricityDistributionChart>
        </a-col>
      </a-row>
    </div>
  </div>
</template>

<style lang="less" scoped>
.supermarketPortrait {

}
</style>