1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
$(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;
    }
}