<template>
  <div class="device-detail-page">
    <!-- <div class="detail-header">
      <el-button icon="ArrowLeft" circle @click="handleBack" />
      <span class="detail-title">设备信息</span>
    </div> -->
    <div class="tabs-box">
      <el-button icon="ArrowLeft" circle @click="handleBack" />
      <span class="title">设备信息（{{ device?.gatewayMac }}）</span>
      <el-radio-group v-model="activeMenu" size="large" fill="#409eff">
        <el-radio-button label="设备详情" value="info" />
        <el-radio-button label="线路列表" value="line" />
        <el-radio-button label="运行趋势" value="trend" />
        <el-radio-button label="参数配置" value="config" />
      </el-radio-group>
    </div>

    <DeviceInfo v-if="activeMenu === 'info'" :device="device" />
    <DeviceLine v-if="activeMenu === 'line'" :device="device" />
    <DeviceTrend v-if="activeMenu === 'trend'" :device="device" />
    <DeviceConfig v-if="activeMenu === 'config'" :device="device" />
    <!-- <DeviceAlarm v-show="activeMenu === 'alarm'" :device="device" /> -->
  </div>
</template>

<script setup>
  import { ref, onMounted } from 'vue'
  import DeviceInfo from './components/info/index.vue'
  import DeviceLine from './components/line/index.vue'
  import DeviceTrend from './components/trend/index.vue'
  import DeviceConfig from './components/config/index.vue'
  import DeviceAlarm from './components/alarm/index.vue'

  defineProps({
    device: {
      type: Object,
      default: () => null
    }
  })

  const activeMenu = ref('info')
  const emit = defineEmits(['back'])

  const handleBack = () => {
    activeMenu.value = ''
    emit('back')
  }
</script>

<style lang="scss" scoped>
  .device-detail-page {
    // padding: 20px;
    .tabs-box {
      @apply p-4 bg-white text-slate-700 dark:text-slate-400 dark:bg-slate-900 rounded my-2 rounded-lg;
      display: flex;
      align-items: center;
      > .title {
        margin: 0 15px;
        font-size: 18px;
        font-weight: 600;
        color: var(--el-text-color-primary, #303133);
      }
    }
  }

  .detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
  }

  .detail-menu {
    margin-bottom: 20px;
    // border-radius: 8px;
    // background-color: var(--el-bg-color-overlay, #ffffff);
    // border: 1px solid var(--el-border-color, #e4e7ed);
  }
</style>
