新版/旧版过滤条件切换时的参数获取原创
金蝶云社区-louismartin
louismartin
2人赞赏了该文章 238次浏览 未经作者许可,禁止转载编辑于2022年12月29日 14:41:58

每当我们对列表的过滤条件(新版/旧版)进行切换时,我们会发现页面自动触发了刷新事件,那如果想捕获切换的动作,应该怎么处理呢?

  1. 进行旧版切换

    上传图片

  2. 按 F12获取本次请求的执行数据


    上传图片

    此时可以观察到传递的key是 filtercontainerap,参数值是0,再进行一次新版切换,参数值会变为1

3.通过filtercontainerap 全局进行类搜索,可以定位到是 kd.bos.filter.FilterContainer,里面有filterMode属性,就是用于控制新旧版本的标识,但是无法直接从filtercontainerap的实例获取到filterMode,因为是私有属性,此时我们可以通过listCache对象去获取

//kd.bos.list.ListCache 获取新旧版标识的源码
public Optional<Integer> getFilterMode() {
        if (this.filterMode.isPresent()) {
            return this.filterMode;
        } else {
            String filterModeKey = this.getFilterModeKey();
            String filterModeString = (String)this.getCacheMap().get(filterModeKey);
            if (filterModeString == null) {
                return Optional.empty();
            } else {
                this.filterMode = Optional.of(Integer.valueOf(filterModeString));
                return this.filterMode;
            }
        }
    }

具体的使用方式:

ListCache listCache = new ListCache(this.getPageCache());
Integer filterMode = listCache.getFilterMode();


另外,以上使用的参数排查的方式在其他控件上也是行得通的,可以通过F12的请求参数去找到答案~

赞 2