|
@@ -1,221 +1,221 @@
|
|
|
-var prefix = "/sys/online"
|
|
|
-$(function() {
|
|
|
- load();
|
|
|
-});
|
|
|
-
|
|
|
-function load() {
|
|
|
- $('#exampleTable')
|
|
|
- .bootstrapTable(
|
|
|
- {
|
|
|
- method : 'get',
|
|
|
- url : prefix + "/list",
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- iconSize : 'outline',
|
|
|
- toolbar : '#exampleToolbar',
|
|
|
- striped : true,
|
|
|
- dataType : "json",
|
|
|
- pagination : true,
|
|
|
-
|
|
|
-
|
|
|
- singleSelect : false,
|
|
|
-
|
|
|
-
|
|
|
- pageSize : 10,
|
|
|
- pageNumber : 1,
|
|
|
-
|
|
|
- showColumns : false,
|
|
|
- sidePagination : "client",
|
|
|
-
|
|
|
- queryParams : function(params) {
|
|
|
- return {
|
|
|
-
|
|
|
- limit : params.limit,
|
|
|
- offset : params.offset,
|
|
|
- name : $('#searchName').val()
|
|
|
- };
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- columns : [
|
|
|
- {
|
|
|
- checkbox : true
|
|
|
- },
|
|
|
- {
|
|
|
- field : 'id',
|
|
|
- title : '序号'
|
|
|
- },
|
|
|
- {
|
|
|
- field : 'username',
|
|
|
- title : '用户名'
|
|
|
- },
|
|
|
- {
|
|
|
- field : 'host',
|
|
|
- title : '主机'
|
|
|
- },
|
|
|
- {
|
|
|
- field : 'startTimestamp',
|
|
|
- title : '登录时间'
|
|
|
- },
|
|
|
- {
|
|
|
- field : 'lastAccessTime',
|
|
|
- title : '最后访问时间'
|
|
|
- },
|
|
|
- {
|
|
|
- field : 'timeout',
|
|
|
- title : '过期时间'
|
|
|
- },
|
|
|
- {
|
|
|
- field : 'status',
|
|
|
- title : '状态',
|
|
|
- align : 'center',
|
|
|
- formatter : function(value, row, index) {
|
|
|
- if (value == 'on_line') {
|
|
|
- return '<span class="label label-success">在线</span>';
|
|
|
- } else if (value == 'off_line') {
|
|
|
- return '<span class="label label-primary">离线</span>';
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- title : '操作',
|
|
|
- field : 'id',
|
|
|
- align : 'center',
|
|
|
- formatter : function(value, row, index) {
|
|
|
- var d = '<a class="btn btn-warning btn-sm" href="#" title="删除" mce_href="#" onclick="forceLogout(\''
|
|
|
- + row.id
|
|
|
- + '\')"><i class="fa fa-remove"></i></a> ';
|
|
|
- return d;
|
|
|
- }
|
|
|
- } ]
|
|
|
- });
|
|
|
-}
|
|
|
-function reLoad() {
|
|
|
- $('#exampleTable').bootstrapTable('refresh');
|
|
|
-}
|
|
|
-function add() {
|
|
|
-
|
|
|
- layer.open({
|
|
|
- type : 2,
|
|
|
- title : '增加用户',
|
|
|
- maxmin : true,
|
|
|
- shadeClose : false,
|
|
|
- area : [ '800px', '520px' ],
|
|
|
- content : prefix + '/add'
|
|
|
- });
|
|
|
-}
|
|
|
-function forceLogout(id) {
|
|
|
- layer.confirm('确定要强制选中用户下线吗?', {
|
|
|
- btn : [ '确定', '取消' ]
|
|
|
- }, function() {
|
|
|
- $.ajax({
|
|
|
- url : prefix+"/forceLogout/" + id,
|
|
|
- type : "post",
|
|
|
- data : {
|
|
|
- 'id' : id
|
|
|
- },
|
|
|
- success : function(r) {
|
|
|
- if (r.code == 0) {
|
|
|
- layer.msg(r.msg);
|
|
|
- reLoad();
|
|
|
- } else {
|
|
|
- layer.msg(r.msg);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- })
|
|
|
-}
|
|
|
-function edit(id) {
|
|
|
- layer.open({
|
|
|
- type : 2,
|
|
|
- title : '用户修改',
|
|
|
- maxmin : true,
|
|
|
- shadeClose : true,
|
|
|
- area : [ '800px', '520px' ],
|
|
|
- content : prefix + '/edit/' + id
|
|
|
- });
|
|
|
-}
|
|
|
-function resetPwd(id) {
|
|
|
- layer.open({
|
|
|
- type : 2,
|
|
|
- title : '重置密码',
|
|
|
- maxmin : true,
|
|
|
- shadeClose : false,
|
|
|
- area : [ '400px', '260px' ],
|
|
|
- content : prefix + '/resetPwd/' + id
|
|
|
- });
|
|
|
-}
|
|
|
-function batchRemove() {
|
|
|
- var rows = $('#exampleTable').bootstrapTable('getSelections');
|
|
|
- if (rows.length == 0) {
|
|
|
- layer.msg("请选择要删除的数据");
|
|
|
- return;
|
|
|
- }
|
|
|
- layer.confirm("确认要删除选中的'" + rows.length + "'条数据吗?", {
|
|
|
- btn : [ '确定', '取消' ]
|
|
|
-
|
|
|
- }, function() {
|
|
|
- var ids = new Array();
|
|
|
-
|
|
|
- $.each(rows, function(i, row) {
|
|
|
- ids[i] = row['userId'];
|
|
|
- });
|
|
|
- $.ajax({
|
|
|
- type : 'POST',
|
|
|
- data : {
|
|
|
- "ids" : ids
|
|
|
- },
|
|
|
- url : prefix + '/batchRemove',
|
|
|
- success : function(r) {
|
|
|
- if (r.code == 0) {
|
|
|
- layer.msg(r.msg);
|
|
|
- reLoad();
|
|
|
- } else {
|
|
|
- layer.msg(r.msg);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }, function() {
|
|
|
- });
|
|
|
-}
|
|
|
-function getTreeData() {
|
|
|
- $.ajax({
|
|
|
- type : "GET",
|
|
|
- url : "/sys/dept/tree",
|
|
|
- success : function(tree) {
|
|
|
- loadTree(tree);
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-function loadTree(tree) {
|
|
|
- $('#jstree').jstree({
|
|
|
- 'core' : {
|
|
|
- 'data' : tree
|
|
|
- },
|
|
|
- "plugins" : [ "search" ]
|
|
|
- });
|
|
|
- $('#jstree').jstree().open_all();
|
|
|
-}
|
|
|
-$('#jstree').on("changed.jstree", function(e, data) {
|
|
|
- if (data.selected == -1) {
|
|
|
- var opt = {
|
|
|
- query : {
|
|
|
- deptId : '',
|
|
|
- }
|
|
|
- }
|
|
|
- $('#exampleTable').bootstrapTable('refresh', opt);
|
|
|
- } else {
|
|
|
- var opt = {
|
|
|
- query : {
|
|
|
- deptId : data.selected[0],
|
|
|
- }
|
|
|
- }
|
|
|
- $('#exampleTable').bootstrapTable('refresh', opt);
|
|
|
- }
|
|
|
-
|
|
|
+var prefix = "/sys/online"
|
|
|
+$(function() {
|
|
|
+ load();
|
|
|
+});
|
|
|
+
|
|
|
+function load() {
|
|
|
+ $('#exampleTable')
|
|
|
+ .bootstrapTable(
|
|
|
+ {
|
|
|
+ method : 'get',
|
|
|
+ url : prefix + "/list",
|
|
|
+ showRefresh : true,
|
|
|
+
|
|
|
+
|
|
|
+ iconSize : 'outline',
|
|
|
+ toolbar : '#exampleToolbar',
|
|
|
+ striped : true,
|
|
|
+ dataType : "json",
|
|
|
+ pagination : true,
|
|
|
+
|
|
|
+
|
|
|
+ singleSelect : false,
|
|
|
+
|
|
|
+
|
|
|
+ pageSize : 10,
|
|
|
+ pageNumber : 1,
|
|
|
+
|
|
|
+ showColumns : false,
|
|
|
+ sidePagination : "client",
|
|
|
+
|
|
|
+ queryParams : function(params) {
|
|
|
+ return {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ name : $('#searchName').val()
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ columns : [
|
|
|
+ {
|
|
|
+ checkbox : true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field : 'id',
|
|
|
+ title : '序号'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field : 'username',
|
|
|
+ title : '用户名'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field : 'host',
|
|
|
+ title : '主机'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field : 'startTimestamp',
|
|
|
+ title : '登录时间'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field : 'lastAccessTime',
|
|
|
+ title : '最后访问时间'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field : 'timeout',
|
|
|
+ title : '过期时间'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field : 'status',
|
|
|
+ title : '状态',
|
|
|
+ align : 'center',
|
|
|
+ formatter : function(value, row, index) {
|
|
|
+ if (value == 'on_line') {
|
|
|
+ return '<span class="label label-success">在线</span>';
|
|
|
+ } else if (value == 'off_line') {
|
|
|
+ return '<span class="label label-primary">离线</span>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title : '操作',
|
|
|
+ field : 'id',
|
|
|
+ align : 'center',
|
|
|
+ formatter : function(value, row, index) {
|
|
|
+ var d = '<a class="btn btn-warning btn-sm" href="#" title="删除" mce_href="#" onclick="forceLogout(\''
|
|
|
+ + row.id
|
|
|
+ + '\')"><i class="fa fa-remove"></i></a> ';
|
|
|
+ return d;
|
|
|
+ }
|
|
|
+ } ]
|
|
|
+ });
|
|
|
+}
|
|
|
+function reLoad() {
|
|
|
+ $('#exampleTable').bootstrapTable('refresh');
|
|
|
+}
|
|
|
+function add() {
|
|
|
+
|
|
|
+ layer.open({
|
|
|
+ type : 2,
|
|
|
+ title : '增加用户',
|
|
|
+ maxmin : true,
|
|
|
+ shadeClose : false,
|
|
|
+ area : [ '800px', '520px' ],
|
|
|
+ content : prefix + '/add'
|
|
|
+ });
|
|
|
+}
|
|
|
+function forceLogout(id) {
|
|
|
+ layer.confirm('确定要强制选中用户下线吗?', {
|
|
|
+ btn : [ '确定', '取消' ]
|
|
|
+ }, function() {
|
|
|
+ $.ajax({
|
|
|
+ url : prefix+"/forceLogout/" + id,
|
|
|
+ type : "post",
|
|
|
+ data : {
|
|
|
+ 'id' : id
|
|
|
+ },
|
|
|
+ success : function(r) {
|
|
|
+ if (r.code == 0) {
|
|
|
+ layer.msg(r.msg);
|
|
|
+ reLoad();
|
|
|
+ } else {
|
|
|
+ layer.msg(r.msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+}
|
|
|
+function edit(id) {
|
|
|
+ layer.open({
|
|
|
+ type : 2,
|
|
|
+ title : '用户修改',
|
|
|
+ maxmin : true,
|
|
|
+ shadeClose : true,
|
|
|
+ area : [ '800px', '520px' ],
|
|
|
+ content : prefix + '/edit/' + id
|
|
|
+ });
|
|
|
+}
|
|
|
+function resetPwd(id) {
|
|
|
+ layer.open({
|
|
|
+ type : 2,
|
|
|
+ title : '重置密码',
|
|
|
+ maxmin : true,
|
|
|
+ shadeClose : false,
|
|
|
+ area : [ '400px', '260px' ],
|
|
|
+ content : prefix + '/resetPwd/' + id
|
|
|
+ });
|
|
|
+}
|
|
|
+function batchRemove() {
|
|
|
+ var rows = $('#exampleTable').bootstrapTable('getSelections');
|
|
|
+ if (rows.length == 0) {
|
|
|
+ layer.msg("请选择要删除的数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ layer.confirm("确认要删除选中的'" + rows.length + "'条数据吗?", {
|
|
|
+ btn : [ '确定', '取消' ]
|
|
|
+
|
|
|
+ }, function() {
|
|
|
+ var ids = new Array();
|
|
|
+
|
|
|
+ $.each(rows, function(i, row) {
|
|
|
+ ids[i] = row['userId'];
|
|
|
+ });
|
|
|
+ $.ajax({
|
|
|
+ type : 'POST',
|
|
|
+ data : {
|
|
|
+ "ids" : ids
|
|
|
+ },
|
|
|
+ url : prefix + '/batchRemove',
|
|
|
+ success : function(r) {
|
|
|
+ if (r.code == 0) {
|
|
|
+ layer.msg(r.msg);
|
|
|
+ reLoad();
|
|
|
+ } else {
|
|
|
+ layer.msg(r.msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, function() {
|
|
|
+ });
|
|
|
+}
|
|
|
+function getTreeData() {
|
|
|
+ $.ajax({
|
|
|
+ type : "GET",
|
|
|
+ url : "/sys/dept/tree",
|
|
|
+ success : function(tree) {
|
|
|
+ loadTree(tree);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+function loadTree(tree) {
|
|
|
+ $('#jstree').jstree({
|
|
|
+ 'core' : {
|
|
|
+ 'data' : tree
|
|
|
+ },
|
|
|
+ "plugins" : [ "search" ]
|
|
|
+ });
|
|
|
+ $('#jstree').jstree().open_all();
|
|
|
+}
|
|
|
+$('#jstree').on("changed.jstree", function(e, data) {
|
|
|
+ if (data.selected == -1) {
|
|
|
+ var opt = {
|
|
|
+ query : {
|
|
|
+ deptId : '',
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#exampleTable').bootstrapTable('refresh', opt);
|
|
|
+ } else {
|
|
|
+ var opt = {
|
|
|
+ query : {
|
|
|
+ deptId : data.selected[0],
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#exampleTable').bootstrapTable('refresh', opt);
|
|
|
+ }
|
|
|
+
|
|
|
});
|