UpdateJYDate.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * 更新交样日期
  3. */
  4. Ext.define('erp.view.core.button.UpdateJYDate', {
  5. extend : 'Ext.Button',
  6. alias : 'widget.erpUpdateJYDateButton',
  7. iconCls : 'x-button-icon-submit',
  8. cls : 'x-btn-gray',
  9. text : '更新交样日期',
  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('ct_statuscode');
  20. if(status && status.value != 'AUDITED'){
  21. btn.hide();
  22. }
  23. }
  24. },
  25. handler: function() {
  26. var me = this, win = Ext.getCmp('prlevel-win');
  27. if(!win) {
  28. var f = Ext.getCmp('ct_date_4'), a = Ext.getCmp('ct_date_5'),
  29. val = f ? f.value : '', val1 = a ? a.value : '';
  30. win = Ext.create('Ext.Window', {
  31. id: 'prlevel-win',
  32. title: '更新交样日期',
  33. height: 200,
  34. width: 400,
  35. items: [{
  36. margin: '10 0 0 0',
  37. xtype: 'datefield',
  38. fieldLabel: '更新交样日期',
  39. name:'ct_date_4',
  40. value: val,
  41. format:'Y-m-d',
  42. },{
  43. margin: '10 0 0 0',
  44. xtype: 'datefield',
  45. fieldLabel: '实际交样日期',
  46. name:'ct_date_5',
  47. value: val1,
  48. format:'Y-m-d',
  49. }],
  50. closeAction: 'hide',
  51. buttonAlign: 'center',
  52. layout: {
  53. type: 'vbox',
  54. align: 'center'
  55. },
  56. buttons: [{
  57. text: $I18N.common.button.erpConfirmButton,
  58. cls: 'x-btn-blue',
  59. handler: function(btn) {
  60. var date1=btn.ownerCt.ownerCt.down('textfield[name=ct_date_4]'),
  61. date2=btn.ownerCt.ownerCt.down('textfield[name=ct_date_5]');
  62. if((date1.isDirty() && !Ext.isEmpty(date1.value))|| (date2.isDirty() && !Ext.isEmpty(date2.value))) {
  63. me.updateJYDate(Ext.getCmp('ct_id').value, date1.value, date2.value);
  64. }
  65. }
  66. }, {
  67. text: $I18N.common.button.erpCloseButton,
  68. cls: 'x-btn-blue',
  69. handler: function(btn) {
  70. btn.ownerCt.ownerCt.hide();
  71. }
  72. }]
  73. });
  74. }
  75. win.show();
  76. },
  77. updateJYDate: function(id, val1, val2) {
  78. Ext.Ajax.request({
  79. url: basePath + 'scm/sale/updateYJDate.action',
  80. params: {
  81. id: id,
  82. date1: val1 ,
  83. date2: val2
  84. },
  85. callback: function(opt, s, r) {
  86. var rs = Ext.decode(r.responseText);
  87. if(rs.exceptionInfo) {
  88. showError(rs.exceptionInfo);
  89. } else {
  90. alert('设置成功!');
  91. window.location.reload();
  92. }
  93. }
  94. });
  95. }
  96. });