FastAdmin自定义搜索,通用搜索失效

在js中自定义搜索:

  $(document).on("click", ".btn-singlesearchone", function () {
            var options = table.bootstrapTable('getOptions');
            options.pageNumber = 1;
            options.queryParams = function (params) {
                return {
                    search: params.search,
                    sort: params.sort,
                    order: params.order,
                    offset: params.offset,
                    limit: params.limit,
                    filter: JSON.stringify({'getcs.orderstatus':'value2'}),
                    op: JSON.stringify({'getcs.orderstatus': 'like'}),
                };
            };
            table.bootstrapTable('refresh', {});
            Toastr.info("查询成功");
            return false;
        });

自定义搜索后,发现通用搜索失效了,发现是没有发送查询参数


image.png

解决方法,对比了两个版本的bootstrap-table-commonsearch.js文件(前面是新版,后面是旧版):

新版:

BootstrapTable.prototype.onCommonSearch = function () {
      var searchQuery = getSearchQuery(this);
      this.trigger('common-search', this, searchQuery);
      this.options.pageNumber = 1;
      this.refresh({});
  };

改为旧版,问题解决:

 BootstrapTable.prototype.onCommonSearch = function () {
        var searchQuery = getSearchQuery(this);
        var params = getQueryParams(this.options.queryParams({}), searchQuery, true);
        this.trigger('common-search',this, params,searchQuery);
        this.options.pageNumber = 1;
        this.options.queryParams = function (options) {
            return $.extend({},options,params);
        };
        this.refresh({query: params});
    };
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。