List.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /**
  2. * 课程表
  3. */
  4. Ext.define('school.view.interaction.timetable.List', {
  5. extend: 'school.view.core.base.BasePanel',
  6. xtype: 'interaction-timetable-list',
  7. controller: 'interaction-timetable-list',
  8. // dataUrl: 'http://10.1.80.47:9520/api/school/curriculum/list',
  9. dataUrl: '/api/school/curriculum/list',
  10. _title: '课程表',
  11. caller: 'Curriculum',
  12. pathKey: 'curriculum',
  13. initComponent: function() {
  14. var me = this;
  15. Ext.apply(this, {
  16. searchField: [{
  17. xtype: 'textfield',
  18. name: 'mcur_name',
  19. fieldLabel: '课表名称'
  20. }, {
  21. xtype: 'gradecombo',
  22. name: 'grade_name',
  23. fieldLabel: '年级',
  24. listeners: {
  25. select: function (combo, record, eOpts) {
  26. combo.up('form').getForm().findField('clazz_name').setValue(null);
  27. }
  28. }
  29. }, {
  30. xtype: 'classcombo',
  31. name: 'clazz_name',
  32. fieldLabel: '班级',
  33. listeners: {
  34. expand: function (combo, eOpts) {
  35. combo.store.clearFilter();
  36. var gradeCombo = combo.up('form').getForm().findField('grade_name');
  37. var gradeName = gradeCombo.getValue();
  38. var filter = new Ext.util.Filter({
  39. property: 'clazz_grade',
  40. value: gradeName
  41. });
  42. if (!!gradeName) {
  43. combo.store.setFilters([filter]);
  44. }
  45. },
  46. select: function (combo, record, eOpts) {
  47. combo.up('form').getForm().findField('grade_name').setValue(record.get('clazz_grade'));
  48. }
  49. }
  50. }, {
  51. xtype: 'combobox',
  52. name: 'mcur_term_part',
  53. fieldLabel: '学年',
  54. queryModel: 'local',
  55. displayField: 'value',
  56. valueField: 'value',
  57. store: Ext.create('Ext.data.ArrayStore', {
  58. fields: ['value'],
  59. data: (function() {
  60. let now = new Date();
  61. let year = now.getFullYear();
  62. let op = [], o1, o2;
  63. o1 = [(year - 1) + '-' + year];
  64. o2 = [year + '-' + (year + 1)];
  65. op.push(o1);
  66. op.push(o2);
  67. return op;
  68. })()
  69. }),
  70. value: (function() {
  71. let now = new Date();
  72. let year = now.getFullYear();
  73. let month = now.getMonth() + 1;
  74. let o1, o2;
  75. o1 = [(year - 1) + '-' + year];
  76. o2 = [year + '-' + (year + 1)];
  77. return (month < 9) ? o1[0] : o2[0]
  78. })()
  79. }, {
  80. xtype: "combobox",
  81. name: "mcur_term_name",
  82. fieldLabel: "学期",
  83. queryModel: 'local',
  84. displayField: 'value',
  85. valueField: 'value',
  86. editable: false,
  87. clearable: true,
  88. store: Ext.create('Ext.data.ArrayStore', {
  89. fields: ['value'],
  90. data: [['第一学期'], ['第二学期']]
  91. }),
  92. value: (function() {
  93. let now = new Date();
  94. let month = now.getMonth() + 1;
  95. return (month < 9) ? '第一学期' : '第二学期'
  96. })()
  97. }],
  98. gridConfig: {
  99. addTitle: '课程表',
  100. addXtype: 'interaction-timetable-detail',
  101. idField: 'id',
  102. codeField: 'name',
  103. detailField: 'name',
  104. dataUrl: me.dataUrl,
  105. caller: null,
  106. rootProperty: 'data.list',
  107. totalProperty: 'data.total',
  108. actionColumn: [],
  109. selModel: {
  110. checkOnly:true,
  111. type:'checkboxmodel',
  112. mode : "MULTI" ,
  113. ignoreRightMouseSelection : false
  114. },
  115. hiddenTools: false,
  116. toolBtns: [{
  117. xtype: 'button',
  118. text: '新增',
  119. handler: 'onAddClick'
  120. }, {
  121. xtype: 'importbutton',
  122. text: '导入',
  123. belong: me,
  124. caller: me.caller,
  125. pathKey: me.pathKey,
  126. onSuccess: function () {
  127. //刷新界面
  128. var g = me.down('grid');
  129. g.store.loadPage(g.store.currentPage);
  130. }
  131. }, {
  132. xtype: 'button',
  133. text: '删除',
  134. handler: function() {
  135. let grid = this.up('grid'),
  136. selectedRecords = grid.getSelection();
  137. let data;
  138. data = selectedRecords.map(function (r) {
  139. return {
  140. id: r.get('id')
  141. };
  142. });
  143. if (data.length == 0) {
  144. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  145. return;
  146. }
  147. grid.setLoading(true);
  148. school.util.BaseUtil.request({
  149. // url: 'http://10.1.80.36:9520/api/school/curriculum/batchDelete',
  150. url: '/api/school/curriculum/batchDelete',
  151. method: 'POST',
  152. params: JSON.stringify({
  153. baseDTOs: data
  154. })
  155. }).then(function (res) {
  156. grid.setLoading(false);
  157. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  158. grid.store.loadPage(grid.store.currentPage);
  159. }).catch(function (e) {
  160. grid.setLoading(false);
  161. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  162. });
  163. }
  164. }],
  165. columns : [{
  166. text: 'id',
  167. dataIndex: 'id',
  168. hidden: true
  169. }, {
  170. text: '课表名称',
  171. dataIndex: 'name',
  172. width: 120,
  173. // tdCls: 'x-detail-column',
  174. // listeners: {
  175. // click: function(view, td, row, col, e, record, tr, eOpts, event) {
  176. // let gridConfig = me.gridConfig;
  177. // school.util.BaseUtil.openTab(gridConfig.addXtype, gridConfig.addTitle + '(' + record.get('id') + ')', gridConfig.addXtype + record.get(gridConfig.idField), {
  178. // initId: record.get(gridConfig.idField)
  179. // });
  180. // }
  181. // }
  182. }, {
  183. text: '年级',
  184. dataIndex: 'gradeName'
  185. }, {
  186. text: '班级',
  187. dataIndex: 'clazzName'
  188. }, {
  189. text: '学年',
  190. dataIndex: 'termPart'
  191. }, {
  192. text: '学期',
  193. dataIndex: 'termName',
  194. width: 120
  195. }]
  196. },
  197. });
  198. this.callParent(arguments);
  199. },
  200. refresh: function() {
  201. Ext.StoreMgr.get('store_grade').load();
  202. Ext.StoreMgr.get('store_class').load();
  203. Ext.StoreMgr.get('store_subject').load();
  204. this.items.items[0].store.load();
  205. }
  206. });