导致实训

chromesetting
daiao 5 years ago
parent be6971b1dd
commit fde2ad7f2f

@ -12,6 +12,11 @@ $(document).on('turbolinks:load', function() {
window.location.href = "/admins/shixun_settings.xls?" + searchForm.serialize();
});
// 基础数据导出
searchContainer.on('click', "#shixun-settings-base-export", function () {
window.location.href = "/admins/shixun_settings.xls?base_data=1" + searchForm.serialize();
});
$(".shixun-settings-list-container").on("change", '.shixun-setting-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();

@ -53,3 +53,8 @@ input.form-control {
position: absolute;
}
.export-base-absolute{
right:100px;
position: absolute;
}

@ -28,7 +28,13 @@ class Admins::ShixunSettingsController < Admins::BaseController
format.html
format.xls{
filename = "实训详情_#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}.xls"
send_data(shixun_list_xls(shixun_settings), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
export_url =
if params[:base_data].present?
shixun_base_list_xls(shixun_settings)
else
shixun_list_xls(shixun_settings)
end
send_data(export_url, :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
end
@ -91,6 +97,34 @@ class Admins::ShixunSettingsController < Admins::BaseController
xls_report.string
end
def shixun_base_list_xls shixuns
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "sheet"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
sheet1.row(0).concat(["实训ID","实训名称","技术平台", "Fork源", "状态","创建者", "单位", "职业", "关卡序号","关卡名称"])
count_row = 1
shixuns.includes(:mirror_repositories, :challenges, user: [user_extension: :school]).find_each do |shixun|
sheet1[count_row, 0] = shixun.identifier
sheet1[count_row, 1] = shixun.name
sheet1[count_row, 2] = shixun.mirror_repositories.select{|mr| mr.main_type == "1"}.first&.type_name
sheet1[count_row, 3] = shixun.fork_from
sheet1[count_row, 4] = shixun.shixun_status
sheet1[count_row, 5] = shixun.user.show_real_name
sheet1[count_row, 6] = shixun.user.school_name
sheet1[count_row, 7] = shixun.user.identity
shixun.challenges.each do |challenge|
sheet1[count_row, 8] = "#{challenge.position}"
sheet1[count_row, 9] = challenge.subject
count_row += 1
end
count_row += 1
end
book.write xls_report
xls_report.string
end
def setting_params
params.permit(:use_scope,:excute_time,:close,:status,:can_copy,:webssh,:hidden,:homepage_show,:task_pass,:code_hidden,:page_no, :id,tag_repertoires:[])
end

@ -24,6 +24,7 @@
<%= submit_tag('搜索', class: 'btn btn-primary ml-3','data-disable-with': '搜索中...') %>
<%= link_to "清除",admins_shixun_settings_path,class: "btn btn-default",'data-disable-with': '清除中...' %>
<div class="">
<a href="javascript:void(0)" class="btn btn-primary export-base-absolute" id="shixun-settings-base-export" data-disable-with = '导出中...'>导出基础数据</a>
<a href="javascript:void(0)" class="btn btn-primary export-absolute" id="shixun-settings-export" data-disable-with = '导出中...'>导出</a>
</div>
</div>

Loading…
Cancel
Save