ReceiveBudget.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.fp.ReceiveBudget', {
  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.ReceiveBudget','core.form.Panel',
  8. 'core.button.CalBudget',
  9. 'core.button.Add','core.button.Save','core.button.Update','core.button.Delete',
  10. 'core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.ResAudit',
  11. 'core.grid.Panel2','core.toolbar.Toolbar','core.grid.YnColumn',
  12. 'core.button.Sync','core.button.Close','core.button.Update',
  13. 'core.trigger.DbfindTrigger','core.form.YnField','core.form.MonthDateField',
  14. 'core.form.FileField','core.trigger.MultiDbfindTrigger',
  15. 'core.form.FtDateField','core.form.ConDateFPField'],
  16. init : function() {
  17. var me = this;
  18. this.control({
  19. 'erpGridPanel2' : {
  20. itemclick : this.onGridItemClick
  21. },
  22. /*'erpFormPanel' : {
  23. afterload : function(form) {
  24. form.getForm().getFields().each(function() {
  25. var val = getUrlParam(this.name);
  26. if(!Ext.isEmpty(val) && Ext.isEmpty(this.getValue())) {
  27. this.setValue(val);
  28. }
  29. });
  30. }
  31. },*/
  32. 'field[name=rb_code]' : {
  33. aftertrigger : function(f) {
  34. if (f.value != null && f.value != '') {
  35. me.GridUtil.loadNewStore(Ext.getCmp('grid'), {
  36. caller: caller,
  37. condition: 'rbd_rbid='+ Ext.getCmp('rb_id').value
  38. });
  39. }
  40. }
  41. },
  42. 'condatefpfield[name=rb_period]': {
  43. afterrender:function(t){
  44. Ext.defer(function(){
  45. me.hidecolumns(t.combo.value);
  46. }, 100);
  47. t.combo.on('select', function(m){
  48. Ext.defer(function(){
  49. me.hidecolumns(m.value);
  50. }, 100);
  51. });
  52. }
  53. },
  54. 'erpAddButton': {
  55. click: function(){
  56. me.FormUtil.onAdd('addReceiveBudget', '新收款预算', 'jsps/fa/fp/ReceiveBudget.jsp');
  57. }
  58. },
  59. 'erpSaveButton': {
  60. click: function(btn){
  61. var form = me.getForm(btn);
  62. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  63. me.BaseUtil.getRandomNumber();
  64. }
  65. this.FormUtil.beforeSave(this);
  66. }
  67. },
  68. 'erpDeleteButton' : {
  69. click: function(btn){
  70. me.FormUtil.onDelete(Ext.getCmp('rb_id').value);
  71. }
  72. },
  73. 'erpUpdateButton': {
  74. click: function(btn){
  75. this.FormUtil.onUpdate(this);
  76. }
  77. },
  78. 'erpCloseButton': {
  79. click: function(btn){
  80. me.FormUtil.beforeClose(me);
  81. }
  82. },
  83. 'erpSubmitButton': {
  84. afterrender: function(btn){
  85. var status = Ext.getCmp('rb_statuscode');
  86. if(status && status.value != 'ENTERING'){
  87. btn.hide();
  88. }
  89. },
  90. click: function(btn){
  91. me.FormUtil.onSubmit(Ext.getCmp('rb_id').value);
  92. }
  93. },
  94. 'erpResSubmitButton': {
  95. afterrender: function(btn){
  96. var status = Ext.getCmp('rb_statuscode');
  97. if(status && status.value != 'COMMITED'){
  98. btn.hide();
  99. }
  100. },
  101. click: function(btn){
  102. me.FormUtil.onResSubmit(Ext.getCmp('rb_id').value);
  103. }
  104. },
  105. 'erpAuditButton': {
  106. afterrender: function(btn){
  107. var status = Ext.getCmp('rb_statuscode');
  108. if(status && status.value != 'COMMITED'){
  109. btn.hide();
  110. }
  111. },
  112. click: function(btn){
  113. me.FormUtil.onAudit(Ext.getCmp('rb_id').value);
  114. }
  115. },
  116. 'erpResAuditButton': {
  117. afterrender: function(btn){
  118. var status = Ext.getCmp('rb_statuscode');
  119. if(status && status.value != 'AUDITED'){
  120. btn.hide();
  121. }
  122. },
  123. click: function(btn){
  124. me.FormUtil.onResAudit(Ext.getCmp('rb_id').value);
  125. }
  126. },
  127. 'erpCalBudgetButton' : {
  128. afterrender: function(btn){
  129. var status = Ext.getCmp('rb_statuscode');
  130. if(status && status.value != 'AUDITED'){
  131. btn.hide();
  132. }
  133. },
  134. click : function(btn) {
  135. var grid = Ext.getCmp('grid');
  136. grid.setLoading(true);
  137. Ext.Ajax.request({
  138. url : basePath + "fa/fp/ReceiveBudgetCalBudget.action",
  139. params:{
  140. yearmonth:Ext.getCmp('rb_date').value,
  141. },
  142. method : 'post',
  143. timeout : 300000,
  144. callback : function(options, success, response) {
  145. grid.setLoading(false);
  146. var res = Ext.decode(response.responseText);
  147. if (res.exceptionInfo) {
  148. showError(res.exceptionInfo);
  149. return;
  150. }
  151. if (res.success) {
  152. showMessage("提示", "计算收款预算成功!");
  153. }
  154. }
  155. });
  156. }
  157. }
  158. });
  159. },
  160. hidecolumns:function(value){
  161. if(!Ext.isEmpty(value)) {
  162. var grid = Ext.getCmp("grid");
  163. if(value <= 2){
  164. grid.down('gridcolumn[dataIndex=rbd_weekone]').show();
  165. grid.down('gridcolumn[dataIndex=rbd_weektwo]').show();
  166. grid.down('gridcolumn[dataIndex=rbd_weekthree]').show();
  167. grid.down('gridcolumn[dataIndex=rbd_weekfour]').show();
  168. grid.down('gridcolumn[dataIndex=rbd_monthone]').hide();
  169. grid.down('gridcolumn[dataIndex=rbd_monthtwo]').hide();
  170. grid.down('gridcolumn[dataIndex=rbd_monththree]').hide();
  171. grid.down('gridcolumn[dataIndex=rbd_season1]').hide();
  172. grid.down('gridcolumn[dataIndex=rbd_season2]').hide();
  173. grid.down('gridcolumn[dataIndex=rbd_season3]').hide();
  174. grid.down('gridcolumn[dataIndex=rbd_season4]').hide();
  175. grid.down('gridcolumn[dataIndex=rbd_subtotalmonth]').show();
  176. grid.down('gridcolumn[dataIndex=rbd_subtotalseason]').hide();
  177. grid.down('gridcolumn[dataIndex=rbd_subtotalyear]').hide();
  178. grid.down('gridcolumn[dataIndex=rbd_subtotal]').hide();
  179. } else if(value >= 2 && value <= 6){
  180. grid.down('gridcolumn[dataIndex="rbd_weekone"]').hide();
  181. grid.down('gridcolumn[dataIndex=rbd_weektwo]').hide();
  182. grid.down('gridcolumn[dataIndex=rbd_weekthree]').hide();
  183. grid.down('gridcolumn[dataIndex=rbd_weekfour]').hide();
  184. grid.down('gridcolumn[dataIndex=rbd_monthone]').show();
  185. grid.down('gridcolumn[dataIndex=rbd_monthtwo]').show();
  186. grid.down('gridcolumn[dataIndex=rbd_monththree]').show();
  187. grid.down('gridcolumn[dataIndex=rbd_season1]').hide();
  188. grid.down('gridcolumn[dataIndex=rbd_season2]').hide();
  189. grid.down('gridcolumn[dataIndex=rbd_season3]').hide();
  190. grid.down('gridcolumn[dataIndex=rbd_season4]').hide();
  191. grid.down('gridcolumn[dataIndex=rbd_subtotalmonth]').hide();
  192. grid.down('gridcolumn[dataIndex=rbd_subtotalseason]').show();
  193. grid.down('gridcolumn[dataIndex=rbd_subtotalyear]').hide();
  194. grid.down('gridcolumn[dataIndex=rbd_subtotal]').hide();
  195. } else if(value == 7){
  196. grid.down('gridcolumn[dataIndex=rbd_weekone]').hide();
  197. grid.down('gridcolumn[dataIndex=rbd_weektwo]').hide();
  198. grid.down('gridcolumn[dataIndex=rbd_weekthree]').hide();
  199. grid.down('gridcolumn[dataIndex=rbd_weekfour]').hide();
  200. grid.down('gridcolumn[dataIndex=rbd_monthone]').hide();
  201. grid.down('gridcolumn[dataIndex=rbd_monthtwo]').hide();
  202. grid.down('gridcolumn[dataIndex=rbd_monththree]').hide();
  203. grid.down('gridcolumn[dataIndex=rbd_season1]').show();
  204. grid.down('gridcolumn[dataIndex=rbd_season2]').show();
  205. grid.down('gridcolumn[dataIndex=rbd_season3]').show();
  206. grid.down('gridcolumn[dataIndex=rbd_season4]').show();
  207. grid.down('gridcolumn[dataIndex=rbd_subtotalmonth]').hide();
  208. grid.down('gridcolumn[dataIndex=rbd_subtotalseason]').hide();
  209. grid.down('gridcolumn[dataIndex=rbd_subtotalyear]').show();
  210. grid.down('gridcolumn[dataIndex=rbd_subtotal]').hide();
  211. } else if(value == 8){
  212. grid.down('gridcolumn[dataIndex=rbd_weekone]').hide();
  213. grid.down('gridcolumn[dataIndex=rbd_weektwo]').hide();
  214. grid.down('gridcolumn[dataIndex=rbd_weekthree]').hide();
  215. grid.down('gridcolumn[dataIndex=rbd_weekfour]').hide();
  216. grid.down('gridcolumn[dataIndex=rbd_monthone]').hide();
  217. grid.down('gridcolumn[dataIndex=rbd_monthtwo]').hide();
  218. grid.down('gridcolumn[dataIndex=rbd_monththree]').hide();
  219. grid.down('gridcolumn[dataIndex=rbd_season1]').hide();
  220. grid.down('gridcolumn[dataIndex=rbd_season2]').hide();
  221. grid.down('gridcolumn[dataIndex=rbd_season3]').hide();
  222. grid.down('gridcolumn[dataIndex=rbd_season4]').hide();
  223. grid.down('gridcolumn[dataIndex=rbd_subtotalmonth]').hide();
  224. grid.down('gridcolumn[dataIndex=rbd_subtotalseason]').hide();
  225. grid.down('gridcolumn[dataIndex=rbd_subtotalyear]').hide();
  226. grid.down('gridcolumn[dataIndex=rbd_subtotal]').show();
  227. }
  228. }
  229. },
  230. onGridItemClick : function(selModel, record) {//grid行选择
  231. this.GridUtil.onGridItemClick(selModel, record);
  232. },
  233. getForm : function(btn) {
  234. return btn.ownerCt.ownerCt;
  235. }
  236. });