开发 ->全局脚本库 添加两个方法

方法一:addLocationRightBar

/**
*方法注释
*方法参数自行添加
*/
function addLocationRightBar(){
    //重写顶部bar面板的afterRender
   Ext.override(JE.app.view.header.LocationBar,{
        afterRender:function(){
        //给j_query加一个类型
        JE.DB.j_queryTypes.push('gridrightbar');
        //查询字段
        var me = this;
        me.callParent(arguments);
        //查询字段
        me.queryFieldCode = 'SY_CREATEORGID';
        //加载树形数据
        var treedata = JE.ajax({
            url:'/je/getTree',
            params:{
                excludes: 'checked',
                moreRoot: false,
                tableCode: 'JE_CORE_DEPARTMENT',
                node: 'ROOT',
                onlyItem: true,
                j_query: Ext.encode([{"type":"!=","code":"PARENT","value":""}]),
                funcCode: 'JE_CORE_DEPARTMENT',
            }
        });
        //顶部bar最右侧面板
        var panel = {
            xtype:'box',
            margin:'0 5 0 0',
            width:150,
           // grid:grid,
            cls:'je-hhsjy-rightBar',
            itemId:'rightTreeLoad',
            data:[{text:'无',id:''}],
            tpl:[
                '<tpl for=".">',
                    '<span class="hhsjy-title">部门:<span class="hhsjy-text" data-id="{id}">{text}</span></span>',
                '</tpl>',
            ],
            listeners:{
                afterrender: function(view){
                    view.getEl().on({
                        //点击弹出tree
                        click: function(e){
                            //顶部bar最右侧面板
                            var rightTreeLoad =  me.getCmp('rightTreeLoad');
                            //获得功能grid
                            var grid =rightTreeLoad.grid || grid;
                            if(JE.isEmpty(grid)){
                                return false;
                            }
                            //该面是否可点击
                            var activePanel = Ext.getCmp('_appcenterview').getLayout().getActiveItem();
                            var gridFuncCode= grid.funcData.info.funcCode;
                            if(JE.isNotEmpty(activePanel) && activePanel.funcCode != gridFuncCode){
                                return false;
                            }
                            if(JE.isNotEmpty(activePanel)){
                                var jeCenterView = activePanel.getCmp('jecenterview');
                                var centerActivePanel = jeCenterView && jeCenterView.getLayout().getActiveItem();
                                if(JE.isNotEmpty(centerActivePanel) && centerActivePanel.xtype != 'jedataview'){
                                    return false;
                                }
                            }
                            var text = e.getTarget('.hhsjy-text',2);
                            if(text){
                                //tree 面板
                                var treePanel = {
                                        xtype:'jetreeview',
                                        type:'func',
                                        codeSearch:true,
                                        border:0,
                                        flex: 1,
                                        margin:'15 15 0 15',
                                        //overflowX:'hidden',
                                        //overflowY:'auto',
                                        onlyItem:true,
                                        rootData:treedata,
                                        listeners:{
                                            selectionchange:function(model,selected,e){
                                                //tree 节点选中触发
                                                var rightTreeLoad =  me.getCmp('rightTreeLoad');
                                                var grid = rightTreeLoad.grid;
                                                var gridStore = grid.store;
                                                //tree节点选中
                                                if(selected.length>0){
                                                    var text = selected[0].get('text');
                                                    var id = selected[0].get('id');
                                                    var flag = true;
                                                    //如果列表中已经有该j_query就不在查询
                                                    if(gridStore.j_query && gridStore.j_query.gridrightbar){
                                                        var gridrightbar = gridStore.j_query.gridrightbar;
                                                        Ext.each(gridrightbar,function(item){
                                                            if(item.value == id){
                                                                    flag = false;
                                                                    return false;
                                                                }
                                                        });
                                                    }
                                                    if(flag){
                                                        //更新顶部tab最右侧面板数据
                                                        rightTreeLoad.update({text:text,id:id});
                                                        //grid拼接j_query
                                                        var custom = {code:me.queryFieldCode,value:id,type:'='}
                                                        JE.DB.setJ_query(gridStore,[custom],'gridrightbar');
                                                        //刷新grid
                                                        if(grid.groupQuery){
                                                            var dataView = grid.up('[xtype=jedataview]');
                                                            if(dataView){
                                                                var groupQueryForm = dataView.down('[itemId=groupQueryForm]');
                                                                if(groupQueryForm){
                                                                    var groupQuery = groupQueryForm.down('button[ref=groupQuery]');
                                                                    groupQuery && JE.Action.doGroupQuery(grid, groupQueryForm, "form")
                                                                }else{
                                                                    grid.reload();
                                                                }
                                                            }
                                                        }else{
                                                            grid.reload();
                                                        }
                                                    }
                                                }

                                            }
                                        }
                                    }
                                var buttons ={
                                    text:"清除",
                                    cls: "je-hhsjy-rightBar-btn",
                                    height:35,
                                    //iconCls:'jeicon jeicon-remove',
                                    handler:function(btn){
                                        //点击按钮触发
                                        ////顶部bar最右侧面板
                                        var rightTreeLoad =  me.getCmp('rightTreeLoad');
                                        //获得功能grid
                                        var grid = rightTreeLoad.grid;
                                        //清空树的选中状态
                                        btn.up('[itemId=hhsjyMenu]').down('[xtype=jetreeview]').getSelectionModel().deselectAll();
                                        //修改顶部bar最右侧面板的数据
                                        me.getCmp('rightTreeLoad').update({text:'无',id:''});
                                        //置空功能grid的j_query
                                        JE.DB.setJ_query(grid.store,[],'gridrightbar');
                                        //刷新grid
                                        grid.reload();    
                                        return false;        
                                    }
                                };
                                    //treemenu面板
                                var menu = Ext.create('Ext.menu.Menu', {
                                    width: 300,
                                    cls:'je-menu-item34h je-menu-arrow je-menu-arrow-tr je-hhsjy-rightBar-menu',
                                    height:400,
                                    itemId:'hhsjyMenu',
                                    plain: true,
                                    shadow:false,
                                    autoScroll: false,
                                    layout: {
                                        type: 'vbox',
                                        align: 'center'
                                    },
                                    items: [treePanel,buttons],
                                    listeners:{
                                        show: function(view){
                                            setTimeout(function(){
                                                //menu显示的时候回显tree
                                                var rightTreeLoad =  me.getCmp('rightTreeLoad');
                                                if(rightTreeLoad.data && JE.isNotEmpty(rightTreeLoad.data.id)){
                                                    var treePanel = view.down('[xtype=jetreeview]');
                                                    var node = treePanel.store.getNodeById(rightTreeLoad.data.id);
                                                    treePanel.getSelectionModel().select(node);
                                                }
                                            });
                                        }
                                    }
                                });
                                //显示面板
                                menu.showBy(text,'tr-bl',[40,0]);
                            }
                        }   
                    });
                }
            }
        };
        me.add(panel);
        }
    });
}

方法二:loadLocationRightBar

/**
*方法注释
*方法参数自行添加
*/
function(grid,fieldCode,type){
    //获得顶部bar面板
    var locationBar = Ext.getCmp('app-location-bar');
    //定义查询字段
    var queryField = fieldCode || 'SY_CREATEORGID';
    locationBar.queryFieldCode = queryField;
    grid.groupQuery = type;
    //获得添加的面板
    var rightTreeLoad = locationBar.getCmp('rightTreeLoad');
    if(JE.isNotEmpty(rightTreeLoad)){
        //把grid赋值
        rightTreeLoad.grid = grid;
        //判断该功能是否可以进行grid刷新
        var activePanel = Ext.getCmp('_appcenterview').getLayout().getActiveItem();
        var gridFuncCode= grid.funcData.info.funcCode;
        if(JE.isNotEmpty(activePanel) && activePanel.funcCode != gridFuncCode){
            return false;
        }
        if(JE.isNotEmpty(activePanel)){
            var jeCenterView = activePanel.getCmp('jecenterview');
            var centerActivePanel = jeCenterView && jeCenterView.getLayout().getActiveItem();
            if(JE.isNotEmpty(centerActivePanel) && centerActivePanel.xtype != 'jedataview'){
                return false;
            }
        }
        //选择数据的id
        var id = rightTreeLoad.data && rightTreeLoad.data.id;
        if(JE.isNotEmpty(id)){
            //给grid拼接j_query
            var custom = {code:queryField,value:id,type:'='}
            JE.DB.setJ_query(grid.store,[custom],'gridrightbar');
        }else{
            JE.DB.setJ_query(grid.store,[],'gridrightbar');
        }
        //刷新grid
        grid.reload();
    }
}

在想要实现数据查询的功能列表添加 激活后(afteractivate)事件



给添加的事件中写入方法

/**
 * @param {Object} grid 列表对象
 * @param {String} fieldCode 查询字段
 * @param {Boolean} type 是否级联高级查询  true为级联 ,不传参/false就不级联
 */
function(grid){
    JE.callCustomFn('loadLocationRightBar',grid,fieldCode,type);
}

注意:有该事件该功能才可以查询

开发 ->全局样式库 添加两个css

je-hhsjy-rightBar-menu

.x-box-target .x-docked-noborder-bottom.x-docked-noborder-left{
    overflow-x: hidden !important;
}
.je-hhsjy-rightBar-btn{
    text-align: center !important;
}
.je-hhsjy-rightBar-btn{
    text-align: center !important;
    border-top: 1px solid #ddd !important;
}
.je-hhsjy-rightBar-btn .x-menu-item-link .x-menu-item-text{
    font-size: 14px !important;
    color: #386bd0 !important;
}

je-hhsjy-rightBar

.hhsjy-text{
    cursor:pointer;
    color: #386bd0;
}
.hhsjy-title {
    font-size: 14px;
}
最后编辑: 呼丽华  文档更新时间: 2024-08-21 10:58   作者:呼丽华