Merge branches 'dev_aliyun' and 'ysm1' of https://bdgit.educoder.net/Hjqreturn/educoder into ysm1

problem_set
杨树明 5 years ago
commit 6acc599eb9

@ -3,7 +3,7 @@ $(document).on('turbolinks:load', function() {
let search_form = $(".search-form");
//导出
$(".competition-enroll-list-form").on("click","#enroll-lists-export",function () {
window.location.href = "/admins/competitions/"+$(this).attr("data-competition-id")+"/enroll_lists.xls?" + search_form.serialize();
window.location.href = "/admins/competitions/"+$(this).attr("data-competition-id")+"/enroll_lists/export.xlsx?" + search_form.serialize();
});
}
});

@ -22,7 +22,9 @@ class Admins::EnrollListsController < Admins::BaseController
def export
default_sort('created_at', 'desc')
@enroll_lists = Admins::CompetitionEnrollListQuery.call(current_competition, params)
@enroll_lists = @enroll_lists.preload(competition_team: [:user, :teachers], user: { user_extension: :school })
@competition_scores = current_competition.competition_scores.where(competition_stage_id: 0).order("score desc, cost_time desc").pluck(:competition_team_id)
@personal = current_competition.personal?
filename = ["#{current_competition.name}竞赛报名列表", Time.zone.now.strftime('%Y-%m-%d%H:%M:%S')].join('-') << '.xlsx'
render xlsx: 'export', filename: filename
end

@ -106,13 +106,8 @@ class Competitions::CompetitionsController < Competitions::BaseController
@stage = @competition.competition_stages.find_by(id: params[:stage_id])
end
if @competition.identifier == "gcc-annotation-2018"
@records = @competition.competition_teams.joins(:competition_scores)
.select("competition_teams.*, score, cost_time").order("score desc, cost_time desc")
else
@records = @competition.competition_teams.joins(:competition_scores).where(competition_scores: {competition_stage_id: @stage&.id.to_i})
.select("competition_teams.*, score, cost_time").order("score desc, cost_time desc")
end
@records = @competition.competition_teams.joins(:competition_scores).where(competition_scores: {competition_stage_id: @stage&.id.to_i})
.select("competition_teams.*, score, cost_time").order("score desc, cost_time desc")
current_team_ids = @competition.team_members.where(user_id: current_user.id).pluck(:competition_team_id).uniq
@user_ranks = @records.select{|com_team| current_team_ids.include?(com_team.id)}

@ -0,0 +1,29 @@
wb = xlsx_package.workbook
wb.add_worksheet(name: '报名列表') do |sheet|
sheet.add_row %w(序号 战队ID 战队名称 创建者 指导老师 队员姓名 职业 手机号 邮箱 学号 实名认证 职业认证 队员学校 地区 报名时间 排名)
@enroll_lists.each_with_index do |member, index|
team = member.competition_team
member_user = member.user
rank = @competition_scores.length > 0 ? @competition_scores.index(member.competition_team_id).to_i + 1 : "--"
data = [
index + 1,
member.competition_team_id,
@personal ? "--" : team.name,
team.user.real_name,
@personal ? "--" : team.teachers_info,
member_user.real_name,
member_user.identity,
member_user.phone,
member_user.mail,
member_user.student_id,
member_user.authentication ? "√" : "",
member_user.professional_certification ? "√" : "",
member_user.school_name,
member_user.school_province,
member.created_at.strftime('%Y-%m-%d %H:%M'),
rank
]
sheet.add_row(data)
end
end

@ -24,7 +24,7 @@
<%= link_to "清除", admins_competition_enroll_lists_path(@competition), class: "btn btn-default",'data-disable-with': '清除中...' %>
<% end %>
<a href="javascript:void(0)" class="btn btn-primary mt-3" id="enroll-lists-export" data-competition-id="<%= @competition.id %>" data-disable-with = '导出中...'>导出</a>
<a href="javascript:void(0)" class="btn btn-primary mt-3" id="enroll-lists-export" data-competition-id="<%= @competition.id %>">导出</a>
</div>
</div>

@ -17,14 +17,10 @@
<% myshixuns.each do |myshixun| %>
<tr class="myshixun-item-<%= myshixun.id %>">
<td><%= myshixun.id %></td>
<td>
<td><%= myshixun.identifier %></td>
<td class="text-left">
<% current_task = myshixun.last_executable_task || myshixun.last_task %>
<%= link_to "/myshixuns/#{myshixun.identifier}/stages/#{current_task.identifier}", target: '_blank' do %>
<%= myshixun.identifier %>
<% end %>
</td>
<td class="text-left">
<%= link_to "/shixuns/#{myshixun.shixun.identifier}", target: '_blank' do %>
<%= overflow_hidden_span myshixun.shixun.name, width: 280 %>
<% end %>
</td>

@ -21,7 +21,7 @@
</div>
</div>
<%= f.input :link, as: :url, label: '跳转地址', placeholder: '请输入跳转地址' %>
<%= f.input :link, label: '跳转地址', placeholder: '请输入跳转地址' %>
<div class="error text-danger"></div>
<% end %>

@ -21,7 +21,7 @@
</div>
</div>
<%= f.input :link, as: :url, label: '跳转地址', placeholder: '请输入跳转地址' %>
<%= f.input :link, label: '跳转地址', placeholder: '请输入跳转地址' %>
<div class="error text-danger"></div>
<% end %>

@ -1023,7 +1023,9 @@ Rails.application.routes.draw do
end
resources :competition_settings, only: [:index, :update]
resources :enroll_lists, only: [:index]
resources :enroll_lists, only: [:index] do
get :export, on: :collection
end
end
resources :weapp_carousels, only: [:index, :create, :update, :destroy] do

@ -0,0 +1,7 @@
class MigrateCompetitionScoreStageId < ActiveRecord::Migration[5.2]
def change
change_column_default :competition_scores, :competition_stage_id, 0
CompetitionScore.where("competition_stage_id is null").update_all(competition_stage_id: 0)
end
end
Loading…
Cancel
Save