loginlogmanage.js
6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/**
* Created by chenbiao on 2017/11/14.
*/
/**
* Created by chenbiao on 2017/11/13.
*/
//
(function() {
var fun = {
init: function() {
//初始化下拉框
// fun.initSelect();
fun.createTableData();
},
//生成表格数据
createTableData: function() {
$('#recordtable').bootstrapTable('destroy').bootstrapTable({
striped: true, //表格显示条纹
pagination: true, //启动分页
pageNumber: 1, //当前第几页
showColumns: false,
pageSize: 10, //每页显示的记录数
pageList: [10, 15, 20], //记录数可选列表
sidePagination: 'server', //表示服务端分页
queryParamsType: 'limit',
method: 'POST', //请求方法
// fixedColumns:true,
// fixedNumber:1,
// leftFixedColumns: true,
// leftFixedNumber: 2,
paginationPreText: '<',
paginationNextText: '>',
ajax: tableLoadRequest, //自定义ajax加载数据
uniqueId: 'id',
columns: [
{
field: 'loginCode',
title: '登录账号',
width: '5%',
align: 'center'
},
{
field: 'opName',
title: '操作员名称',
width: '5%',
align: 'center',
formatter: fun.carTypeFormatter
},
{
field: 'loginType',
title: '登录类型',
width: '10%',
align: 'center',
formatter: function(value, row, index) {
if(undefined != value && null != value) {
if(value == "1" ) {
return "登录";
} else {
return "登出";
}
}
}
},
{
field: 'loginIp',
title: '登录IP',
width: '8%',
align: 'center'
},
{
field: 'resultDesc',
title: '结果描述',
width: '10%',
align: 'center'
},
{
field: 'createDate',
title: '登录时间',
width: '10%',
align: 'center',
formatter: fun.outDatatimeFormatter
}
]
});
},
/*获取查询参数*/
getQueryParam: function() {
/*登录账号*/
var loginCode = $("#loginCode").val();
/*开始时间*/
var beginTime = $('#beginTime').val();
/*结束时间*/
var endTime = $('#endTime').val();
beginTime = beginTime == null || beginTime.length == 0 ? null : new Date(beginTime);
endTime = endTime == null || endTime.length == 0 ? null : new Date(endTime+" 23:59:59");
// console.log(beginTime);
// console.log(endTime);
/*解析时间*/
var req = {
loginCode: loginCode,
beginTime: beginTime,
endTime: endTime
};
console.log(req);
return req;
},
outDatatimeFormatter: function(value, row, index) {
if(value == null) {
return "";
} else {
return DateUtils.long2String(value, 7);
}
},
};
//初始执行
fun.init();
documentBindFunc.on('click', '#queryBtn', function() {
fun.createTableData();
});
/*进场时间筛选框*/
$("#beginTime").datetimepicker({
endDate: moment().subtract('seconds', 0).format('YYYY-MM-DD'),
format: 'yyyy-mm-dd',
autoclose: true,
// //maxDate:moment().subtract('months', 3),
minView: 3,
forceParse: false,
locale: "zh-CN",
language: 'zh-CN',
pickerPosition: "bottom-left"
}).on("click", function () {
$("#beginTime").datetimepicker("setEndDate", $("#endTime").val())
});
$("#endTime").datetimepicker({
endDate: moment().subtract('seconds', 0).format('YYYY-MM-DD'),
format: 'yyyy-mm-dd',
autoclose: true,
// startView: 3,
// //maxDate:moment().subtract('months', 3),
minView: 3,
forceParse: false,
locale: "zh-CN",
language: 'zh-CN',
pickerPosition: "bottom-left"
}).on("click", function () {
$("#endTime").datetimepicker("setStartDate", $("#beginTime").val())
});
/**
* 自定义table AJAX请求
* @param {Object} params
*/
function tableLoadRequest(params) {
var req = fun.getQueryParam();
//设置请求参数
var pageNum = (params.data.offset / params.data.limit) + 1;
//条件查询
req.baseRequest = {
pageNum: pageNum,
pageSize: params.data.limit
};
req.sysCode = sysComm.sysCode;
var opt = {
method: 'post',
url: dataUrl.util.queryLoginLog(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(res) {
console.log(res);
if(res.code == '8888') {
params.success(res.data);
}
}
};
sysAjax(opt);
}
})
();