StudentList.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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: 'http://10.1.80.47:9560/student/list',
  8. dataUrl: '/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. school.util.BaseUtil.showConfirm('确认删除', '确定要删除这' + data.length + '条记录吗?')
  110. .then(function(yes) {
  111. if(yes == 'yes') {
  112. grid.setLoading(true);
  113. school.util.BaseUtil.request({
  114. // url: 'http://10.1.80.47:9560/student/batchDelete',
  115. url: '/api/school/student/batchDelete',
  116. method: 'POST',
  117. params: JSON.stringify({
  118. baseDTOs: data
  119. })
  120. }).then(function(res) {
  121. grid.setLoading(false);
  122. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  123. grid.store.loadPage(grid.store.currentPage);
  124. }).catch(function(e) {
  125. grid.setLoading(false);
  126. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  127. });
  128. }
  129. });
  130. }
  131. }],
  132. columns : [{
  133. text: 'id',
  134. dataIndex: 'stu_id',
  135. hidden: true
  136. }, {
  137. text: '学号',
  138. dataIndex: 'stu_number',
  139. width: 150
  140. }, {
  141. text: '姓名',
  142. dataIndex: 'stu_name',
  143. width: 120
  144. }, {
  145. text: '性别',
  146. dataIndex: 'stu_sex',
  147. width: 120,
  148. renderer: function(v, m, r) {
  149. return v == 1 ? '男' : (v == 0 ? '女' : '未知');
  150. }
  151. }, {
  152. text: '年级',
  153. dataIndex: 'stu_grade',
  154. editor: {
  155. xtype: 'combobox',
  156. displayField: 'name',
  157. valueField: 'value',
  158. store: {
  159. type: 'store_grade'
  160. },
  161. queryMode: 'local'
  162. },
  163. }, {
  164. text: '班级',
  165. dataIndex: 'stu_class'
  166. }, {
  167. text: '入学日期',
  168. dataIndex: 'stu_enroll_date',
  169. xtype: 'datecolumn',
  170. format: 'Y-m-d'
  171. }, {
  172. text: '出生日期',
  173. dataIndex: 'stu_birthday',
  174. width: 120,
  175. xtype: 'datecolumn',
  176. format: 'Y-m-d'
  177. }, {
  178. text: '校园通卡号',
  179. dataIndex: 'stu_cardNo'
  180. }]
  181. },
  182. });
  183. this.callParent(arguments);
  184. },
  185. refresh: function() {
  186. Ext.StoreMgr.get('store_grade').load();
  187. Ext.StoreMgr.get('store_class').load();
  188. this.items.items[0].store.load();
  189. }
  190. });