List.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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.36: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: 'textfield',
  22. name: 'grade_name',
  23. fieldLabel: '年级'
  24. }, {
  25. xtype: 'textfield',
  26. name: 'clazz_name',
  27. fieldLabel: '班级'
  28. }, {
  29. xtype: 'textfield',
  30. name: 'mcur_term_part',
  31. fieldLabel: '学年'
  32. }, {
  33. xtype: 'textfield',
  34. name: 'mcur_term_name',
  35. fieldLabel: '学期'
  36. }],
  37. gridConfig: {
  38. addTitle: '课程表',
  39. addXtype: 'interaction-timetable-detail',
  40. idField: 'id',
  41. codeField: null,
  42. detailField: 'name',
  43. dataUrl: me.dataUrl,
  44. caller: null,
  45. rootProperty: 'data.list',
  46. totalProperty: 'data.total',
  47. actionColumn: [],
  48. selModel: {
  49. checkOnly:true,
  50. type:'checkboxmodel',
  51. mode : "MULTI" ,
  52. ignoreRightMouseSelection : false
  53. },
  54. hiddenTools: false,
  55. toolBtns: [{
  56. xtype: 'button',
  57. text: '新增',
  58. handler: 'onAddClick'
  59. }, {
  60. xtype: 'importbutton',
  61. text: '导入',
  62. belong: me,
  63. caller: me.caller,
  64. pathKey: me.pathKey,
  65. onSuccess: function () {
  66. //刷新界面
  67. var g = me.down('grid');
  68. g.store.loadPage(g.store.currentPage);
  69. }
  70. }, {
  71. xtype: 'button',
  72. text: '删除',
  73. handler: function() {
  74. let grid = this.up('grid'),
  75. selectedRecords = grid.getSelection();
  76. let data;
  77. data = selectedRecords.map(function (r) {
  78. return {
  79. id: r.get('id')
  80. };
  81. });
  82. if (data.length == 0) {
  83. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  84. return;
  85. }
  86. grid.setLoading(true);
  87. school.util.BaseUtil.request({
  88. url: '/api/school/curriculum/deleteDetail',
  89. method: 'POST',
  90. params: JSON.stringify({
  91. baseDTOs: data
  92. })
  93. }).then(function (res) {
  94. grid.setLoading(false);
  95. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  96. grid.store.loadPage(grid.store.currentPage);
  97. }).catch(function (e) {
  98. grid.setLoading(false);
  99. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  100. });
  101. }
  102. }],
  103. columns : [{
  104. text: 'id',
  105. dataIndex: 'id',
  106. hidden: true
  107. }, {
  108. text: '课表名称',
  109. dataIndex: 'name',
  110. width: 120,
  111. tdCls: 'x-detail-column',
  112. listeners: {
  113. click: function(view, td, row, col, e, record, tr, eOpts, event) {
  114. let gridConfig = me.gridConfig;
  115. school.util.BaseUtil.openTab(gridConfig.addXtype, gridConfig.addTitle + '(' + record.get('id') + ')', gridConfig.addXtype + record.get(gridConfig.idField), {
  116. initId: record.get(gridConfig.idField)
  117. });
  118. }
  119. }
  120. }, {
  121. text: '年级',
  122. dataIndex: 'gradeName'
  123. }, {
  124. text: '班级',
  125. dataIndex: 'clazzName'
  126. }, {
  127. text: '学年',
  128. dataIndex: 'termPart'
  129. }, {
  130. text: '学期',
  131. dataIndex: 'termName',
  132. width: 120
  133. }]
  134. },
  135. });
  136. this.callParent(arguments);
  137. },
  138. /**
  139. * 处理部分字段值
  140. */
  141. getConditionValue: function (field, value) {
  142. var me = this,
  143. xtypes = field.getXTypes().split('/'),
  144. conditionValue;
  145. if (me.isContainsAny(xtypes, ['datefield'])) {
  146. conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
  147. } else if (me.isContainsAny(xtypes, ['conmonthfield'])) {
  148. var from = value.from,
  149. to = value.to;
  150. conditionValue = from + ',' + to;
  151. } else if (me.isContainsAny(xtypes, ['condatefield'])) {
  152. var from = value.from,
  153. to = value.to;
  154. conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
  155. } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
  156. conditionValue = value;
  157. } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) {
  158. conditionValue = value;
  159. } else if (me.isContainsAny(xtypes, ['multicombo'])) {
  160. conditionValue = value.map ? value.map(function (v) {
  161. return v.value;
  162. }).join(',') : '';
  163. } else {
  164. conditionValue = value;
  165. }
  166. return conditionValue;
  167. },
  168. getExtraParams: function(store, op, condition) {
  169. var temp = {};
  170. for(let x = 0; x < condition.length; x++) {
  171. let c = condition[x];
  172. if(c.field == 'keyword') {
  173. temp.keyword = c.value;
  174. }else if(c.field == 'date') {
  175. temp.fromDate = new Date(c.value.split(',')[0]).getTime();
  176. temp.endDate = new Date(c.value.split(',')[1]).getTime();
  177. }else if(c.field == 'quoted') {
  178. temp.quoted = c.value == 'all' ? null : c.value;
  179. }else if(c.field == 'closed') {
  180. // temp.endDate = c.value == 'all' ? null : (
  181. // c.value == '0' ?
  182. // );
  183. }
  184. }
  185. let obj = {
  186. pageNumber: store.exportNumber?store.exportNumber:op._page,
  187. pageSize: store.exportPageSize?store.exportPageSize:store.pageSize
  188. };
  189. for(let k in temp) {
  190. if(!!temp[k]) {
  191. obj[k] = temp[k];
  192. }
  193. }
  194. return obj;
  195. },
  196. });