提供超级管理员的检索导出功能
This commit is contained in:
parent
9161d4c065
commit
cd6d56059f
|
|
@ -688,11 +688,11 @@ end
|
|||
end
|
||||
@search = params[:search] # 搜索字
|
||||
@keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索
|
||||
status = params[:status].to_i
|
||||
courselist = params[:course_list]
|
||||
@status = params[:status]
|
||||
@courselist = params[:course_list]
|
||||
@school_id = params[:school_id]
|
||||
|
||||
if params[:school_id] && params[:school_id] != ''
|
||||
@school_id = params[:school_id]
|
||||
@courses = Course.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id").where("ue.school_id = #{params[:school_id]}")
|
||||
end
|
||||
|
||||
|
|
@ -701,12 +701,11 @@ end
|
|||
end
|
||||
|
||||
if params[:course_list] && params[:course_list] != ''
|
||||
@courses = @courses.where(:course_list_id => courselist)
|
||||
@courses = @courses.where(:course_list_id => @courselist)
|
||||
end
|
||||
|
||||
if params[:status] && params[:status]!=''
|
||||
@status = params[:status]
|
||||
@courses =@courses.where(:is_end =>status)
|
||||
@courses =@courses.where(:is_end => @status.to_i)
|
||||
end
|
||||
if "u_name" == @keyword
|
||||
if @search.blank?
|
||||
|
|
@ -719,6 +718,7 @@ end
|
|||
@courses= @courses.where("name like '%#{@search}%'")
|
||||
end
|
||||
@courses = @courses.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").reorder("updatetime #{@sx_order}")
|
||||
@export_courses = @courses
|
||||
@courses_count = @courses.count
|
||||
limit = 20
|
||||
@is_remote = true
|
||||
|
|
@ -728,6 +728,11 @@ end
|
|||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
format.xls{
|
||||
@export_courses = @export_courses.all
|
||||
filename = "#{l(:label_course_list_xls)}.xls"
|
||||
send_data(course_list_xls(@export_courses), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1379,28 +1384,29 @@ end
|
|||
render_404
|
||||
end
|
||||
|
||||
def course_list_xls course
|
||||
def course_list_xls courses
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
sheet1 = book.create_worksheet :name => "course"
|
||||
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
||||
sheet1.row(0).default_format = blue
|
||||
sheet1.row(0).concat([l(:issue_xls_id),l(:issue_xls_tracker_id),l(:issue_xls_title),l(:issue_xls_description),l(:issue_xls_status),l(:issue_xls_assign),l(:issue_xls_priority),l(:issue_xls_author),l(:issue_xls_created_at),l(:milestone),l(:issue_xls_start),l(:issue_xls_due),l(:issue_xls_ratio)])
|
||||
sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","私有","状态","创建者单位","创建者","动态时间"])
|
||||
count_row = 1
|
||||
issues.each do |issue|
|
||||
sheet1[count_row,0] = issue.id
|
||||
sheet1[count_row,1] = issue_tracker_change(issue.tracker_id)
|
||||
sheet1[count_row,2] = issue.subject
|
||||
sheet1[count_row,3] = (issue.description.gsub(/<\/?.*?>/,"")).html_safe
|
||||
sheet1[count_row,4] = issue_status_change(issue.status_id)
|
||||
sheet1[count_row,5] = issue.assigned_to.try(:show_name)
|
||||
sheet1[count_row,6] = issue_priority_change(issue.priority_id)
|
||||
sheet1[count_row,7] = issue.author.show_name
|
||||
sheet1[count_row,8] = issue.created_on.nil? ? issue.created_on : issue.created_on.strftime('%Y-%m-%d %H:%M:%S')
|
||||
sheet1[count_row,9] = issue.fixed_version.try(:name)
|
||||
sheet1[count_row,10] = issue.start_date.nil? ? issue.start_date : issue.start_date.strftime('%Y-%m-%d')
|
||||
sheet1[count_row,11] = issue.due_date.nil? ? issue.due_date : issue.due_date.strftime('%Y-%m-%d')
|
||||
sheet1[count_row,12] = issue_ratio_change(issue.done_ratio, issue.status_id)
|
||||
courses.each do |course|
|
||||
school = course.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : course.teacher.school_name
|
||||
teacher_name = course.teacher ? course.teacher.show_real_name : ""
|
||||
sheet1[count_row,0] = course.id
|
||||
sheet1[count_row,1] = course.name
|
||||
sheet1[count_row,2] = course.members.count
|
||||
sheet1[count_row,3] = course.attachments.count
|
||||
sheet1[count_row,4] = course.homework_commons.where(:homework_type => 1).count
|
||||
sheet1[count_row,5] = course.homework_commons.where(:homework_type => 4).count
|
||||
sheet1[count_row,6] = course.exercises.count
|
||||
sheet1[count_row,7] = course.is_public.to_i == 1 ? '否' : '是'
|
||||
sheet1[count_row,8] = course.is_end ? "已结束" : "正在进行"
|
||||
sheet1[count_row,9] = school
|
||||
sheet1[count_row,10] = teacher_name
|
||||
sheet1[count_row,11] = format_time(course.updatetime)
|
||||
count_row += 1
|
||||
end
|
||||
book.write xls_report
|
||||
|
|
|
|||
|
|
@ -34,7 +34,19 @@
|
|||
|
||||
</select>
|
||||
<input name="sx_order" type="hidden">
|
||||
<%#= link_to "导出Excel", export_excel_managements_path(:format => "xls"), :class => "task-btn task-btn-blue ml5 mt3 fr mb5 mr30" %>
|
||||
<div id="export_course_to_excel">
|
||||
<%= link_to "导出Excel",
|
||||
classroom_classment_managements_path(
|
||||
:search => @search,
|
||||
:keyword => @keyword,
|
||||
:status => @status,
|
||||
:course_list => @courselist,
|
||||
:school_id => @school_id,
|
||||
:format => "xls"
|
||||
),
|
||||
:method => "POST",
|
||||
:class => "task-btn task-btn-blue ml5 mt3 fr mb5 mr30" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="edu-con-bg01 mt15" id="managements_classroom_classment">
|
||||
|
|
|
|||
|
|
@ -1 +1,12 @@
|
|||
$("#managements_classroom_classment").html("<%= j(render :partial => "managements/classroom_classment_list") %>");
|
||||
$("#export_course_to_excel").html('<%= link_to "导出Excel",
|
||||
classroom_classment_managements_path(
|
||||
:search => @search,
|
||||
:keyword => @keyword,
|
||||
:status => @status,
|
||||
:course_list => @courselist,
|
||||
:school_id => @school_id,
|
||||
:format => "xls"
|
||||
),
|
||||
:method => "POST",
|
||||
:class => "task-btn task-btn-blue ml5 mt3 fr mb5 mr30"%>');
|
||||
Loading…
Reference in New Issue