<template>
  <ConfigPageBase
    section="fleet"
    title="车队全生命周期"
    description="分区域/跨楼层/多车协作；OTA、批量操作、网络诊断（FleetLifecycleConfig）"
    :defaults="DEFAULT_FLEET">
    <template #default="{ payload }">
      <el-tabs model-value="groups">
        <el-tab-pane name="groups" label="车队分组">
          <el-table :data="payload.groups" size="small" border>
            <el-table-column label="ID" prop="id" width="100" />
            <el-table-column label="名称" prop="name" width="140" />
            <el-table-column label="楼层" prop="floor" width="80" />
            <el-table-column label="区域" prop="region" width="80" />
            <el-table-column label="车辆">
              <template #default="s">
                <el-tag v-for="c in s.row.carIds" :key="c" size="small" style="margin: 2px">{{ c }}</el-tag>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane name="ota" label="OTA 升级">
          <el-descriptions :column="2" border>
            <el-descriptions-item label="启用">{{ payload.ota.enabled ? '是' : '否' }}</el-descriptions-item>
            <el-descriptions-item label="批次大小">{{ payload.ota.batchSize }}</el-descriptions-item>
            <el-descriptions-item label="失败回滚">{{ payload.ota.rollbackOnFail ? '是' : '否' }}</el-descriptions-item>
          </el-descriptions>
        </el-tab-pane>
        <el-tab-pane name="batch" label="批量操作">
          <el-descriptions :column="2" border>
            <el-descriptions-item label="需确认">{{ payload.batchOps.confirmationRequired ? '是' : '否' }}</el-descriptions-item>
            <el-descriptions-item label="最大批量">{{ payload.batchOps.maxBatch }}</el-descriptions-item>
          </el-descriptions>
        </el-tab-pane>
        <el-tab-pane name="diag" label="网络诊断">
          <el-descriptions :column="2" border>
            <el-descriptions-item label="RTT 阈值 (ms)">{{ payload.networkDiag.rttThresholdMs }}</el-descriptions-item>
            <el-descriptions-item label="丢包阈值">{{ payload.networkDiag.packetLossThreshold }}</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_FLEET } from '@/mock/data/configs'
</script>
