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

<template>
  <div class="yield-copilot">
    <section class="top flex">
      <db-container class="std-yield" title="标准组件产出" icon="std">
        <std-output :period="period" />
      </db-container>
      <db-container class="chip-yield" title="芯片产出" icon="chip2">
        <chip-output :period="period" />
      </db-container>
      <db-container class="bipv-yield" title="BIPV产出" icon="bipv">
        <bipv-output :period="period" />
      </db-container>
    </section>
    <section class="bottom flex">
      <db-container class="fto-involve" title="FTO投入">
        <fto-invest :period="period" />
      </db-container>
      <db-container class="chip-involve" title="芯片投入" icon="chip">
        <chip-invest :period="period" />
      </db-container>
    </section>
  </div>
</template>

<script>
import Container from "@/views/copilot/components/Container.vue";
import StdOutput from "./components/StdOutput.vue";
import ChipOutput from "./components/ChipOutput.vue";
import FtoInvest from "./components/FtoInvest.vue";
import BipvOutput from "./components/BipvOutput.vue";
import ChipInvest from "./components/ChipInvest.vue";

export default {
  name: "YieldCopilot",
  components: {
    DbContainer: Container,
    StdOutput,
    ChipOutput,
    BipvOutput,
    FtoInvest,
    ChipInvest,
  },
  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: "yield" });
    },
  },
};
</script>

<style scoped>
.yield-copilot {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.flex {
  display: flex;
  gap: 16px;
  flex: 1;
}

.top > div,
.bottom > div {
  height: 100%;
}
</style>
