js 回车键绑定事件

<label class="col-sm-1 control-label">快速搜索<span
                                    style="color:red;"> </span> </label>
                            <div class="col-sm-5">
                                <input id="searchName" name="searchName"  
                                       class="form-control"  placeholder="根据商品名称和sku编码模糊搜索,回车即可!"
                                       type="text">
                            </div>
$("#searchName").keypress(function(event){
    if(event.which === 13) {
        //点击回车要执行的事件
        $('#exampleTable').bootstrapTable('refresh');
    }
})
function load() {
    $('#exampleTable')
        .bootstrapTable(
            {
                method : 'get', // 服务器数据的请求方式 get or post
                url : "/base/supplierQuotationsDetailed/list", // 服务器数据的加载地址
                //	showRefresh : true,
                //	showToggle : true,
                //	showColumns : true,
                iconSize : 'outline',
                toolbar : '#exampleToolbar',
                striped : true, // 设置为true会有隔行变色效果
                dataType : "json", // 服务器返回的数据类型
                pagination : true, // 设置为true会在底部显示分页条
                // queryParamsType : "limit",
                // //设置为limit则会发送符合RESTFull格式的参数
                singleSelect : false, // 设置为true将禁止多选
                // contentType : "application/x-www-form-urlencoded",
                // //发送到服务器的数据编码类型
                pageSize : 10, // 如果设置了分页,每页数据条数
                pageNumber : 1, // 如果设置了分布,首页页码
                //search : true, // 是否显示搜索框
                showColumns : false, // 是否显示内容下拉框(选择显示的列)
                sidePagination : "server", // 设置在哪里进行分页,可选值为"client" 或者 "server"
                queryParams : function(params) {
                    return {
                        //说明:传入后台的参数包括offset开始索引,limit步长,sort排序列,order:desc或者,以及所有列的键值对
                        limit: params.limit,
                        offset:params.offset,
                        offerId:$('#id').val(),
                        drs:"9996",
                        searchName:"%"+$('#searchName').val()+"%",
                        // username:$('#searchName').val()
                    };
                },
                // //请求服务器数据时,你可以通过重写参数的方式添加一些额外的参数,例如 toolbar 中的参数 如果
                // queryParamsType = 'limit' ,返回参数必须包含
                // limit, offset, search, sort, order 否则, 需要包含:
                // pageSize, pageNumber, searchText, sortName,
                // sortOrder.
                // 返回false将会终止请求
                columns : [
                    // {
                    //     checkbox : true
                    // },
                    {
                        field : 'id',
                        title : '主键',
                        align : 'center',
                        width:120
                    },
                    {
                        field : 'tid',
                        title : '主键',
                        align : 'center',
                        width:120
                    },
                    {
                        field : 'skuNo',
                        title : 'sku编码',
                        align : 'center',
                        width:120
                    },
                    {
                        field : 'brandNo',
                        title : '品牌',
                        align : 'center',
                        width:80
                    },
                    {
                        field : 'brand',
                        title : '品牌',
                        align : 'center',
                        width:80
                    },
                    {
                        field : 'goodsName',
                        title : '商品名称',
                        align : 'center',
                        width:120
                    },
                    {
                        field : 'goodsSpec',
                        title : '规格',
                        align : 'center',
                        width:120
                    },
                    {
                        field : 'unit',
                        title : '单位',
                        align : 'center',
                        width:60
                    },
                    {
                        field : 'taxFreePrice',
                        title : '无税价',
                        align : 'center',
                        width:80,
                        formatter : numtwo
                    },
                    {
                        field : 'freePrice',
                        title : '税价',
                        align : 'center',
                        width:80,
                        formatter : numtwo
                    },
                    {
                        field : 'taxRate',
                        title : '税率',
                        align : 'center',
                        width:80,
                        formatter : numtwo
                    },
                    {
                        title : '操作',
                        field : 'ids',
                        align : 'center',
                        width:120,
                        formatter : function(value, row, index) {
                            var a=","
                            var b="'"
                            var d = '<a class="btn btn-warning btn-sm " href="#" title="删除"  mce_href="#" onclick="remove(\''
                                + row.id +b+a+b+row.tid
                                + '\')"><i class="fa fa-remove">&nbsp;&nbsp;删除</i></a> ';
                            var f = '<a class="btn btn-success btn-sm" href="#" title="备用"  mce_href="#" onclick="resetPwd(\''
                                + row.id
                                + '\')"><i class="fa fa-key">备用</i></a> ';
                            return d ;
                        }
                    } ]
            });
}

找到给需要的输入框绑定回车事件

$("#searchName").keypress(function(event){
    if(event.which === 13) {
        //点击回车要执行的事件
        $('#exampleTable').bootstrapTable('refresh');
    }
})

猜你喜欢

转载自blog.csdn.net/qq_40680190/article/details/82850435