List.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. type: 'publish',
  164. path: 'batchPublish',
  165. reference: 'publish',
  166. handler: 'onPublishClick'
  167. }, {
  168. xtype: 'button',
  169. text: '删除',
  170. handler: function() {
  171. let grid = this.up('grid'),
  172. selectedRecords = grid.getSelection();
  173. let data;
  174. data = selectedRecords.map(function (r) {
  175. return {
  176. id: r.get('id')
  177. };
  178. });
  179. if (data.length == 0) {
  180. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  181. return;
  182. }
  183. school.util.BaseUtil.showConfirm('确认删除', '确定要删除这' + data.length + '条记录吗?')
  184. .then(function(yes) {
  185. if(yes == 'yes') {
  186. grid.setLoading(true);
  187. school.util.BaseUtil.request({
  188. // url: 'http://10.1.80.36:9520/api/school/curriculum/batchDelete',
  189. url: '/api/school/curriculum/batchDelete',
  190. method: 'POST',
  191. params: JSON.stringify({
  192. baseDTOs: data
  193. })
  194. }).then(function (res) {
  195. grid.setLoading(false);
  196. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  197. grid.store.loadPage(grid.store.currentPage);
  198. }).catch(function (e) {
  199. grid.setLoading(false);
  200. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  201. });
  202. }
  203. });
  204. }
  205. }],
  206. columns : [{
  207. text: 'id',
  208. dataIndex: 'id',
  209. hidden: true
  210. }, {
  211. text: '课表名称',
  212. dataIndex: 'name',
  213. width: 120,
  214. // tdCls: 'x-detail-column',
  215. // listeners: {
  216. // click: function(view, td, row, col, e, record, tr, eOpts, event) {
  217. // let gridConfig = me.gridConfig;
  218. // school.util.BaseUtil.openTab(gridConfig.addXtype, gridConfig.addTitle + '(' + record.get('id') + ')', gridConfig.addXtype + record.get(gridConfig.idField), {
  219. // initId: record.get(gridConfig.idField)
  220. // });
  221. // }
  222. // }
  223. }, {
  224. text: '年级',
  225. dataIndex: 'gradeName'
  226. }, {
  227. text: '班级',
  228. dataIndex: 'clazzName'
  229. }, {
  230. text: '学年',
  231. dataIndex: 'termPart'
  232. }, {
  233. text: '学期',
  234. dataIndex: 'termName',
  235. width: 120
  236. }, {
  237. text: '状态',
  238. dataIndex: 'status',
  239. renderer: function(v) {
  240. return v == '1' ? '已生效' : '未生效'
  241. }
  242. }],
  243. listeners: {
  244. selectionchange: 'selectionchange'
  245. }
  246. },
  247. });
  248. this.callParent(arguments);
  249. },
  250. refresh: function() {
  251. Ext.StoreMgr.get('store_grade').load();
  252. Ext.StoreMgr.get('store_class').load();
  253. Ext.StoreMgr.get('store_subject').load();
  254. this.items.items[0].store.load();
  255. }
  256. });