GridPanel.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. Ext.define('erp.view.oa.officialDocument.instruction.manage.GridPanel',{
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.erpInstructionGridPanel',
  4. id: 'grid',
  5. emptyText : '无数据',
  6. columnLines : true,
  7. autoScroll : true,
  8. FormUtil: Ext.create('erp.util.FormUtil'),
  9. GridUtil: Ext.create('erp.util.GridUtil'),
  10. plugins: [Ext.create('Ext.ux.grid.GridHeaderFilters')],
  11. BaseUtil: Ext.create('erp.util.BaseUtil'),
  12. store: [],
  13. iconCls: 'icon-grid',
  14. frame: true,
  15. bodyStyle:'background-color:#f1f1f1;',
  16. features: [Ext.create('Ext.grid.feature.Grouping',{
  17. groupHeaderTpl: '{name} ({rows.length} 封)'
  18. })],
  19. selModel: Ext.create('Ext.selection.CheckboxModel',{
  20. // renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
  21. // if(record.data.rod_statuscode != 'OVERED'){
  22. // metaData.tdCls = Ext.baseCSSPrefix + 'grid-cell-special';
  23. // return '<div class="' + Ext.baseCSSPrefix + 'grid-row-checker">&#160;</div>';
  24. // }
  25. // }
  26. onRowMouseDown: function(view, record, item, index, e) {
  27. view.el.focus();
  28. var me = this,
  29. checker = e.getTarget('.' + Ext.baseCSSPrefix + 'grid-row-checker');
  30. if (!me.allowRightMouseSelection(e)) {
  31. return;
  32. }
  33. // checkOnly set, but we didn't click on a checker.
  34. if (me.checkOnly && !checker) {
  35. return;
  36. }
  37. if (checker) {
  38. var mode = me.getSelectionMode();
  39. // dont change the mode if its single otherwise
  40. // we would get multiple selection
  41. if (mode !== 'SINGLE') {
  42. me.setSelectionMode('SIMPLE');
  43. }
  44. me.selectWithEvent(record, e);
  45. me.setSelectionMode(mode);
  46. } else {
  47. me.selectWithEvent(record, e);
  48. }
  49. }
  50. }),
  51. dockedItems: [{
  52. id : 'paging',
  53. xtype: 'erpMailPaging',
  54. dock: 'bottom',
  55. displayInfo: true
  56. }],
  57. columns: [],
  58. tbar: [{
  59. iconCls: 'group-delete',
  60. text: $I18N.common.button.erpDeleteButton,
  61. handler: function(btn){
  62. var selectItem = Ext.getCmp('grid').selModel.selected.items;
  63. console.log(selectItem);
  64. // if (selectItem.length == 0) {
  65. // showError("请先选中要删除的收文");return;
  66. // } else {
  67. // var ids = new Array();
  68. // Ext.each(selectItem, function(item, index){
  69. // ids[index] = item.data.rod_id;
  70. //// alert(ids[index]);
  71. // });
  72. // Ext.Ajax.request({//拿到grid的columns
  73. // url : basePath + 'oa/officialDocument/receiveODM/deleteROD.action',
  74. // params: {
  75. // ids : ids.join(',')
  76. // },
  77. // method : 'post',
  78. // async: false,
  79. // callback : function(options, success, response){
  80. // parent.Ext.getCmp("content-panel").getActiveTab().setLoading(false);
  81. // var res = new Ext.decode(response.responseText);
  82. // if(res.exceptionInfo){
  83. // showError(res.exceptionInfo);return;
  84. // }
  85. // if(res.success){
  86. // alert(' 删除成功!');
  87. // }
  88. // }
  89. // });
  90. // url = "oa/officialDocument/receiveODM/getRODList.action";
  91. // btn.ownerCt.ownerCt.getGroupData();
  92. // }
  93. }
  94. },{
  95. iconCls: 'x-button-icon-print',
  96. text: $I18N.common.button.erpPrintButton,
  97. id: 'print',
  98. handler: function(btn){
  99. }
  100. }],
  101. initComponent : function(){
  102. var gridParam = {caller: caller, condition: ''};
  103. this.GridUtil.getGridColumnsAndStore(this, 'common/singleGridPanel.action', gridParam, "");
  104. this.callParent(arguments);
  105. url = "oa/officialDocument/instruction/getInstructionList.action";
  106. this.getGroupData(page, pageSize);
  107. },
  108. listeners: {//滚动条有时候没反应,添加此监听器
  109. scrollershow: function(scroller) {
  110. if (scroller && scroller.scrollEl) {
  111. scroller.clearManagedListeners();
  112. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  113. }
  114. }
  115. },
  116. getGroupData: function(page, pageSize){
  117. var me = this;
  118. if(!page){
  119. page = 1;
  120. }
  121. if(!pageSize){
  122. pageSize = 15;
  123. }
  124. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(true);//loading...
  125. Ext.Ajax.request({//拿到grid的columns
  126. url : basePath + url,
  127. params: {
  128. page: page,
  129. pageSize: pageSize
  130. },
  131. method : 'post',
  132. async: false,
  133. callback : function(options, success, response){
  134. console.log(response);
  135. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(false);
  136. var res = new Ext.decode(response.responseText);
  137. if(res.exceptionInfo){
  138. showError(res.exceptionInfo);return;
  139. }
  140. if(res.error){
  141. showError(res.error);return;
  142. }
  143. if(!res.success){
  144. return;
  145. } else {
  146. dataCount = res.count;
  147. me.store.loadData(res.success);
  148. }
  149. }
  150. });
  151. },
  152. // updateWindow: function(id){
  153. // var win = new Ext.window.Window({
  154. // id : 'win2',
  155. // title: "修改协同",
  156. // height: "90%",
  157. // width: "80%",
  158. // maximizable : false,
  159. // buttonAlign : 'left',
  160. // layout : 'anchor',
  161. // items: [{
  162. // tag : 'iframe',
  163. // frame : true,
  164. // anchor : '100% 100%',
  165. // layout : 'fit',
  166. // html : '<iframe id="iframe_' + id + '" src="' + basePath + 'jsps/common/commonpage.jsp?whoami=Agenda&formCondition=ag_idIS' + id + '&gridCondition=" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  167. // }]
  168. // });
  169. // win.show();
  170. // }
  171. });