FixedIncome.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.fp.FixedIncome', {
  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:[
  8. 'core.form.Panel','fa.fp.FixedIncome','core.grid.Panel2','core.toolbar.Toolbar',
  9. 'core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.ResAudit',
  10. 'core.button.Save','core.button.Add','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
  11. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.form.ColorField'
  12. ],
  13. init:function(){
  14. var me = this;
  15. me.gridLastSelected = null;
  16. this.control({
  17. 'erpGridPanel2': {
  18. itemclick: this.onGridItemClick
  19. },
  20. 'erpSaveButton': {
  21. click: function(btn){
  22. var form = me.getForm(btn);
  23. //保存之前的一些前台的逻辑判定
  24. this.FormUtil.beforeSave(this);
  25. }
  26. },
  27. 'erpDeleteButton' : {
  28. click: function(btn){
  29. me.FormUtil.onDelete(Ext.getCmp('fi_id').value);
  30. }
  31. },
  32. 'erpUpdateButton': {
  33. click: function(btn){
  34. this.FormUtil.onUpdate(this);
  35. }
  36. },
  37. 'erpAddButton': {
  38. click: function(){
  39. me.FormUtil.onAdd('addFixedIncome', '新增其他收入单', 'jsps/fa/fp/FixedIncome.jsp');
  40. }
  41. },
  42. 'erpCloseButton': {
  43. click: function(btn){
  44. this.FormUtil.beforeClose(this);
  45. }
  46. },
  47. 'erpSubmitButton': {
  48. afterrender: function(btn){
  49. var status = Ext.getCmp('fi_statuscode');
  50. if(status && status.value != 'ENTERING'){
  51. btn.hide();
  52. }
  53. },
  54. click: function(btn){
  55. me.beforeSubmit(btn);
  56. }
  57. },
  58. 'erpResSubmitButton': {
  59. afterrender: function(btn){
  60. var status = Ext.getCmp('fi_statuscode');
  61. if(status && status.value != 'COMMITED'){
  62. btn.hide();
  63. }
  64. },
  65. click: function(btn){
  66. me.FormUtil.onResSubmit(Ext.getCmp('fi_id').value);
  67. }
  68. },
  69. 'erpAuditButton': {
  70. afterrender: function(btn){
  71. var status = Ext.getCmp('fi_statuscode');
  72. if(status && status.value != 'COMMITED'){
  73. btn.hide();
  74. }
  75. },
  76. click: function(btn){
  77. me.FormUtil.onAudit(Ext.getCmp('fi_id').value);
  78. }
  79. },
  80. 'erpResAuditButton': {
  81. afterrender: function(btn){
  82. var status = Ext.getCmp('fi_statuscode');
  83. if(status && status.value != 'AUDITED'){
  84. btn.hide();
  85. }
  86. },
  87. click: function(btn){
  88. me.FormUtil.onResAudit(Ext.getCmp('fi_id').value);
  89. }
  90. },
  91. 'field[name=fi_enddate]': {
  92. change: function(f){
  93. if(f.value == null || f.value == ''){
  94. f.value = 0;
  95. }
  96. if(Ext.getCmp('fi_startdate')){
  97. var e = Ext.util.Format.date(Ext.getCmp('fi_startdate').value, 'Y-m-d');// 格式化日期控件值
  98. var s= Ext.util.Format.date(Ext.getCmp('fi_enddate').value, 'Y-m-d');// 格式化日期控件值
  99. var end = new Date(s);
  100. var start = new Date(e);
  101. var elapsed = Math.ceil((end.getTime() - start.getTime())/(86400000*30)); // 计算间隔月数
  102. Ext.getCmp('fi_month').setValue(elapsed);
  103. }
  104. }
  105. }
  106. });
  107. },
  108. beforeSubmit:function(btn){
  109. var me = this;
  110. me.FormUtil.onSubmit(Ext.getCmp('fi_id').value);
  111. },
  112. getForm: function(btn){
  113. return btn.ownerCt.ownerCt;
  114. }
  115. });