<script>
import CoreData from "@/components/common/coreData.vue";
import ColdTrendChart from "@/components/dashboard/portrait/cold/coldTrendChart.vue";
import api from "@/api/dashboard/apiDashboard";

export default {
  data() {
    let range = this.$util.dateUtil.getNearlyMonthRange();
    return {
      queryData: {
        companyId: '0',
        deptId: '0',
        timeRange: range
      },
      coreData: [
        {
          type: 0,
          title: '月总用冷量(kWh)',
          num: 0,
          historyDesc: '同比',
          historyNum: 0
        },
        {
          type: 0,
          title: '今日用冷趋势',
          num: 0,
          historyDesc: '环比',
          showTrendIcon: true,
        },
        {
          type: 1,
          title: '能效比',
          content: '',
        },
        {
          type: 0,
          title: '月人均用冷量(kWh)',
          num: 0,
          historyDesc: '同比',
          historyNum: '0'
        },
        {
          type: 1,
          isHighLight: false,
          showStar: true,
          title: '值得关注',
          content: ''
        },
      ]
    }
  },
  props: {
    chartHeight: Number,

  },
  components: {
    CoreData,
    ColdTrendChart,
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.getCoreData()
    },
    getCoreData() {
      api.getColdCoreData(this.queryData).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].content = res.list[2].value
        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">
      <ColdTrendChart :height="chartHeight" :query-data="queryData"></ColdTrendChart>
    </div>
  </div>
</template>

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

}
</style>