CarAllowance.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.fee.CarAllowance', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'oa.fee.CarAllowance','core.form.Panel',
  8. 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print',
  9. 'core.button.Upload','core.button.Update','core.button.Delete','core.button.ResAudit','core.button.ResSubmit',
  10. 'core.form.YnField','core.trigger.DbfindTrigger','core.form.MultiField','core.form.FileField','core.button.Confirm'
  11. ],
  12. init:function(){
  13. var me = this;
  14. this.control({
  15. 'erpSaveButton': {
  16. click: function(btn){
  17. var form = me.getForm(btn);
  18. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  19. me.BaseUtil.getRandomNumber();//自动添加编号
  20. }
  21. this.FormUtil.beforeSave(this);
  22. }
  23. },
  24. 'erpCloseButton': {
  25. click: function(btn){
  26. this.FormUtil.beforeClose(this);
  27. }
  28. },
  29. 'erpAddButton': {
  30. click: function(btn){
  31. me.FormUtil.onAdd('CarAllowance', '新增购车补贴申请', 'jsps/oa/fee/carAllowance.jsp');
  32. }
  33. },
  34. 'erpUpdateButton': {
  35. afterrender: function(btn) {
  36. var status = Ext.getCmp('ca_statuscode');
  37. if (status && status.value != 'ENTERING') {
  38. btn.hide();
  39. }
  40. },
  41. click: function(btn){
  42. this.FormUtil.onUpdate(this);
  43. }
  44. },
  45. 'erpDeleteButton': {
  46. afterrender: function(btn) {
  47. var status = Ext.getCmp('ca_statuscode');
  48. if (status && status.value != 'ENTERING') {
  49. btn.hide();
  50. }
  51. },
  52. click: function(btn){
  53. me.FormUtil.onDelete((Ext.getCmp('ca_id').value));
  54. }
  55. },
  56. 'erpAuditButton': {
  57. afterrender: function(btn) {
  58. var status = Ext.getCmp('ca_statuscode');
  59. if (status && status.value != 'COMMITED') {
  60. btn.hide();
  61. }
  62. },
  63. click: function(btn){
  64. this.FormUtil.onAudit(Ext.getCmp('ca_id').value);
  65. }
  66. },
  67. 'erpResAuditButton': {
  68. afterrender: function(btn) {
  69. var status = Ext.getCmp('ca_statuscode');
  70. if (status && status.value != 'AUDITED') {
  71. btn.hide();
  72. }
  73. },
  74. click: function(btn){
  75. this.FormUtil.onResAudit(Ext.getCmp('ca_id').value);
  76. }
  77. },
  78. 'erpSubmitButton': {
  79. afterrender: function(btn) {
  80. var status = Ext.getCmp('ca_statuscode');
  81. if (status && status.value != 'ENTERING') {
  82. btn.hide();
  83. }
  84. },
  85. click: function(btn){
  86. this.FormUtil.onSubmit(Ext.getCmp('ca_id').value);
  87. }
  88. },
  89. 'erpConfirmButton': {afterrender: function(btn){
  90. var statu = Ext.getCmp('ca_statuscode');
  91. if(statu && statu.value != 'AUDITED'){
  92. btn.hide();
  93. }
  94. },
  95. click: function(btn){
  96. me.onConfirm(Ext.getCmp('ca_id').value);
  97. }
  98. } ,
  99. 'erpResSubmitButton': {
  100. afterrender: function(btn) {
  101. var status = Ext.getCmp('ca_statuscode');
  102. if (status && status.value != 'COMMITED') {
  103. btn.hide();
  104. }
  105. },
  106. click: function(btn){
  107. this.FormUtil.onResSubmit(Ext.getCmp('ca_id').value);
  108. }
  109. }
  110. });
  111. },
  112. getForm: function(btn){
  113. return btn.ownerCt.ownerCt;
  114. },
  115. onConfirm: function(id){
  116. var form = Ext.getCmp('form');
  117. Ext.Ajax.request({
  118. url : basePath + form.confirmUrl,
  119. params: {
  120. id: id,
  121. caller:caller
  122. },
  123. method : 'post',
  124. callback : function(options,success,response){
  125. //me.setLoading(false);
  126. var localJson = new Ext.decode(response.responseText);
  127. if(localJson.success){
  128. //audit成功后刷新页面进入可编辑的页面
  129. //auditSuccess(function(){
  130. showMessage("提示", '确认成功');
  131. window.location.reload();
  132. //});
  133. } else {
  134. if(localJson.exceptionInfo){
  135. var str = localJson.exceptionInfo;
  136. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  137. str = str.replace('AFTERSUCCESS', '');
  138. showMessage("提示", '确认成功');
  139. //auditSuccess(function(){
  140. window.location.reload();
  141. //});
  142. } else {
  143. showError(str);return;
  144. }
  145. }
  146. }
  147. }
  148. });
  149. }
  150. });