| <div class="layui-fluid layui-anim febs-anim" id="febs-online" lay-title="在线用户"> | 
|     <div class="layui-row febs-container"> | 
|         <div class="layui-col-md12"> | 
|             <div class="layui-card"> | 
|                 <div class="layui-card-body febs-table-full"> | 
|                     <form class="layui-form layui-table-form" lay-filter="online-table-form"> | 
|                         <div class="layui-row"> | 
|                             <div class="layui-col-md11"> | 
|                                 <div class="layui-form-item"> | 
|                                     <div class="layui-inline"> | 
|                                         <label class="layui-form-label layui-form-label-sm">用户名</label> | 
|                                         <div class="layui-input-inline"> | 
|                                             <input type="text" name="username" autocomplete="off" class="layui-input"> | 
|                                         </div> | 
|                                     </div> | 
|                                 </div> | 
|                             </div> | 
|                             <div class="layui-col-md1 table-action-area"> | 
|                                 <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain  table-action" id="query"> | 
|                                     <i class="layui-icon"></i> | 
|                                 </div> | 
|                                 <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain  table-action" id="reset"> | 
|                                     <i class="layui-icon"></i> | 
|                                 </div> | 
|                             </div> | 
|                         </div> | 
|                     </form> | 
|                     <div class="febs-hide"> | 
|                         <span class="febs-alert-base febs-alert-success" id="count"></span> | 
|                     </div> | 
|                     <table lay-filter="onlineTable" lay-data="{id: 'onlineTable'}"></table> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|     </div> | 
| </div> | 
| <script type="text/html" id="online-username"> | 
|     <div> | 
|         {{d.username}} | 
|         {{# | 
|         if (d.current) { | 
|         }} | 
|         <span class="layui-badge febs-tag-red">current</span> | 
|         {{# | 
|         } | 
|         }} | 
|     </div> | 
| </script> | 
| <script type="text/html" id="online-status"> | 
|     {{# | 
|     var status = { | 
|     1: {title: '在线', color: 'green'}, | 
|     0: {title: '离线', color: 'volcano'} | 
|     }[d.status]; | 
|     }} | 
|     <span class="layui-badge febs-bg-{{status.color}}">{{ status.title }}</span> | 
| </script> | 
| <script type="text/html" id="online-option"> | 
|     <span shiro:lacksPermission="user:kickout"> | 
|         <span class="layui-badge-dot febs-bg-orange"></span> 无权限 | 
|     </span> | 
|     <a lay-event="del" shiro:hasPermission="user:kickout"><i class="layui-icon febs-edit-area febs-red"></i></a> | 
| </script> | 
| <script data-th-inline="none" type="text/javascript"> | 
|     layui.use(['jquery', 'form', 'table', 'febs'], function () { | 
|         var $ = layui.jquery, | 
|             laydate = layui.laydate, | 
|             febs = layui.febs, | 
|             form = layui.form, | 
|             table = layui.table, | 
|             $view = $('#febs-online'), | 
|             $query = $view.find('#query'), | 
|             $reset = $view.find('#reset'), | 
|             $searchForm = $view.find('form'), | 
|             tableIns; | 
|   | 
|         form.render(); | 
|   | 
|         initTable(); | 
|   | 
|         table.on('tool(onlineTable)', function (obj) { | 
|             var data = obj.data, | 
|                 layEvent = obj.event; | 
|             if (layEvent === 'del') { | 
|                 febs.modal.confirm('踢出用户', '确定将该用户踢出?', function () { | 
|                     if (data.current) { | 
|                         $.get(ctx + 'logout', function () { | 
|                             window.location.reload(); | 
|                         }); | 
|                     } else { | 
|                         febs.get(ctx + "session/delete/" + data.id, null, function () { | 
|                             febs.alert.success('踢出用户成功'); | 
|                             $query.click(); | 
|                         }); | 
|                     } | 
|                 }); | 
|             } | 
|         }); | 
|   | 
|         $query.on('click', function () { | 
|             tableIns.reload({where: getQueryParams()}); | 
|         }); | 
|   | 
|         $reset.on('click', function () { | 
|             $searchForm[0].reset(); | 
|             tableIns.reload({where: getQueryParams()}); | 
|         }); | 
|   | 
|         function initTable() { | 
|             tableIns = febs.table.init({ | 
|                 elem: $view.find('table'), | 
|                 id: 'onlineTable', | 
|                 url: ctx + 'session/list', | 
|                 page: false, | 
|                 cols: [[ | 
|                     {title: '用户名', templet: '#online-username', minWidth: 180}, | 
|                     {field: 'startTimestamp', title: '登录时间', minWidth: 180}, | 
|                     {field: 'lastAccessTime', title: '最后访问时间', minWidth: 180}, | 
|                     {field: 'host', title: 'IP地址', minWidth: 165}, | 
|                     {field: 'location', title: '登录地点', minWidth: 180}, | 
|                     {title: '状态', templet: '#online-status'}, | 
|                     {title: '操作', toolbar: '#online-option'} | 
|                 ]], | 
|                 done: function (r) { | 
|                     $view.find('span#count').html('当前共<strong> ' + r.count + ' </strong>人在线') | 
|                         .parents('div.febs-hide').show(); | 
|                 } | 
|             }); | 
|         } | 
|   | 
|         function getQueryParams() { | 
|             return { | 
|                 username: $searchForm.find('input[name="username"]').val().trim() | 
|             }; | 
|         } | 
|     }) | 
| </script> |