<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>在线用户</title>
</head>
<body>
	<div class="base-extend">
		<input type="hidden" id="sessionId" th:value="${sessionId}"/>
		<ol class="breadcrumb">
		  	<li>系统管理</li>
		  	<li>在线用户</li>
		</ol>
		<div class="listBackBox">
			<div style="padding: 0 0.2rem;min-width: 10.35rem;">
				<button id="refresh" class="btn btn-white btn-info">刷新</button>
			</div>
			<div class="weekmeeting-detail col-xs-12 businessTable" style="padding:0.05rem 0.2rem 0 0.2rem;float:none;">
				<table id="sessionList" style="width: 100%;"></table>
				<div id="sessionListPage"></div>
			</div>
		</div>
    </div>
    <!-- 判断权限 -->
	<div style="display:none;">
		<span tag:hasPermission="signOutUser" id="signOutUser"></span>
	</div>
   
<script type="text/javascript" >	
jQuery(document).ready(function() {
	function loadData(){
		$('#sessionList').setGridParam({
			mtype:'GET',
			url : '/session/do_list',
			datatype : 'json',
			postData: { 'org.id':sxUtil.tree.getSelectOrgId() },
			page : 1
		});
		$('#sessionList').trigger('reloadGrid');
	}
	
	function operationFmatter(cellvalue, options, rowObject){
		if( $("#signOutUser").length<=0 ){
			return '';
		}else{
			return '<div class="operateIcon noHover"><p><span style="display: none;">注销</span><i onclick="sginOut('+rowObject.id+')" class="operateIconfont operateIcon-zhuxiao"></i></div>'	
		}
	}; 
	
	sxUtil.jqGrid('#sessionList',{
		colNames:['ID','序号','登录名','姓名', '最后访问时间','最后访问链接','操作'],
		colModel:[
			{name: 'id', label: 'id', hidedlg:true, hidden:true,sortable:false,title:false},
			{name: 'orderNumber', label: '序号', width:70,sortable:false,title:false},
			{name:'loginName',index:'loginName',width:80,align:'center',sortable:false,title:false},
			{name:'userName',index:'userName',width:80,align:'center',sortable:false,title:false},
			{name:'laterTime',index:'laterTime', width:100,align:'center',sortable:false,title:false},
			{name:'url',index:'url', width:100,sortable:false,title:false},
			{name: 'desc', label: '操作', formatter:operationFmatter,sortable:false,align:'center',width:100,title:false}
		], 
		height:'auto',
		mtype:'GET',
		url : '/session/do_list',
		pager : "#sessionListPage",
		multiselect: false,
		rownumbers:false,
		loadError:function(){
			new $.zui.Messager('列表加载失败', {
			    type: 'warning',
			    time:1500
			}).show();
		},
		onPaging:function(pgButton){
			console.log(pgButton)
		}
	},true);

	//刷新
	$('#refresh').click(function(){
		$('#sessionList').jqGrid('setGridParam',{ 
            mtype:'GET',
			url:'/session/do_list', 
            page:1 
        }).trigger('reloadGrid'); //重新载入
	});
		
});

function sginOut(id){
	var sessionId = $("#sessionId").val();
	if(id==sessionId){
		new $.zui.Messager('您不能注销自己的账号', {
		    type: 'warning',
		    time:1500
		}).show();
		return;
	}
	if(null!=id){
		bootbox.confirm({
			title : "删除",
			message : '<div style="text-align:left;font-size:0.12rem">您是否确认注销该用户？</div>',
			size : 'small',
			buttons : {
				cancel : {
					label : '取消',
					className:'btn-white btn-info'
				},
				confirm : {
					label : '确定',
					className:'btn-white btn-info colorbtn'
				}
			},
			callback : function(result) {
				if (result) {
					$.ajax({ 
			              type:'POST',
						  url: '/session/do_sginOut', 
			              data: {'id':id}, 
			              success: function(msg){ 
			            	  if(msg.success==true){ 
			            		   $('#sessionList').trigger('reloadGrid'); //重新载入 
			            		   new $.zui.Messager('此账号注销成功', {
					          		    type: 'success',
					          		    time:1500
					          		}).show();
			                   }else{ 
			                	   new $.zui.Messager('此账号注销失败', {
					          		    type: 'danger',
					          		    time:1500
					          		}).show();
			                   } 
			              },
			              error:function(){
			            	  new $.zui.Messager('注销时发生错误', {
			          		    type: 'danger',
			          		    time:1500
			          		}).show();
			              }
			        });
				}
			}
		});	 
	}else{
		new $.zui.Messager('注销失败', {
		    type: 'danger',
		    time:1500
		}).show();
	}
 }
</script>
</body>
</html>