[Extjs6]随记--创建window窗体对象

   //异常车次率
    motorErrorFunc:function(node,event){
        console.log("异常车次率");
        console.log(node);
        console.log(node.previousNode("lineoverview"));
        var lineOverView = node.previousNode("lineoverview");  //获取当前节点之前的第一个xtype为lineoverview的component对象
            var subView = Ext.getCmp('smartdispatchsubview'); //根据id获取对象
        //console.log(subView);
        //alert(subView.getScrollY())
        //遍历当前的窗口集合 若存在则激活当前窗口 不存在则创建一个加入集合
        var title = '<span style="color:#e44959;">'+lineOverView.title+' 异常车次'+'</span>';
        var tempWin = null;
        Ext.each(lineDetailWinList,function(win,index){
            console.log(win);
            console.log(index);
            if(title == win.title)
                tempWin = win;
        });
        //若存在则前置显示
        if(tempWin){
            //alert("getScrollY "+subView.getScrollY()+" getY "+subView.getY()+" getLocalY "+subView.getLocalY());
            var y = subView.getScrollY()==0? 150:subView.getScrollY()+30; 
            tempWin.setLocalY(y);
            tempWin.toFront();
            return;
        }
        var newWin = Ext.create('Ext.window.Window', {
                        title: title,
                        height: 300,
                        width: 600,
                        cls: 'lineOverviewErrorWindow',
                        iconCls: 'fa fa-bus lineOverviewErrorWindowBus',
                        layout: 'fit',
                        maximizable: true,
                        draggable: true,
                        constrain: true,
                        constrainHeader: true,
                        renderTo: 'dispatchlineview',
                        //anchor: "-10 -10",
                        //x: (Ext.Element.getViewportWidth()-700)/2 + 30*lineDetailWinSize,
                        //y: (Ext.Element.getViewportHeight()-500)/2+20 + 30*lineDetailWinSize,
                        x: 100+ 30*lineDetailWinSize,
                        y: subView.getScrollY()+30+ 30*lineDetailWinSize,
                        items: {  // Let's put an empty grid in just to illustrate fit layout
                            xtype: 'panel',
                            border: false,
                            html: 'some information about '+title
                            //columns: [{header: 'World'}],                 // One header just for show. There's no data,
                            //store: Ext.create('Ext.data.ArrayStore', {}) // A dummy empty data store
                        },
                        destroy:function(panel,eOpts){
                            console.log(panel);
                            console.log(eOpts);
                            console.log(this);
                            //从集合中移除当前的窗口
                            Ext.Array.remove(lineDetailWinList,this);
                            //this.callParent(arguments);
                            lineDetailWinSize = lineDetailWinSize - 1 > 0 ?lineDetailWinSize - 1:0;
                        }
        });
        newWin.show(); 
        lineDetailWinList.push(newWin);
        lineDetailWinSize = lineDetailWinSize + 1 < 5 ?lineDetailWinSize + 1:10;
    }

---------------------------------------------------------------------------------------------
    //panel的tools属性,可以添加一些工具按钮
    tools:[
        {
            type: 'maximize',
            tooltip: '查看详情',
            handler: function(event, toolEl, panelHeader){
                //alert("click the button 查看详情"); 
                //alert("创建一个window对象..."); // dispatchlineview
                var subView = Ext.getCmp('smartdispatchsubview');
                //console.log(subView);
                //alert(subView.getScrollY())
                //遍历当前的窗口集合 若存在则激活当前窗口 不存在则创建一个加入集合
                var title = panelHeader.title.text+' 详情';
                var tempWin = null;
                Ext.each(lineDetailWinList,function(win,index){
                    console.log(win);
                    console.log(index);
                    if(title == win.title)
                        tempWin = win;
                });
                //若存在则前置显示
                if(tempWin){
                    //alert("getScrollY "+subView.getScrollY()+" getY "+subView.getY()+" getLocalY "+subView.getLocalY());
                    var y = subView.getScrollY()==0? 150:subView.getScrollY()+30; 
                    tempWin.setLocalY(y);
                    tempWin.toFront();
                    return;
                }
                var newWin = Ext.create('Ext.window.Window', {
                        title: title,
                        height: 300,
                        width: 600,
                        iconCls: 'fa fa-bus',
                        layout: 'fit',
                        maximizable: true,
                        draggable: true,
                        constrain: true,
                        constrainHeader: true,
                        renderTo: 'dispatchlineview',
                        //anchor: "-10 -10",
                        //x: (Ext.Element.getViewportWidth()-700)/2 + 30*lineDetailWinSize,
                        //y: (Ext.Element.getViewportHeight()-500)/2+20 + 30*lineDetailWinSize,
                        x: 100+ 30*lineDetailWinSize,
                        y: subView.getScrollY()+30+ 30*lineDetailWinSize,
                        items: {  // Let's put an empty grid in just to illustrate fit layout
                            xtype: 'panel',
                            border: false,
                            html: 'some information about '+title
                            //columns: [{header: 'World'}],                 // One header just for show. There's no data,
                            //store: Ext.create('Ext.data.ArrayStore', {}) // A dummy empty data store
                        },
                        destroy:function(panel,eOpts){
                            console.log(panel);
                            console.log(eOpts);
                            console.log(this);
                            //从集合中移除当前的窗口
                            Ext.Array.remove(lineDetailWinList,this);
                            //this.callParent(arguments);
                            lineDetailWinSize = lineDetailWinSize - 1 > 0 ?lineDetailWinSize - 1:0;
                        }
                });
                newWin.show(); 
                lineDetailWinList.push(newWin);
                lineDetailWinSize = lineDetailWinSize + 1 < 5 ?lineDetailWinSize + 1:10;
            }
        }
    ],
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值