BillAP.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.gs.BillAP', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'fa.gs.BillAP','core.form.Panel','core.form.MultiField','core.form.FileField','core.form.MultiField',
  8. 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close',
  9. 'core.button.ResSubmit','core.button.Update','core.button.Delete','core.button.Nullify',
  10. 'core.button.ResAudit','core.button.UpdateInfo',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.SeparNumber','core.form.YnField'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'field[name=bap_duedate]':{
  17. beforerender: function(field){
  18. field.readOnly=false;
  19. }
  20. },
  21. 'textfield[name=bap_doublebalance]':{
  22. beforerender: function(field){
  23. if(Ext.getCmp('bap_paybillcode')&&Ext.getCmp('bap_paybillcode').value!=""){
  24. field.readOnly=true;
  25. }
  26. }
  27. },
  28. 'erpSaveButton': {
  29. click: function(btn){
  30. var form = me.getForm(btn);
  31. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  32. me.BaseUtil.getRandomNumber();
  33. }
  34. this.FormUtil.beforeSave(me);
  35. }
  36. },
  37. 'erpCloseButton': {
  38. click: function(btn){
  39. this.FormUtil.beforeClose(this);
  40. }
  41. },
  42. 'erpAddButton': {
  43. click: function(){
  44. me.FormUtil.onAdd('addBillAP', '新增应付票据', 'jsps/fa/gs/billAP.jsp');
  45. }
  46. },
  47. 'erpUpdateButton': {
  48. click: function(btn){
  49. this.FormUtil.onUpdate(this);
  50. }
  51. },
  52. 'erpDeleteButton': {
  53. click: function(btn){
  54. this.FormUtil.onDelete(Ext.getCmp('bap_id').value);
  55. }
  56. },
  57. 'erpSubmitButton': {
  58. afterrender: function(btn){
  59. var status = Ext.getCmp('bap_statuscode');
  60. if(status && status.value != 'ENTERING'){
  61. btn.hide();
  62. }
  63. },
  64. click: function(btn){
  65. me.FormUtil.onSubmit(Ext.getCmp('bap_id').value);
  66. }
  67. },
  68. 'erpResSubmitButton': {
  69. afterrender: function(btn){
  70. var status = Ext.getCmp('bap_statuscode');
  71. if(status && status.value != 'COMMITED'){
  72. btn.hide();
  73. }
  74. },
  75. click: function(btn){
  76. me.FormUtil.onResSubmit(Ext.getCmp('bap_id').value);
  77. }
  78. },
  79. 'erpAuditButton': {
  80. afterrender: function(btn){
  81. var status = Ext.getCmp('bap_statuscode');
  82. if(status && status.value != 'COMMITED'){
  83. btn.hide();
  84. }
  85. },
  86. click: function(btn){
  87. me.FormUtil.onAudit(Ext.getCmp('bap_id').value);
  88. }
  89. },
  90. 'erpResAuditButton': {
  91. afterrender: function(btn){
  92. var status = Ext.getCmp('bap_statuscode');
  93. if(status && status.value != 'AUDITED'){
  94. btn.hide();
  95. }
  96. },
  97. click: function(btn){
  98. me.FormUtil.onResAudit(Ext.getCmp('bap_id').value);
  99. }
  100. },
  101. 'erpNullifyButton': {
  102. afterrender: function(btn){
  103. var status = Ext.getCmp('bap_nowstatus');
  104. if(status && status.value != '已作废'){
  105. btn.hide();
  106. }
  107. },
  108. click: function(btn){
  109. me.FormUtil.onNullify(Ext.getCmp('bap_id').value);
  110. }
  111. },
  112. 'textfield[name=bap_cmrate]':{
  113. change: me.gettopaybalance
  114. },
  115. 'textfield[name=bap_doublebalance]':{
  116. change: me.gettopaybalance
  117. },
  118. 'erpUpdateInfoButton':{
  119. click:function(){
  120. var text=Ext.getCmp('bap_duedate');
  121. me.updateInfo(text.value,Ext.getCmp('bap_id').value);
  122. }
  123. },
  124. });
  125. },
  126. updateInfo:function(text,id){
  127. Ext.Ajax.request({
  128. url : basePath + 'fa/gs/billap/updateInfo.action',
  129. params: {text:text,id:id},
  130. method : 'post',
  131. async:false,
  132. callback : function(options,success,response){
  133. var res = new Ext.decode(response.responseText);
  134. if(res.exceptionInfo != null){
  135. showError(res.exceptionInfo);return;
  136. }
  137. showMessage("提示", '更新成功!');
  138. window.location.reload();
  139. }
  140. });
  141. },
  142. getForm: function(btn){
  143. return btn.ownerCt.ownerCt;
  144. },
  145. gettopaybalance: function(){
  146. if(Ext.getCmp('bap_doublebalance') && Ext.getCmp('bap_cmrate')) {
  147. var doublebalance = Ext.Number.from(Ext.getCmp('bap_doublebalance').getValue(), 0);
  148. var cmrate = Ext.Number.from(Ext.getCmp('bap_cmrate').getValue(), 0);
  149. Ext.getCmp('bap_topaybalance').setValue(Ext.Number.toFixed(doublebalance*cmrate, 2));
  150. if (typeof (f = Ext.getCmp('bap_leftamount')) != 'undefined' ) {
  151. var v1 = (Ext.getCmp('bap_settleamount').value || 0);
  152. Ext.getCmp('bap_leftamount').setValue(Ext.Number.toFixed(doublebalance-v1, 2));
  153. }
  154. }
  155. }
  156. });