Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

添加评语设置界面

  • Loading branch information...
commit 56656f6f10b6b422500a5c98cab8a184c2f6e0cf 1 parent 8724400
@mouse-lin authored
View
30 app/controllers/settings_controller.rb
@@ -31,7 +31,7 @@ def destroy_course
render_json "success"
end
- #保存更新班级科目信息
+ #保存更新班级科目信息 | 评语类别、评语 添加更新
def ajax_request
if params[:action_type] == "create"
params[:object_type].constantize.create(params[:form_data])
@@ -41,4 +41,32 @@ def ajax_request
render_json "success"
end
+ def comment
+ respond_to do |wants|
+ wants.html
+ wants.json do
+ comments = Comment.all.collect &fields_provider
+ render_json comments
+ end
+ end
+ end
+
+ def comment_type
+ if fields_provider
+ comment_types = CommentType.all.collect &fields_provider
+ else
+ comment_types = CommentType.all
+ end
+ render_json comment_types
+ end
+
+ def destroy_comment
+ Comment.find(params[:id]).delete
+ render_json "success"
+ end
+
+ def destroy_comment_type
+ CommentType.find(params[:id]).delete
+ render_json "success"
+ end
end
View
2  app/views/layouts/application.html.erb
@@ -55,7 +55,7 @@
<a class="dock-item2" href="#"><span>Music</span><img src="../images/music.png" alt="music" /></a>
<a class="dock-item2" href="#"><span>Video</span><img src="../images/video.png" alt="video" /></a>
<a class="dock-item2" href="#"><span>History</span><img src="../images/history.png" alt="history" /></a>
- <a class="dock-item2" href="#"><span>Calendar</span><img src="/images/calendar.png" alt="calendar" /></a>
+ <a class="dock-item2" href="/settings/comment"><span>评语设置</span><img src="/images/calendar.png" alt="calendar" /></a>
<a class="dock-item2" href="/settings/classes"><span>班别科目主档</span><img src="/images/link.png" alt="links" /></a>
<a class="dock-item2" href="/settings"><span>主档设置</span><img src="/images/rss.png" alt="rss" /></a>
<a class="dock-item2" href="logout"><span>退出</span><img src="/images/rss2.png" alt="rss" /></a>
View
6 app/views/settings/comment.html.erb
@@ -0,0 +1,6 @@
+<%= javascript_include_tag '/javascripts/PF/pages/comment.js' %>
+<script language="javascript" type="text/javascript">
+ Ext.onReady(function() {
+ Pf.pages.currentInstance = Pf.settings.comment.panel();
+ });
+</script>
View
4 config/routes.rb
@@ -21,8 +21,12 @@
get "index"
get "classes"
get "get_course"
+ get "comment"
+ get "comment_type"
post "destroy_classes"
post "destroy_course"
+ post "destroy_comment"
+ post "destroy_comment_type"
post "ajax_request"
end
end
View
354 public/javascripts/PF/pages/comment.js
@@ -0,0 +1,354 @@
+Pf.settings.comment = {
+ panel: function(){
+ var _this = this;
+ var commentTypeGrid = this.createcommentTypeGrid();
+ var commentTypeFormPanel = this.createCommentTypeFormPanel();
+ var commentGrid = this.createCommentGrid();
+ var commentPanel = this.createCommentFormPanel();
+
+ commentTypeGrid.on('cellclick', function(grid, rowIndex){
+ var record = commentTypeGrid.store.getAt(rowIndex);
+ commentTypeFormPanel.getForm().loadRecord(record);
+ });
+
+ commentGrid.on('cellclick', function(grid, rowIndex){
+ var record = commentGrid.store.getAt(rowIndex);
+ commentPanel.getForm().loadRecord(record);
+ });
+
+ commentTypeGrid.store.load();
+ commentGrid.store.load();
+
+ var panel = new Ext.Panel({
+ title: "评语设置",
+ autoScroll: true,
+ layout: "border",
+ items: [
+ {
+ region: "center",
+ layout: "border",
+ items:[{
+ region: "center",
+ layout: "border",
+ items: [commentTypeGrid]
+ },{
+ region: "east",
+ layout: "border",
+ tbar:[{ text:"添加", iconCls: "add", handler: function(){
+ Ext.Msg.confirm('提示', "是否确定保存?", function(button){
+ if(button != "no"){
+ if(Ext.getCmp("commentTypeName").getValue() != "")
+ {
+ _this.ajaxRequest("CommentType","create");
+ }
+ else
+ Ext.Msg.alert("提示","评语类别名称不能为空!")
+ }
+ })
+ }}],
+ width: 350,
+ items: [commentTypeFormPanel]
+ }]
+ },{
+ region: "south",
+ layout: "border",
+ height: 320,
+ items: [{
+ region: "center",
+ layout: "border",
+ items: [commentGrid]
+ },{
+ region: "east",
+ layout: "border",
+ tbar:[{ text: "添加", iconCls: "add", handler: function(){
+ Ext.Msg.confirm('提示', "是否确定保存?", function(button){
+ if(button != "no"){
+ if(Ext.getCmp("commentContent").getValue() != "")
+ {
+ _this.ajaxRequest("Comment","create");
+ }
+ else
+ Ext.Msg.alert("提示","评语内容不能为空!")
+ }
+ })
+ }}],
+ width: 350,
+ items: [commentPanel]
+ }]
+ }]
+ })
+ return panel;
+ },
+
+ ajaxRequest: function(objectType,action,id){
+ if(!id)
+ id = "null";
+ var formName = objectType == "CommentType" ? "commentTypeFormPanel" : "commentPanel";
+ var formData = Ext.getCmp(formName).getForm().getValues();
+ var data = { object_type: objectType, action_type: action, form_data: formData, id: id}
+ Ext.Ajax.request({
+ url: "/settings/ajax_request.json",
+ method: "POST",
+ jsonData: data ,
+ success: function(response, opts){
+ objectType == "CommentType" ? Ext.getCmp("commentTypeGrid").store.reload(): Ext.getCmp("commentGrid").store.reload();
+ Ext.Msg.alert("提示","保存成功");
+ },
+ failure: function(response, opts){
+ Ext.Msg.alert("提示","保存失败");
+ }
+ })
+ },
+
+ createCommentFormPanel: function(){
+ var _this = this;
+ var commentTypeCombox = new Ext.form.ComboBox({
+ hiddenName: "comment_type_id",
+ fieldLabel: " 评语类别",
+ triggerAction : 'all',
+ displayField : 'name',
+ valueField: 'id',
+ mode : 'remote',
+ width : 180,
+ editable: false,
+ forceSelection : true,
+ emptyText : '请选择评语类别',
+ store : new Pf.util.FieldsJsonStore({
+ url : '/settings/comment_type.json',
+ fields : ["id", "name"],
+ autoLoad: true
+ }),
+ });
+
+ var panel = new Ext.form.FormPanel({
+ region: "center",
+ id: "commentPanel",
+ autoScroll : true,
+ frame: true,
+ buttonAlign: "center",
+ bodyStyle: 'padding:40px 10px',
+ buttons: [{
+ text: "更新", handler: function(){
+ var grid = Ext.getCmp("commentGrid");
+ var record = grid.getSelectionModel().getSelected();
+ if(!record){ Ext.Msg.alert("提示","请选择评语") }
+ else{
+ Ext.Msg.confirm("提示","是否确定保存更改",function(button){
+ if(button != "no"){
+ _this.ajaxRequest("Comment","update",record.id);
+ }
+ })
+ };
+ }
+ },{
+ text: "重置", handler: function(){ Ext.getCmp("commentPanel").getForm().reset() }
+ }],
+ items: [{
+ layout: "column",
+ items:[{
+ defaults: { anchor: "95%" },
+ columnWidth: 1,
+ labelWidth: 70,
+ defaultType: "textfield",
+ layout: "form",
+ items:[{
+ fieldLabel: "评语内容",
+ name: "content",
+ id: "commentContent",
+ allowBlank: false,
+ },
+ commentTypeCombox,
+ {
+ fieldLabel: "备注",
+ name: "remark",
+ xtype: "textarea",
+ }]
+ }]
+ }]
+ });
+ return panel;
+ },
+
+ createCommentGrid: function(){
+ var commentGridStore = new Pf.util.FieldsJsonStore({
+ fields: [
+ "id",
+ "content",
+ "remark",
+ "created_at",
+ "updated_at",
+ "comment_type/name",
+ "comment_type_id",
+ ],
+ root: 'root',
+ url: '/settings/comment.json',
+ totalProperty:'total',
+ method:'GET',
+ });
+
+ var cm = new Ext.grid.ColumnModel([
+ new Ext.grid.RowNumberer(),
+ { header: '评语内容', sortable: true, dataIndex: 'content'},
+ { header: '评语类别', sortable: true, dataIndex: 'comment_type/name'},
+ { header: '备注', sortable: true, dataIndex: 'remark'},
+ { header: '创建时间', sortable: true, dataIndex: 'created_at'},
+ { header: '更新时间', sortable: true, dataIndex: 'updated_at'},
+ ]);
+
+ var tbar = [
+ { iconCls: 'delete', text: '删除', handler: function(){
+ var grid = Ext.getCmp("commentGrid");
+ var record = grid.getSelectionModel().getSelected();
+ if(!record){ Ext.Msg.alert("提示","请选择评语") }
+ else{
+ Ext.Msg.confirm('提示', "是否确定删除?", function(button){
+ if(button != "no"){
+ Pf.util.loadMask.show();
+ Ext.Ajax.request({
+ url: "/settings/destroy_comment.json",
+ method: "POST",
+ jsonData: { id: record.id } ,
+ success: function(response, opts){
+ Pf.util.callback.success();
+ Ext.Msg.alert("提示","删除成功");
+ grid.store.reload();
+ },
+ failure: function(response, opts){
+ Pf.util.callback.failure();
+ }
+ })
+ }
+ })
+ }
+ }},
+ ];
+
+ var commentGrid = new Ext.grid.EditorGridPanel({
+ loadMask: true,
+ id: "commentGrid",
+ sm: new Ext.grid.RowSelectionModel({
+ singleSelect: true
+ }),
+ viewConfig: { forceFit: true },
+ store: commentGridStore,
+ region: "center",
+ cm: cm,
+ tbar: tbar,
+ bbar: new Pf.util.Bbar({ store: commentGridStore })
+ });
+ return commentGrid;
+ },
+
+ createCommentTypeFormPanel: function(){
+ var _this = this;
+ var panel = new Ext.form.FormPanel({
+ region: "center",
+ id: "commentTypeFormPanel",
+ autoScroll : true,
+ frame: true,
+ buttonAlign: "center",
+ bodyStyle: 'padding:40px 10px',
+ buttons: [{
+ text: "更新", handler: function(){
+ var grid = Ext.getCmp("commentTypeGrid");
+ var record = grid.getSelectionModel().getSelected();
+ if(!record){ Ext.Msg.alert("提示","请选择评语类别") }
+ else{
+ Ext.Msg.confirm("提示","是否确定保存更改",function(button){
+ if(button != "no"){
+ _this.ajaxRequest("CommentType","update",record.id);
+ }
+ })
+ };
+ }
+ },{
+ text: "重置", handler: function(){ Ext.getCmp("commentTypeFormPanel").getForm().reset() }
+ }],
+ items: [{
+ layout: "column",
+ items:[{
+ defaults: { anchor: "95%" },
+ columnWidth: 1,
+ labelWidth: 50,
+ defaultType: "textfield",
+ layout: "form",
+ items:[{
+ fieldLabel: "名称",
+ name: "name",
+ id: "commentTypeName",
+ allowBlank: false,
+ },{
+ fieldLabel: "备注",
+ name: "remark",
+ xtype: "textarea",
+ }]
+ }]
+ }]
+ });
+ return panel;
+ },
+
+ createcommentTypeGrid: function(){
+ var commentTypeGridStore = new Pf.util.FieldsJsonStore({
+ fields: [
+ "name",
+ "id",
+ "created_at",
+ "updated_at",
+ "remark",
+ ],
+ root: 'root',
+ url: '/settings/comment_type.json',
+ totalProperty:'total',
+ method:'GET',
+ });
+ var cm = new Ext.grid.ColumnModel([
+ new Ext.grid.RowNumberer(),
+ { header: '类别名称', sortable: true, dataIndex: 'name'},
+ { header: '备注', sortable: true, dataIndex: 'remark'},
+ { header: '创建时间', sortable: true, dataIndex: 'created_at'},
+ { header: '更新时间', sortable: true, dataIndex: 'updated_at'},
+ ]);
+ var tbar = [
+ { iconCls: 'delete', text: '删除', handler: function(){
+ var grid = Ext.getCmp("commentTypeGrid");
+ var record = grid.getSelectionModel().getSelected();
+ if(!record){ Ext.Msg.alert("提示","请选择评语类别") }
+ else{
+ Ext.Msg.confirm('提示', "是否确定删除?", function(button){
+ if(button != "no"){
+ Pf.util.loadMask.show();
+ Ext.Ajax.request({
+ url: "/settings/destroy_comment_type.json",
+ method: "POST",
+ jsonData: { id: record.id } ,
+ success: function(response, opts){
+ Pf.util.callback.success();
+ Ext.Msg.alert("提示","删除成功");
+ grid.store.reload();
+ },
+ failure: function(response, opts){
+ Pf.util.callback.failure();
+ }
+ })
+ }
+ })
+ }
+ }},
+ ];
+ var commentTypeGrid = new Ext.grid.EditorGridPanel({
+ loadMask: true,
+ id: "commentTypeGrid",
+ sm: new Ext.grid.RowSelectionModel({
+ singleSelect: true
+ }),
+ region: "center",
+ viewConfig: { forceFit: true },
+ store: commentTypeGridStore,
+ cm: cm,
+ tbar: tbar,
+ bbar: new Pf.util.Bbar({ store: commentTypeGridStore })
+ });
+ return commentTypeGrid;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.