TabPanel.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. Ext.define('erp.view.common.main.TabPanel',{
  2. extend: 'Ext.tab.Panel',
  3. alias: 'widget.erpTabPanel',
  4. id: 'content-panel',
  5. region: 'center',
  6. defaults: {
  7. autoScroll:true,
  8. cls: 'my-panel'
  9. },
  10. activeTab: 0,
  11. border: false,
  12. animScroll:true, //使用动画滚动效果
  13. layoutOnTabChange : true, //随着布局变化
  14. resizeTabs:true, // turn on tab resizing
  15. enableTabScroll : true, //tab标签超宽时自动出现滚动效果
  16. deferredRender : false,
  17. items: [{
  18. xtype: 'panel',
  19. id: 'HomePage',
  20. title: $I18N.common.main.homePageTitle,
  21. bodyPadding: '0 0 2 0',
  22. iconCls : 'x-tree-icon-tab-main',
  23. closable: false,
  24. firstGrid:null,
  25. html : '<iframe id="iframe_homePage" src="' + basePath + 'jsps/common/desktop.jsp" height="100%" width="100%" frameborder="0" style="border-width: 0px;"></iframe>'
  26. }] ,
  27. plain: true,
  28. plugins:[Ext.create('Ext.ux.TabCloseMenu', {
  29. closeTabText: $I18N.common.main.closeTabText,
  30. closeOthersTabsText: $I18N.common.main.closeOtherText,
  31. closeAllTabsText: $I18N.common.main.closeAllText,
  32. extraItemsTail: ['-', {
  33. text: $I18N.common.main.closeable,
  34. checked: true,
  35. hideOnClick: true,
  36. handler: function (item) {
  37. currentItem.tab.setClosable(item.checked);
  38. }
  39. }],
  40. listeners: {
  41. aftermenu: function () {
  42. currentItem = null;
  43. },
  44. beforemenu: function (menu, item) {
  45. var menuitem = menu.child('*[text=' + $I18N.common.main.closeable + ']');
  46. currentItem = item;
  47. menuitem.setChecked(item.closable);
  48. }
  49. }
  50. }),
  51. new Ext.ux.TabScrollerMenu({
  52. pageSize: 10,
  53. maxText : 15
  54. })
  55. ],
  56. initComponent : function(){
  57. this.callParent(arguments);
  58. },
  59. listeners: {
  60. add: function(t, p) {
  61. t.lastActiveTab = t.activeTab;
  62. p.on('activate', function(){
  63. if(p.body) {
  64. var iframe = p.getEl().down('iframe').dom;
  65. var win = iframe.contentWindow;
  66. if(win == null || win.Ext === undefined) {
  67. return;
  68. }
  69. if(contains(iframe.src, 'common/datalist.jsp', false)) {//列表
  70. var grid = win.Ext.getCmp("grid");
  71. if(grid){
  72. grid.lastSelected = grid.selModel.getSelection();//记录当前选中的record
  73. grid.getColumnsAndStore();
  74. }
  75. } else if(contains(iframe.src, 'common/editDatalist.jsp', false)) {//列表
  76. var grid = win.Ext.getCmp("grid");
  77. if(grid){
  78. grid.lastSelected = grid.selModel.getSelection();//记录当前选中的record
  79. grid.getColumnsAndStore();
  80. }
  81. } else if(contains(iframe.src, 'common/batchDeal.jsp', false)) {//批量处理
  82. var form = win.Ext.getCmp("dealform");
  83. if(form){
  84. form.onQuery(true);
  85. }
  86. } else if(contains(iframe.src, 'common/query.jsp', false)) {//查询
  87. var form = win.Ext.getCmp("queryform");
  88. if(form){
  89. form.onQuery();
  90. }
  91. } else if(contains(iframe.src, 'common/jprocessDeal.jsp', false)) {//流程界面
  92. var iframe = win.Ext.get('iframe_maindetail');
  93. if(iframe){
  94. }
  95. } else {
  96. var form = win.Ext.getCmp("form");
  97. if(form) {
  98. var uu = form.uulistener, //active时刷新Header的uu连接
  99. tp = t.ownerCt.down('erpHeader');
  100. if(uu && uu.length > 0) {
  101. tp.refreshUU(p, form, uu);
  102. }
  103. }
  104. }
  105. }
  106. });
  107. },
  108. beforeremove: function(t, p) {
  109. if(p.body) {
  110. var iframe = p.getEl().down('iframe').dom;
  111. var win = iframe.contentWindow;
  112. if(win == null || win.Ext === undefined) {
  113. return;
  114. }
  115. var form = win.Ext.getCmp("form");
  116. if(form) {
  117. var uu = form.uulistener, //remove前清除Header的uu连接
  118. tp = t.ownerCt.down('erpHeader');
  119. if(uu && uu.length > 0) {
  120. tp.removeUU(p);
  121. }
  122. }
  123. }
  124. if (t.lastActiveTab && t.lastActiveTab.id != p.id) {
  125. Ext.defer(function(){
  126. t.setActiveTab(t.lastActiveTab);
  127. }, 100);
  128. }
  129. }
  130. }
  131. });