GroupGrid.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /**
  2. * ERP项目groupgrid样式
  3. */
  4. Ext.define('erp.view.core.grid.GroupGrid',{
  5. extend: 'Ext.grid.Panel',
  6. alias: 'widget.erpGroupGrid',
  7. region: 'south',
  8. layout : 'fit',
  9. id: 'grid',
  10. emptyText : $I18N.common.grid.emptyText,
  11. columnLines : true,
  12. autoScroll : true,
  13. store: Ext.create('Ext.data.Store', {
  14. fields: [{
  15. name:'group',
  16. type:'string'
  17. }, {
  18. name:'from',
  19. type:'string'
  20. },{
  21. name:'subject',
  22. type:'string'
  23. },{
  24. name:'sendDate',
  25. type:'string'
  26. }],
  27. sorters: [{
  28. property : 'sendDate',
  29. direction: 'DESC'
  30. }],
  31. groupField: 'group'//??????????
  32. }),
  33. iconCls: 'icon-grid',
  34. frame: true,
  35. bodyStyle:'background-color:#f1f1f1;',
  36. features: [Ext.create('Ext.grid.feature.Grouping',{
  37. groupHeaderTpl: '{name} ({rows.length} 封)'
  38. })],
  39. selModel: Ext.create('Ext.selection.CheckboxModel',{
  40. }),
  41. dockedItems: [{
  42. id : 'paging',
  43. xtype: 'erpMailPaging',
  44. dock: 'bottom',
  45. displayInfo: true
  46. }],
  47. columns: [{
  48. text: '',
  49. width: 80,
  50. dataIndex: 'group'
  51. },{
  52. text: '发件人',
  53. width: 150,
  54. dataIndex: 'ma_from'
  55. },{
  56. text: '主题',
  57. width: 630,
  58. dataIndex: 'ma_subject'
  59. },{
  60. text: '时间',
  61. width: 210,
  62. dataIndex: 'ma_senddate'
  63. }],
  64. tbar: [{
  65. iconCls: 'group-delete',
  66. text: $I18N.common.button.erpDeleteButton,
  67. name: 'delete'
  68. },{
  69. iconCls: 'group-post',
  70. text: "转发",
  71. handler: function(){
  72. }
  73. },{
  74. iconCls: 'group-all',
  75. text: "查看所有邮件",
  76. handler: function(btn){
  77. url = "oa/mail/getAllReceMail.action";
  78. btn.ownerCt.ownerCt.getGroupData();
  79. }
  80. },{
  81. iconCls: 'group-read',
  82. text: "查看已读邮件",
  83. handler: function(btn){
  84. url = "oa/mail/getReadMail.action";
  85. btn.ownerCt.ownerCt.getGroupData();
  86. }
  87. },{
  88. iconCls: 'group-unread',
  89. text: "查看未读邮件",
  90. handler: function(btn){
  91. url = "oa/mail/getUnReadMail.action";
  92. btn.ownerCt.ownerCt.getGroupData();
  93. }
  94. },{
  95. iconCls: 'group-draft',
  96. text: "查看回收站邮件",
  97. handler: function(btn){
  98. url = "oa/mail/getDeletedReadMail.action";
  99. btn.ownerCt.ownerCt.getGroupData();
  100. }
  101. },{
  102. iconCls: 'group-close',
  103. text: $I18N.common.button.erpCloseButton,
  104. handler: function(){
  105. parent.Ext.getCmp("content-panel").getActiveTab().close();
  106. }
  107. }],
  108. initComponent : function(){
  109. this.callParent(arguments);
  110. url = this.switchUrl(getUrlParam("ma_status"));
  111. this.getGroupData(page, pageSize);
  112. },
  113. switchUrl: function(s){
  114. var url = 'oa/mail/getAllReceMail.action';
  115. switch (s){
  116. case '1':
  117. url = 'oa/mail/getUnReadMail.action';break;
  118. case '2':
  119. url = 'oa/mail/getReadMail.action';break;
  120. case '3':
  121. url = 'oa/mail/getDeletedReadMail.action';break;
  122. }
  123. return url;
  124. },
  125. listeners: {//滚动条有时候没反应,添加此监听器
  126. scrollershow: function(scroller) {
  127. if (scroller && scroller.scrollEl) {
  128. scroller.clearManagedListeners();
  129. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  130. }
  131. }
  132. },
  133. getGroupData: function(page, pageSize){
  134. var me = this;
  135. if(!page){
  136. page = 1;
  137. }
  138. if(!pageSize){
  139. pageSize = 15;
  140. }
  141. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(true);//loading...
  142. Ext.Ajax.request({//拿到grid的columns
  143. url : basePath + url,
  144. params: {
  145. page: page,
  146. pageSize: pageSize
  147. },
  148. method : 'post',
  149. async: false,
  150. callback : function(options, success, response){
  151. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(false);
  152. var res = new Ext.decode(response.responseText);
  153. if(res.exceptionInfo){
  154. showError(res.exceptionInfo);return;
  155. }
  156. if(!res.mails){
  157. return;
  158. } else {
  159. me.store.loadData(res.mails);
  160. }
  161. }
  162. });
  163. }
  164. });