ATPOpDetailGridPanel6.js.svn-base 7.8 KB

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