<script setup>
import Devices from '@/views/smartFarm/components/devices.vue';
import Common from '@/views/smartFarm/components/common.vue';
import stream from '@/views/smartFarm/components/stream.vue';
import { ref, onMounted, onBeforeUnmount } from 'vue';
import { getAssetsFile } from '@/utils/index.js';
import * as echarts from 'echarts';
import BugData from '@/views/smartFarm/components/bugData.vue';
import SickData from '@/views/smartFarm/components/sickData.vue';

const currentDevice = ref(0);
const devices = ref([
  {
    name: 'A-001',
    icon: 'temp',
    detail: 'A区-监控设备1',
    status: '1',
    id: 0,
  },
  {
    name: 'A-003',
    icon: 'ph',
    detail: 'A区-监控设备3',
    status: '1',
    id: 2,
  },
  {
    name: 'A-005',
    icon: 'O2',
    detail: 'A区-监控设备5',
    status: '1',
    id: 4,
  },
  {
    name: 'A-006',
    icon: 'elect',
    detail: 'A区-监控设备6',
    status: '0',
    id: 5,
  },
  {
    name: 'B-001',
    icon: 'light',
    detail: 'B区-监控设备1',
    status: '1',
    id: 6,
  },
  {
    name: 'B-004',
    icon: 'dust',
    detail: 'B区-监控设备4',
    status: '1',
    id: 9,
  },
  {
    name: 'B-005',
    icon: 'float',
    detail: 'B区-监控设备5',
    status: '1',
    id: 10,
  },
]);
const rules = ref([
  {
    name: '温度',
    icon: 'temp',
    unit: '℃',
    goat: '15',
    status: '1',
  },
  {
    name: 'PH值',
    icon: 'ph',
    unit: '',
    goat: '6.5',
    status: '1',
  },
  {
    name: '溶解氧',
    icon: 'O2',
    goat: '0.4',
    unit: 'mg/L',
    status: '1',
  },
  {
    name: '色度',
    icon: 'light',
    goat: '15',
    unit: 'PCU',
    status: '1',
  },
  {
    name: '浊度',
    icon: 'dust',
    goat: '1.5',
    unit: 'NTU',
    status: '1',
  },
  {
    name: '导电率',
    icon: 'elect',
    goat: '3000',
    unit: 'μS/cm',
    status: '1',
  },
  {
    name: '悬浮物',
    icon: 'float',
    goat: '9000',
    unit: 'mg/L',
    status: '0',
  },
]);
const isFullscreen = ref(false);
const toggleFullscreen = () => {
  isFullscreen.value = !isFullscreen.value;
};

const chooseIcon = (type) => {
  switch (type) {
    case 'light':
      return '分光器.png';
    case 'float':
      return '悬浮物.png';
    case 'O2':
      return '水质溶解氧.png';
    case 'elect':
      return '水质电导率.png';
    case 'dust':
      return '浊度.png';
    case 'temp':
      return '温度.png';
    case 'ph':
      return '酸碱度.png';
  }
};

// #endregion
</script>

<template>
  <div>
    <common>
      <template #main>
        <div>
          <devices :title="'病虫害监测设备'" :devices="devices"></devices>
        </div>
        <div style="margin-top: 10px; display: flex; justify-content: space-between">
          <div style="display: flex; justify-content: space-between; margin-top: 10px">
            <stream :title="'病害监测监控'" :num="3" :devices="devices" style="width: 60%; height: fit-content"></stream>
            <div style="width: 38%">
              <el-card style="border-radius: 16px; padding: 10px">
                <div style="font-size: 16px; font-weight: bold; text-align: left; color: #000">病害数据</div>
                <sick-data style="width: 38%; min-width: 300px"></sick-data>
              </el-card>
            </div>
          </div>
        </div>
        <div style="margin-top: 10px; display: flex; justify-content: space-between">
          <div style="display: flex; justify-content: space-between; margin-top: 10px; width: 100%">
            <stream :title="'虫害监测监控'" :num="2" :devices="devices" style="width: 60%; height: fit-content"></stream>
            <div style="width: 38%">
              <el-card style="border-radius: 16px; padding: 10px">
                <div style="font-size: 16px; font-weight: bold; text-align: left; color: #000">虫害数据</div>
                <bug-data style="width: 38%; min-width: 300px"></bug-data>
              </el-card>
            </div>
          </div>
        </div>
      </template>
    </common>
  </div>
</template>

<style scoped lang="scss">
.rates {
  margin: 10px 0;
  height: 100px;
  font-size: 14px;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
  width: 25%;
  img {
    height: 20px;
  }
}
</style>
