linzhijie
2021-04-12 c632636e2f5b4188b430f5efc9d9f68c8dbe3d6d
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
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('在线用户列表')" />
</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="online-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                [[#{jsp.monitor.online.loginAddress}]]:<input type="text" name="ipaddr"/>
                            </li>
                            <li>
                                [[#{jsp.monitor.online.operator}]]:<input type="text" name="loginName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;[[#{basis.search}]]</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;[[#{basis.reset}]]</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger multiple disabled" onclick="javascript:batchForceLogout()" shiro:hasPermission="monitor:online:batchForceLogout">
                    <i class="fa fa-sign-out"></i> [[#{jsp.monitor.online.retreat}]]
                </a>
            </div>
            
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var forceFlag = [[${@permission.hasPermi('monitor:online:forceLogout')}]];
        var prefix = ctx + "monitor/online";
 
        $(function() {
            var options = {
                uniqueId: "sessionId",
                url: prefix + "/list",
                exportUrl: prefix + "/export",
                sortName: "lastAccessTime",
                sortOrder: "desc",
                showExport: true,
                escape: true,
                columns: [{
                    checkbox: true
                },
                {
                    title: [[#{basis.number}]],
                    formatter: function (value, row, index) {
                         return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'sessionId',
                    title: [[#{jsp.monitor.online.sessionNumber}]]
                },
                {
                    field: 'loginName',
                    title: [[#{jsp.system.user.profile.002}]],
                    sortable: true
                },
                {
                    field: 'deptName',
                    title: [[#{jsp.system.dept.002}]]
                },
                {
                    field: 'ipaddr',
                    title: [[#{jsp.monitor.operlog.hostComputer}]]
                },
                {
                    field: 'loginLocation',
                    title: [[#{jsp.monitor.online.registrationLocation}]]
                },
                {
                    field: 'browser',
                    title: [[#{jsp.monitor.online.browser}]]
                },
                {
                    field: 'os',
                    title: [[#{jsp.monitor.online.operatingSystem}]]
                },
                {
                    field: 'status',
                    title: [[#{jsp.monitor.online.sessionState}]],
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (value == 'on_line') {
                            return '<span class="badge badge-primary">'+[[#{basis.online}]]+'</span>';
                        } else if (value == 'off_line') {
                            return '<span class="badge badge-danger">'+[[#{basis.offline}]]+'</span>';
                        }
                    }
                },
                {
                    field: 'startTimestamp',
                    title: [[#{jsp.monitor.online.logInTime}]],
                    sortable: true
                },
                {
                    field: 'lastAccessTime',
                    title: [[#{jsp.monitor.online.lastAccessTime}]],
                    sortable: true
                },
                {
                    title: [[#{basis.operate}]],
                    align: 'center',
                    formatter: function(value, row, index) {
                        var msg = '<a class="btn btn-danger btn-xs ' + forceFlag + '" href="javascript:void(0)" onclick="forceLogout(\'' + row.sessionId + '\')"><i class="fa fa-sign-out"></i>[[#{dict.ic24}]]</a> ';
                        return msg;
                    }
                }]
            };
            $.table.init(options);
        });
 
        // 单条强退
        function forceLogout(sessionId) {
            $.modal.confirm("确定要强制选中用户下线吗?", function() {
                var data = { "sessionId": sessionId };
                $.operate.post(prefix + "/forceLogout", data);
        })
        }
 
        // 批量强退
        function batchForceLogout() {
            var rows = $.table.selectColumns("sessionId");
            if (rows.length == 0) {
                $.modal.alertWarning("请选择要强退的用户");
                return;
            }
            $.modal.confirm("确认要强退选中的" + rows.length + "条数据吗?", function() {
                var url = prefix + "/batchForceLogout";
                var data = { "ids": rows };
                $.operate.post(url, data);
            });
        }
    </script>
</body>
</html>