<template>
  <ConfigPageBase
    section="task"
    title="任务分配机制"
    description="负载均衡、就近分配、优先级调度（TaskAllocationPolicy）"
    :defaults="DEFAULT_TASK">
    <template #default="{ payload, update }">
      <el-form label-width="160px" :model="payload">
        <el-form-item label="分配模式">
          <el-radio-group :model-value="payload.mode" @update:model-value="(v: any) => update({ ...payload, mode: v })">
            <el-radio-button value="roundRobin">轮询</el-radio-button>
            <el-radio-button value="nearest">就近</el-radio-button>
            <el-radio-button value="leastLoad">最少负载</el-radio-button>
            <el-radio-button value="custom">自定义</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="启用负载均衡">
          <el-switch :model-value="payload.loadBalance" @update:model-value="(v: string | number | boolean) => update({ ...payload, loadBalance: Boolean(v) })" />
        </el-form-item>
        <el-form-item label="单车队列上限">
          <el-input-number :model-value="payload.maxQueuePerCar" :min="1" :max="100" @update:model-value="(v: number | undefined) => update({ ...payload, maxQueuePerCar: v ?? 0 })" />
        </el-form-item>
      </el-form>
    </template>
  </ConfigPageBase>
</template>

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