/**
|
* 在线用户列表
|
* @author weidy@2019-07-19
|
* @constructor
|
*/
|
layui.define(['layer','table'],function(exports){
|
var Class = function(){
|
this.moduleKey = "vciWebOnlineUser";
|
this.id='vciWebOnlineUser';
|
this.sourceData={};//来源数据,需要至少包含type,如果没有则默认为批产
|
this.columns = [];
|
this.backPath = path;//默认流程和项目的路径是一样的
|
this.url={
|
dataGrid:'/webOnlineUserController/dataGrid'//列表数据和查询
|
};
|
this.buttonIconMap = {
|
SEARCH:'layui-icon-refresh-2',
|
SENIORSEARCH:'layui-icon-query'
|
};
|
this.getContent=function(){//返回这个组件的基础html
|
var that = this;
|
var html = "";
|
html = [
|
'<div class="layui-layout-border">',
|
'<div class="layui-center">',
|
that.getToolbarHtml(),
|
'<table id="table_', that.id , '" lay-filter="',that.id , '" style="overflow-x:auto;"></table>',//主列表
|
'</div>',
|
'</div>'
|
].join("");
|
return html;
|
};
|
this.getToolbarHtml =function(){
|
var that = this;
|
var html = [
|
'<div layui-filter="toolbar_',that.id, '" class="layui-btn-container">',//主列表的按钮
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
|
'</div>'
|
].join("");
|
return html;
|
};
|
this.init=function(){//基础的html被添加后,再执行初始化
|
var that = this;
|
$webUtil.copyConfig(that,that.moduleKey);
|
var table = layui.table;
|
that.checkColumns();//主列表中列。
|
table.render({
|
elem: '#table_' + that.id,
|
id: 'table_' + that.id,
|
url: that.backPath + that.url.dataGrid,
|
cols: [that.columns]
|
});
|
$('[layui-filter="toolbar_' + that.id + '_refresh"]').unbind("click").click(function(){
|
that.refresh();
|
});
|
};
|
this.checkColumns = function(){
|
var that = this;
|
var table = layui.table;
|
if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
|
that.columns = [table.getIndexColumn(),table.getCheckColumn(),{
|
field:'userId',
|
title:'用户名',
|
width:150
|
},{
|
field:'userName',
|
title:'用户姓名',
|
width:150
|
},{
|
field:'ip',
|
title:'IP地址',
|
width:150
|
},{
|
field:'lastRequestTime',
|
title:'最后请求服务时间',
|
width:200
|
}];
|
}
|
};
|
this.refresh = function(){
|
var that = this;
|
layui.table.reload('table_' + that.id,{});
|
};
|
};
|
var cs = new Class();
|
exports('vciWebOnlineUser',cs);
|
});
|