PayBudget.js 8.6 KB

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