<script setup lang="ts">
import LineChart from "./LineChart.vue";
import VideoVue from "./VideoVue.vue";
import InfoVue from "./InfoVue.vue";
import BaseinfoVue from "./BaseinfoVue.vue";
import { provide, ref } from "vue";
import api from "/@/api/projects";

const projectCode = ref("");
const deviceKey = ref("");
const projectList = ref<any[]>([]);

provide("projectCode", projectCode);

api.screen
  .projects({
    pageNum: 1,
    pageSize: 500,
    status: 1,
  })
  .then(({ list }: { list: any[] }) => {
    projectList.value = list || [];
    if (list?.length) {
      setTimeout(() => {
        projectCode.value = list[0].code;
      }, 1000);
    }
  });
</script>

<template>
  <el-form class="container" size="small">
    <div class="part">
      <VideoVue :projectList="projectList" @change="projectCode = $event"></VideoVue>
      <LineChart :deviceKey="deviceKey" :index="0"></LineChart>
    </div>
    <div class="part">
      <InfoVue :projectList="projectList" @change="projectCode = $event"></InfoVue>
      <BaseinfoVue @change="deviceKey = $event"></BaseinfoVue>
      <LineChart :deviceKey="deviceKey" :index="1"></LineChart>
    </div>
  </el-form>
</template>

<style lang="scss" scoped>
.container {
  width: 100%;
  display: flex;
  justify-content: space-between;
  height: 100%;
  overflow: hidden;
  gap: 15px;
  ::v-deep(.project-card) {
    background-color: var(--el-color-white) !important;
    padding: 15px 20px;
    border-radius: 6px;
    .title {
      font-size: 14px;
      font-weight: 500;
      margin-bottom: 12px;
      .icon {
        height: 28px;
        margin-right: 8px;
      }
    }
  }

  .part {
    flex: 1;
    display: flex;
    flex-flow: column nowrap;
    justify-content: space-between;
    z-index: 10;
    overflow: hidden;
    gap: 15px;
  }
}
</style>
