CmQuery.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.ars.CmQuery', {
  3. extend: 'Ext.app.Controller',
  4. GridUtil: Ext.create('erp.util.GridUtil'),
  5. condition:'',
  6. views:[
  7. 'fa.ars.cmQuery.Viewport','fa.ars.cmQuery.GridPanel','fa.ars.cmQuery.QueryForm','fa.ars.cmQuery.QueryWin',
  8. 'core.trigger.DbfindTrigger','core.form.FtField','core.form.ConDateField','core.form.YnField',
  9. 'core.form.FtDateField','core.form.FtFindField','core.grid.YnColumn','core.grid.TfColumn','core.form.ConMonthDateField',
  10. 'core.button.Refresh'
  11. ],
  12. refs: [{ref: 'grid', selector: '#cmquerygrid'}],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'erpQueryFormPanel button[name=confirm]': {
  17. },
  18. 'button[name=refresh]':{
  19. click: function(btn){
  20. me.getGrid().setLoading(true);
  21. Ext.Ajax.request({
  22. url: basePath + 'fa/ars/CmQueryController/refreshCmQuery.action',
  23. method: 'GET',
  24. timeout: 120000,
  25. callback: function(opt, s, r) {
  26. me.getGrid().setLoading(false);
  27. var rs = Ext.decode(r.responseText);
  28. if(rs.success) {
  29. //grid 刷新操作
  30. me.query(me.condition);
  31. }else{
  32. //grid 刷新操作
  33. me.query(me.condition);
  34. }
  35. }
  36. });
  37. }
  38. },
  39. 'button[name=query]':{
  40. afterrender: function(btn){
  41. var me = this;
  42. var filter = me.filter = me.createFilterPanel(btn);
  43. filter.show();
  44. },
  45. click: function(btn){
  46. var me = this;
  47. if (me.filter){
  48. me.filter.show();
  49. } else{
  50. var filter = me.filter = me.createFilterPanel(btn);
  51. filter.show();
  52. }
  53. }
  54. }
  55. });
  56. },
  57. createFilterPanel:function(btn){
  58. var me = this;
  59. var filter = Ext.create('Ext.Window', {
  60. id: btn.getId() + '-filter',
  61. style: 'background:#f1f1f1',
  62. title: '筛选条件',
  63. width: 500,
  64. modal:true,
  65. height: 385,
  66. layout: 'column',
  67. defaults: {
  68. margin: '2 2 2 10'
  69. },
  70. items: [{
  71. id: 'cm_yearmonth',
  72. name: 'cm_yearmonth',
  73. xtype: 'conmonthdatefield',
  74. fieldLabel: '期间',
  75. labelWidth: 80,
  76. margin: '10 2 2 10',
  77. columnWidth: .51,
  78. getValue: function() {
  79. if(!Ext.isEmpty(this.value)) {
  80. return {begin: this.firstVal, end: this.secondVal};
  81. }
  82. return null;
  83. },
  84. listeners:{
  85. afterrender:function(cmd){
  86. me.getCurrentYearmonth(cmd);
  87. }
  88. }
  89. },{
  90. xtype: 'dbfindtrigger',
  91. fieldLabel: '币别',
  92. height: 23,
  93. labelWidth: 80,
  94. id: 'cm_currency',
  95. name:'cm_currency',
  96. margin: '10 2 2 10',
  97. flex: 0.2,
  98. columnWidth: .51
  99. },{
  100. fieldLabel: '客户编码',
  101. labelWidth: 80,
  102. height: 23,
  103. layout: 'hbox',
  104. columnWidth: 1,
  105. xtype: 'fieldcontainer',
  106. id: 'cmq_custcode',
  107. defaults: {
  108. fieldStyle : "background:#FFFAFA;color:#515151;"
  109. },
  110. items: [{
  111. labelWidth: 35,
  112. xtype: 'dbfindtrigger',
  113. flex: 0.32,
  114. id: 'cm_custcode',
  115. name: 'cm_custcode'
  116. },{
  117. xtype: 'textfield',
  118. id: 'cm_custname',
  119. name: 'cm_custname',
  120. flex:0.32,
  121. readOnly: true,
  122. fieldStyle: 'background:#f1f1f1;'
  123. }],
  124. getValue: function() {
  125. var a = Ext.getCmp('cm_custcode');
  126. if(!Ext.isEmpty(a.value)) {
  127. return {cm_custcode: a.value};
  128. }
  129. return null;
  130. }
  131. },{
  132. xtype: 'checkbox',
  133. id: 'chkumio',
  134. name: 'chkumio',
  135. columnWidth: .51,
  136. boxLabel: '包含未开票未转发出商品出货'
  137. },{
  138. xtype: 'checkbox',
  139. id: 'chkzerobalance',
  140. name: 'chkzerobalance',
  141. columnWidth: .51,
  142. boxLabel: '余额为零的不显示'
  143. },{
  144. xtype: 'checkbox',
  145. id: 'chknoamount',
  146. name: 'chknoamount',
  147. columnWidth: .51,
  148. boxLabel: '无发生额的不显示'
  149. },{
  150. xtype: 'checkbox',
  151. id: 'chkstatis',
  152. name: 'chkstatis',
  153. checked:true,
  154. columnWidth: .51,
  155. boxLabel: '是否显示汇总数'
  156. }],
  157. buttonAlign: 'center',
  158. buttons: [{
  159. text: '确定',
  160. width: 60,
  161. cls: 'x-btn-blue',
  162. handler: function(btn) {
  163. var fl = btn.ownerCt.ownerCt;
  164. var con = me.getCondition(fl);
  165. var grid = Ext.getCmp('cmquerygrid');
  166. grid.chkumio = Ext.getCmp('chkumio').getValue();
  167. me.condition = con;
  168. me.query(con);
  169. fl.hide();
  170. }
  171. },{
  172. text: '关闭',
  173. width: 60,
  174. cls: 'x-btn-blue',
  175. handler: function(btn) {
  176. var fl = btn.ownerCt.ownerCt;
  177. fl.hide();
  178. }
  179. }]
  180. });
  181. return filter;
  182. },
  183. getCondition: function(pl) {
  184. var r = new Object(),v;
  185. Ext.each(pl.items.items, function(item){
  186. if(item.getValue !== undefined) {
  187. v = item.getValue();
  188. if(!Ext.isEmpty(v)) {
  189. r[item.id] = v;
  190. }
  191. }
  192. });
  193. var tb = Ext.getCmp('gl_info_ym');
  194. if(tb)
  195. tb.updateInfo(r);
  196. return r;
  197. },
  198. query: function(cond) {
  199. var me = this;
  200. cond = cond || me.getCondition(me.filter);
  201. var grid = me.getGrid();
  202. grid.setLoading(true);
  203. Ext.Ajax.request({
  204. url: basePath + 'fa/ars/CmQueryController/getCmQuery.action',
  205. params: {
  206. condition: Ext.encode(cond)
  207. },
  208. callback : function(options,success,response){
  209. grid.setLoading(false);
  210. var res = new Ext.decode(response.responseText);
  211. if(res.exceptionInfo){
  212. showError(res.exceptionInfo);return;
  213. }
  214. if(res.columns){
  215. //data
  216. var data = [];
  217. if(!res.data){
  218. me.GridUtil.add10EmptyData(grid.detno, data);
  219. me.GridUtil.add10EmptyData(grid.detno, data);//添加20条空白数据
  220. } else {
  221. if(res.data instanceof Array) {
  222. data = res.data;
  223. } else {
  224. data = Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  225. }
  226. }
  227. //view
  228. if(grid.selModel.views == null){
  229. grid.selModel.views = [];
  230. }
  231. grid.store.loadData(data);
  232. var lockedView = grid.view.lockedView;
  233. if(lockedView){
  234. var tableEl = lockedView.el.child('.x-grid-table');
  235. if(tableEl){
  236. tableEl.dom.style.marginBottom = '9px';
  237. }
  238. }
  239. }
  240. }
  241. });
  242. },
  243. getCurrentYearmonth: function(f) {
  244. Ext.Ajax.request({
  245. url: basePath + 'fa/ars/getCurrentYearmonth.action',
  246. method: 'GET',
  247. callback: function(opt, s, r) {
  248. var rs = Ext.decode(r.responseText);
  249. if(rs.exceptionInfo) {
  250. showError(rs.exceptionInfo);
  251. } else if(rs.data) {
  252. f.setValue(rs.data);
  253. }
  254. }
  255. });
  256. }
  257. });