FundPlanning.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.fp.FundPlanning', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views: ['fa.fp.FundPlanning', 'core.button.Query', 'core.button.Export', 'core.button.Print', 'core.button.Close',
  8. 'core.form.MonthDateField','core.form.ConDateFPField'],
  9. init:function(){
  10. var me = this;
  11. this.control({
  12. 'combo[name=fs_name]': {
  13. afterrender: function(f) {
  14. me.getRepCodes(f);
  15. },
  16. change: function(f) {
  17. if(!Ext.isEmpty(f.value)) {
  18. var d = f.lastSelection[0].data.data,
  19. form = f.ownerCt;
  20. form.down('textfield[name=fs_code]').setValue(d.FS_CODE);
  21. var grid = form.ownerCt.down('grid');
  22. me.resetGrid(grid, d);
  23. }
  24. }
  25. },
  26. 'button[name=export]': {
  27. click: function(btn) {
  28. var grid = btn.ownerCt.ownerCt.ownerCt.down('gridpanel');
  29. this.BaseUtil.exportGrid(grid);
  30. }
  31. },
  32. 'erpQueryButton': {
  33. click: function(b) {
  34. var grid = b.ownerCt.ownerCt.ownerCt.down('gridpanel');
  35. this.getGridData(grid);
  36. }
  37. }
  38. });
  39. },
  40. getRepCodes: function(f) {
  41. Ext.Ajax.request({
  42. url : basePath + 'common/getFieldsDatas.action',
  43. params: {
  44. caller: 'FARepSet',
  45. fields: 'fs_code,fs_name,fs_title1,fs_title2,fs_righttitle1,fs_righttitle2,fs_head,fs_righthead',
  46. condition: '1=1'
  47. },
  48. method : 'post',
  49. callback : function(options,success,response){
  50. var rs = new Ext.decode(response.responseText);
  51. if(rs.exceptionInfo){
  52. showError(rs.exceptionInfo);return;
  53. }
  54. if(rs.success){
  55. var data = Ext.decode(rs.data), s = [];
  56. Ext.each(data, function(d){
  57. s.push({
  58. display: d.FS_NAME,
  59. value: d.FS_NAME,
  60. data: d
  61. });
  62. });
  63. f.store.loadData(s);
  64. if(s.length > 0) {
  65. f.setValue(s[0].value);
  66. }
  67. }
  68. }
  69. });
  70. },
  71. resetGrid: function(grid, d) {
  72. var columns = [{
  73. text: d.FS_HEAD,
  74. dataIndex: 'frd_name',
  75. cls: 'x-grid-header-1',
  76. flex: 1
  77. }, {
  78. text: '行次',
  79. dataIndex: 'frd_step',
  80. cls: 'x-grid-header-1',
  81. flex: 0.3
  82. }, {
  83. text: d.FS_TITLE1,
  84. dataIndex: 'frd_amount1',
  85. cls: 'x-grid-header-1',
  86. xtype: 'numbercolumn',
  87. format: '0,000.00',
  88. align: 'right',
  89. flex: 1,
  90. renderer: function(v, m, r) {
  91. if (v == 0) {
  92. m.style = 'text-align: center;color:red;';
  93. return '-';
  94. }
  95. return Ext.util.Format.number(v, '0,000.00');
  96. }
  97. }, {
  98. text: d.FS_TITLE2,
  99. dataIndex: 'frd_completerate',
  100. cls: 'x-grid-header-1',
  101. xtype: 'numbercolumn',
  102. format: '0,000.00',
  103. align: 'right',
  104. flex: 1,
  105. renderer: function(v, m, r) {
  106. if (v == 0) {
  107. m.style = 'text-align: center;color:red;';
  108. return '-';
  109. }
  110. return Ext.util.Format.number(v, '0,000.00');
  111. }
  112. },{
  113. text: d.FS_RIGHTHEAD,
  114. dataIndex: 'frd_rightname',
  115. cls: 'x-grid-header-1',
  116. flex: 1
  117. }, {
  118. text: '行次',
  119. dataIndex: 'frd_rightstep',
  120. cls: 'x-grid-header-1',
  121. flex: 0.3
  122. }, {
  123. text: d.FS_RIGHTTITLE1,
  124. dataIndex: 'frd_rightamount1',
  125. cls: 'x-grid-header-1',
  126. xtype: 'numbercolumn',
  127. format: '0,000.00',
  128. align: 'right',
  129. flex: 1,
  130. renderer: function(v, m, r) {
  131. if (v == 0) {
  132. m.style = 'text-align: center;color:red;';
  133. return '-';
  134. }
  135. return Ext.util.Format.number(v, '0,000.00');
  136. }
  137. }, {
  138. text: d.FS_RIGHTTITLE2,
  139. dataIndex: 'frd_rightcompleterate',
  140. cls: 'x-grid-header-1',
  141. xtype: 'numbercolumn',
  142. format: '0,000.00',
  143. align: 'right',
  144. flex: 1,
  145. renderer: function(v, m, r) {
  146. if (v == 0) {
  147. m.style = 'text-align: center;color:red;';
  148. return '-';
  149. }
  150. return Ext.util.Format.number(v, '0,000.00');
  151. }
  152. }];
  153. var store = new Ext.data.Store({
  154. fields: ['frd_name', 'frd_step', 'frd_amount1', 'frd_completerate', 'frd_rightname', 'frd_rightstep',
  155. 'frd_rightamount1', 'frd_rightcompleterate'],
  156. data: [{frd_step: 1},{frd_step: 2},{frd_step: 3},{frd_step: 4},{frd_step: 5}]
  157. });
  158. grid.reconfigure(store, columns);
  159. this.getGridData(grid);
  160. },
  161. getGridData: function(grid) {
  162. var code = Ext.getCmp('fs_code').value,
  163. fc = Ext.getCmp('frd_fpcircle').value,
  164. cond = '';
  165. if(!Ext.isEmpty(code)) {
  166. cond = "frd_fscode='" + code + "'";
  167. }
  168. if(!Ext.isEmpty(fc)) {
  169. if(cond.length > 0)
  170. cond += ' AND frd_fpcircle ' + fc;
  171. else
  172. cond = 'frd_fpcircle ' + fc;
  173. }
  174. if(cond.length == 0) {
  175. cond = '1=1';
  176. }
  177. cond += ' order by to_number(frd_step)';
  178. Ext.Ajax.request({
  179. url : basePath + 'common/getFieldsDatas.action',
  180. params: {
  181. caller: 'FARepSetDet left join FARepSet on fs_id=fsd_fsid left join FAReportDetail on frd_fscode=fs_code and fsd_step=frd_step',
  182. fields: 'distinct frd_name, frd_step, fsd_rate*frd_amount1 frd_amount1, frd_completerate, frd_rightname, frd_rightstep, fsd_rightrate*frd_rightamount1 frd_rightamount1, frd_rightcompleterate',
  183. condition: cond
  184. },
  185. method : 'post',
  186. callback : function(options,success,response){
  187. var rs = new Ext.decode(response.responseText);
  188. if(rs.exceptionInfo){
  189. showError(rs.exceptionInfo);return;
  190. }
  191. if(rs.success){
  192. var data = Ext.decode(rs.data), s = [];
  193. Ext.each(data, function(d){
  194. s.push({
  195. frd_name: d.FRD_NAME,
  196. frd_step: d.FRD_STEP,
  197. frd_amount1: d.FRD_AMOUNT1,
  198. frd_completerate: d.FRD_COMPLETERATE,
  199. frd_rightname: d.FRD_RIGHTNAME,
  200. frd_rightstep: d.FRD_RIGHTSTEP,
  201. frd_rightamount1: d.FRD_RIGHTAMOUNT1,
  202. frd_rightcompleterate: d.FRD_RIGHTCOMPLETERATE
  203. });
  204. });
  205. grid.store.loadData(s);
  206. }
  207. }
  208. });
  209. }
  210. });