我的issue导出功能(未完)

This commit is contained in:
daiao 2016-11-28 15:32:02 +08:00
parent 2a768cbd49
commit 2c664dcd21
3 changed files with 11 additions and 2 deletions

View File

@ -127,6 +127,10 @@ class UsersController < ApplicationController
@issues_author_count = Issue.where("author_id =? and subject like ?", @user.id, "%#{@subject}%").count
@issue_open_count = Issue.where(" (author_id =? or assigned_to_id =?) and status_id in (1,2,3,4,6)", (author_id ? author_id : @user.id) , @user).count
@issue_close_count = Issue.where("(author_id =? or assigned_to_id =?) and status_id = 5", (author_id ? author_id : @user.id) , @user.id).count
# 导出excel的issues
@excel_issues = @issues
@issue_count = @issues.count
@limit = 10
@is_remote = true
@ -135,6 +139,10 @@ class UsersController < ApplicationController
@issues = paginateHelper @issues, @limit
respond_to do |format|
format.html{render :layout => 'static_base'}
format.xls{
filename = "我的_#{l(:label_issue_list_xls)}.xls"
send_data(issue_list_xls(@excel_issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
format.api
format.js
end

View File

@ -10,7 +10,8 @@
<div style="text-align:left;">
<div style="width:auto; display:inline-block;">
<ul>
<a href="javascript:void(0)" class="hw_btn_blue ml10 mt10 mb10" style="visibility:hidden;" alt="导出EXCEL">导出EXCEL</a>
<!-- <a href="javascript:void(0)" class="hw_btn_blue ml10 mt10 mb10" style="visibility:hidden;" alt="导出EXCEL">导出EXCEL</a>-->
<%= link_to "导出EXCEL", user_issues_user_path(:format => 'xls'), :class => "hw_btn_blue ml10 mt10 mb10" %>
</ul>
</div>

View File

@ -269,7 +269,7 @@
<p class="nodata mt10"><%= l(:label_no_data) %></p>
<% else %>
<div id="issue_list">
<%= render :partial => 'users/all_issue_list', :locals => {:issues => @issues, :issue_pages => @issue_pages,:issue_count => @issue_count, :subject => @subject } %>
<%= render :partial => 'users/all_issue_list', :locals => {:issues => @issues, :excel_issues => @excel_issues, :issue_pages => @issue_pages,:issue_count => @issue_count, :subject => @subject } %>
</div>
<% end %>
</div>