<!-- 
    filename: index.vue
    author: liubin
    date: 2024-04-16 14:40:15
    description: 综合驾驶舱
-->

<template>
  <div class="energy-copilot">
    <Container title="仓库监控·当前" icon="chip2">
      <StockMonitorVue :period="period" />
    </Container>
    <Container title="天然气能耗" icon="std">
      <NatGasVue :period="period" />
    </Container>
    <Container title="电能耗" icon="chip">
      <ElecCostVue :period="period" />
    </Container>
    <Container title="水能耗" icon="cube">
      <WaterCostVue :period="period" />
    </Container>
  </div>
</template>

<script>
import Container from "@/views/copilot/components/Container.vue";
import StockMonitorVue from "./components/StockMonitor.vue";
import ElecCostVue from "./components/ElecCost.vue";
import NatGasVue from "./components/NatGas.vue";
import WaterCostVue from "./components/WaterCost.vue";

export default {
  name: "EnergyCopilot",
  components: {
    Container,
    StockMonitorVue,
    ElecCostVue,
    NatGasVue,
    WaterCostVue,
  },
  props: {
    period: {
      type: String,
      default: "日",
    },
  },
  data() {
    return {};
  },
  watch: {
    period: {
      handler(val) {
        val && this.fetchData(val);
      },
      immediate: true,
    },
  },
  methods: {
    fetchData(period = "日") {
      console.log(`效率驾驶舱，获取${period}数据`);
      this.$store.dispatch("copilot/initCopilot", {
        period,
        source: "comprehensive",
      });
    },
  },
};
</script>

<style scoped>
.energy-copilot {
  flex: 1;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.energy-copilot > div {
  height: 100%;
}
</style>
