layui 表格搜索框 动态加载数据

inpunt 框如下

  • class="layui-input-block" style="float: left; position: relative;"> style="width: auto;" type="text" id="select_orderId" name="select_orderId" lay-verify="required" placeholder="请输入订单编号" autocomplete="off" class="layui-input">
  • 事件如下

    //订单搜索
    
        $('#searchBtn').on('click',function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        // 点击获取数据
        var  active = {
            getInfo: function () {
                var orderId=$('#select_orderId').val();
                if (orderId) {
                    var index = layer.msg('查询中,请稍候...',{icon: 16,time:false,shade:0});
                    setTimeout(function(){
                        table.reload('LAY-app-message-all', { //表格的id
                            url:'/Order/selectByOrderId',
                            where: {
                                'orderId':$.trim(orderId)
                            }
                        });
                        layer.close(index);
                    },800);
                } else {
                    layer.msg("请输入编号");
                }
            },
        };
      //监听回车事件,扫描枪一扫描或者按下回车键就直接执行查询
        $("#select_orderId").bind("keyup", function (e) {
            if (e.keyCode == 13) {
                var type = "getInfo";
                active[type] ? active[type].call(this) : '';
            }
        });

    你可能感兴趣的:(layui)