Skip to content

Commit

Permalink
添加打印功能
Browse files Browse the repository at this point in the history
  • Loading branch information
mouse-lin committed Mar 23, 2012
1 parent b568303 commit 10c9108
Show file tree
Hide file tree
Showing 173 changed files with 6,839 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/controllers/students_controller.rb
@@ -1,4 +1,5 @@
class StudentsController < ApplicationController
layout"application", :except => [ :print ]
#获取学生信息
def get_all_students
students = Student.all.collect &fields_provider
Expand Down Expand Up @@ -40,4 +41,8 @@ def update_student
rescue => e
render_error e.message,'text/html'
end

def print
@student = Student.find(params[:id])
end
end
5 changes: 5 additions & 0 deletions app/helpers/application_helper.rb
@@ -1,2 +1,7 @@
module ApplicationHelper
def blank(n)
result = ""
n.times { result += '&nbsp;' }
result.html_safe
end
end
37 changes: 37 additions & 0 deletions app/views/students/print.html.erb
@@ -0,0 +1,37 @@
<%= kindeditor_javacript_include_tag%>
<textarea id="kindeditor" rows="28" cols="95" >
<table style="width:100%;" cellpadding="1" cellspacing="2" border="1" bordercolor="#CCCCCC">
<tbody>
<tr>
<td width=50>&nbsp;<%= image_tag @student.image.url(:thumb) %></td>
<td><p>&nbsp;姓名:<%=@student.name%> </p></td>
</tr>
<tr>
<td>&nbsp;学号:</td>
<td>&nbsp;<%=@student.number%></td>
</tr>
<tr>
<td><p>&nbsp;性别:</p>
</td>
<td>&nbsp;<%=@student.sex %></td>
</tr>
<tr>
<td>&nbsp;班级:</td>
<td>&nbsp;<%=@student.classes.name%></td>
</tr>
<tr><td>&nbsp;电话:</td>
<td>&nbsp;<%=@student.phone%></td>
</tr>
<tr><td>&nbsp;住址:</td>
<td>&nbsp;<%=@student.home%></td>
</tr>
<tr><td>&nbsp;备注:</td>
<td><p>&nbsp;<%=@student.remark%></p>
</td>
</tr>
<tr><td>评语:</td>
<td height=120>&nbsp;<%=@student.comment%></td>
</tr>
</tbody>
</table>
</textarea>
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -21,6 +21,7 @@
collection do
get "get_all_students"
get "student_total_score"
get "print"
post "destroy_student"
post "update_student"
end
Expand Down
18 changes: 16 additions & 2 deletions public/javascripts/PF/pages/home_index.js
Expand Up @@ -251,8 +251,22 @@ Pf.classes.homeIndex.MainPanel = Ext.extend(Ext.Panel, {
return form;
},

printHandler : function () {

printHandler : function() {
var record = Ext.getCmp("student-grid").getSelectionModel().getSelected();
if(record){
var url = 'students/print?id=' + record.data.id;
var win = new Ext.Window({
title: "资料打印",
width: 800,
height: 500,
resizable: false,
modal: true,
constrain: true,
items: { html:'<iframe src='+ url + " frameborder='0' width='100%' height='100%'></iframe>"}
});
win.show();
}else
Ext.Msg.alert("提示","请选择学生");
},

});
168 changes: 168 additions & 0 deletions public/javascripts/kindeditor/kindeditor-min.js

Large diffs are not rendered by default.

0 comments on commit 10c9108

Please sign in to comment.