List.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /**
  2. * 学校通知
  3. */
  4. Ext.define('school.view.interaction.notice.List', {
  5. extend: 'school.view.core.base.BasePanel',
  6. xtype: 'interaction-notice-list',
  7. // dataUrl: 'http://10.1.80.47:9560/notice/list',
  8. dataUrl: '/api/school/notice/list',
  9. _title: '学校通知',
  10. initComponent: function() {
  11. var me = this;
  12. Ext.apply(this, {
  13. searchField: [{
  14. xtype: 'textfield',
  15. name: 'keyword',
  16. fieldLabel:'关键字',
  17. getCondition: function (value) {
  18. return ' (notify_title like\'%' + value + '%\' or notify_details like \'%' + value + '%\') ';
  19. }
  20. }, {
  21. xtype: 'textfield',
  22. name: 'notify_creator',
  23. fieldLabel: '发布人'
  24. }, {
  25. xtype: 'combobox',
  26. name: 'notify_status',
  27. fieldLabel: '发布状态',
  28. displayField: 'name',
  29. valueField: 'value',
  30. editable: true,
  31. store: Ext.create('Ext.data.ArrayStore', {
  32. fields: ['name', 'value'],
  33. data: [['已发布', 1], ['未发布', 2]]
  34. }),
  35. minChars: 0,
  36. queryMode: 'local'
  37. }, {
  38. xtype: 'condatefield',
  39. name: 'publish_date',
  40. fieldLabel: '发布时间',
  41. columnWidth: 0.5
  42. }],
  43. gridConfig: {
  44. addTitle: '学校通知',
  45. addXtype: 'interaction-notice-schoolnotice',
  46. idField: 'notify_id',
  47. codeField: null,
  48. detailField: 'notify_title',
  49. dataUrl: me.dataUrl,
  50. caller: null,
  51. rootProperty: 'data.list',
  52. totalProperty: 'data.total',
  53. actionColumn: [],
  54. selModel: {
  55. checkOnly:true,
  56. type:'checkboxmodel',
  57. mode : "MULTI" ,
  58. ignoreRightMouseSelection : false
  59. },
  60. hiddenTools: false,
  61. toolBtns: [{
  62. xtype: 'button',
  63. text: '删除',
  64. handler: function() {
  65. let grid = this.up('grid'),
  66. selectedRecords = grid.getSelection();
  67. let data;
  68. data = selectedRecords.map(function(r) {
  69. return {
  70. id: r.get('notify_id')
  71. };
  72. });
  73. if(data.length == 0) {
  74. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  75. return;
  76. }
  77. grid.setLoading(true);
  78. school.util.BaseUtil.request({
  79. // url: 'http://10.1.80.47:9560/teacher/batchDelete',
  80. url: '/api/school/notice/batchDelete',
  81. method: 'POST',
  82. params: JSON.stringify({
  83. baseDTOs: data
  84. })
  85. }).then(function(res) {
  86. grid.setLoading(false);
  87. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  88. grid.store.loadPage(grid.store.currentPage);
  89. }).catch(function(e) {
  90. grid.setLoading(false);
  91. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  92. });
  93. }
  94. }, {
  95. xtype: 'button',
  96. text: '新增',
  97. handler: function() {
  98. school.util.BaseUtil.openTab('interaction-notice-schoolnotice', '新增学校通知', 'interaction-notice-schoolnotice-add');
  99. }
  100. }],
  101. columns : [{
  102. text: 'id',
  103. dataIndex: 'notify_id',
  104. hidden: true
  105. }, {
  106. text: '标题',
  107. dataIndex: 'notify_title',
  108. width: 120,
  109. tdCls: 'x-detail-column',
  110. listeners: {
  111. click: function(view, td, row, col, e, record, tr, eOpts, event) {
  112. let gridConfig = me.gridConfig;
  113. school.util.BaseUtil.openTab(gridConfig.addXtype, gridConfig.addTitle + '(' + record.get('notify_title') + ')', gridConfig.addXtype + record.get(gridConfig.idField), {
  114. initId: record.get(gridConfig.idField)
  115. });
  116. }
  117. }
  118. }, {
  119. text: '内容',
  120. dataIndex: 'notify_details',
  121. width: 300
  122. }, {
  123. text: '发布人',
  124. dataIndex: 'notify_creator',
  125. width: 150
  126. }, {
  127. text: '发布状态',
  128. dataIndex: 'notify_status',
  129. width: 120,
  130. renderer: function(v) {
  131. return !!v ? (v == 2 ? '未发布' : '已发布') : '未发布'
  132. }
  133. }, {
  134. xtype: 'datecolumn',
  135. formate: 'Y-m-d H:i:s',
  136. text: '发布时间',
  137. dataIndex: 'publish_date',
  138. width: 120
  139. }]
  140. },
  141. });
  142. this.callParent(arguments);
  143. },
  144. /**
  145. * 处理部分字段值
  146. */
  147. getConditionValue: function (field, value) {
  148. var me = this,
  149. xtypes = field.getXTypes().split('/'),
  150. conditionValue;
  151. if (me.isContainsAny(xtypes, ['datefield'])) {
  152. conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
  153. } else if (me.isContainsAny(xtypes, ['conmonthfield'])) {
  154. var from = value.from,
  155. to = value.to;
  156. conditionValue = from + ',' + to;
  157. } else if (me.isContainsAny(xtypes, ['condatefield'])) {
  158. var from = value.from,
  159. to = value.to;
  160. 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');
  161. } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
  162. conditionValue = value;
  163. } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) {
  164. conditionValue = value;
  165. } else if (me.isContainsAny(xtypes, ['multicombo'])) {
  166. conditionValue = value.map ? value.map(function (v) {
  167. return v.value;
  168. }).join(',') : '';
  169. } else {
  170. conditionValue = value;
  171. }
  172. return conditionValue;
  173. },
  174. getExtraParams: function(store, op, condition) {
  175. var temp = {};
  176. for(let x = 0; x < condition.length; x++) {
  177. let c = condition[x];
  178. if(c.field == 'keyword') {
  179. temp.keyword = c.value;
  180. }else if(c.field == 'date') {
  181. temp.fromDate = new Date(c.value.split(',')[0]).getTime();
  182. temp.endDate = new Date(c.value.split(',')[1]).getTime();
  183. }else if(c.field == 'quoted') {
  184. temp.quoted = c.value == 'all' ? null : c.value;
  185. }else if(c.field == 'closed') {
  186. // temp.endDate = c.value == 'all' ? null : (
  187. // c.value == '0' ?
  188. // );
  189. }
  190. }
  191. let obj = {
  192. pageNumber: store.exportNumber?store.exportNumber:op._page,
  193. pageSize: store.exportPageSize?store.exportPageSize:store.pageSize
  194. };
  195. for(let k in temp) {
  196. if(!!temp[k]) {
  197. obj[k] = temp[k];
  198. }
  199. }
  200. return obj;
  201. },
  202. });