ATPOpDetailGridPanel2.js.svn-base 7.6 KB

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