{{define "device_batch_config"}}
<div class="card">
  <div class="section-title">
    <div>
      <h2 class="title-with-icon">{{icon "devices"}}<span>已选设备</span></h2>
    </div>
    <div class="actions compact">
      <a class="btn secondary" href="{{.SelectedDevicesURL}}#batch-config">返回设备列表</a>
      <a class="btn secondary" href="/ui/devices">重新选择</a>
    </div>
  </div>
  <div class="info-list">
    {{range .SelectedDevices}}
    <div>
      <span>{{.DisplayName}}</span>
      <strong class="mono">{{.DeviceID}}</strong>
    </div>
    {{else}}
    <div class="full">
      <span>目标设备</span>
      <strong>还没有选中设备</strong>
    </div>
    {{end}}
  </div>
</div>

<div class="card">
  <div class="section-title">
    <div>
      <h2 class="title-with-icon">{{icon "config"}}<span>下发设备分配</span></h2>
      <div class="muted">按每台设备当前保存的设备分配，批量创建下发任务。</div>
    </div>
  </div>

  <form method="post" action="/ui/devices/batch-config">
    {{range .SelectedDeviceIDs}}<input type="hidden" name="device_id" value="{{.}}" />{{end}}
    <div class="actions">
      <button type="submit" class="primary">创建下发任务</button>
    </div>
  </form>
</div>

<div class="card">
  <div class="section-title">
    <div>
      <h2 class="title-with-icon">{{icon "preview"}}<span>设备分配摘要</span></h2>
    </div>
  </div>
  {{if .DeviceAssignments}}
  <div class="table-wrap">
    <table>
      <thead>
        <tr>
          <th>设备</th>
          <th>场景模板</th>
          <th>识别单元</th>
        </tr>
      </thead>
      <tbody>
        {{range .DeviceAssignments}}
        <tr>
          <td class="mono">{{.DeviceID}}</td>
          <td class="mono">{{if .ProfileName}}{{.ProfileName}}{{else}}-{{end}}</td>
          <td>{{.RecognitionCount}} 路</td>
        </tr>
        {{end}}
      </tbody>
    </table>
  </div>
  {{else}}
  <div class="empty-state">
    <div class="empty-title">还没有可用设备分配</div>
    <div class="muted">请先到设备分配中完成设备与识别单元绑定，再回来下发。</div>
  </div>
  {{end}}
</div>
{{end}}
