import _ from 'lodash' import $ from 'jquery' export default function () { Ext.define('Yvan.MainTab', { extend: 'Ext.tab.Panel', xtype: 'maintab', constructor(config) { const self = this const newConfig = _.defaultsDeep({}, config, { listeners: { tabchange(tabPanel, newCard, oldCard, eOpts) { console.log('tabChange') $(window).trigger('tabChange', { tabPanel, newCard, oldCard, eOpts }); if (typeof config.tabchange === 'function') { config.tabchange.apply(this, arguments) } } } }) this.superclass.constructor.call(self, newConfig) }, /** * 添加一个业务模块实例到选项卡 * @param scopeInstance 业务对象实例 */ addScope(scopeInstance) { this.add({ closable: true, ...scopeInstance.config, }) this.setActiveTab(scopeInstance._handle); } }); }