ATPOpDetailGridPanel1.js.svn-base 6.9 KB

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