PayPleaseDetailGrid.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. Ext.define('erp.view.fa.arp.payplease.PayPleaseDetailGrid',{
  2. extend:'Ext.grid.Panel',
  3. alias:'widget.paypleasedetailGrid',
  4. requires:['erp.view.fa.arp.payplease.PPDtoolbar'],
  5. layout:'fit',
  6. id:'paypleasedetailGrid',
  7. emptyText : $I18N.common.grid.emptyText,
  8. columnLines : true,
  9. autoScroll : true,
  10. detno:'ppdd_detno',
  11. keyField:'ppdd_id',
  12. mainField:'ppdd_ppdid',
  13. columns:[],
  14. multiselected: [],
  15. bodyStyle:'bachgroud-color:#f1f1f1;',
  16. plugins:Ext.create('Ext.grid.plugin.CellEditing',{
  17. clicksToEdit:1
  18. }),
  19. bbar:{
  20. xtype: 'erpPPDToolbar'
  21. },
  22. GridUtil:Ext.create('erp.util.GridUtil'),
  23. BaseUtil:Ext.create('erp.util.BaseUtil'),
  24. selModel: Ext.create('Ext.selection.CheckboxModel',{
  25. // checkOnly:true,
  26. ignoreRightMouseSelection : false,
  27. getEditor: function(){
  28. return null;
  29. },
  30. onRowMouseDown: function(view, record, item, index, e) {//改写的onRowMouseDown方法
  31. var status = Ext.getCmp('pp_statuscode');
  32. var me = Ext.getCmp('paypleasedetailGrid');
  33. if(status&&status.value=='AUDITED'){
  34. var bool = true;
  35. var items = me.selModel.getSelection();
  36. Ext.each(items, function(item, index){
  37. if(this.index == record.index){
  38. bool = false;
  39. me.selModel.deselect(record);
  40. Ext.Array.remove(items, item);
  41. Ext.Array.remove(me.multiselected, record);
  42. }
  43. });
  44. Ext.each(me.multiselected, function(item, index){
  45. items.push(item);
  46. });
  47. me.selModel.select(items);
  48. if(bool){
  49. view.el.focus();
  50. var checkbox = item.childNodes[0].childNodes[0].childNodes[0];
  51. if(checkbox.getAttribute && checkbox.getAttribute('class') == 'x-grid-row-checker'){
  52. me.multiselected.push(record);
  53. items.push(record);
  54. me.selModel.select(items);
  55. } else {
  56. me.selModel.deselect(record);
  57. Ext.Array.remove(me.multiselected, record);
  58. }
  59. }
  60. }else{
  61. me.selModel.select(index);
  62. }
  63. // me.summary();
  64. },
  65. onHeaderClick: function(headerCt, header, e) {
  66. if (header.isCheckerHd) {
  67. e.stopEvent();
  68. var isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');
  69. if (isChecked) {
  70. this.deselectAll(true);
  71. var grid = Ext.getCmp('paypleasedetailGrid');
  72. this.deselect(grid.multiselected);
  73. grid.multiselected = new Array();
  74. var els = Ext.select('div[@class=x-grid-row-checker-checked]').elements;
  75. Ext.each(els, function(el, index){
  76. el.setAttribute('class','x-grid-row-checker');
  77. });
  78. header.el.removeCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');//添加这个
  79. } else {
  80. var grid = Ext.getCmp('batchDealGridPanel');
  81. this.deselect(grid.multiselected);
  82. grid.multiselected = new Array();
  83. var els = Ext.select('div[@class=x-grid-row-checker-checked]').elements;
  84. Ext.each(els, function(el, index){
  85. el.setAttribute('class','x-grid-row-checker');
  86. });
  87. this.selectAll(true);
  88. header.el.addCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');//添加这个
  89. }
  90. }
  91. // Ext.getCmp('paypleasedetailGrid').summary();
  92. }
  93. }),
  94. // listeners:{
  95. // activate:function(){
  96. // console.log(this);
  97. // console.log(this.readOnly);
  98. // }
  99. // },
  100. /**
  101. * 修改为selection改变时,summary也动态改变
  102. */
  103. // summary: function(){
  104. // var me = this,
  105. // store = this.store,
  106. // value;
  107. // Ext.each(me.columns, function(c){
  108. // if(c.summaryType == 'sum'){
  109. // value = store.getSum(c.dataIndex);
  110. // me.down('tbtext[id=' + c.dataIndex + '_sum]').setText(c.header + '(sum):' + value);
  111. // } else if(c.summaryType == 'count'){
  112. // value = store.getCount();
  113. // me.down('tbtext[id=' + c.dataIndex + '_count]').setText(c.header + '(count):' + value);
  114. // } else if(c.summaryType == 'average'){
  115. // value = store.getAverage(c.dataIndex);
  116. // me.down('tbtext[id=' + c.dataIndex + '_average]').setText(c.header + '(average):' + value);
  117. // }
  118. // });
  119. // },
  120. getMultiSelected: function(){
  121. var grid = this;
  122. var items = grid.selModel.getSelection();
  123. Ext.each(items, function(item, index){
  124. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  125. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  126. grid.multiselected.push(item);
  127. }
  128. });
  129. return Ext.Array.unique(grid.multiselected);
  130. },
  131. initComponent:function(){
  132. this.callParent(arguments);
  133. // console.log(urlCondition);
  134. //得到页面上显示的formCondition属性
  135. var gridCondition=this.BaseUtil.getUrlParam('gridCondition');
  136. var condition="";
  137. if(gridCondition==null){
  138. var urlCondition = this.BaseUtil.getUrlParam('formCondition');
  139. //定义通过IS拆分后的数组
  140. var cons=null;
  141. //存在urlCondition的情况下
  142. if(urlCondition){
  143. //对urlCondition进行拆分 urlCondition的格式一般为pp_idIS1
  144. cons = urlCondition.split("IS");
  145. }
  146. var pp_id=0;
  147. if(cons!=null){
  148. if(cons[0]&&cons[1]){
  149. if(cons[0]!=null&&cons[0]!=''){
  150. if(cons[1]>0){
  151. pp_id=cons[1];
  152. }else{
  153. pp_id=0;
  154. }
  155. }
  156. }
  157. }
  158. condition ="ppd_ppid='"+pp_id+"'";
  159. }else condition=gridCondition.replace(/IS/g,'=');
  160. this.getMyData(condition);
  161. },
  162. // getMultiSelected: function(){
  163. // var grid = this;
  164. // var items = grid.selModel.getSelection();
  165. // Ext.each(items, function(item, index){
  166. // if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  167. // && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  168. // grid.multiselected.push(item);
  169. // }
  170. // });
  171. // return Ext.Array.unique(grid.multiselected);
  172. // },
  173. getMyData:function(condition){
  174. var me = this;
  175. var params = {
  176. caller:"PayPlease",
  177. condition:condition
  178. };
  179. if(me.columns && me.columns.length > 2){
  180. me.GridUtil.loadNewStore(me,params);
  181. } else {
  182. me.GridUtil.getGridColumnsAndStore(me,'common/singleGridPanel.action',params);
  183. }
  184. // console.log('444');
  185. //// console.log(me);
  186. // if(me){
  187. // console.log(me.readOnly);
  188. // if(me.readOnly){
  189. // console.log('rrrr');
  190. // }
  191. // }
  192. }/*,
  193. getEffectiveData: function(){
  194. var me = this;
  195. var effective = new Array();
  196. var s = this.store.data.items;
  197. for(var i=0;i<s.length;i++){
  198. var data = s[i].data;
  199. if(data[me.keyField] != null && data[me.keyField] != ""){
  200. effective.push(data);
  201. }
  202. }
  203. return effective;
  204. },
  205. setReadOnly: function(bool){
  206. this.readOnly = bool;
  207. },
  208. reconfigure: function(store, columns){
  209. var d = this.headerCt;
  210. if (this.columns.length <= 1 && columns) {
  211. d.suspendLayout = true;
  212. d.removeAll();
  213. d.add(columns);
  214. }
  215. if (store) {
  216. try{
  217. this.bindStore(store);
  218. } catch (e){
  219. }
  220. } else {
  221. this.getView().refresh();
  222. }
  223. if (columns) {
  224. d.suspendLayout = false;
  225. this.forceComponentLayout();
  226. }
  227. this.fireEvent("reconfigure", this);
  228. },
  229. *//**
  230. * Grid上一条
  231. *//*
  232. prev: function(grid, record){
  233. grid = grid || Ext.getCmp('paypleasedetailGrid');
  234. record = record || grid.selModel.lastSelected;
  235. if(record){
  236. //递归查找上一条,并取到数据
  237. var d = grid.store.getAt(record.index - 1);
  238. if(d){
  239. try {
  240. grid.selModel.select(d);
  241. return d;
  242. } catch (e){
  243. }
  244. } else {
  245. if(record.index - 1 > 0){
  246. return this.prev(grid, d);
  247. } else {
  248. return null;
  249. }
  250. }
  251. }
  252. },
  253. *//**
  254. * Grid下一条
  255. *//*
  256. next: function(grid, record){
  257. grid = grid || Ext.getCmp('paypleasedetailGrid');
  258. record = record || grid.selModel.lastSelected;
  259. if(record){
  260. //递归查找下一条,并取到数据
  261. var d = grid.store.getAt(record.index + 1);
  262. if(d){
  263. try {
  264. grid.selModel.select(d);
  265. return d;
  266. } catch (e){
  267. }
  268. } else {
  269. if(record.index + 1 < grid.store.data.items.length){
  270. return this.next(grid, d);
  271. } else {
  272. return null;
  273. }
  274. }
  275. }
  276. }*/
  277. });