dev_jupyter
parent
2bb43cecf4
commit
e99ed00fff
@ -0,0 +1,22 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-item-authentications-index-page').length > 0) {
|
||||
var $searchFrom = $('.item-authentication-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if($link.data('value') === 'processed'){
|
||||
$('.batch-action-container').hide();
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$('.batch-action-container').show();
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,49 @@
|
||||
class Admins::ItemAuthenticationsController < Admins::BaseController
|
||||
def index
|
||||
params[:status] ||= 'pending'
|
||||
params[:sort_direction] = params[:status] == 'pending' ? 'asc' : 'desc'
|
||||
|
||||
applies = Admins::ApplyItemBankQuery.call(params.merge(type: "ItemBank"))
|
||||
|
||||
@applies = paginate applies.preload(user: { user_extension: [:school, :department] })
|
||||
end
|
||||
|
||||
def show
|
||||
apply = ApplyAction.find params[:id]
|
||||
@item = ItemBank.find apply.container_id
|
||||
end
|
||||
|
||||
def agree
|
||||
Admins::ProfessionalAuths::AgreeApplyService.call(current_apply)
|
||||
render_success_js
|
||||
end
|
||||
|
||||
def refuse
|
||||
Admins::ProfessionalAuths::RefuseApplyService.call(current_apply, params)
|
||||
|
||||
render_success_js
|
||||
end
|
||||
|
||||
def batch_agree
|
||||
ApplyUserAuthentication.professional_auth.where(id: params[:ids]).each do |apply|
|
||||
begin
|
||||
Admins::ProfessionalAuths::AgreeApplyService.call(apply)
|
||||
rescue => e
|
||||
Util.logger_error(e)
|
||||
end
|
||||
end
|
||||
|
||||
render_ok
|
||||
end
|
||||
|
||||
def revoke
|
||||
Admins::ProfessionalAuths::RevokeApplyService.call(current_apply)
|
||||
render_success_js
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_apply
|
||||
@_current_apply ||= ApplyUserAuthentication.professional_auth.find(params[:id])
|
||||
end
|
||||
end
|
@ -0,0 +1,34 @@
|
||||
class Admins::ApplyItemBankQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :params
|
||||
|
||||
sort_columns :updated_at, default_by: :updated_at, default_direction: :desc
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
applies = ApplyAction.where(container_type: params[:type].presence || "ItemBank")
|
||||
|
||||
status =
|
||||
case params[:status]
|
||||
when 'pending' then 0
|
||||
when 'processed' then [1, 2]
|
||||
when 'agreed' then 1
|
||||
when 'refused' then 2
|
||||
else 0
|
||||
end
|
||||
applies = applies.where(status: status) if status.present?
|
||||
|
||||
# 关键字模糊查询
|
||||
keyword = params[:keyword].to_s.strip
|
||||
if keyword.present?
|
||||
applies = applies.joins(user: { user_extension: :school })
|
||||
.where('CONCAT(lastname,firstname) LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%")
|
||||
end
|
||||
|
||||
custom_sort(applies, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
@ -0,0 +1,30 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('题库审批') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container flex-column mb-0 pb-0 item-authentication-list-form">
|
||||
<ul class="nav nav-tabs w-100 search-form-tabs">
|
||||
<li class="nav-item">
|
||||
<%= link_to '待审批', admins_item_authentications_path(status: :pending), remote: true, 'data-value': 'pending',
|
||||
class: "nav-link search-form-tab #{params[:status] == 'pending' ? 'active' : ''}" %>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<%= link_to '已审批', admins_item_authentications_path(status: :processed), remote: true, 'data-value': 'processed',
|
||||
class: "nav-link search-form-tab #{params[:status] != 'pending' ? 'active' : ''}" %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<%= form_tag(admins_item_authentications_path(unsafe_params), method: :get, class: 'form-inline search-form justify-content-end mt-3', remote: true) do %>
|
||||
<div class="form-group status-filter" style="<%= params[:status] != 'pending' ? '' : 'display: none;' %>">
|
||||
<label for="status">审核状态:</label>
|
||||
<% status_options = [['全部', 'processed'], ['已同意', 'agreed'], ['已拒绝', 'refused']] %>
|
||||
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
|
||||
</div>
|
||||
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '姓名/学校/单位检索') %>
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box admin-list-container item-authentication-list-container">
|
||||
<%= render(partial: 'admins/item_authentications/shared/list', locals: { applies: @applies }) %>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
$('.item-authentication-list-container').html("<%= j( render partial: 'admins/item_authentications/shared/list', locals: { applies: @applies } ) %>");
|
@ -0,0 +1,58 @@
|
||||
<% is_processed = params[:status].to_s != 'pending' %>
|
||||
<table class="table table-hover text-center professional-authentication-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="4%">序号</th>
|
||||
<th width="8%">头像</th>
|
||||
<th width="14%">创建者</th>
|
||||
<th width="10%">学校</th>
|
||||
<th width="24%">试题</th>
|
||||
<th width="8%">题型</th>
|
||||
<th width="16%">提交时间</th>
|
||||
<% if !is_processed %>
|
||||
<th width="16%">操作</th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if applies.present? %>
|
||||
<% applies.each_with_index do |apply, index| %>
|
||||
<% user = apply.user %>
|
||||
<% item = ItemBank.find apply.container_id %>
|
||||
<tr class="item-authentication-item item-authentication-<%= apply.id %>">
|
||||
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
||||
<td>
|
||||
<%= link_to "/users/#{user.login}", class: 'item-authentication-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %>
|
||||
<img src="/images/<%= url_to_avatar(user) %>" class="rounded-circle" width="40" height="40" />
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= user.real_name %></td>
|
||||
<td><%= raw [user.school_name.presence, user.department_name.presence].compact.join('<br/>') %></td>
|
||||
<td>
|
||||
<% if item.item_type == "PROGRAM" %>
|
||||
<%= link_to item.name, "/questions/#{item.identifier}", target: "_blank" %>
|
||||
<% else %>
|
||||
<%= link_to item.name, admins_item_authentication_path(apply), remote: true %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= item.type_string %></td>
|
||||
|
||||
<td><%= apply.updated_at.strftime('%Y-%m-%d %H:%M') %></td>
|
||||
|
||||
<td class="action-container">
|
||||
<%= agree_link '同意', agree_admins_item_authentication_path(apply, element: ".item-authentication-#{apply.id}"), 'data-confirm': '确认审核通过?', 'data-disable-with': "提交中..." %>
|
||||
<%= javascript_void_link('拒绝', class: 'action refuse-action',
|
||||
data: {
|
||||
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id,
|
||||
url: refuse_admins_item_authentication_path(apply, element: ".item-authentication-#{apply.id}")
|
||||
}, 'data-disable-with': "拒绝中...") %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in new issue