/
home_index.js
228 lines (216 loc) · 7.65 KB
/
home_index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
Ext.ns("Pf.classes.homeIndex");
Pf.classes.homeIndex.MainPanel = Ext.extend(Ext.Panel, {
autoScroll : true,
layout : 'border',
region : 'center',
initComponent : function () {
this.addDefaultComponents();
Pf.classes.homeIndex.MainPanel.superclass.initComponent.call(this);
},
addDefaultComponents : function(){
this.grid = this.createGrid();
this.form = this.createForm();
this.items = [this.grid,{
title : '学生详细信息',
region : "center",
layout : 'fit',
tbar : new Ext.Toolbar({
id : 'form-tbar',
items : [
{ id : 'update-btn', text: '打印', handler: Pf.util.scope(this.printHandler,this), icon : Pf.Icon.Print },
]
}),
items : [ this.form ]
}];
},
createGrid : function() {
var scope = this;
var store = new Pf.util.FieldsJsonStore({
root : 'root',
url : '/homes/get_classes_students.json',
fields : [
"id",
'name',
'number',
'phone',
'home',
'remark' ,
'sex',
'classes/name',
'comment',
'image/url',
'grade'
]
});
var cm = new Ext.grid.ColumnModel({
columns: [
{ header: '学号' , dataIndex: 'number' },
{ header: '姓名' , dataIndex: 'name' },
],
defaults: { menuDisabled : true, sortable : true }
});
var classCombox = new Ext.form.ComboBox({
triggerAction : 'all',
displayField : 'name',
mode : 'remote',
autoSelect : true,
width : 180,
forceSelection : true,
emptyText : '请选择班级',
store : new Pf.util.FieldsJsonStore({
url : '/homes/get_classes.json',
fields : ["id", "name"],
autoLoad: false
}),
listeners : {
select : function(combo, record, index) {
var store = Ext.getCmp("student-grid").getStore();
store.removeAll();
store.setBaseParam("c_id", record.get("id"));
store.load();
}
}
});
var grid = new Ext.grid.EditorGridPanel({
id : 'student-grid',
store: store,
cm : cm,
border: false,
containerScroll: true,
loadMask : true,
width: 200,
region: 'west',
split: true,
title : "学生列表",
stripeRows: true,
viewConfig: { forceFit: true },
tbar: new Ext.Toolbar({
layout : 'form',
labelWidth : 1,
items : ['班级:',classCombox, '学号查询:',new Ext.ux.form.SearchField({ emptyText : '请输入学号' ,store: store, width: 180 }) ]
}),
sm : new Ext.grid.RowSelectionModel({
listeners : {
rowselect : function (model, row, record) {
//加载成绩
var s_id = record.get("id");
var scoreGridStore = Ext.getCmp('score-grid').getStore();
scoreGridStore.load({ params : { s_id : s_id } });
//显示详细
var form = scope.form.getForm()
form.reset();
form.loadRecord(record);
//加载头像
//$("#image img").attr("src", record.get('image/url'));
}
}
}),
listeners: { }
});
return grid;
},
createForm : function() {
var store = new Pf.util.FieldsJsonStore({
root : 'root',
url : '/homes/student_score.json',
fields : ['course/name','grade','score','remark','score_type']
});
var cm = new Ext.grid.ColumnModel({
columns: [
{ header: '科目' , dataIndex: 'course/name', width : 50 },
{ header: '学期' , dataIndex: 'grade',width : 50 },
{ header: '成绩' , dataIndex: 'score', width : 50 },
{ header: '成绩评级' , dataIndex: 'score_type', width : 50 },
{ header: '备注' , dataIndex: 'remark' },
],
defaults: { menuDisabled : true, sortable : true }
});
var grid = new Ext.grid.EditorGridPanel({
id : 'score-grid',
store: store,
loadMask :true,
cm : cm,
height : 200,
sm : new Ext.grid.RowSelectionModel({}),
title : "学生成绩",
stripeRows: true,
viewConfig: { forceFit: true },
});
var form = new Ext.FormPanel({
region : 'center',
frame : true,
autoScroll : true,
labelWidth: 60,
labelAlign : 'right',
bodyStyle: 'padding:5px 5px 0',
items: [{
layout: 'column',
items: [{
width : 150,
layout: 'fit',
items: [new Ext.form.FieldSet({
title : '头像',
layout : 'fit',
height : 130,
items :[{
html : '<span id="image"><img src="/images/Temp.png" height=110px width=120px alt="图片" /></span>'
}]
})]
}, {
defaults : { anchor : '95%', readOnly : true },
defaultType : 'textfield',
columnWidth: .25,
layout: 'form',
items: [{
fieldLabel: '学号',
name: 'number',
},{
fieldLabel: '姓名',
name: 'name',
},{
fieldLabel: '性别',
name: 'sex',
}, {
fieldLabel: '班级',
name: 'classes/name',
}, {
fieldLabel: '评级',
name: 'grade',
}]
},{
defaults : { anchor : '95%' ,readOnly : true},
defaultType : 'textfield',
columnWidth: .45,
layout: 'form',
items: [ {
fieldLabel: '电话',
name: 'phone',
}, {
fieldLabel: '住址',
name: 'home',
}, {
xtype : 'textarea',
fieldLabel: '备注',
name: 'remark',
height : 80
}]
}]
},new Ext.form.FieldSet({
title : '评语',
layout : 'fit',
items : [{
xtype: 'textarea',
name : 'comment',
height: 150,
readOnly : true,
anchor: '98%'
}]
}),
grid
]
});
return form;
},
printHandler : function () {
},
});