<template>
  <ConfigPageBase
    section="charge"
    title="充电逻辑"
    description="充电优先级、空闲充电、任务中断充电（ChargePolicy）"
    :defaults="DEFAULT_CHARGE">
    <template #default="{ payload, update }">
      <el-form label-width="180px" :model="payload">
        <el-form-item label="允许任务中断充电">
          <el-switch :model-value="payload.allowMidTaskCharge" @update:model-value="(v: string | number | boolean) => update({ ...payload, allowMidTaskCharge: Boolean(v) })" />
        </el-form-item>
        <el-form-item label="空闲多少秒后充电">
          <el-input-number :model-value="payload.idleChargeAfterSec" :min="0" :max="86400" @update:model-value="(v: number | undefined) => update({ ...payload, idleChargeAfterSec: v ?? 0 })" />
        </el-form-item>
        <el-form-item label="充电优先级规则">
          <el-table :data="payload.priority" size="small">
            <el-table-column label="ID" prop="id" width="100" />
            <el-table-column label="条件" prop="condition" />
            <el-table-column label="权重" prop="weight" width="100" />
          </el-table>
        </el-form-item>
      </el-form>
    </template>
  </ConfigPageBase>
</template>

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