List.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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: 'textfield',
  52. name: 'mcur_term_part',
  53. fieldLabel: '学年'
  54. }, {
  55. xtype: 'textfield',
  56. name: 'mcur_term_name',
  57. fieldLabel: '学期'
  58. }],
  59. gridConfig: {
  60. addTitle: '课程表',
  61. addXtype: 'interaction-timetable-detail',
  62. idField: 'id',
  63. codeField: 'id',
  64. detailField: 'name',
  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: 'onAddClick'
  81. }, {
  82. xtype: 'importbutton',
  83. text: '导入',
  84. belong: me,
  85. caller: me.caller,
  86. pathKey: me.pathKey,
  87. onSuccess: function () {
  88. //刷新界面
  89. var g = me.down('grid');
  90. g.store.loadPage(g.store.currentPage);
  91. }
  92. }, {
  93. xtype: 'button',
  94. text: '删除',
  95. handler: function() {
  96. let grid = this.up('grid'),
  97. selectedRecords = grid.getSelection();
  98. let data;
  99. data = selectedRecords.map(function (r) {
  100. return {
  101. id: r.get('id')
  102. };
  103. });
  104. if (data.length == 0) {
  105. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  106. return;
  107. }
  108. grid.setLoading(true);
  109. school.util.BaseUtil.request({
  110. url: '/api/school/curriculum/deleteDetail',
  111. method: 'POST',
  112. params: JSON.stringify({
  113. baseDTOs: data
  114. })
  115. }).then(function (res) {
  116. grid.setLoading(false);
  117. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  118. grid.store.loadPage(grid.store.currentPage);
  119. }).catch(function (e) {
  120. grid.setLoading(false);
  121. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  122. });
  123. }
  124. }],
  125. columns : [{
  126. text: 'id',
  127. dataIndex: 'id',
  128. hidden: true
  129. }, {
  130. text: '课表名称',
  131. dataIndex: 'name',
  132. width: 120,
  133. // tdCls: 'x-detail-column',
  134. // listeners: {
  135. // click: function(view, td, row, col, e, record, tr, eOpts, event) {
  136. // let gridConfig = me.gridConfig;
  137. // school.util.BaseUtil.openTab(gridConfig.addXtype, gridConfig.addTitle + '(' + record.get('id') + ')', gridConfig.addXtype + record.get(gridConfig.idField), {
  138. // initId: record.get(gridConfig.idField)
  139. // });
  140. // }
  141. // }
  142. }, {
  143. text: '年级',
  144. dataIndex: 'gradeName'
  145. }, {
  146. text: '班级',
  147. dataIndex: 'clazzName'
  148. }, {
  149. text: '学年',
  150. dataIndex: 'termPart'
  151. }, {
  152. text: '学期',
  153. dataIndex: 'termName',
  154. width: 120
  155. }]
  156. },
  157. });
  158. this.callParent(arguments);
  159. },
  160. refresh: function() {
  161. Ext.StoreMgr.get('store_grade').load();
  162. Ext.StoreMgr.get('store_class').load();
  163. this.items.items[0].store.load();
  164. }
  165. });