Ext.namespace('Shipping'); Ext.define("Shipping.Main.LeftPanel", { extend: 'Ext.panel.Panel', requires: ['DsShipping.ux.ModuleModel'], initComponent: function () { this.storeModuTree = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.ModuleModel', proxy: { url: '/MvcShipping/MsBaseInfo/GetUserModuTreeList' } }); this.topleft = Ext.create('Ext.panel.Panel', { title: "west", layout: "accordion", //设置为手风琴布局 layoutConfig: { animate: true }, width: 250, minWidth: 90, region: "west", //设置方位 split: true, collapsible: true }); this.buildTree(); Ext.apply(this, { layout: 'border', items: [ this.tabtree ] }); this.callParent(arguments); }, buildTree: function () { // 菜单树 _this = this; this.storeModuTree.load({ params: { condition: "" }, callback: function (r, options, success) { if (success) { if (this.storeModuTree.getCount() > 0) { for (var j = 0; j < this.storeModuTree.getCount(); j += 1) { var member = this.storeModuTree.getAt(j); var treestore = new Ext.data.TreeStore({ model: 'DsShipping.ux.ModuleModel', nodeParam: 'PARENTID', proxy: { type: 'ajax', url: '/MvcShipping/MsBaseInfo/GetModuTreeRefList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } }, autoLoad: true, root: { name: '根节点', expanded: true, id: member.data.id } }); var tabtree = new Ext.tree.Panel({ region: 'west', title: '', split: true, width: 180, collapsible: true, margins: '0 0 0 0', store: treestore, rootVisible: false, hideHeaders: true, animate: false, lines: false, columns: [{ xtype: 'treecolumn', text: '模块名称', width: 178, dataIndex: 'DESCRIPTION' }], listeners: { scope: this, 'itemclick': function (_this, record, item, index, e, eOpts) { var path = rec.get("LoadPath"); //--功能地址 var openType = rec.get("OpenType"); //--打开方式 var me = this; if (!Ext.Object.isEmpty(path) && !Ext.Object.isEmpty(openType)) { if (openType == "window") { var win_id = 'syswin_' + rec.get("id"); var win = Ext.WindowManager.get(win_id); if (win) { Ext.WindowManager.bringToFront(win); } else { win = Ext.create(path, { title: rec.get("text"), iconCls: rec.get("iconCls"), id: win_id }); win.show(); } } else if (openType == "tab") { //--选项卡方式打开,先判断当前功能是否已经打开,如果已打开,则无需新建,直接将该功能设为活动选项卡就行了。 //--me.ownerCt.ownerCt.centerPart是主框架的中间内容模块。 var tab = me.ownerCt.ownerCt.centerPart.getComponent('tab_sys_' + rec.get('id')); if (!tab) { var newitem = Ext.create(path, {}); tab = Ext.create('Ext.panel.Panel', { title: rec.get('text'), itemId: 'tab_sys_' + rec.get('id'), layout: 'fit', closable: true, iconCls: rec.get('iconCls') || 'icon_preview', items: newitem }); me.ownerCt.ownerCt.centerPart.add(tab); } //--设为活动选项卡 me.ownerCt.ownerCt.centerPart.setActiveTab(tab); } } } } }); _this.topleft.add(tabtree); }; } else { } } }, scope: this }); } });