效果图如下:
前台代码:
页面定义表格
<table id="BWxuserTable" ></table>
<script>
var BWxuser = {
id: "BWxuserTable",
seItem: null,
table: null,
layerIndex: -1,
pageSize: 20,
pageNumber: 1
};
layui.use(['layer','form','bootstrap_table_edit'], function () {
var layer = layui.layer
, table = layui.table
, $ = layui.jquery
, form = layui.form;
BWxuser.initColumn = function () {
return [
{checkbox: true, halign: 'center', align: "center", width: 50},
{
title: '序号', align: "center", halign: 'center', width: 50, formatter: function (value, row, index) {
return (BWxuser.pageNumber - 1) * BWxuser.pageSize + 1 + index;
}
},
{title: '员工ID', field: 'struId', align: 'center', halign: 'center'},
{title: '员工姓名', field: 'name', align: 'center', halign: 'center'},
{title: '员工工号', field: 'workId', align: 'center', halign: 'center'}
];
};
$(function () {
var defaultColunms = BWxuser.initColumn();
$('#BWxuserTable').bootstrapTable({
dataType: "json",
url: '/userListManagen/list',
pagination: true,
pageList: [10, 15, 20, 50, 100],
striped: true,
pageSize: 20,
queryParams: queryParams,
queryParamsType: '',
columns: defaultColunms,
height: $("body").height() - $(".layui-form").outerHeight(true) - 26,
sidePagination: "server",
onPageChange: function (number, size) {
BWxuser.pageNumber = number;
BWxuser.pageSize = size
}
});
})
function queryParams(){
var nameOrPhone=$("#condition").val();
var temp={
pageSize:this.pageSize,
pageNumber:this.pageNumber
};
return temp;
}
});
</script>