MainTab.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import _ from 'lodash'
  2. import $ from 'jquery'
  3. export default function () {
  4. Ext.define('Yvan.MainTab', {
  5. extend: 'Ext.tab.Panel',
  6. xtype: 'maintab',
  7. constructor(config) {
  8. const self = this
  9. const newConfig = _.defaultsDeep({}, config, {
  10. listeners: {
  11. tabchange(tabPanel, newCard, oldCard, eOpts) {
  12. console.log('tabChange')
  13. $(window).trigger('tabChange', {
  14. tabPanel, newCard, oldCard, eOpts
  15. });
  16. if (typeof config.tabchange === 'function') {
  17. config.tabchange.apply(this, arguments)
  18. }
  19. }
  20. }
  21. })
  22. this.superclass.constructor.call(self, newConfig)
  23. },
  24. /**
  25. * 添加一个业务模块实例到选项卡
  26. * @param scopeInstance 业务对象实例
  27. */
  28. addScope(scopeInstance) {
  29. this.add({
  30. closable: true,
  31. ...scopeInstance.config,
  32. })
  33. this.setActiveTab(scopeInstance._handle);
  34. }
  35. });
  36. }