Close.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * 关闭按钮
  3. */
  4. Ext.define('erp.view.core.button.Close', {
  5. extend : 'Ext.Button',
  6. alias : 'widget.erpCloseButton',
  7. text : $I18N.common.button.erpCloseButton,
  8. iconCls : 'x-button-icon-close',
  9. cls : 'x-btn-gray',
  10. width : 65,
  11. style : {
  12. marginLeft : '10px'
  13. },
  14. initComponent : function() {
  15. this.callParent(arguments);
  16. },
  17. handler : function(btn) {
  18. var modal = parent.Ext.getCmp('modalwindow');
  19. if (modal) {
  20. var history = modal.historyMaster;
  21. Ext.Ajax.request({
  22. url : basePath + 'common/changeMaster.action',
  23. params : {
  24. to : history
  25. },
  26. callback : function(opt, s, r) {
  27. if (s) {
  28. modal.close();
  29. } else {
  30. alert('切换到原账套失败!');
  31. }
  32. }
  33. });
  34. } else {
  35. var main = parent.Ext.getCmp("content-panel");
  36. if (main) {
  37. main.getActiveTab().close();
  38. } else {
  39. var win = parent.Ext.ComponentQuery.query('window');
  40. if (win) {
  41. Ext.each(win, function() {
  42. this.close();
  43. });
  44. } else {
  45. window.close();
  46. }
  47. }
  48. }
  49. }
  50. });