<table class="table table-hover text-center department_applies-list-table">
  <thead class="thead-light">
  <tr>
    <th width="4%">序号</th>
    <th width="8%">ID</th>
    <th width="22%" class="text-left">部门名称</th>
    <th width="20%" class="text-left">单位名称</th>
    <th width="11%">创建者</th>
    <th width="15%"><%= sort_tag('创建于', name: 'created_at', path: admins_department_applies_path) %></th>
    <th width="20%">操作</th>
  </tr>
  </thead>
  <tbody>
  <% if applies.present? %>
    <% applies.each_with_index do |apply, index| %>
      <tr class="department-apply-<%= apply.id %>">
        <td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
        <td><%= apply.id %></td>
        <td class="text-left"> <%= apply.name %></td>
        <td class="text-left"> <%= apply.school.try(:name) %></td>
        <td><%= apply&.user&.real_name %></td>
        <td><%= format_time apply.created_at %></td>
        <td class="action-container">
          <%= agree_link '批准', agree_admins_department_apply_path(apply, element: ".department-apply-#{apply.id}"), 'data-confirm': '确认批准通过？' %>
          <%= javascript_void_link('删除', class: 'action refuse-action',
                                   data: {
                                       toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id, title: "删除原因", type: "delete",
                                       url: admins_department_apply_path(apply,tip:"unapplied", element: ".department-apply-#{apply.id}")
                                   }) %>
          <%= javascript_void_link '更改', class: 'action', data: { school_id: apply.school_id, department_id: apply.id,
                                                                  toggle: 'modal', target: '.admin-merge-department-modal', url: merge_admins_department_applies_path  } %>
        </td>
      </tr>
    <% end %>
  <% else %>
    <%= render 'admins/shared/no_data_for_table' %>
  <% end %>
  </tbody>
</table>

<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>