GridPanel.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. Ext.define('erp.view.oa.persontask.myAgenda.arrangeQuery.GridPanel',{
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.erpArrangeQueryGridPanel',
  4. id: 'querygrid',
  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: Ext.create('Ext.data.Store', {
  13. fields: [{
  14. name:'executor',
  15. type:'string'
  16. },{
  17. name:'title',
  18. type:'string'
  19. },{
  20. name:'content',
  21. type:'string'
  22. },{
  23. name:'start',
  24. type:'date'
  25. },{
  26. name:'end',
  27. type:'date'
  28. },{
  29. name:'type',
  30. type:'string'
  31. }]
  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: 150,
  50. dataIndex: 'ag_executor'
  51. },{
  52. text: '事件标题',
  53. width: 150,
  54. dataIndex: 'ag_title',
  55. renderer: function(val, meta, record){
  56. var s = '';
  57. if(record.data.ag_atid != 0){
  58. Ext.Ajax.request({//拿到grid的columns
  59. url : basePath + 'oa/persontask/myAgenda/getAgendaType.action',
  60. params: {
  61. id : record.data.ag_atid
  62. },
  63. method : 'post',
  64. async: false,
  65. callback : function(options, success, response){
  66. // console.log(response);
  67. var res = new Ext.decode(response.responseText);
  68. if(res.exceptionInfo){
  69. showError(res.exceptionInfo);return ;
  70. }
  71. if(res.success){
  72. s = '<font style="color: #' + res.color +'">' + val +'</font>';
  73. }
  74. }
  75. });
  76. }
  77. return s == '' ? val : s;
  78. }
  79. },{
  80. text: '事件内容',
  81. width: 150,
  82. dataIndex: 'ag_content'
  83. },{
  84. text: '开始时间',
  85. width: 150,
  86. dataIndex: 'ag_start',
  87. renderer: function(val, meta, record){
  88. return Ext.util.Format.date(new Date(val),'Y-m-d H:i:s');
  89. }
  90. },{
  91. text: '结束时间',
  92. width: 150,
  93. dataIndex: 'ag_end',
  94. renderer: function(val, meta, record){
  95. return Ext.util.Format.date(new Date(val),'Y-m-d H:i:s');
  96. }
  97. },{
  98. text: '日程类型',
  99. width: 150,
  100. dataIndex: 'ag_type'
  101. }],
  102. tbar: [{
  103. iconCls: 'group-delete',
  104. text: $I18N.common.button.erpDeleteButton,
  105. handler: function(btn){
  106. var selectItem = Ext.getCmp('querygrid').selModel.selected.items;
  107. if (selectItem.length == 0) {
  108. showError("请先选中要删除的文档");return;
  109. } else {
  110. var ids = new Array();
  111. Ext.each(selectItem, function(item, index){
  112. ids[index] = item.data.ag_id;
  113. alert(ids[index]);
  114. });
  115. Ext.Ajax.request({//拿到grid的columns
  116. url : basePath + 'oa/persontask/myAgenda/deleteArrange.action',
  117. params: {
  118. ids : ids.join(',')
  119. },
  120. method : 'post',
  121. async: false,
  122. callback : function(options, success, response){
  123. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(false);
  124. var res = new Ext.decode(response.responseText);
  125. if(res.exceptionInfo){
  126. showError(res.exceptionInfo);return;
  127. }
  128. if(res.success){
  129. alert(' 删除成功!');
  130. }
  131. }
  132. });
  133. url = "oa/persontask/myAgenda/myArrangeList.action";
  134. btn.ownerCt.ownerCt.getGroupData();
  135. }
  136. }
  137. },{
  138. iconCls: 'x-button-icon-print',
  139. text: $I18N.common.button.erpPrintButton,
  140. id: 'print',
  141. handler: function(btn){
  142. // var name = Ext.getCmp('titlelike').value;
  143. // if(name != '' && name != null){
  144. // url = "oa/persontask/myAgenda/search.action?name=" + Ext.getCmp('titlelike').value;
  145. // btn.ownerCt.ownerCt.getGroupData();
  146. // } else {
  147. // showError("请先在输入框输入类型名称");return;
  148. // }
  149. }
  150. }],
  151. initComponent : function(){
  152. this.callParent(arguments);
  153. url = "oa/persontask/myAgenda/myArrangeList.action";
  154. this.getGroupData(page, pageSize);
  155. },
  156. listeners: {//滚动条有时候没反应,添加此监听器
  157. scrollershow: function(scroller) {
  158. if (scroller && scroller.scrollEl) {
  159. scroller.clearManagedListeners();
  160. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  161. }
  162. }
  163. },
  164. getGroupData: function(page, pageSize){
  165. var me = this;
  166. if(!page){
  167. page = 1;
  168. }
  169. if(!pageSize){
  170. pageSize = 15;
  171. }
  172. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(true);//loading...
  173. Ext.Ajax.request({//拿到grid的columns
  174. url : basePath + url,
  175. params: {
  176. page: page,
  177. pageSize: pageSize
  178. },
  179. method : 'post',
  180. async: false,
  181. callback : function(options, success, response){
  182. // console.log(response);
  183. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(false);
  184. var res = new Ext.decode(response.responseText);
  185. if(res.exceptionInfo){
  186. showError(res.exceptionInfo);return;
  187. }
  188. if(!res.success){
  189. return;
  190. } else {
  191. console.log(res.success);
  192. dataCount = res.count;
  193. me.store.loadData(res.success);
  194. }
  195. }
  196. });
  197. },
  198. updateWindow: function(id){
  199. var win = new Ext.window.Window({
  200. id : 'win2',
  201. title: "修改日程",
  202. height: "90%",
  203. width: "80%",
  204. maximizable : false,
  205. buttonAlign : 'left',
  206. layout : 'anchor',
  207. items: [{
  208. tag : 'iframe',
  209. frame : true,
  210. anchor : '100% 100%',
  211. layout : 'fit',
  212. 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>'
  213. }]
  214. });
  215. win.show();
  216. }
  217. });