TabPanel.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. closeRightsTabsText: $I18N.common.main.closeRightsTabsText,
  33. /* extraItemsTail: ['-', {
  34. text: $I18N.common.main.closeable,
  35. checked: true,
  36. hideOnClick: true,
  37. handler: function (item) {
  38. console.log(item);
  39. currentItem.tab.setClosable(item.checked);
  40. }
  41. }],*/
  42. listeners: {
  43. aftermenu: function () {
  44. currentItem = null;
  45. },
  46. /*beforemenu: function (menu, item) {
  47. var menuitem = menu.child('*[text=' + $I18N.common.main.closeable + ']');
  48. currentItem = item;
  49. menuitem.setChecked(item.closable);
  50. }*/
  51. }
  52. }),
  53. new Ext.ux.TabScrollerMenu({
  54. pageSize: 10,
  55. maxText : 15
  56. })
  57. ],
  58. initComponent : function(){
  59. this.callParent(arguments);
  60. },
  61. listeners: {
  62. beforerender:function(){
  63. if(hascheckInitpwd=='null'){
  64. Ext.Ajax.request({
  65. url : basePath + 'common/getFieldsData.action',
  66. params: {
  67. caller: 'Employee',
  68. fields: 'em_password',
  69. condition: 'em_id='+em_id
  70. },
  71. method : 'post',
  72. callback : function(opt, s, res){
  73. var r = new Ext.decode(res.responseText);
  74. if(r.exceptionInfo){
  75. showError(r.exceptionInfo);return;
  76. } else if(r.success && r.data){
  77. var password=r.data.em_password;
  78. if(password&&password=='111111'){
  79. Ext.create('erp.view.core.window.InitPwdWindow',{initPwd:password});
  80. }
  81. }
  82. }
  83. });
  84. }
  85. },
  86. add: function(t, p) {
  87. t.lastActiveTab = t.activeTab;
  88. p.on('activate', function(){
  89. if(p.body) {
  90. var iframe = p.getEl().down('iframe').dom;
  91. var win = iframe.contentWindow;
  92. if(win == null || win.Ext === undefined) {
  93. return;
  94. }
  95. if(contains(iframe.src, 'common/datalist.jsp', false)) {//列表
  96. var grid = win.Ext.getCmp("grid");
  97. if(grid){
  98. grid.lastSelected = grid.selModel.getSelection();//记录当前选中的record
  99. grid.getColumnsAndStore();
  100. }
  101. } /*else if(contains(iframe.src, 'common/editDatalist.jsp', false)) {//列表
  102. var grid = win.Ext.getCmp("grid");
  103. if(grid){
  104. grid.lastSelected = grid.selModel.getSelection();//记录当前选中的record
  105. grid.getColumnsAndStore();
  106. }
  107. } else if(contains(iframe.src, 'common/batchDeal.jsp', false)) {//批量处理
  108. var form = win.Ext.getCmp("dealform");
  109. if(form){
  110. form.onQuery(true);
  111. }
  112. } else if(contains(iframe.src, 'common/query.jsp', false)) {//查询
  113. var form = win.Ext.getCmp("queryform");
  114. if(form){
  115. form.onQuery();
  116. }
  117. } else if(contains(iframe.src, 'common/jprocessDeal.jsp', false)) {//流程界面
  118. var iframe = win.Ext.get('iframe_maindetail');
  119. if(iframe){
  120. }
  121. }*/ else {
  122. var form = win.Ext.getCmp("form");
  123. if(form) {
  124. var uu = form.uulistener, //active时刷新Header的uu连接
  125. tp = t.ownerCt.down('erpHeader');
  126. if(uu && uu.length > 0) {
  127. tp.refreshUU(p, form, uu);
  128. }
  129. }
  130. /**刷新首页信息*/
  131. var desktabpanel =win.Ext.getCmp("desktabpanel");
  132. if(desktabpanel){
  133. var grid = desktabpanel.activeTab;
  134. grid.lastSelected = grid.selModel.getSelection();
  135. grid.getColumnsAndStore();
  136. }
  137. }
  138. }
  139. });
  140. },
  141. beforeremove: function(t, p) {
  142. if(p.body) {
  143. var iframe = p.getEl().down('iframe').dom;
  144. var win = iframe.contentWindow;
  145. if(win == null || win.Ext === undefined) {
  146. return;
  147. }
  148. var form = win.Ext.getCmp("form");
  149. if(form) {
  150. var uu = form.uulistener, //remove前清除Header的uu连接
  151. tp = t.ownerCt.down('erpHeader');
  152. if(uu && uu.length > 0) {
  153. tp.removeUU(p);
  154. }
  155. }
  156. }
  157. if (t.lastActiveTab && t.lastActiveTab.id != p.id) {
  158. Ext.defer(function(){
  159. t.setActiveTab(t.lastActiveTab);
  160. }, 100);
  161. }
  162. }
  163. }
  164. });