List.js 7.6 KB

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