layui.use('laydate', function () {
    let form = layui.form;
    var laydate = layui.laydate;


    laydate.render({
        elem: '.dt2'
    });
     

    form.on('checkbox(chk_all)', function (data) {

        var s = data.elem.checked;
        if (s == true) {
            $(".chk_item[disabled!=disabled]").prop("checked", true);
            form.render('checkbox');
        } else {
            $(".chk_item[disabled!=disabled]").prop("checked", false);
            form.render('checkbox');
        }
    }
    )


});




function chkAll() {
    let form = layui.form;
    form.on('checkbox(chk_all)', function (data) {

        var s = data.elem.checked;
        if (s == true) {
            $(".chk_item[disabled!=disabled]").prop("checked", true);

        } else {
            $(".chk_item[disabled!=disabled]").prop("checked", false);
        }
        form.render('checkbox');
    })
}




function reRender() {
    layui.form.render();
}





$(document).ready(function () {
    $("body").keydown(function (e) {
        var curKey = e.which;
        if (curKey == 13) {
            document.getElementById("search").click();
            return false;
        }
    });
});



$(document).on("click", ".layui-table-body table.layui-table tbody tr", function () {
    var index = $(this).attr('data-index');
    var tableBox = $(this).parents('.layui-table-box');
    //存在固定列
    if (tableBox.find(".layui-table-fixed.layui-table-fixed-l").length > 0) {
        tableDiv = tableBox.find(".layui-table-fixed.layui-table-fixed-l");
    } else {
        tableDiv = tableBox.find(".layui-table-body.layui-table-main");
    }
    var checkCell = tableDiv.find("tr[data-index=" + index + "]").find("td div.laytable-cell-checkbox div.layui-form-checkbox I");
    if (checkCell.length > 0) {
        checkCell.click();
    }
});

$(document).on("click", "td div.laytable-cell-checkbox div.layui-form-checkbox", function (e) {
    e.stopPropagation();
});



function issel() {

    var checked = 0;
    var allvalue = '';

    var _c = 0;
    $(".chk_item").each(

        function () {
            if ($(this).is(':checked')) {
                checked++;

                if (checked > 1) {
                    allvalue += ',' + $(this).val();
                }
                else {
                    allvalue = $(this).val();
                }
            }

        });

    $("#hf_ids").val(allvalue);

    if (checked > 0) {
        return true;
    }
    else {
        layer.msg('请至少选择一条记录');
        return false;
    }

}


function Pop(_src, _width, _height, _title) {
    if (!_width) {
        _width = 800;
    }

    if (!_height) {
        _height = 550;
    }

    if (!_title) {
        _title = "信息说明";
    }


    layer.open({
        type: 2,
        title: _title,
        shadeClose: true,
        shade: 0.8,
        area: [_width + 'px', _height + 'px'],
        content: _src
    });

}


