List.js 10 KB

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