CreditChange.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.sale.CreditChange', {
  3. extend : 'Ext.app.Controller',
  4. FormUtil : Ext.create('erp.util.FormUtil'),
  5. BaseUtil : Ext.create('erp.util.BaseUtil'),
  6. views : [ 'scm.sale.CreditChange', 'core.form.Panel',
  7. 'core.form.MultiField', 'core.form.FileField', 'core.button.Add',
  8. 'core.button.Save', 'core.button.Close', 'core.button.Upload',
  9. 'core.button.Update', 'core.button.Delete', 'core.button.Sync',
  10. 'core.button.Submit', 'core.button.ResSubmit', 'core.button.Print',
  11. 'core.button.ResAudit', 'core.button.Audit','core.form.SeparNumber',
  12. 'core.trigger.DbfindTrigger', 'core.trigger.TextAreaTrigger',
  13. 'core.form.YnField' ],
  14. init : function() {
  15. var me = this;
  16. this.control({
  17. 'erpSaveButton' : {
  18. click : function(btn) {
  19. var form = me.getForm(btn);
  20. if (Ext.getCmp(form.codeField).value == null
  21. || Ext.getCmp(form.codeField).value == '') {
  22. me.BaseUtil.getRandomNumber();// 自动添加编号
  23. }
  24. var newtempdate = new Date(Ext.util.Format.date(Ext
  25. .getCmp('cc_newtempcreditdate').value, 'Y-m-d'));
  26. var now = new Date(Ext.util.Format
  27. .date(new Date(), 'Y-m-d'));
  28. if(Ext.getCmp('cc_newtempcreditdate').value==null && Ext.getCmp('cc_newtempcredit').value!=null && Ext.getCmp('cc_newtempcredit').value >0){
  29. showError('请先填写临时额度有效期');
  30. return;
  31. }
  32. if (now > newtempdate) {
  33. showError('新临时额度有效期小于当前日期,请更改!');
  34. return;
  35. }
  36. this.FormUtil.beforeSave(this);
  37. }
  38. },
  39. 'erpUpdateButton' : {
  40. click : function(btn) {
  41. var newtempdate = new Date(Ext.util.Format.date(Ext
  42. .getCmp('cc_newtempcreditdate').value, 'Y-m-d'));
  43. var now = new Date(Ext.util.Format
  44. .date(new Date(), 'Y-m-d'));
  45. if(Ext.getCmp('cc_newtempcreditdate').value==null && Ext.getCmp('cc_newtempcredit').value!=null && Ext.getCmp('cc_newtempcredit').value >0){
  46. showError('请先填写临时额度有效期');
  47. return;
  48. }
  49. if (now > newtempdate) {
  50. showError('新临时额度有效期小于当前日期,请更改!');
  51. return;
  52. }
  53. this.FormUtil.onUpdate(this);
  54. }
  55. },
  56. 'erpAddButton' : {
  57. click : function() {
  58. me.FormUtil.onAdd('addCreditChange', '新增客户信用变更',
  59. 'jsps/scm/sale/creditChange.jsp');
  60. }
  61. },
  62. 'erpCloseButton' : {
  63. click : function(btn) {
  64. me.FormUtil.beforeClose(me);
  65. }
  66. },
  67. 'erpDeleteButton' : {
  68. click : function(btn) {
  69. me.FormUtil.onDelete(Ext.getCmp('cc_id').value);
  70. }
  71. },
  72. 'erpSubmitButton' : {
  73. afterrender : function(btn) {
  74. var status = Ext.getCmp('cc_statuscode');
  75. if (status && status.value != 'ENTERING') {
  76. btn.hide();
  77. }
  78. },
  79. click : function(btn) {
  80. me.FormUtil.onSubmit(Ext.getCmp('cc_id').value);
  81. }
  82. },
  83. 'erpResSubmitButton' : {
  84. afterrender : function(btn) {
  85. var status = Ext.getCmp('cc_statuscode');
  86. if (status && status.value != 'COMMITED') {
  87. btn.hide();
  88. }
  89. },
  90. click : function(btn) {
  91. me.FormUtil.onResSubmit(Ext.getCmp('cc_id').value);
  92. }
  93. },
  94. 'erpAuditButton' : {
  95. afterrender : function(btn) {
  96. var status = Ext.getCmp('cc_statuscode');
  97. if (status && status.value != 'COMMITED') {
  98. btn.hide();
  99. }
  100. },
  101. click : function(btn) {
  102. me.FormUtil.onAudit(Ext.getCmp('cc_id').value);
  103. }
  104. },
  105. 'erpResAuditButton' : {
  106. afterrender : function(btn) {
  107. var status = Ext.getCmp('cc_statuscode');
  108. if (status && status.value != 'AUDITED') {
  109. btn.hide();
  110. }
  111. },
  112. click : function(btn) {
  113. me.FormUtil.onResAudit(Ext.getCmp('cc_id').value);
  114. }
  115. },
  116. 'erpPrintButton' : {
  117. afterrender : function(btn) {
  118. var status = Ext.getCmp('cc_statuscode');
  119. if (status && status.value != 'AUDITED') {
  120. btn.hide();
  121. }
  122. },
  123. click : function(btn) {
  124. var reportName = '';
  125. reportName = "CreditChange";
  126. var condition = '{CreditChange.cc_id}='
  127. + Ext.getCmp('cc_id').value + '';
  128. var id = Ext.getCmp('cc_id').value;
  129. me.FormUtil.onwindowsPrint(id, reportName, condition);
  130. }
  131. },
  132. 'textfield[name=cc_custcode]' : {
  133. aftertrigger : function(field) {
  134. if (field != null && field != '') {
  135. Ext.getCmp('cc_newcredit').setValue(
  136. Ext.getCmp('cc_credit').value);
  137. }
  138. }
  139. }
  140. });
  141. },
  142. getForm : function(btn) {
  143. return btn.ownerCt.ownerCt;
  144. }
  145. });