ATPOpDetailGridPanel5.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. Ext.define('erp.view.pm.atp.ATPOpDetailGridPanel5',{
  2. extend: 'Ext.grid.Panel',
  3. requires: ['erp.view.core.plugin.CopyPasteMenu'],
  4. alias: 'widget.ATPOpDetailGridPanel5',
  5. emptyText : $I18N.common.grid.emptyText,
  6. columnLines : true,
  7. autoScroll : true,
  8. id:'grid5',
  9. store: [],
  10. columns: new Array(),
  11. height:height,
  12. gridcondition:"",
  13. bodyStyle:'background-color:#f1f1f1;',
  14. selModel: Ext.create('Ext.selection.CheckboxModel',{
  15. headerWidth: 0
  16. }),
  17. LastCondition:"",
  18. dockedItems: [{
  19. id : 'pagingtoolbar5',
  20. xtype: 'erpMpsToolbar',
  21. dock: 'bottom',
  22. displayInfo: true
  23. }],
  24. GridUtil: Ext.create('erp.util.GridUtil'),
  25. BaseUtil: Ext.create('erp.util.BaseUtil'),
  26. plugins: [Ext.create('Ext.ux.grid.GridHeaderFilters'), Ext.create('erp.view.core.plugin.CopyPasteMenu')],
  27. initComponent : function(){
  28. this.getCount(caller,"");
  29. this.callParent(arguments);
  30. },
  31. getCount: function(c, condition){
  32. var me = this;
  33. c=c||caller;
  34. condition=me.getCondition(condition);
  35. Ext.Ajax.request({//拿到grid的数据总数count
  36. url : basePath + '/common/datalistCount.action',
  37. params: {
  38. caller: c,
  39. condition: condition,
  40. _noc:1
  41. },
  42. method : 'post',
  43. callback : function(options,success,response){
  44. var res = new Ext.decode(response.responseText);
  45. if(res.exception || res.exceptionInfo){
  46. showError(res.exceptionInfo);
  47. return;
  48. }
  49. dataCount = res.count;
  50. me.getColumnsAndStore(caller, condition, page, pageSize);
  51. }
  52. });
  53. },
  54. getCondition:function(condition){
  55. condition=(!condition || condition=="")?atpcondition:condition+" AND "+atpcondition;
  56. condition+=" AND ad_kind='SUPPLY'";
  57. condition =BaseQueryCondition==""?condition:condition+" AND "+BaseQueryCondition;
  58. condition=condition.replace(/pr_code/g,'ad_prodcode');
  59. if(!Ext.isEmpty(this.filterCondition)) {
  60. if(condition == '') {
  61. condition = this.filterCondition;
  62. } else {
  63. condition = '(' + condition + ') AND (' + this.filterCondition + ')';
  64. }
  65. }
  66. return condition;
  67. },
  68. listeners: {
  69. 'headerfiltersapply': function(grid, filters) {
  70. if(this.allowFilter){
  71. var condition = null;
  72. for(var fn in filters){
  73. var value = filters[fn],f = grid.getHeaderFilterField(fn);
  74. if(!Ext.isEmpty(value)){
  75. if(f.filtertype) {
  76. if (f.filtertype == 'numberfield') {
  77. value = fn + "=" + value + " ";
  78. }
  79. } else {
  80. if(Ext.isDate(value)){
  81. value = Ext.Date.toString(value);
  82. value = "to_char(" + fn + ",'yyyy-MM-dd')='" + value + "' ";
  83. } else {
  84. var exp_t = /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,
  85. exp_d = /^(\d{4})\-(\d{2})\-(\d{2})$/;
  86. if(exp_d.test(value)){
  87. value = "to_char(" + fn + ",'yyyy-MM-dd')='" + value + "' ";
  88. } else if(exp_t.test(value)){
  89. value = "to_char(" + fn + ",'yyyy-MM-dd')='" + value.substr(0, 10) + "' ";
  90. } else{
  91. if(!f.autoDim) {
  92. value = fn + " LIKE '" + value + "%' ";
  93. } else {
  94. value = fn + " LIKE '%" + value + "%' ";
  95. }
  96. }
  97. }
  98. }
  99. if(condition == null){
  100. condition = value;
  101. } else {
  102. condition = condition + " AND " + value;
  103. }
  104. }
  105. }
  106. this.filterCondition = condition;
  107. page = 1;
  108. this.getCount(caller,"");
  109. } else {
  110. this.allowFilter = true;
  111. }
  112. return false;
  113. }
  114. },
  115. getColumnsAndStore: function(caller, condition, page, pageSize){
  116. var me = this;
  117. me.gridcondition=condition;
  118. me.BaseUtil.getActiveTab().setLoading(true);//loading...
  119. Ext.Ajax.request({//拿到grid的columns
  120. url : basePath + 'common/datalist.action',
  121. params: {
  122. caller: caller,
  123. condition: condition,
  124. page: page,
  125. pageSize: pageSize,
  126. _noc:1
  127. },
  128. method : 'post',
  129. callback : function(options,success,response){
  130. me.BaseUtil.getActiveTab().setLoading(false);
  131. var res = new Ext.decode(response.responseText);
  132. if(res.exception || res.exceptionInfo){
  133. showError(res.exceptionInfo);
  134. return;
  135. }
  136. var data = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : [];//一定要去掉多余逗号,ie对此很敏感
  137. if(me.columns && me.columns.length > 2){
  138. me.store.loadData(data);
  139. }else {
  140. var store = Ext.create('Ext.data.Store', {
  141. fields: res.fields,
  142. data: data
  143. });
  144. Ext.getCmp('grid5').reconfigure(store, res.columns);
  145. }
  146. Ext.getCmp('pagingtoolbar5').afterOnLoad();
  147. Ext.Ajax.request({//拿到grid的columns
  148. url : basePath + 'pm/mps/getSum.action',
  149. params: {
  150. caller: caller,
  151. condition:condition,
  152. fields:'ad_needqty',
  153. _noc:1
  154. },
  155. method : 'post',
  156. callback : function(options,success,response){
  157. me.BaseUtil.getActiveTab().setLoading(false);
  158. var res = new Ext.decode(response.responseText);
  159. if(res.exception || res.exceptionInfo){
  160. showError(res.exceptionInfo);
  161. return;
  162. }else if(res.success){
  163. var obj=new Ext.decode(res.data);
  164. var text=Ext.getCmp('text5');
  165. if(text){
  166. text.setText('数量 :'+obj.md_Needqty);
  167. }else {
  168. Ext.getCmp('pagingtoolbar5').insert(16,{
  169. xtype:'tbtext',
  170. id:'text5',
  171. text:'数量 :'+obj.md_Needqty
  172. });
  173. }
  174. }
  175. }
  176. });
  177. }
  178. });
  179. },
  180. });