<template>
  <div class="project-detail-wrapper">
    <div class="header">
      <div class="title">
        <img style="width: 28px; height: 28px" :src="waterIcon" />
        <span>{{ data.name }}</span>
        <!-- <span>{{ data.scale }}</span>
        <span>{{ data.type }}</span> -->
      </div>
      <div class="btns">
        <el-icon @click="handleClose">
          <Close />
        </el-icon>
      </div>
    </div>
    <div class="content">
      <el-tabs class="main-tabs" :tab-position="'left'" v-model="activeTab">
        <el-tab-pane label="基础信息" name="1" lazy>
          <BaseInfo
            ref="baseInfoRef"
            :resCode="resCode"
            @getResInfo="handleGetResInfo"
          ></BaseInfo>
        </el-tab-pane>
        <el-tab-pane label="监测数据" name="2" lazy>
          <DataStatistics
            ref="dataStatisticsRef"
            :resCode="resCode"
          ></DataStatistics>
        </el-tab-pane>
        <el-tab-pane label="监测预警" name="5" lazy>
          <MonitorWarning
            ref="monitorWarning"
            :resCode="resCode"
          ></MonitorWarning>
        </el-tab-pane>
        <!-- <el-tab-pane label="视频分析" name="6" lazy>
          <VideoAnalysis ref="videoAnalysis" :resCode="resCode"></VideoAnalysis>
        </el-tab-pane> -->
        <el-tab-pane label="视频查看" name="6" disabled lazy> </el-tab-pane>
        <el-tab-pane label="巡查养护" name="7" disabled lazy> </el-tab-pane>
        <el-tab-pane label="动物防治" name="8" disabled lazy> </el-tab-pane>
        <el-tab-pane label="安全鉴定" name="9" disabled lazy> </el-tab-pane>
        <el-tab-pane label="病险核查" name="10" disabled lazy> </el-tab-pane>
        <el-tab-pane label="防汛物资" name="11" disabled lazy> </el-tab-pane>
        <el-tab-pane label="档案管理" name="12" disabled lazy> </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, watch, onMounted } from "vue";
import BaseInfo from "./components/BaseInfo.vue";
import DataStatistics from "./components/DataStatistics.vue";
import MonitorWarning from "./components/MonitorWarning.vue";

import { Close } from "@element-plus/icons-vue";
import RB from "@/assets/map/reservoir_big.png";
import RN from "@/assets/map/reservoir_normal.png";
import RS from "@/assets/map/reservoir_small.png";

// import VideoAnalysis from "./components/VideoAnalysis.vue";
const props = defineProps({
  data: {
    type: Object,
    default: {},
  },
});
const resCode = ref("");
defineOptions({
  name: "Reservoir",
});
const emits = defineEmits(["getResInfo"]);
const waterIcon = ref(RN);
const activeTab = ref("1");

function setWaterIcon() {
  switch (props.data.scale) {
    case "1.0":
    case "2.0":
      waterIcon.value = RB;
      break;
    case "3.0":
      waterIcon.value = RN;
      break;
    case "4.0":
    case "5.0":
      waterIcon.value = RS;
      break;
    default:
      waterIcon.value = RN;
      break;
  }
}
function handleGetResInfo(data: any) {
  emits("getResInfo", data);
}

function handleClose() {
  window.$bus.$emit("close-reservoir-dialog");
}

watch(
  () => props.data,
  (val) => {
    if (val) {
      resCode.value = val.code;
    }
  },
  { immediate: true }
);

onMounted(() => {
  setWaterIcon();
});
</script>
<style scoped lang="scss">
.project-detail-wrapper {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 80%;
  min-height: 600px;
  max-height: 800px;
  transform: translate(-50%, -50%);
  border-radius: 4px;
  background: #fff;
  .header {
    display: flex;
    padding: 0 20px;
    height: 42px;
    color: #262626;
    font-family: PingFang SC;
    font-size: 16px;
    font-weight: 500;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    .title {
      display: flex;
      align-items: center;
      font-size: 20px;
      font-weight: 700;
      img {
        width: 16px;
        height: 16px;
        margin-right: 4px;
      }
    }
    .btns {
      cursor: pointer;
    }
  }
  .content {
    height: 748px;
    :deep(.main-tabs) {
      height: 100%;
      .sy-tabs__content,
      .sy-tab-pane {
        height: 100%;
      }
    }
  }
}
</style>
