diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb
index 7a8e6495..4d249508 100644
--- a/app/controllers/managements_controller.rb
+++ b/app/controllers/managements_controller.rb
@@ -791,7 +791,14 @@ class ManagementsController < ApplicationController
def shixun_feedback_message
@menu_type = 8
@sub_type = 2
- @discusses = Discuss.where(:dis_type => "Shixun").reorder("created_at desc")
+ @search = params[:search]
+ if @search.present?
+ shixun_ids = Shixun.where("name like ?", "%#{params[:search]}%").pluck(:id)
+ @discusses = Discuss.where(:dis_type => "Shixun", :dis_id => shixun_ids).reorder("created_at desc")
+ else
+ @discusses = Discuss.where(:dis_type => "Shixun").reorder("created_at desc")
+ end
+ @all_discusses = @discusses
@discusses_count = @discusses.count
@limit = 20
@is_remote = true
@@ -802,6 +809,11 @@ class ManagementsController < ApplicationController
respond_to do |format|
format.js
format.html
+ format.xls{
+ shixun_ids = @all_discusses.pluck(:dis_id).uniq
+ filename = "#{Time.now.strftime("%Y%m%d")}-实训反馈.xls"
+ send_data(shixun_feedback_xls(shixun_ids), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
+ }
end
end
@@ -4045,6 +4057,39 @@ end
return sheet.rows
end
+ def shixun_feedback_xls shixun_ids
+ xls_report = StringIO.new
+ book = Spreadsheet::Workbook.new
+ sheet1 = book.create_worksheet :name => "报名列表"
+ blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
+ sheet1.row(0).default_format = blue
+ count_row = 1
+ shixuns = Shixun.where(:id => shixun_ids).includes(discusses: [:user])
+ sheet1.row(0).concat(["序号", "实训ID", "实训名称","评论数", "评论内容", "关卡", "评论者", "评论者职业",
+ "评论者单位", "评论时间", "社区导师是否已回复"])
+ shixuns.each_with_index do |shixun, i|
+ discusses = shixun.discusses.where("user_id != ?", 1)
+ sheet1[count_row, 0] = i + 1
+ sheet1[count_row, 1] = shixun.identifier
+ sheet1[count_row, 2] = shixun.name
+ sheet1[count_row, 3] = discusses.count
+ discusses.each_with_index do |discuss, j|
+ user = discuss.user
+ sheet1[count_row, 4] = discuss.content.gsub(/