<table class="layui-hide" id="loadList" lay-filter="menu-filter" style=" margin: 0 10px;"></table>
<script type="text/html" id="toolbtn">
<a class="" lay-event="down"><img src="/images/add.png" alt=""></a> //按钮样式
</script>
table.render({
elem: '#loadList'
, url: 'loadList'
, id: 'loadList'
, method : 'POST'
, cols: [[
{type: 'checkbox', toolbar: '#toolbtn', minWidth: 10,width:30}
, {type: 'nn', toolbar: '#toolbtn', minWidth: 10,width:50}
, {field: 'codeUder', title: '揽收员', minWidth: 80,width:110}
]]
, page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
, curr: 1
, groups: 5 //只显示 1 个连续页码
, first: false //不显示首页
, last: false //不显示尾页
}
});
//新添按钮弹窗
$('.layui-btn').on('click', function () {
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
table.on('tool(menu-filter)', function (obj) {
var data = obj.data;
if (obj.event == "down") {
sendRequestByAjax("orderCsbDetail", "orderNo="+data.orderNo, function (data) {
var reg = /<[^>]+>/g;
if (!reg.test(data)){
layer.alert(data);
return;
}
layer.open({
type: 0,
title: "订单管理列表详情",
shadeClose: true,
shade: 0.8,
offset: "200px",
move: false,
area: ['1300px', '570px'],
content: data
});
}, function () {
layer.alert("请求失败!");
});
}
});
});
//监听复选框事件,被选中的行高亮显示
table.on('checkbox(menu-filter)', function (obj) {
// console.log(obj)
if (obj.checked == true && obj.type == 'all') {
//点击全选
$('.layui-table-body table.layui-table tbody tr').addClass('layui-table-click');
} else if (obj.checked == false && obj.type == 'all') {
//点击全不选
$('.layui-table-body table.layui-table tbody tr').removeClass('layui-table-click');
} else if (obj.checked == true && obj.type == 'one') {
//点击单行
if (obj.checked == true) {
obj.tr.addClass('layui-table-click');
var checkStatus = table.checkStatus('loadList')
, data = checkStatus.data;
$('.sp_num').text(data.length)
} else {
obj.tr.removeClass('layui-table-click');
}
} else if (obj.checked == false && obj.type == 'one') {
//点击全选之后点击单行
if (obj.tr.hasClass('layui-table-click')) {
obj.tr.removeClass('layui-table-click');
var checkStatus = table.checkStatus('loadList')
, data = checkStatus.data;
$('.sp_num').text(data.length)
}
}
});