StudentList.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /**
  2. * 学生信息
  3. */
  4. Ext.define('school.view.basic.student.StudentList', {
  5. extend: 'school.view.core.base.BasePanel',
  6. xtype: 'basic-student-studentlist',
  7. dataUrl: '/api/school/student/list',
  8. // dataUrl: 'http:/api/school/student/list',
  9. _title: '学生信息',
  10. caller: 'Student',
  11. pathKey: 'student',
  12. initComponent: function() {
  13. var me = this;
  14. Ext.apply(this, {
  15. searchField: [{
  16. xtype: 'gradecombo',
  17. name: 'stu_grade',
  18. fieldLabel: '年级',
  19. listeners: {
  20. select: function (combo, record, eOpts) {
  21. combo.up('form').getForm().findField('stu_class').setValue(null);
  22. }
  23. }
  24. }, {
  25. xtype: 'classcombo',
  26. name: 'stu_class',
  27. fieldLabel: '班级',
  28. listeners: {
  29. expand: function (combo, eOpts) {
  30. combo.store.clearFilter();
  31. var gradeCombo = combo.up('form').getForm().findField('stu_grade');
  32. var gradeName = gradeCombo.getValue();
  33. var filter = new Ext.util.Filter({
  34. property: 'clazz_grade',
  35. value: gradeName
  36. });
  37. if (!!gradeName) {
  38. combo.store.setFilters([filter]);
  39. }
  40. },
  41. select: function (combo, record, eOpts) {
  42. combo.up('form').getForm().findField('stu_grade').setValue(record.get('clazz_grade'));
  43. }
  44. }
  45. }, {
  46. xtype: 'textfield',
  47. name: 'stu_number',
  48. fieldLabel:'学号'
  49. }, {
  50. xtype: 'textfield',
  51. name: 'stu_name',
  52. fieldLabel: '姓名'
  53. }, {
  54. xtype: 'condatefield',
  55. name: 'stu_enroll_date',
  56. fieldLabel: '入学日期',
  57. columnWidth: 0.5
  58. }],
  59. gridConfig: {
  60. addTitle: '学生信息',
  61. addXtype: 'basic-student-studentdetail',
  62. idField: 'stu_id',
  63. codeField: 'stu_number',
  64. detailField: 'stu_number',
  65. dataUrl: me.dataUrl,
  66. caller: null,
  67. rootProperty: 'data.list',
  68. totalProperty: 'data.total',
  69. actionColumn: [],
  70. selModel: {
  71. checkOnly:true,
  72. type:'checkboxmodel',
  73. mode : "MULTI" ,
  74. ignoreRightMouseSelection : false
  75. },
  76. hiddenTools: false,
  77. toolBtns: [{
  78. xtype: 'button',
  79. text: '新增',
  80. handler: function() {
  81. school.util.BaseUtil.openTab('basic-student-studentdetail', '新增学生信息', 'basic-student-studentdetail-add');
  82. }
  83. }, {
  84. xtype: 'importbutton',
  85. belong: me,
  86. caller: me.caller,
  87. pathKey: me.pathKey,
  88. onSuccess: function() {
  89. //刷新界面
  90. var g = me.down('grid');
  91. g.store.loadPage(g.store.currentPage);
  92. }
  93. }, {
  94. xtype: 'button',
  95. text: '删除',
  96. handler: function() {
  97. let grid = this.up('grid'),
  98. selectedRecords = grid.getSelection();
  99. let data;
  100. data = selectedRecords.map(function(r) {
  101. return {
  102. id: r.get('stu_id')
  103. };
  104. });
  105. if(data.length == 0) {
  106. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  107. return;
  108. }
  109. grid.setLoading(true);
  110. school.util.BaseUtil.request({
  111. // url: 'http://10.1.80.47:9560/student/batchDelete',
  112. url: '/api/school/student/batchDelete',
  113. method: 'POST',
  114. params: JSON.stringify({
  115. baseDTOs: data
  116. })
  117. }).then(function(res) {
  118. grid.setLoading(false);
  119. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  120. grid.store.loadPage(grid.store.currentPage);
  121. }).catch(function(e) {
  122. grid.setLoading(false);
  123. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  124. });
  125. }
  126. }],
  127. columns : [{
  128. text: 'id',
  129. dataIndex: 'stu_id',
  130. hidden: true
  131. }, {
  132. text: '学号',
  133. dataIndex: 'stu_number',
  134. width: 150
  135. }, {
  136. text: '姓名',
  137. dataIndex: 'stu_name',
  138. width: 120
  139. }, {
  140. text: '性别',
  141. dataIndex: 'stu_sex',
  142. width: 120,
  143. renderer: function(v, m, r) {
  144. return v == 1 ? '男' : (v == 0 ? '女' : '未知');
  145. }
  146. }, {
  147. text: '年级',
  148. dataIndex: 'stu_grade',
  149. editor: {
  150. xtype: 'combobox',
  151. displayField: 'name',
  152. valueField: 'value',
  153. store: {
  154. type: 'store_grade'
  155. },
  156. queryMode: 'local'
  157. },
  158. }, {
  159. text: '班级',
  160. dataIndex: 'stu_class'
  161. }, {
  162. text: '入学日期',
  163. dataIndex: 'stu_enroll_date',
  164. xtype: 'datecolumn',
  165. format: 'Y-m-d'
  166. }, {
  167. text: '出生日期',
  168. dataIndex: 'stu_birthday',
  169. width: 120,
  170. xtype: 'datecolumn',
  171. format: 'Y-m-d'
  172. }]
  173. },
  174. });
  175. this.callParent(arguments);
  176. },
  177. refresh: function() {
  178. Ext.StoreMgr.get('store_grade').load();
  179. Ext.StoreMgr.get('store_class').load();
  180. this.items.items[0].store.load();
  181. }
  182. });