layui.use(['table', 'jquery'], function () {
    var table = layui.table;
    //监听表格复选框选择
    table.on('checkbox(demo)', function (obj) {
        console.log(obj)
    });

    var $ = layui.$, active = {
        //查询按钮
        reload: function () {
            var callnumber = $('#callnumber');
            var leavedate = $('#leavedate');
            var status = $('#status');
            //执行重载
            table.reload('recordtable', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
              , where: {
                  NowDateTime: new Date(),
                      callnumber: callnumber.val(),
                  leavedate: leavedate.val(),
                  status: status.val()                  
              }
            });
        }

    };

    //回车执行
    document.onkeydown = function (event) {
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if (e && e.keyCode == 13) {
            var callnumber = $('#callnumber');
            var leavedate = $('#leavedate');
            var status = $('#status');
            //执行重载
            table.reload('recordtable', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
              , where: {
                  NowDateTime: new Date(),
                  callnumber: callnumber.val(),
                  leavedate: leavedate.val(),
                  status: status.val()
              }
            });
        }
    };


    $('.searchfilter .layui-btn').on('click', function () {
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
});