BillDateUpdate.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * 更改开票日期按钮
  3. */
  4. Ext.define('erp.view.core.button.BillDateUpdate',{
  5. extend : 'Ext.Button',
  6. alias : 'widget.erpBillDateUpdateButton',
  7. iconCls : 'x-button-icon-submit',
  8. cls : 'x-btn-gray',
  9. text : $I18N.common.button.erpBillDateUpdateButton,
  10. style : {
  11. marginLeft : '10px'
  12. },
  13. width : 120,
  14. initComponent : function() {
  15. this.callParent(arguments);
  16. },
  17. listeners: {
  18. afterrender: function(btn) {
  19. var status = Ext.getCmp('ab_statuscode');
  20. if(status && status.value == 'POSTED'){
  21. btn.show();
  22. }else{
  23. btn.hide();
  24. }
  25. }
  26. },
  27. handler: function() {
  28. var me = this, win = Ext.getCmp('Complaint-win');
  29. if(!win) {
  30. var olddate = Ext.getCmp('ab_date'),
  31. val = olddate ? olddate.value : '';
  32. win = Ext.create('Ext.Window', {
  33. id: 'Complaint-win',
  34. title: '更新发票 ' + Ext.getCmp('ab_code').value + ' 的开票日期',
  35. height: 200,
  36. width: 400,
  37. items: [{
  38. margin: '10 0 0 0',
  39. xtype: 'datefield',
  40. fieldLabel: '原开票日期',
  41. readOnly:true,
  42. name:'ab_date',
  43. value: val
  44. },{
  45. margin: '3 0 0 0',
  46. xtype: 'datefield',
  47. fieldLabel: '新开票日期',
  48. name:'ab_datenew',
  49. value: val
  50. }],
  51. closeAction: 'hide',
  52. buttonAlign: 'center',
  53. layout: {
  54. type: 'vbox',
  55. align: 'center'
  56. },
  57. buttons: [{
  58. text: $I18N.common.button.erpConfirmButton,
  59. cls: 'x-btn-blue',
  60. handler: function(btn) {
  61. var form = btn.ownerCt.ownerCt,
  62. nd = form.down('datefield[name=ab_datenew]');
  63. if(nd.isDirty() && !Ext.isEmpty(nd.value)) {
  64. me.updateBillDate(Ext.getCmp('ab_id').value,
  65. Ext.Date.format(nd.value,'Y-m-d'), Ext.Date.format(nd.value,'Ym'));
  66. }
  67. }
  68. }, {
  69. text: $I18N.common.button.erpCloseButton,
  70. cls: 'x-btn-blue',
  71. handler: function(btn) {
  72. btn.ownerCt.ownerCt.hide();
  73. }
  74. }]
  75. });
  76. }
  77. win.show();
  78. },
  79. updateBillDate: function(id, val1, val2) {
  80. Ext.Ajax.request({
  81. url: basePath + 'fa/arp/updateBillDate.action',
  82. params: {
  83. id: id,
  84. date: val1,
  85. yearmonth: val2
  86. },
  87. callback: function(opt, s, r) {
  88. var rs = Ext.decode(r.responseText);
  89. if(rs.exceptionInfo) {
  90. showError(rs.exceptionInfo);
  91. } else {
  92. alert('设置成功!');
  93. window.location.reload();
  94. }
  95. }
  96. });
  97. }
  98. });