CmDetailQuery.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.ars.CmDetailQuery', {
  3. extend: 'Ext.app.Controller',
  4. BaseUtil: Ext.create('erp.util.BaseUtil'),
  5. views: ['core.trigger.DbfindTrigger', 'fa.ars.CmDetailQuery', 'fa.ars.QueryGrid', 'core.form.MonthDateField',
  6. 'core.form.ConMonthDateField', 'core.form.YearDateField'],
  7. init:function(){
  8. var me = this;
  9. this.control({
  10. 'button[id=query]': {
  11. afterrender: function(btn) {
  12. setTimeout(function(){
  13. me.showFilterPanel(btn);
  14. }, 200);
  15. },
  16. click: function(btn) {
  17. me.showFilterPanel(btn);
  18. }
  19. },
  20. 'button[name=export]': {
  21. click: function() {
  22. var grid = Ext.getCmp('querygrid');
  23. me.BaseUtil.exportGrid(grid, '应收明细账');
  24. }
  25. }
  26. });
  27. },
  28. showFilterPanel: function(btn) {
  29. var filter = Ext.getCmp(btn.getId() + '-filter');
  30. if(!filter) {
  31. filter = this.createFilterPanel(btn);
  32. }
  33. filter.show();
  34. },
  35. hideFilterPanel: function(btn) {
  36. var filter = Ext.getCmp(btn.getId() + '-filter');
  37. if(filter) {
  38. filter.hide();
  39. }
  40. },
  41. query: function(cond) {
  42. var grid = Ext.getCmp('querygrid');
  43. grid.setLoading(true);
  44. Ext.Ajax.request({
  45. url: basePath + 'fa/ars/CmQueryController/getCmDetailQuery.action',
  46. params: {
  47. condition: Ext.encode(cond)
  48. },
  49. callback: function(opt, s, r) {
  50. var res = Ext.decode(r.responseText);
  51. if(grid && res.data) {
  52. grid.store.loadData(res.data);
  53. }
  54. grid.setLoading(false);
  55. }
  56. });
  57. },
  58. getCondition: function(pl) {
  59. var r = new Object(),v;
  60. Ext.each(pl.items.items, function(item){
  61. if(item.getValue !== undefined) {
  62. v = item.getValue();
  63. if(!Ext.isEmpty(v)) {
  64. r[item.id] = v;
  65. }
  66. }
  67. });
  68. var tb = Ext.getCmp('gl_info_ym');
  69. if(tb)
  70. tb.updateInfo(r);
  71. return r;
  72. },
  73. loadDetail: function(store, record) {
  74. var ym = record.get('cm_yearmonth'),
  75. caCode = this._getCaCode(store, record),
  76. cr = record.get('cmc_currency');
  77. this.BaseUtil.onAdd('GLDetail_' + ym + '_' + caCode, '明细账',
  78. 'jsps/fa/gla/glDetail.jsp?y=' + ym + '&c=' + caCode + '&cr=' + cr);
  79. },
  80. _getCaCode: function(store, record) {
  81. var c = record.get('ca_code');
  82. if(Ext.isEmpty(c)) {
  83. return this._getCaCode(store, store.getAt(store.indexOf(record) - 1));
  84. }
  85. return c;
  86. },
  87. getCurrentYearmonth: function(f) {
  88. Ext.Ajax.request({
  89. url: basePath + 'fa/ars/getCurrentYearmonth.action',
  90. method: 'GET',
  91. callback: function(opt, s, r) {
  92. var rs = Ext.decode(r.responseText);
  93. if(rs.exceptionInfo) {
  94. showError(rs.exceptionInfo);
  95. } else if(rs.data) {
  96. f.setValue(rs.data);
  97. }
  98. }
  99. });
  100. },
  101. createFilterPanel: function(btn) {
  102. var me = this;
  103. var filter = Ext.create('Ext.Window', {
  104. id: btn.getId() + '-filter',
  105. style: 'background:#f1f1f1',
  106. title: '筛选条件',
  107. width: 500,
  108. height: 385,
  109. layout: 'column',
  110. defaults: {
  111. margin: '2 2 2 10'
  112. },
  113. //期间 从…到…/币别/客户/单据类型(全部/发票/其它应收单/出货单/收款单/退款单/冲账单)/包含已出货未开票/包含未记账发票/余额为零不显示/无发生额不显示
  114. items: [{
  115. id: 'cm_yearmonth',
  116. name: 'cm_yearmonth',
  117. xtype: 'conmonthdatefield',
  118. fieldLabel: '期间',
  119. labelWidth: 80,
  120. margin: '10 2 2 10',
  121. columnWidth: .51,
  122. getValue: function() {
  123. if(!Ext.isEmpty(this.value)) {
  124. return {begin: this.firstVal, end: this.secondVal};
  125. }
  126. return null;
  127. },
  128. listeners:{
  129. afterrender:function(cmd){
  130. me.getCurrentYearmonth(cmd);
  131. }
  132. }
  133. },{
  134. xtype: 'dbfindtrigger',
  135. fieldLabel: '币别',
  136. height: 23,
  137. labelWidth: 80,
  138. id: 'cm_currency',
  139. name:'cm_currency',
  140. // margin: '10 2 2 10',
  141. flex: 0.2,
  142. columnWidth: .51
  143. },{
  144. fieldLabel: '客户编码',
  145. labelWidth: 80,
  146. height: 23,
  147. layout: 'hbox',
  148. columnWidth: 1,
  149. xtype: 'fieldcontainer',
  150. id: 'cmq_custcode',
  151. defaults: {
  152. fieldStyle : "background:#FFFAFA;color:#515151;"
  153. },
  154. items: [{
  155. labelWidth: 35,
  156. xtype: 'dbfindtrigger',
  157. flex: 0.32,
  158. id: 'cm_custcode',
  159. name: 'cm_custcode'
  160. },{
  161. xtype: 'textfield',
  162. id: 'cm_custname',
  163. name: 'cm_custname',
  164. flex:0.32,
  165. readOnly: true,
  166. fieldStyle: 'background:#f1f1f1;'
  167. }],
  168. getValue: function() {
  169. var a = Ext.getCmp('cm_custcode');
  170. if(!Ext.isEmpty(a.value)) {
  171. return {cm_custcode: a.value};
  172. }
  173. return null;
  174. }
  175. },{
  176. xtype: 'combo',
  177. // flex: 1,
  178. editable: false,
  179. labelWidth: 80,
  180. name: 'tb_source',
  181. id: 'tb_source',
  182. fieldLabel: '单据类型',
  183. displayField: 'display',
  184. valueField: 'value',
  185. queryMode: 'local',
  186. value: "all",
  187. columnWidth: .51,
  188. store: Ext.create('Ext.data.Store', {
  189. fields: ['display', 'value'],
  190. data : [
  191. {"display": "全部", "value": "all"},
  192. {"display": "发票", "value": "arbill"},
  193. {"display": "其它应收单", "value": "other"},
  194. {"display": "出货单", "value": "inout"},
  195. {"display": "收款单", "value": "recb"},
  196. {"display": "退款单", "value": "recbr"},
  197. {"display": "冲账单", "value": "cmb"},
  198. {"display": "预收款", "value": "prer"}
  199. ]
  200. })
  201. },{
  202. xtype: 'checkbox',
  203. id: 'chknoturn',
  204. name: 'chknoturn',
  205. columnWidth: .51,
  206. boxLabel: '包括已出货未开票信息'
  207. },{
  208. xtype: 'checkbox',
  209. id: 'chknopost',
  210. name: 'chknopost',
  211. columnWidth: .51,
  212. boxLabel: '包含未记账发票'
  213. },{
  214. xtype: 'checkbox',
  215. id: 'chkzerobalance',
  216. name: 'chkzerobalance',
  217. columnWidth: .51,
  218. boxLabel: '余额为零的不显示'
  219. },{
  220. xtype: 'checkbox',
  221. id: 'chknoamount',
  222. name: 'chknoamount',
  223. columnWidth: .51,
  224. boxLabel: '无发生额的不显示'
  225. }],
  226. buttonAlign: 'center',
  227. buttons: [{
  228. text: '确定',
  229. width: 60,
  230. cls: 'x-btn-blue',
  231. handler: function(btn) {
  232. var fl = btn.ownerCt.ownerCt,
  233. con = me.getCondition(fl);
  234. me.query(con);
  235. fl.hide();
  236. }
  237. },{
  238. text: '关闭',
  239. width: 60,
  240. cls: 'x-btn-blue',
  241. handler: function(btn) {
  242. var fl = btn.ownerCt.ownerCt;
  243. fl.hide();
  244. }
  245. }]
  246. });
  247. return filter;
  248. }
  249. });