List.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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, termPart;
  75. o1 = [(year - 1) + '-' + year];
  76. o2 = [year + '-' + (year + 1)];
  77. if((month > 2 && month < 8) || (month == 2 && date > 15) || (month == 8 && date < 15)) {
  78. termPart = o1[0];
  79. }else {
  80. termPart = o2[0];
  81. }
  82. return termPart;
  83. })()
  84. }, {
  85. xtype: "combobox",
  86. name: "mcur_term_name",
  87. fieldLabel: "学期",
  88. queryModel: 'local',
  89. displayField: 'value',
  90. valueField: 'value',
  91. editable: false,
  92. clearable: true,
  93. store: Ext.create('Ext.data.ArrayStore', {
  94. fields: ['value'],
  95. data: [['第一学期'], ['第二学期']]
  96. }),
  97. value: (function() {
  98. let now = new Date(),
  99. month = now.getMonth() + 1,
  100. date = now.getDate(),
  101. term;
  102. if((month > 2 && month < 8) || (month == 2 && date > 15) || (month == 8 && date < 15)) {
  103. term = '第二学期';
  104. }else {
  105. term = '第一学期'
  106. }
  107. return term;
  108. })()
  109. }, {
  110. xtype: 'combobox',
  111. name: 'status',
  112. fieldLabel: '发布状态',
  113. displayField: 'name',
  114. valueField: 'value',
  115. editable: false,
  116. clearable: true,
  117. store: Ext.create('Ext.data.ArrayStore', {
  118. fields: ['name', 'value'],
  119. data: [
  120. ['已生效', 1],
  121. ['未生效', 0]
  122. ]
  123. }),
  124. minChars: 0,
  125. queryMode: 'local'
  126. }],
  127. gridConfig: {
  128. addTitle: '课程表',
  129. addXtype: 'interaction-timetable-detail',
  130. idField: 'id',
  131. codeField: 'name',
  132. detailField: 'name',
  133. dataUrl: me.dataUrl,
  134. caller: null,
  135. rootProperty: 'data.list',
  136. totalProperty: 'data.total',
  137. actionColumn: [],
  138. selModel: {
  139. checkOnly:true,
  140. type:'checkboxmodel',
  141. mode : "MULTI" ,
  142. ignoreRightMouseSelection : false
  143. },
  144. hiddenTools: false,
  145. toolBtns: [{
  146. xtype: 'button',
  147. text: '新增',
  148. handler: 'onAddClick'
  149. }, {
  150. xtype: 'importbutton',
  151. text: '导入',
  152. belong: me,
  153. caller: me.caller,
  154. pathKey: me.pathKey,
  155. onSuccess: function () {
  156. //刷新界面
  157. var g = me.down('grid');
  158. g.store.loadPage(g.store.currentPage);
  159. }
  160. }, {
  161. xtype: 'button',
  162. text: '删除',
  163. handler: function() {
  164. let grid = this.up('grid'),
  165. selectedRecords = grid.getSelection();
  166. let data;
  167. data = selectedRecords.map(function (r) {
  168. return {
  169. id: r.get('id')
  170. };
  171. });
  172. if (data.length == 0) {
  173. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  174. return;
  175. }
  176. school.util.BaseUtil.showConfirm('确认删除', '确定要删除这' + data.length + '条记录吗?')
  177. .then(function(yes) {
  178. if(yes == 'yes') {
  179. grid.setLoading(true);
  180. school.util.BaseUtil.request({
  181. // url: 'http://10.1.80.36:9520/api/school/curriculum/batchDelete',
  182. url: '/api/school/curriculum/batchDelete',
  183. method: 'POST',
  184. params: JSON.stringify({
  185. baseDTOs: data
  186. })
  187. }).then(function (res) {
  188. grid.setLoading(false);
  189. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  190. grid.store.loadPage(grid.store.currentPage);
  191. }).catch(function (e) {
  192. grid.setLoading(false);
  193. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  194. });
  195. }
  196. });
  197. }
  198. }],
  199. columns : [{
  200. text: 'id',
  201. dataIndex: 'id',
  202. hidden: true
  203. }, {
  204. text: '课表名称',
  205. dataIndex: 'name',
  206. width: 120,
  207. // tdCls: 'x-detail-column',
  208. // listeners: {
  209. // click: function(view, td, row, col, e, record, tr, eOpts, event) {
  210. // let gridConfig = me.gridConfig;
  211. // school.util.BaseUtil.openTab(gridConfig.addXtype, gridConfig.addTitle + '(' + record.get('id') + ')', gridConfig.addXtype + record.get(gridConfig.idField), {
  212. // initId: record.get(gridConfig.idField)
  213. // });
  214. // }
  215. // }
  216. }, {
  217. text: '年级',
  218. dataIndex: 'gradeName'
  219. }, {
  220. text: '班级',
  221. dataIndex: 'clazzName'
  222. }, {
  223. text: '学年',
  224. dataIndex: 'termPart'
  225. }, {
  226. text: '学期',
  227. dataIndex: 'termName',
  228. width: 120
  229. }, {
  230. text: '状态',
  231. dataIndex: 'status',
  232. renderer: function(v) {
  233. return v == '1' ? '已生效' : '未生效'
  234. }
  235. }]
  236. },
  237. });
  238. this.callParent(arguments);
  239. },
  240. refresh: function() {
  241. Ext.StoreMgr.get('store_grade').load();
  242. Ext.StoreMgr.get('store_class').load();
  243. Ext.StoreMgr.get('store_subject').load();
  244. this.items.items[0].store.load();
  245. }
  246. });