From 9090c423469438249b4712615fa632b59da3db6a Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Mon, 11 Jan 2021 23:11:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=9C=A8=E7=BA=BF=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/OnlineUserViewController.java | 30 +++++++ .../modular/system/onlineUser/online_user.js | 83 +++++++++++++++++++ .../system/onlineUser/online_user.html | 32 +++++++ 3 files changed, 145 insertions(+) create mode 100644 src/main/java/cn/stylefeng/guns/modular/user/OnlineUserViewController.java create mode 100644 src/main/webapp/assets/modular/system/onlineUser/online_user.js create mode 100644 src/main/webapp/pages/modular/system/onlineUser/online_user.html diff --git a/src/main/java/cn/stylefeng/guns/modular/user/OnlineUserViewController.java b/src/main/java/cn/stylefeng/guns/modular/user/OnlineUserViewController.java new file mode 100644 index 00000000..23d8ddd3 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/modular/user/OnlineUserViewController.java @@ -0,0 +1,30 @@ +package cn.stylefeng.guns.modular.user; + +import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource; +import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; + +/** + * 在线用户查看界面 + * + * @author fengshuonan + * @date 2021/1/11 22:02 + */ +@Controller +@Slf4j +@ApiResource(name = "在线用户查看界面") +public class OnlineUserViewController { + + /** + * 在线用户查看界面 + * + * @author fengshuonan + * @date 2021/1/11 22:03 + */ + @GetResource(name = "在线用户查看界面", path = "/view/onlineUser") + public String onlineUser() { + return "/modular/system/onlineUser/online_user.html"; + } + +} diff --git a/src/main/webapp/assets/modular/system/onlineUser/online_user.js b/src/main/webapp/assets/modular/system/onlineUser/online_user.js new file mode 100644 index 00000000..5f1a41f2 --- /dev/null +++ b/src/main/webapp/assets/modular/system/onlineUser/online_user.js @@ -0,0 +1,83 @@ +layui.use(['table', 'HttpRequest'], function () { + var $ = layui.$; + var table = layui.table; + var HttpRequest = layui.HttpRequest; + + /** + * 参数配置管理 + */ + var OnlineUser = { + tableId: "onlineUserTable" + }; + + /** + * 初始化表格的列 + */ + OnlineUser.initColumn = function () { + return [[ + {type: 'checkbox'}, + {field: 'userId', hide: true, title: '主键'}, + {field: 'token', hide: true, title: '用户token'}, + {field: 'account', sort: true, align: "center", title: '账号'}, + {field: 'nickName', sort: true, align: "center", title: '昵称'}, + {field: 'realName', sort: true, align: "center", title: '姓名'}, + {field: 'sex', sort: true, align: "center", title: '性别'}, + {field: 'roleName', sort: true, align: "center", title: '角色名称'}, + {field: 'loginTime', sort: true, align: "center", title: '登录时间'}, + {align: 'center', toolbar: '#tableBar', title: '操作'} + ]]; + }; + + /** + * 点击查询按钮 + */ + OnlineUser.search = function () { + var queryData = {}; + queryData['account'] = $("#account").val(); + table.reload(OnlineUser.tableId, { + where: queryData, page: {curr: 1} + }); + }; + + /** + * 踢下线某个人 + * + * @param data 点击按钮时候的行数据 + */ + OnlineUser.removeSession = function (data) { + var httpRequest = new HttpRequest(Feng.ctxPath + '/sysUser/removeSession', 'post', function (data) { + Feng.success("踢下线成功!"); + table.reload(OnlineUser.tableId); + }, function (data) { + Feng.error(data.message + "!"); + }); + console.log(data) + httpRequest.set('token', data.token); + httpRequest.start(true); + }; + + // 渲染表格 + var tableResult = table.render({ + elem: '#' + OnlineUser.tableId, + url: Feng.ctxPath + '/sysUser/onlineUserList', + page: false, + height: "full-158", + cellMinWidth: 100, + cols: OnlineUser.initColumn() + }); + + // 搜索按钮点击事件 + $('#btnSearch').click(function () { + OnlineUser.search(); + }); + + // 工具条点击事件 + table.on('tool(' + OnlineUser.tableId + ')', function (obj) { + var data = obj.data; + var layEvent = obj.event; + + if (layEvent === 'offline') { + OnlineUser.removeSession(data); + } + }); +}); diff --git a/src/main/webapp/pages/modular/system/onlineUser/online_user.html b/src/main/webapp/pages/modular/system/onlineUser/online_user.html new file mode 100644 index 00000000..746a9637 --- /dev/null +++ b/src/main/webapp/pages/modular/system/onlineUser/online_user.html @@ -0,0 +1,32 @@ +@layout("/layout/_container.html",{js:["/assets/modular/system/onlineUser/online_user.js"]}){ + +
+ 在线用户查看 +
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+ + +@}