<template>
  <ConfigPageBase
    section="device"
    title="第三方设备统一接入"
    description="电梯/卷帘门/安全门/充电桩/AP/交换机/摄像头/读码器/PLC（DeviceManagementConfig）"
    :defaults="DEFAULT_DEVICE">
    <template #default="{ payload }">
      <el-tabs model-value="drivers">
        <el-tab-pane name="drivers" label="驱动绑定">
          <el-table :data="payload.drivers" size="small" border>
            <el-table-column label="ID" prop="id" width="120" />
            <el-table-column label="设备类型" prop="deviceType" width="120" />
            <el-table-column label="驱动名" prop="driverName" />
            <el-table-column label="版本" prop="version" width="100" />
          </el-table>
        </el-tab-pane>
        <el-tab-pane name="devices" label="设备实例">
          <el-table :data="payload.devices" size="small" border>
            <el-table-column label="ID" prop="id" width="120" />
            <el-table-column label="名称" prop="name" width="140" />
            <el-table-column label="类型" prop="deviceType" width="100" />
            <el-table-column label="协议" prop="protocol" width="120" />
            <el-table-column label="地址" prop="address" />
            <el-table-column label="启用" width="80">
              <template #default="s"><el-switch v-model="s.row.enabled" /></template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane name="policy" label="健康 / 告警">
          <el-descriptions :column="2" border>
            <el-descriptions-item label="心跳周期 (s)">{{ payload.healthPolicy.heartbeatSec }}</el-descriptions-item>
            <el-descriptions-item label="离线判定 (s)">{{ payload.healthPolicy.offlineSec }}</el-descriptions-item>
            <el-descriptions-item label="告警启用">{{ payload.alarmPolicy.enabled ? '是' : '否' }}</el-descriptions-item>
            <el-descriptions-item label="规则数">{{ payload.alarmPolicy.rules.length }}</el-descriptions-item>
          </el-descriptions>
        </el-tab-pane>
      </el-tabs>
    </template>
  </ConfigPageBase>
</template>

<script setup lang="ts">
import ConfigPageBase from '@/components/ConfigPageBase.vue'
import { DEFAULT_DEVICE } from '@/mock/data/configs'
</script>
