CashFlowSum.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.gla.CashFlowSum', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil', 'erp.util.RenderUtil'],
  5. views: ['fa.gla.cashFlowSum.Viewport','fa.gla.cashFlowSum.CashFlowGrid',
  6. 'core.form.MonthDateField','core.button.Print', 'core.button.Close'],
  7. BaseUtil: Ext.create('erp.util.BaseUtil'),
  8. FormUtil: Ext.create('erp.util.FormUtil'),
  9. init:function(){
  10. var me = this;
  11. this.control({
  12. 'erpCashFlowGrid': {
  13. itemclick: function(selModel, record){
  14. var treegrid = Ext.getCmp('cashflowgrid');
  15. treegrid.selModel.select(record);
  16. me.loadNode(selModel, record);
  17. }
  18. } ,
  19. 'erpVastPrintButton': {
  20. click: function(btn){
  21. me.vastDeal(btn.ownerCt.ownerCt.dealUrl);
  22. }
  23. },
  24. 'monthdatefield': {
  25. afterrender: function(f) {
  26. this.getCurrentMonth(f, 'MONTH-A');
  27. }
  28. },
  29. 'button[name=export]': {
  30. click: function(btn) {
  31. var grid = btn.ownerCt.ownerCt.ownerCt.down('cashflowgrid');
  32. this.BaseUtil.exportGrid(grid);
  33. }
  34. },
  35. 'button[name=catchdata]': {
  36. click: function(btn) {
  37. this.onCatchData();
  38. }
  39. },
  40. '#setVoucher': {
  41. click: function(btn) {
  42. this.showSetVoucher();
  43. }
  44. },
  45. '#noSetVoucher': {
  46. click: function(btn) {
  47. this.showNoSetVoucher();
  48. }
  49. },
  50. '#cashflowset': {
  51. click: function(btn) {
  52. this.cashFlowSet();
  53. }
  54. }
  55. });
  56. },
  57. loadNode: function(selModel, record){
  58. var me = this;
  59. var tree = Ext.getCmp('cashflowgrid');
  60. if (!record.get('leaf')) {
  61. if(record.isExpanded() && record.childNodes.length > 0){//是根节点,且已展开
  62. record.collapse(true,true);//收拢
  63. me.flag = true;
  64. me.setParentNodes(selModel.ownerCt, record, false);
  65. } else {//未展开
  66. //看是否加载了其children
  67. if(record.childNodes.length == 0){
  68. //从后台加载
  69. tree.setLoading(true);
  70. Ext.Ajax.request({//拿到tree数据
  71. url : basePath + 'fa/gla/cashFlowSum.action',
  72. params: {
  73. yearmonth : Ext.getCmp('yearmonth').value,
  74. type : record.data.cfs_typename,
  75. catecode : record.data.cfs_catecode
  76. },
  77. callback: function(opt, s, r) {
  78. tree.setLoading(false);
  79. var rs = Ext.decode(r.responseText);
  80. if(rs.exceptionInfo) {
  81. showError(rs.exceptionInfo);
  82. } else {
  83. record.appendChild(rs.tree);
  84. record.expand(false, true);//展开
  85. }
  86. }
  87. });
  88. } else {
  89. record.expand(false, true);//展开
  90. }
  91. }
  92. }
  93. },
  94. getActiveTab: function(){
  95. var tab = null;
  96. if(Ext.getCmp("content-panel")){
  97. tab = Ext.getCmp("content-panel").getActiveTab();
  98. }
  99. if(!tab){
  100. var win = parent.Ext.ComponentQuery.query('window');
  101. if(win.length > 0){
  102. tab = win[win.length-1];
  103. }
  104. }
  105. if(!tab && parent.Ext.getCmp("content-panel"))
  106. tab = parent.Ext.getCmp("content-panel").getActiveTab();
  107. if(!tab && parent.parent.Ext.getCmp("content-panel"))
  108. tab = parent.parent.Ext.getCmp("content-panel").getActiveTab();
  109. return tab;
  110. },
  111. getCurrentMonth: function(f, type, con) {
  112. Ext.Ajax.request({
  113. url: basePath + 'fa/getMonth.action',
  114. params: {
  115. type: type
  116. },
  117. callback: function(opt, s, r) {
  118. var rs = Ext.decode(r.responseText);
  119. if(rs.data) {
  120. f.setValue(rs.data.PD_DETNO);
  121. if(con != null) {
  122. con.setMonthValue(rs.data.PD_DETNO);
  123. }
  124. }
  125. }
  126. });
  127. },
  128. /**
  129. * @param select 保留原筛选行
  130. */
  131. onCatchData: function(){
  132. var yearmonth = Ext.getCmp('yearmonth').value;
  133. var grid = Ext.getCmp("cashflowgrid");
  134. var me = this;
  135. if(!Ext.isEmpty(yearmonth)){
  136. var activeTab = me.getActiveTab();
  137. activeTab.setLoading(true);
  138. Ext.Ajax.request({
  139. url: basePath + 'fa/gla/cashFlowSum.action',
  140. params: {
  141. yearmonth : yearmonth
  142. },
  143. async: false,
  144. callback: function(opt, s, r) {
  145. activeTab.setLoading(false);
  146. var rs = Ext.decode(r.responseText);
  147. if(rs.exceptionInfo) {
  148. showError(rs.exceptionInfo);
  149. } else {
  150. grid.store.setRootNode({
  151. text: 'root',
  152. id: 'root',
  153. expanded: true,
  154. children: rs.tree
  155. });
  156. }
  157. }
  158. });
  159. }
  160. },
  161. cashFlowSet: function(){
  162. var grid = Ext.getCmp("cashflowgrid"), yearmonth = Ext.getCmp('yearmonth').value;
  163. var item = grid.view.contextMenu.record;
  164. if(item){
  165. var catecode = item.data.cfs_catecode;
  166. var catename = item.data.cfs_name;
  167. var cashcode = item.data.ca_defaultcashcode;
  168. var cashflow = item.data.ca_defaultcashflow;
  169. this.FormUtil.onAdd('CashFlowSet_'+catecode, '现金流量设置('+catecode+')', 'jsps/common/batchDeal.jsp?whoami=CashFlowSet&vo_yearmonth='+yearmonth+'&vd_catecode='+catecode+'&ca_name='+catename+'&flowcode='+cashcode+'&flowname='+cashflow+'');
  170. }
  171. },
  172. /**
  173. * 已设置现金流量凭证
  174. * @param btn
  175. */
  176. showSetVoucher: function(btn){
  177. var yearmonth = Ext.getCmp('yearmonth').value;
  178. if(yearmonth != null){
  179. this.FormUtil.onAdd('ShowSetVoucher_'+yearmonth,'已设置现金流量凭证',"jsps/common/query.jsp?whoami=ShowSetVoucher&&vd_yearmonth="+yearmonth);
  180. } else {
  181. showError("请选择期间");
  182. }
  183. },
  184. /**
  185. * 未设置现金流量凭证
  186. * @param btn
  187. */
  188. showNoSetVoucher: function(btn){
  189. var yearmonth = Ext.getCmp('yearmonth').value;
  190. if(yearmonth != null){
  191. this.FormUtil.onAdd('ShowNoSetVoucher_'+yearmonth,'未设置现金流量凭证',"jsps/common/query.jsp?whoami=ShowNoSetVoucher&&vd_yearmonth="+yearmonth);
  192. } else {
  193. showError("请选择期间");
  194. }
  195. }
  196. });