You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
7.2 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var pageNumber;
//获取table的高度
function getHeight() {
return $(window).height() * 0.8;
}
$('#bootstrapTable').bootstrapTable({
toolbar: '#toolbar', //工具按钮用哪个容器
method : 'get',
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存默认为true所以一般情况下需要设置一下这个属性*
pagination: true, //是否显示分页(*
sidePagination : 'server',//server:服务器端分页|client前端分页
paginationPreText : '上一页',
paginationNextText : '下一页',
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 10, //每页的记录行数(*
pageList: [5,10,15,20,50,1000],//可供选择的每页的行数(*
height: getHeight(), //行高如果没有设置height属性表格自动根据记录条数觉得表格高度
columns:[
{
title:'全选',
field:'select',
checkbox:true,
width:25,
align:'center',
valign:'middle'
},
{
field: 'no',
title: '序号',
sortable: true,
formatter: function (value, row, index) {
//获取每页显示的数量
var pageSize=$('#bootstrapTable').bootstrapTable('getOptions').pageSize;
//获取当前是第几页
var pageNumber=$('#bootstrapTable').bootstrapTable('getOptions').pageNumber;
//返回序号注意index是从0开始的所以要加上1
return pageSize * (pageNumber - 1) + index + 1;
}
},
{
title:'操作人',
field:'creater',
},
{
title:'日志主题',
field:'logTitle',
},
{
title:'日志内容',
field:'logContent',
},
{
title:'备注',
field:'remark',
},
{
title:'操作时间',
field:'createDate',
},
{
title:'ip地址',
field:'ip',
},
{
title:'操作',
field:'id',
formatter: function(value,row,index){
var deleteOper = row.deleteOper;
if(deleteOper == 1){
var editanddrop = '<button type="button" onclick="deleteLogById('+row.logId+')" class="btn btn-sm btn-danger">删除</button>';
return editanddrop;
}
}
}
],
locale:'zh-CN',//中文支持,
url:path+'/otherManage/getLogList',//排序方式
queryParams: function (params) {
return{
limit : params.limit, // 每页显示数量
offset : params.offset, // SQL语句起始索引
page : (params.offset / params.limit) + 1, //当前页码
startTime:$("#startTime1").val(),
endTime:$("#endTime1").val(),
creater:$("#creater").val(),
logTitle:$("#logTitle").val(),
logContent:$("#logContent").val()
}
},
//选中单个复选框
onCheck:function(row){
var checks = $("#checks").val();
$("#checks").val(checks+=row.logId + ",");
},
//取消单个复选框
onUncheck:function(row){
var checks = $("#checks").val();
checks = checks.replace(row.logId + ",");
$("#checks").val(checks);
},
//全选
onCheckAll:function(rows){
$("#checks").val("");
var checks = '';
for(var i=0;i<rows.length;i++)
{
checks += rows[i].logId + ","
}
$("#checks").val(checks);
},
//全不选
onUncheckAll: function (rows) {
$("#checks").val("");
},
onLoadSuccess:function(){
$(".page-list").show();
$("#fixed-table-footer").show();
//$(".fixed-table-body").css("overflow","auto");
},
//监听分页点击事件
onPageChange: function(num, type) {
pageNumber = num;
}
})
//查询按钮
function refreshTable(){
$("#checks").val("");
$('#bootstrapTable').bootstrapTable('refresh',{
url : path+'/otherManage/getLogList'
})
$('#bootstrapTable').bootstrapTable('selectPage', pageNumber);
}
//删除
function deleteLogById(logId){
Common.confirm({
title: "提示",
message: '确定删除这条数据吗?',
operate: function (reselt) {
if (reselt) {
$.ajax({
type: 'post',
url: path + '/otherManage/deleteLogById/' + logId,
dataType: 'json',
success: function (data) {
if (data.code == 100) {
toastr.success("删除成功!");
refreshTable();
} else {
toastr.warning(data.msg);
}
}
})
}
}
})
}
//批量删除
function deleteLogByIds(){
var ids = $("#checks").val();
if(ids != ''){
var idStr = ids.split(",");
Common.confirm({
title: "提示",
message: '确定删除选中的'+ (idStr.length-1)+ '条数据吗?',
operate: function (reselt) {
if (reselt) {
$.ajax({
type: 'post',
url: path + '/otherManage/deleteLogByIds/' + ids,
dataType: 'json',
success: function (data) {
if (data.code == 100) {
toastr.success("删除成功!");
$("#checks").val();
refreshTable();
} else {
toastr.warning(data.msg);
}
}
})
}
}
})
}else{
toastr.warning("请至少选中一个!");
}
}
//导出excel功能
function exportExcel(){
var checks = $("#checks").val();
if(checks != '') {
checks = checks.substring(0, checks.length - 1);
var url = path+"/otherManage/exportExcel?startTime="+$("#startTime1").val()+"&endTime="+$("#endTime1").val()+"&creater="+$("#creater").val()+"&logTitle="+$("#logTitle").val()+"&logContent="+$("#logContent").val()
+"&checks="+checks;
window.location.href = url;
}else{
Common.confirm({
title: "提示",
message: "没有选中,您确定要按搜索栏条件导出?",
operate: function (reselt) {
if (reselt) {
var url = path+"/otherManage/exportExcel?startTime="+$("#startTime1").val()+"&endTime="+$("#endTime1").val()+"&creater="+$("#creater").val()+"&logTitle="+$("#logTitle").val()+"&logContent="+$("#logContent").val();
window.open(url);
}
}
})
}
}
$(function () {
initDateInput(1);
})