若依框架,bootstrap table的自定义初始化查询条件赋值

父页面点击查询,附带查询条件,传值另一页面

 /*搜索后的企业列表,点击详情,在原页面上更新详情页*/
    function toQykDetail(comName) {
        /* var prefix = ctx + "system/gxqTyc";*/
       /* search("5");*/
/*
        $.modal.openTab("天眼查企业库详情", encodeURI('system/gxqTyc/toQiyekuDetail?comName=' + comName));
*/
        window.location.href='/system/gxqTyc/toQiyekuDetail?comName='+ comName;
    }

子页面,初始化查询,带上此条件

 var prefix = ctx + "system/gxqTyc";

    //初始化查询条件传参
    queryParams = function(params) {
        var comName = [[${comName}]];
        if(comName!=null&&comName!=""){
            $("input[name=comName]").val(comName);
        }
        var search = {};
        $.each($("#formId").serializeArray(), function(i, field) {
            search[field.name] = field.value;
        });
        search.pageSize = params.limit;
        search.pageNum = params.offset / params.limit + 1;
        search.searchValue = params.search;
        search.orderByColumn = params.sort;
        search.isAsc = params.order;
        return search;
        var comName =null;
    }

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "企业列表",
            showExport: false,
            queryParams:queryParams,
            columns: [
                {
                    field : 'id',
                    title : '序号',
                    visible: false
                },
                {
                    field : 'comName',
                    title : '企业名称',
                    sortable: false
                },
                {
                    field : 'thisCreditCode',
                    title : '企业信用码',
                    sortable: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('+row.comName+'\')">查看 ');
                      /*  actions.push('删除');*/
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

关键代码:

 //初始化查询条件传参
    queryParams = function(params) {
        var comName = [[${comName}]];
        if(comName!=null&&comName!=""){
            $("input[name=comName]").val(comName);
        }
        var search = {};
        $.each($("#formId").serializeArray(), function(i, field) {
            search[field.name] = field.value;
        });
        search.pageSize = params.limit;
        search.pageNum = params.offset / params.limit + 1;
        search.searchValue = params.search;
        search.orderByColumn = params.sort;
        search.isAsc = params.order;
        return search;
        var comName =null;
    }

然后配置

queryParams:queryParams,

就可以了

你可能感兴趣的:(前端)