|
|
@@ -253,274 +253,274 @@
|
|
|
<script src="__JS__/layui/layui.js"></script>
|
|
|
<script src="__JS__/jquery.form.js"></script>
|
|
|
<script type="text/javascript">
|
|
|
- function current(id) {
|
|
|
- $("#type").val(id);
|
|
|
- if (id == 1) {
|
|
|
- $("#current1").css("background","#fff");
|
|
|
- $("#current2").css("background","#eee");
|
|
|
- $("#realTimeForm").css("display","block");
|
|
|
- $("#realTimeTable").css("display","block");
|
|
|
- $("#commentForm").css("display","none");
|
|
|
- $("#commentTable").css("display","none");
|
|
|
- } else if (id == 2) {
|
|
|
- $("#current2").css({"background":"#fff"});
|
|
|
- $("#current1").css({"background":"#eee"});
|
|
|
- $("#realTimeForm").css({"display":"none"});
|
|
|
- $("#realTimeTable").css({"display":"none"});
|
|
|
- $("#commentForm").css({"display":"block"});
|
|
|
- $("#commentTable").css({"display":"block"});
|
|
|
- initTable()
|
|
|
- }
|
|
|
+ function current(id) {
|
|
|
+ $("#type").val(id);
|
|
|
+ if (id == 1) {
|
|
|
+ $("#current1").css("background","#fff");
|
|
|
+ $("#current2").css("background","#eee");
|
|
|
+ $("#realTimeForm").css("display","block");
|
|
|
+ $("#realTimeTable").css("display","block");
|
|
|
+ $("#commentForm").css("display","none");
|
|
|
+ $("#commentTable").css("display","none");
|
|
|
+ } else if (id == 2) {
|
|
|
+ $("#current2").css({"background":"#fff"});
|
|
|
+ $("#current1").css({"background":"#eee"});
|
|
|
+ $("#realTimeForm").css({"display":"none"});
|
|
|
+ $("#realTimeTable").css({"display":"none"});
|
|
|
+ $("#commentForm").css({"display":"block"});
|
|
|
+ $("#commentTable").css({"display":"block"});
|
|
|
+ initTable()
|
|
|
}
|
|
|
- layui.use(['form', 'upload'], function(){
|
|
|
- var form = layui.form;
|
|
|
-
|
|
|
- form.on('select(group)', function(value){
|
|
|
- $("#group_id").val(value.value);
|
|
|
- onSearch()
|
|
|
- });
|
|
|
+ }
|
|
|
+ layui.use(['form', 'upload'], function(){
|
|
|
+ var form = layui.form;
|
|
|
|
|
|
- form.on('select(alarm)', function(value){
|
|
|
- $("#alarm_id").val(value.value);
|
|
|
- onSearch()
|
|
|
- });
|
|
|
+ form.on('select(group)', function(value){
|
|
|
+ $("#group_id").val(value.value);
|
|
|
+ onSearch()
|
|
|
});
|
|
|
- function initTable() {
|
|
|
- //先销毁表格
|
|
|
- $('#cusTable').bootstrapTable('destroy');
|
|
|
- //初始化表格,动态从服务器加载数据
|
|
|
- $("#cusTable").bootstrapTable({
|
|
|
- method: "get", //使用get请求到服务器获取数据
|
|
|
- url: "{:url('kfonitoring/kfjiankong')}", //获取数据的地址
|
|
|
- striped: true, //表格显示条纹
|
|
|
- pagination: true, //启动分页
|
|
|
- pageSize: 50, //每页显示的记录数
|
|
|
- pageNumber: 1, //当前第几页
|
|
|
- pageList: [20, 50], //记录数可选列表
|
|
|
- sidePagination: "server", //表示服务端请求
|
|
|
- paginationFirstText: "首页",
|
|
|
- paginationPreText: "上一页",
|
|
|
- paginationNextText: "下一页",
|
|
|
- paginationLastText: "尾页",
|
|
|
- queryParamsType: "undefined",
|
|
|
- queryParams: function queryParams(params) { //设置查询参数
|
|
|
- var param = {
|
|
|
- pageNumber: params.pageNumber,
|
|
|
- pageSize: params.pageSize,
|
|
|
- searchText: $('#type1').val() + ',' + $('#type2').val() + ',' + $('#type3').val()
|
|
|
- };
|
|
|
- return param;
|
|
|
- },
|
|
|
- onLoadSuccess: function (res) { //加载成功时执行
|
|
|
- if (111 == res.code) {
|
|
|
- window.location.reload();
|
|
|
- }
|
|
|
- layer.msg("加载成功", {time: 1000});
|
|
|
- },
|
|
|
- onLoadError: function () { //加载失败时执行
|
|
|
- layer.msg("加载数据失败");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- $(document).ready(function () {
|
|
|
- //调用函数,初始化表格
|
|
|
- initTable();
|
|
|
|
|
|
- //当点击查询按钮的时候执行
|
|
|
- $("#search").bind("click", initTable);
|
|
|
+ form.on('select(alarm)', function(value){
|
|
|
+ $("#alarm_id").val(value.value);
|
|
|
+ onSearch()
|
|
|
+ });
|
|
|
+ });
|
|
|
+ function initTable() {
|
|
|
+ //先销毁表格
|
|
|
+ $('#cusTable').bootstrapTable('destroy');
|
|
|
+ //初始化表格,动态从服务器加载数据
|
|
|
+ $("#cusTable").bootstrapTable({
|
|
|
+ method: "get", //使用get请求到服务器获取数据
|
|
|
+ url: "{:url('kfonitoring/kfjiankong')}", //获取数据的地址
|
|
|
+ striped: true, //表格显示条纹
|
|
|
+ pagination: true, //启动分页
|
|
|
+ pageSize: 50, //每页显示的记录数
|
|
|
+ pageNumber: 1, //当前第几页
|
|
|
+ pageList: [20, 50], //记录数可选列表
|
|
|
+ sidePagination: "server", //表示服务端请求
|
|
|
+ paginationFirstText: "首页",
|
|
|
+ paginationPreText: "上一页",
|
|
|
+ paginationNextText: "下一页",
|
|
|
+ paginationLastText: "尾页",
|
|
|
+ queryParamsType: "undefined",
|
|
|
+ queryParams: function queryParams(params) { //设置查询参数
|
|
|
+ var param = {
|
|
|
+ pageNumber: params.pageNumber,
|
|
|
+ pageSize: params.pageSize,
|
|
|
+ searchText: $('#type1').val() + ',' + $('#type2').val() + ',' + $('#type3').val()
|
|
|
+ };
|
|
|
+ return param;
|
|
|
+ },
|
|
|
+ onLoadSuccess: function (res) { //加载成功时执行
|
|
|
+ if (111 == res.code) {
|
|
|
+ window.location.reload();
|
|
|
+ }
|
|
|
+ layer.msg("加载成功", {time: 1000});
|
|
|
+ },
|
|
|
+ onLoadError: function () { //加载失败时执行
|
|
|
+ layer.msg("加载数据失败");
|
|
|
+ }
|
|
|
});
|
|
|
+ }
|
|
|
+ $(document).ready(function () {
|
|
|
+ //调用函数,初始化表格
|
|
|
+ initTable();
|
|
|
+
|
|
|
+ //当点击查询按钮的时候执行
|
|
|
+ $("#search").bind("click", initTable);
|
|
|
+ });
|
|
|
</script>
|
|
|
<!--webSocket-->
|
|
|
<script>
|
|
|
- let config = {
|
|
|
- socket: '{$socket}',
|
|
|
- token: '{$token}',
|
|
|
- };
|
|
|
- let myData = [];
|
|
|
- let date = new Date(new Date().setHours(0, 0, 0, 0)) / 1000;
|
|
|
- let getLocation = window.location.href;
|
|
|
- let host = getLocation.split('/admin')[0];
|
|
|
- let apiToken = hex_md5('customer-service'+date+host);
|
|
|
- let socket = new WebSocket('ws://' + config.socket+'?apiToken=' + apiToken);
|
|
|
- socket.onopen = function(res) {
|
|
|
- console.log('握手成功');
|
|
|
- // 登录
|
|
|
- let login_data = JSON.stringify({
|
|
|
- type: 'adminInit',
|
|
|
- token: config.token
|
|
|
- });
|
|
|
- socket.send(login_data);
|
|
|
- };
|
|
|
+ let config = {
|
|
|
+ socket: '{$socket}',
|
|
|
+ token: '{$token}',
|
|
|
+ };
|
|
|
+ let myData = [];
|
|
|
+ let date = new Date(new Date().setHours(0, 0, 0, 0)) / 1000;
|
|
|
+ let getLocation = window.location.href;
|
|
|
+ let host = getLocation.split('/admin')[0];
|
|
|
+ let apiToken = hex_md5('customer-service'+date+host);
|
|
|
+ let socket = new WebSocket('ws://' + config.socket+'?apiToken=' + apiToken);
|
|
|
+ socket.onopen = function(res) {
|
|
|
+ console.log('握手成功');
|
|
|
+ // 登录
|
|
|
+ let login_data = JSON.stringify({
|
|
|
+ type: 'adminInit',
|
|
|
+ token: config.token
|
|
|
+ });
|
|
|
+ socket.send(login_data);
|
|
|
+ };
|
|
|
|
|
|
- // 心跳检测.
|
|
|
- setInterval(function(){
|
|
|
- socket.send(JSON.stringify({
|
|
|
- type: 'ping',
|
|
|
- }));
|
|
|
- }, 5000);
|
|
|
+ // 心跳检测.
|
|
|
+ setInterval(function(){
|
|
|
+ socket.send(JSON.stringify({
|
|
|
+ type: 'ping',
|
|
|
+ }));
|
|
|
+ }, 5000);
|
|
|
|
|
|
|
|
|
- socket.onmessage = function(res) {
|
|
|
- var data = eval("("+res.data+")");
|
|
|
- switch(data['message_type']){
|
|
|
- // 服务端ping客户端
|
|
|
- case 'monitor':
|
|
|
- myData = data.data.cvtList;
|
|
|
- putMonitor(data.data);
|
|
|
- break;
|
|
|
- }
|
|
|
- };
|
|
|
+ socket.onmessage = function(res) {
|
|
|
+ var data = eval("("+res.data+")");
|
|
|
+ switch(data['message_type']){
|
|
|
+ // 服务端ping客户端
|
|
|
+ case 'monitor':
|
|
|
+ myData = data.data.cvtList;
|
|
|
+ putMonitor(data.data);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- socket.onclose = function(res) {
|
|
|
- layer.alert('实时监控连接失败', {
|
|
|
- title: '错误提示', icon: 2, closeBtn: 0
|
|
|
- }, '');
|
|
|
- };
|
|
|
+ socket.onclose = function(res) {
|
|
|
+ layer.alert('实时监控连接失败', {
|
|
|
+ title: '错误提示', icon: 2, closeBtn: 0
|
|
|
+ }, '');
|
|
|
+ };
|
|
|
|
|
|
- /**
|
|
|
- * 时间戳转化为年 月 日 时 分 秒
|
|
|
- * time: 传入时间戳
|
|
|
- * format:返回格式,支持自定义,但参数必须与formateArr里保持一致
|
|
|
- */
|
|
|
- function customFormatDateTime(timeStamp,custom,isDtae) {
|
|
|
- var date = new Date();
|
|
|
- date.setTime(timeStamp * 1000);
|
|
|
- var y = date.getFullYear();
|
|
|
- var m = date.getMonth() + 1;
|
|
|
- m = m < 10 ? ('0' + m) : m;
|
|
|
- var d = date.getDate();
|
|
|
- d = d < 10 ? ('0' + d) : d;
|
|
|
- var h = date.getHours();
|
|
|
- h = h < 10 ? ('0' + h) : h;
|
|
|
- var minute = date.getMinutes();
|
|
|
- var second = date.getSeconds();
|
|
|
- minute = minute < 10 ? ('0' + minute) : minute;
|
|
|
- second = second < 10 ? ('0' + second) : second;
|
|
|
- if (isDtae == 0){
|
|
|
- return y + custom + m //+'student';
|
|
|
- }else if (isDtae ==1){
|
|
|
- return y + custom + m + custom + d;
|
|
|
- } else if (isDtae ==2) {
|
|
|
- return h + ':' + minute;
|
|
|
- } else {
|
|
|
- return y + '-' + m + '-' + d + '-' + h + ':' + minute + ':' + second;
|
|
|
+ /**
|
|
|
+ * 时间戳转化为年 月 日 时 分 秒
|
|
|
+ * time: 传入时间戳
|
|
|
+ * format:返回格式,支持自定义,但参数必须与formateArr里保持一致
|
|
|
+ */
|
|
|
+ function customFormatDateTime(timeStamp,custom,isDtae) {
|
|
|
+ var date = new Date();
|
|
|
+ date.setTime(timeStamp * 1000);
|
|
|
+ var y = date.getFullYear();
|
|
|
+ var m = date.getMonth() + 1;
|
|
|
+ m = m < 10 ? ('0' + m) : m;
|
|
|
+ var d = date.getDate();
|
|
|
+ d = d < 10 ? ('0' + d) : d;
|
|
|
+ var h = date.getHours();
|
|
|
+ h = h < 10 ? ('0' + h) : h;
|
|
|
+ var minute = date.getMinutes();
|
|
|
+ var second = date.getSeconds();
|
|
|
+ minute = minute < 10 ? ('0' + minute) : minute;
|
|
|
+ second = second < 10 ? ('0' + second) : second;
|
|
|
+ if (isDtae == 0){
|
|
|
+ return y + custom + m //+'student';
|
|
|
+ }else if (isDtae ==1){
|
|
|
+ return y + custom + m + custom + d;
|
|
|
+ } else if (isDtae ==2) {
|
|
|
+ return h + ':' + minute;
|
|
|
+ } else {
|
|
|
+ return y + '-' + m + '-' + d + '-' + h + ':' + minute + ':' + second;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ function onSearch() {
|
|
|
+ let table = "";
|
|
|
+ let cvtList = searchData();
|
|
|
+ for(key in cvtList){
|
|
|
+ let start_time = cvtList[key].start_time;
|
|
|
+ let intime = cvtList[key].intime
|
|
|
+ if (key != "length") {
|
|
|
+ table += "<tr>" +
|
|
|
+ "<td>"+cvtList[key].servicelog_id+"</td>" +
|
|
|
+ "<td>"+customFormatDateTime(intime,'',2)+"</td>" +
|
|
|
+ "<td>"+cvtList[key].server_name+"</td>" +
|
|
|
+ "<td>"+cvtList[key].user_name+"</td>" +
|
|
|
+ "<td>"+customFormatDateTime(start_time,'',2)+"</td>" +
|
|
|
+ "<td>"+cvtList[key].allCount+"</td>" +
|
|
|
+ "<td>" +
|
|
|
+ "<a href='/admin/system/detail/id/"+cvtList[key].servicelog_id+"/type/onLine.html'>" +
|
|
|
+ "<button type='button' class='btn btn-primary btn-sm'>" +
|
|
|
+ "<i class='fa fa-paste'></i> 详情" +
|
|
|
+ "</button>" +
|
|
|
+ "</a>" +
|
|
|
+ "</td>" +
|
|
|
+ "</tr>"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (table) {
|
|
|
+ $("#table").html(table);
|
|
|
+ } else {
|
|
|
+ $("#table").html("<tr>" +
|
|
|
+ "<td colspan='6' style='text-align: center'>暂无数据</td>" +
|
|
|
+ "</tr>");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function searchData() {
|
|
|
+ let group_id = $("#group_id").val();
|
|
|
+ let alarm_id = $("#alarm_id").val();
|
|
|
+ let newData = [];
|
|
|
+ if (group_id && alarm_id) {
|
|
|
+ if (alarm_id == 1) {
|
|
|
+ for (keys in myData) {
|
|
|
+ if (group_id == myData[keys].group_id && !myData[keys].allCount) {
|
|
|
+ newData.push(myData[keys])
|
|
|
+ }
|
|
|
}
|
|
|
- };
|
|
|
- function onSearch() {
|
|
|
- let table = "";
|
|
|
- let cvtList = searchData();
|
|
|
- for(key in cvtList){
|
|
|
- let start_time = cvtList[key].start_time;
|
|
|
- let intime = cvtList[key].intime
|
|
|
- if (key != "length") {
|
|
|
- table += "<tr>" +
|
|
|
- "<td>"+cvtList[key].servicelog_id+"</td>" +
|
|
|
- "<td>"+customFormatDateTime(intime,'',2)+"</td>" +
|
|
|
- "<td>"+cvtList[key].server_name+"</td>" +
|
|
|
- "<td>"+cvtList[key].user_name+"</td>" +
|
|
|
- "<td>"+customFormatDateTime(start_time,'',2)+"</td>" +
|
|
|
- "<td>"+cvtList[key].allCount+"</td>" +
|
|
|
- "<td>" +
|
|
|
- "<a href='/admin/system/detail/id/"+cvtList[key].servicelog_id+"/type/onLine.html'>" +
|
|
|
- "<button type='button' class='btn btn-primary btn-sm'>" +
|
|
|
- "<i class='fa fa-paste'></i> 详情" +
|
|
|
- "</button>" +
|
|
|
- "</a>" +
|
|
|
- "</td>" +
|
|
|
- "</tr>"
|
|
|
- }
|
|
|
+ } else if (alarm_id == 2) {
|
|
|
+ for (keys in myData) {
|
|
|
+ if (group_id == myData[keys].group_id && myData[keys].allCount) {
|
|
|
+ newData.push(myData[keys])
|
|
|
+ }
|
|
|
}
|
|
|
- if (table) {
|
|
|
- $("#table").html(table);
|
|
|
- } else {
|
|
|
- $("#table").html("<tr>" +
|
|
|
- "<td colspan='6' style='text-align: center'>暂无数据</td>" +
|
|
|
- "</tr>");
|
|
|
+ }
|
|
|
+ } else if(group_id) {
|
|
|
+ for (keys in myData) {
|
|
|
+ if (group_id == myData[keys].group_id) {
|
|
|
+ newData.push(myData[keys])
|
|
|
}
|
|
|
- }
|
|
|
- function searchData() {
|
|
|
- let group_id = $("#group_id").val();
|
|
|
- let alarm_id = $("#alarm_id").val();
|
|
|
- let newData = [];
|
|
|
- if (group_id && alarm_id) {
|
|
|
- if (alarm_id == 1) {
|
|
|
- for (keys in myData) {
|
|
|
- if (group_id == myData[key].group_id && !myData[key].allCount) {
|
|
|
- newData.push(myData[key])
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (alarm_id == 2) {
|
|
|
- for (keys in myData) {
|
|
|
- if (group_id == myData[key].group_id && myData[key].allCount) {
|
|
|
- newData.push(myData[key])
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if(group_id) {
|
|
|
- for (keys in myData) {
|
|
|
- if (group_id == myData[key].group_id) {
|
|
|
- newData.push(myData[key])
|
|
|
- }
|
|
|
- }
|
|
|
- } else if(alarm_id) {
|
|
|
- if (alarm_id == 1) {
|
|
|
- for (keys in myData) {
|
|
|
- if (!myData[key].allCount) {
|
|
|
- newData.push(myData[key])
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (alarm_id == 2) {
|
|
|
- for (keys in myData) {
|
|
|
- if (myData[key].allCount) {
|
|
|
- newData.push(myData[key])
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- newData = myData
|
|
|
+ }
|
|
|
+ } else if(alarm_id) {
|
|
|
+ if (alarm_id == 1) {
|
|
|
+ for (keys in myData) {
|
|
|
+ if (!myData[keys].allCount) {
|
|
|
+ newData.push(myData[keys])
|
|
|
+ }
|
|
|
}
|
|
|
- return newData;
|
|
|
- }
|
|
|
-
|
|
|
- function msg(id) {
|
|
|
- layui.use('layer', function () {
|
|
|
- layer.open({
|
|
|
- type: 2,
|
|
|
- title: '请输入消息内容',
|
|
|
- area: ['500px', '600px'], //自定义文本域宽高
|
|
|
- content:'/admin/kfnotice/add.html?uid='+id
|
|
|
- });
|
|
|
- }
|
|
|
- )
|
|
|
+ } else if (alarm_id == 2) {
|
|
|
+ for (keys in myData) {
|
|
|
+ if (myData[keys].allCount) {
|
|
|
+ newData.push(myData[keys])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ newData = myData
|
|
|
}
|
|
|
+ return newData;
|
|
|
+ }
|
|
|
|
|
|
- // 渲染
|
|
|
- function putMonitor(data) {
|
|
|
- $("#allSensitive").html(data.userSensitive + data.serverSensitive);
|
|
|
- $("#userSensitive").html(data.userSensitive);
|
|
|
- $("#serverSensitive").html(data.serverSensitive);
|
|
|
- $("#csdNumber").html(data.csdNumber);
|
|
|
- $("#overtimeNumber").html(data.overtimeNumber);
|
|
|
- $("#evaluateCount1").html(data.evaluateCount);
|
|
|
- $("#evaluateCount2").html(data.evaluateCount);
|
|
|
- // 响应超时.
|
|
|
- let n = data.csdTime.length;
|
|
|
- let csdTime = 0;
|
|
|
- for(keys in data.csdTime){
|
|
|
- csdTime += data.csdTime[keys]
|
|
|
- }
|
|
|
- csdTime = csdTime ? Math.ceil(csdTime/n) : 0;
|
|
|
- $("#csdTime").html(csdTime);
|
|
|
- // 会话超时.
|
|
|
- let m = data.overtimeTime.length;
|
|
|
- let overtimeTime = 0;
|
|
|
- for(keys in data.overtimeTime){
|
|
|
- overtimeTime += data.overtimeTime[keys]
|
|
|
+ function msg(id) {
|
|
|
+ layui.use('layer', function () {
|
|
|
+ layer.open({
|
|
|
+ type: 2,
|
|
|
+ title: '请输入消息内容',
|
|
|
+ area: ['500px', '600px'], //自定义文本域宽高
|
|
|
+ content:'/admin/kfnotice/add.html?uid='+id
|
|
|
+ });
|
|
|
}
|
|
|
- overtimeTime = overtimeTime ? Math.ceil(overtimeTime/m) : 0;
|
|
|
- $("#overtimeTime").html(overtimeTime);
|
|
|
- onSearch();
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ // 渲染
|
|
|
+ function putMonitor(data) {
|
|
|
+ $("#allSensitive").html(data.userSensitive + data.serverSensitive);
|
|
|
+ $("#userSensitive").html(data.userSensitive);
|
|
|
+ $("#serverSensitive").html(data.serverSensitive);
|
|
|
+ $("#csdNumber").html(data.csdNumber);
|
|
|
+ $("#overtimeNumber").html(data.overtimeNumber);
|
|
|
+ $("#evaluateCount1").html(data.evaluateCount);
|
|
|
+ $("#evaluateCount2").html(data.evaluateCount);
|
|
|
+ // 响应超时.
|
|
|
+ let n = data.csdTime.length;
|
|
|
+ let csdTime = 0;
|
|
|
+ for(keys in data.csdTime){
|
|
|
+ csdTime += data.csdTime[keys]
|
|
|
+ }
|
|
|
+ csdTime = csdTime ? Math.ceil(csdTime/n) : 0;
|
|
|
+ $("#csdTime").html(csdTime);
|
|
|
+ // 会话超时.
|
|
|
+ let m = data.overtimeTime.length;
|
|
|
+ let overtimeTime = 0;
|
|
|
+ for(keys in data.overtimeTime){
|
|
|
+ overtimeTime += data.overtimeTime[keys]
|
|
|
}
|
|
|
+ overtimeTime = overtimeTime ? Math.ceil(overtimeTime/m) : 0;
|
|
|
+ $("#overtimeTime").html(overtimeTime);
|
|
|
+ onSearch();
|
|
|
+ }
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|