UpdateUseStatus.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. * 更新供应商返还
  3. */
  4. Ext.define('erp.view.core.button.UpdateUseStatus',{
  5. extend: 'Ext.Button',
  6. alias: 'widget.erpUpdateUseStatusButton',
  7. iconCls: 'x-button-icon-submit',
  8. cls: 'x-btn-gray',
  9. tooltip: '更新使用状况',
  10. id: 'erpUpdateUseStatusButton',
  11. text: $I18N.common.button.erpUpdateUseStatusButton,
  12. width: 120,
  13. initComponent : function(){
  14. this.callParent(arguments);
  15. },
  16. listeners: {
  17. afterrender: function(btn) {
  18. var me = this;
  19. var status = Ext.getCmp('ac_statuscode');
  20. if(status && (status.value == 'ENTERING')){
  21. btn.hide();
  22. }
  23. }
  24. },
  25. handler: function() {
  26. var me = this, win = Ext.getCmp('Complaint-win');
  27. var states = Ext.create('Ext.data.Store', {
  28. fields: ['abbr', 'name'],
  29. data : [
  30. {"abbr":"正常使用", "name":"正常使用"},
  31. {"abbr":"未使用", "name":"未使用"},
  32. {"abbr":"停用", "name":"停用"}
  33. ]
  34. });
  35. if(!win) {
  36. var cs = Ext.getCmp('ac_usestatus'),
  37. val1 = cs ? cs.value : '';
  38. win = Ext.create('Ext.Window', {
  39. id: 'Complaint-win',
  40. title: '更新使用状况',
  41. height: 200,
  42. width: 400,
  43. items: [{
  44. xtype: 'form',
  45. height: '100%',
  46. width: '100%',
  47. bodyStyle: 'background:#f1f2f5;',
  48. items: [{
  49. margin: '10 0 0 0',
  50. xtype: 'combo',
  51. fieldLabel: '使用状况',
  52. name:'ac_usestatus',
  53. allowBlank: false,
  54. store: states,
  55. queryMode: 'local',
  56. displayField: 'name',
  57. valueField: 'abbr',
  58. value: val1
  59. }],
  60. closeAction: 'hide',
  61. buttonAlign: 'center',
  62. layout: {
  63. type: 'vbox',
  64. align: 'center'
  65. },
  66. buttons: [{
  67. text: $I18N.common.button.erpConfirmButton,
  68. cls: 'x-btn-blue',
  69. handler: function(btn) {
  70. var form = btn.ownerCt.ownerCt,
  71. cs = form.down('textfield[name=ac_usestatus]');
  72. if(form.getForm().isDirty()) {
  73. me.updateUseStatus(Ext.getCmp('ac_id').value, cs.value);
  74. }
  75. }
  76. }, {
  77. text: $I18N.common.button.erpCloseButton,
  78. cls: 'x-btn-blue',
  79. handler: function(btn) {
  80. btn.up('window').hide();
  81. }
  82. }]
  83. }]
  84. });
  85. }
  86. win.show();
  87. },
  88. updateUseStatus: function(id, cs, cr) {
  89. Ext.Ajax.request({
  90. url: basePath + 'fa/fix/assetscard/updateusestatus.action',
  91. params: {
  92. id: id,
  93. usestatus: cs
  94. },
  95. callback: function(opt, s, r) {
  96. var rs = Ext.decode(r.responseText);
  97. if(rs.exceptionInfo) {
  98. showError(rs.exceptionInfo);
  99. } else {
  100. Ext.Msg.alert("提示","更新成功!");
  101. window.location.reload();
  102. }
  103. }
  104. });
  105. }
  106. });