$(function () {
|
initSystemName();
|
var appid = getAppId()!=null?getAppId():null;
|
$("#jqGrid").jqGrid({
|
url: restServerBaseURL + 'log/logininfo/list',
|
datatype: "json",
|
rownumbers:true,
|
colModel: [
|
{ label: '用户名', name: 'chinesename', index: 'CHINESENAME', width: 80,align:'center' },
|
{ label: '所属系统', name: 'appfullname', index: 'APPFULLNAME', width: 150,align:'center' },
|
{ label: 'IP地址', name: 'loginip', index: 'LOGINIP', width: 80,align:'center' },
|
{ label: '操作时间', name: 'logindate', index: 'LOGINDATE', width: 80,align:'center',formatter:function(value,grid,rows,state){
|
var date =rows.logindate;
|
var d=date.substring(0,11);
|
return date;
|
}
|
},
|
{ label: '操作类型', name: 'logintype', index: 'LOGINTYPE', width: 50,align:'center',formatter:function(value,grid,rows,state){
|
var logintype=rows.logintype;
|
if(logintype==1){
|
return "登入";
|
}
|
if(logintype==2){
|
return "登出";
|
}
|
if(logintype==3){
|
return "Token校验";
|
}
|
}
|
},
|
{ label: '操作状态', name: 'rstatus', index: 'RSTATUS', width: 50,align:'center', formatter:function(value,grid,rows,state){
|
var rstatus=rows.rstatus;
|
if(rstatus==0){
|
return "成功";
|
}
|
if(rstatus==1){
|
return "失败";
|
}
|
|
}
|
}
|
],
|
postData:{'appid':appid},
|
viewrecords: true,
|
height: "auto",
|
rowNum: 10,
|
//rowList : [10,30,50],
|
rownumbers: true,
|
rownumWidth: 50,
|
autowidth:true,
|
|
pager: "#jqGridPager",
|
jsonReader : {
|
root: "page.list",
|
page: "page.currPage",
|
total: "page.totalPage",
|
records: "page.totalCount"
|
},
|
prmNames : {
|
page:"page",
|
rows:"limit",
|
order: "order"
|
},
|
gridComplete:function(){
|
//隐藏grid底部滚动条
|
$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
|
},
|
onSortCol:function(index,colindex,sortorder){
|
jQuery("#jqGrid").jqGrid('setGridParam',{
|
page:$(".ui-pg-input").val()
|
});
|
}
|
});
|
$("#jqGrid").jqGrid('setLabel','rn','序号',{'text-align':'center'},'');
|
});
|
|
var vm = new Vue({
|
el:'#rapp',
|
data:{
|
showList: true,
|
title: null,
|
logininfo: {}
|
},
|
methods: {
|
query: function () {
|
if(!checkDate()) {
|
return false;
|
}
|
vm.reload();
|
},
|
add: function(){
|
vm.showList = false;
|
vm.title = "新增";
|
vm.logininfo = {};
|
},
|
update: function () {
|
var loginid = getSelectedRow();
|
if(loginid == null){
|
return ;
|
}
|
vm.showList = false;
|
vm.title = "修改";
|
|
vm.getInfo(loginid)
|
},
|
saveOrUpdate: function () {
|
var url = vm.logininfo.loginid == null ? "log/logininfo/save" : "log/logininfo/update";
|
$.ajax({
|
type: "POST",
|
url: restServerBaseURL + url,
|
contentType: "application/json",
|
data: JSON.stringify(vm.logininfo),
|
success: function(r){
|
if(r.code === 0){
|
alert('操作成功', function(){
|
vm.reload();
|
});
|
}else{
|
alert(r.msg);
|
}
|
}
|
});
|
},
|
del: function () {
|
var loginids = getSelectedRows();
|
if(loginids == null){
|
return ;
|
}
|
|
confirm('确定要删除选中的记录?', function(){
|
$.ajax({
|
type: "POST",
|
url: restServerBaseURL + "log/logininfo/delete",
|
contentType: "application/json",
|
data: JSON.stringify(loginids),
|
success: function(r){
|
if(r.code == 0){
|
alert('操作成功', function(){
|
vm.reload();
|
});
|
}else{
|
alert(r.msg);
|
}
|
}
|
});
|
});
|
},
|
getInfo: function(loginid){
|
$.get(restServerBaseURL + "log/logininfo/info/"+loginid, function(r){
|
vm.logininfo = r.logininfo;
|
});
|
},
|
reload: function () {
|
var beginDate=$("#Begin_Date").val();
|
var endDate=$("#End_Date").val();
|
var UserName=$("#UserName").val();
|
var appid=$("#appidName").val();
|
vm.showList = true;
|
var page = $("#jqGrid").jqGrid('getGridParam','page');
|
$("#jqGrid").jqGrid('setGridParam',{
|
postData:{'UserName':UserName ,'beginDate':beginDate,'endDate':endDate,"appid":appid},page:1
|
}).trigger("reloadGrid");
|
},
|
refresh: function () {
|
vm.showList = true;
|
window.location.reload();
|
}
|
}
|
});
|
|
function initSystemName() {
|
var local=window.location.href;
|
$.ajax({
|
type: "GET",
|
url: restServerBaseURL + "sys/systeminfo/queryListAll",
|
contentType: "application/json",
|
success: function(msg) {
|
var systemList = msg.systemList;
|
jQuery("#appidName").append("<option value=''>--请选择--</option>");
|
var appid = '';
|
if (getAppId()!=null) {
|
appid = getAppId();
|
}
|
jQuery.each(systemList, function(i, item) {
|
if(appid == item.appid) {
|
jQuery("#appidName").append("<option value=" + item.appid + " selected = 'true'>" + item.appfullname + "</option>");
|
}
|
else {
|
jQuery("#appidName").append("<option value=" + item.appid + ">" + item.appfullname + "</option>");
|
}
|
});
|
|
}
|
});
|
}
|
|
function findUserByWord(){
|
var username = $("#UserName").val();
|
$("#UserName").autocomplete({
|
source: restServerBaseURL + 'org/user/findUserByWord?keyWord='+encodeURI(encodeURI(username)), //请求的url
|
minLength: 1,
|
});
|
}
|
|
function checkDate() {
|
var beginDate=$("#Begin_Date").val();
|
var endDate=$("#End_Date").val();
|
if(beginDate != "" && endDate != ""){
|
var pubdatestart = new Date(beginDate.replace(/-/g,"/"));
|
var pubdateend = new Date(endDate.replace(/-/g,"/"));
|
if(pubdatestart > pubdateend){
|
alert("结束时间不能小于开始时间!", function () {
|
$("#End_Date").focus();
|
$("#End_Date").focus();
|
});
|
return false;
|
}
|
else {
|
return true;
|
}
|
}
|
else {
|
return true;
|
}
|
}
|