IntelligentRecognition/ah-jjsp-web/.svn/pristine/b5/b5d5143847d4f97e695d0e9cd88...

901 lines
25 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let dtree, recordTable, videoTable,imageTable, form, layer, laydate, util, tree;
let noNum = 0, num = 0, all = 0;
let type = 'city';
let dataType = 'video';
let terrace = 'platform'
let arr = [];
let tybns = [];
let upDownData = [];
let passWay;
layui.extend({
dtree: '{/}../../js/layui_dtree/dtree/dtree'
}).use(['layer', 'laydate', 'form', 'table', 'util', 'dtree', 'table'], function () {
layer = layui.layer;
form = layui.form;
laydate = layui.laydate;
recordTable = layui.table;
videoTable = layui.table;
imageTable = layui.table;
util = layui.util;
dtree = layui.dtree;
passWay= localStorage.getItem("passWay");
form.render();
inputTime();
//视频日期范围
laydate.render({
elem: '#videoTime'
, type: 'date'
, range: '~'
, format: 'yyyy-MM-dd',
max: Date.parse(new Date()),
});
//图片日期范围
laydate.render({
elem: '#imgTime'
, type: 'date'
, range: '~'
, format: 'yyyy-MM-dd',
max: Date.parse(new Date()),
});
//记录日期范围
laydate.render({
elem: '#recordTime'
, type: 'date'
, range: '~'
, format: 'yyyy-MM-dd',
max: Date.parse(new Date()),
});
tree = dtree.render({
elem: "#ballTree",
initLevel: 1,
data: [],
checkbar: true,//开启复选框
menubar: false,
ficon: ['2'],
skin: "lay",
record: true,
checkbarFun: checkBarFun,
done: function (res, $ul, first) {
$('.icon-shexiangtou1').next().css('color', "#2f82fb");
$('div[data-id$="top"]').addClass('top');
}
});
initTreeCity("");
getBallVideo();
//工具条事件
videoTable.on('tool(videoTable)', function (obj) {
let data = obj.data;
let layEvent = obj.event;
switch (layEvent) {
case 'see':
data.type = terrace;
console.log(JSON.stringify(data));
toPage(JSON.stringify(data));
break;
default:
break;
}
});
util.event('lay-active', {
//地市
city: function () {
if (type !== 'city') {
changBtn(this, $(this).parent(), 'checkBtn');
initTreeCity("");
type = 'city';
}
},
//风险等级
risk: function () {
if (type !== 'risk') {
changBtn(this, $(this).parent(), 'checkBtn');
initTreeRisk("");
type = 'risk';
}
},
regular: function () {
if (type !== 'regular') {
changBtn(this, $(this).parent(), 'checkBtn');
initTreeRegular("");
type = 'regular';
}
},
//查询
query: function () {
if (type === 'city') {
initTreeCity($('#keyWord').val());
} else if (type === 'risk') {
initTreeRisk($('#keyWord').val());
} else {
initTreeRegular($('#keyWord').val());
}
},
queryRecord: function () {
getBallUpDown();
},
videoQuery: function () {
if (terrace === 'frontEnd') {
getBallVideoWeb();
} else {
getBallVideo()
}
},
imgQuery: function () {
if (terrace === 'frontEnd') {
getBallImageWeb();
} else {
getBallImage()
}
},
recordDownload: function () {
},
//平台
platform: function () {
changBtn(this, $(this).parent(), 'checkBtn');
terrace = 'platform'
if (dataType !== 'record') {
getBallVideo();
}
},
//前端
frontEnd: function () {
changBtn(this, $(this).parent(), 'checkBtn');
terrace = 'frontEnd'
if (dataType !== 'record') {
getBallVideoWeb();
}
},
//录像查询
video: function () {
changBtn(this, $(this).parent(), 'checkLi');
changContentRight('video');
//initVideoTable();
dataType = 'video'
if (terrace === 'frontEnd') {
getBallVideoWeb();
} else {
getBallVideo()
}
},
//图片查询
img: function () {
changContentRight('img');
changBtn(this, $(this).parent(), 'checkLi');
dataType = 'img'
if (terrace === 'frontEnd') {
getBallImageWeb();
} else {
getBallImage()
}
},
//上下线记录查询
history: function () {
changContentRight('record');
changBtn(this, $(this).parent(), 'checkLi');
dataType = 'record'
getBallUpDown();
}
});
});
/**
* 树单选框监听事件
* @type {{chooseDone: checkBarFun.chooseDone}}
*/
let checkBarFun = {
chooseDone: function (obj) {
console.log(obj);
arr = [];
$.each(obj, function (index, item) {
/* var passWay = item.recordData.passWay;
arr.push({
name: item.context,
puId: item.recordData.puid
})*/
if (passWay == 'to-1') {//通道1
tybns.push({
name: item.context,
puId: item.recordData.tCode,
passWay: passWay
})
arr.push({
name: item.context,
puId: item.recordData.tCode,
passWay:passWay
})
} else {
tybns.push({
name: item.context,
puId: item.recordData.puid,
passWay: passWay
})
arr.push({
name: item.context,
puId: item.recordData.puid,
passWay:passWay
})
}
})
if (dataType === 'record') {
getBallUpDown();
}else if (dataType === 'img') {
if (terrace === 'frontEnd') {
getBallImageWeb();
} else {
getBallImage()
}
}else{
if (terrace === 'frontEnd') {
getBallVideoWeb();
} else {
getBallVideo()
}
}
}
}
/**
* 获取设备上下线数据
*/
function getBallUpDown() {
let dom = $('#recordTime');
let startTime = isEmpty(dom.val().split('~')[0]) ? "" : dom.val().split('~')[0];
let endTime = isEmpty(dom.val().split('~')[1]) ? "" : dom.val().split('~')[1];
let params = {
puIdList: JSON.stringify(tybns),
startTime: startTime,
endTime: endTime
}
let loadingMsg = layer.msg('数据加载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
Ajax().post({
url: dataUrl + 'proteam/pot/video/getBallUpDown',
headers: {
"encrypt": sm3(JSON.stringify(params))
},
data: params,
async: true,
success: function (data) {
layer.close(loadingMsg); // 关闭提示层
if (data.code === 200) {
initRecordTable(data.data);
} else {
initRecordTable([]);
}
},
error: function () {
layer.close(loadingMsg); // 关闭提示层
}
});
}
/**
* 获取球机前端录像//图片
*/
function getBallVideoWeb() {
let dom = $('#videoTime');
let startTime = isEmpty(dom.val().split('~')[0]) ? "" : dom.val().split('~')[0];
let endTime = isEmpty(dom.val().split('~')[1]) ? "" : dom.val().split('~')[1];
let params = {
puIdList: JSON.stringify(arr),
type: dataType === 'img' ? "1" : "0",
startTime: startTime,
endTime: endTime
}
let loadingMsg = layer.msg('数据加载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
Ajax().post({
url: dataUrl + 'proteam/pot/video/getBallVideoWeb',
headers: {
"encrypt": sm3(JSON.stringify(params))
},
data: params,
async: true,
success: function (data) {
console.log(data);
if (dataType === 'video') {
initVideoTable(data.data);
}
if (dataType === 'img') {
initImageTable(data.data);
}
layer.close(loadingMsg); // 关闭提示层
console.log(data);
},
error: function () {
layer.close(loadingMsg); // 关闭提示层
}
});
}
/**
* 获取球机前端录像//图片
*/
function getBallImageWeb() {
let dom = $('#imgTime');
let startTime = isEmpty(dom.val().split('~')[0]) ? "" : dom.val().split('~')[0];
let endTime = isEmpty(dom.val().split('~')[1]) ? "" : dom.val().split('~')[1];
let params = {
puIdList: JSON.stringify(arr),
type: dataType === 'img' ? "1" : "0",
startTime: startTime,
endTime: endTime
}
let loadingMsg = layer.msg('数据加载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
Ajax().post({
url: dataUrl + 'proteam/pot/video/getBallVideoWeb',
headers: {
"encrypt": sm3(JSON.stringify(params))
},
data: params,
async: true,
success: function (data) {
console.log(data);
if (dataType === 'video') {
initVideoTable(data.data);
}
if (dataType === 'img') {
initImageTable(data.data);
}
layer.close(loadingMsg); // 关闭提示层
console.log(data);
},
error: function () {
layer.close(loadingMsg); // 关闭提示层
}
});
}
/**
* 获取球机平台录像//图片
*/
function getBallVideo() {
let dom = $('#videoTime');
let startTime = isEmpty(dom.val().split('~')[0]) ? "" : dom.val().split('~')[0];
let endTime = isEmpty(dom.val().split('~')[1]) ? "" : dom.val().split('~')[1];
let params = {
puIdList: JSON.stringify(arr),
type: dataType === 'img' ? "1" : "0",
startTime: startTime,
endTime: endTime.trim()
}
let loadingMsg = layer.msg('数据加载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
Ajax().post({
url: dataUrl + 'proteam/pot/video/getBallVideo',
headers: {
"encrypt": sm3(JSON.stringify(params))
},
data: params,
async: true,
success: function (data) {
console.log(data);
if (dataType === 'video') {
initVideoTable(data.data);
}
if (dataType === 'img') {
initImageTable(data.data);
}
layer.close(loadingMsg); // 关闭提示层
console.log(data);
},
error: function () {
layer.close(loadingMsg); // 关闭提示层
}
});
}
/**
* 获取球机平台录像//图片
*/
function getBallImage() {
let dom = $('#imgTime');
let startTime = isEmpty(dom.val().split('~')[0]) ? "" : dom.val().split('~')[0];
let endTime = isEmpty(dom.val().split('~')[1]) ? "" : dom.val().split('~')[1];
let params = {
puIdList: JSON.stringify(arr),
type: dataType === 'img' ? "1" : "0",
startTime: startTime,
endTime: endTime.trim()
}
let loadingMsg = layer.msg('数据加载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
Ajax().post({
url: dataUrl + 'proteam/pot/video/getBallVideo',
headers: {
"encrypt": sm3(JSON.stringify(params))
},
data: params,
async: true,
success: function (data) {
console.log(data);
if (dataType === 'video') {
initVideoTable(data.data);
}
if (dataType === 'img') {
initImageTable(data.data);
}
layer.close(loadingMsg); // 关闭提示层
console.log(data);
},
error: function () {
layer.close(loadingMsg); // 关闭提示层
}
});
}
function initImageTable(videoTableData) {
imageTable.render({
elem: "#imageTable",
id: "imageTable",
height: "full-80",
data: videoTableData,
page: true, //开启分页
limit: 10, //默认十条数据一页
limits: [10, 20, 30], //数据分页条
loading: false,
cols: [
[//表头
{
type: 'checkbox'
},
{
field: "number",
type: "numbers",
title: "序号",
minWidth: 200,
unresize: true,
align: "center",
},
{
field: "name",
title: "文件名称",
unresize: true,
sort: true,
minWidth: 200,
align: "center"
},
{
field: "size",
title: "文件大小",
unresize: true,
sort: true,
minWidth: 200,
align: "center",
templet: function (d) {
return "<span>" + (d.size / 1024 / 1024).toFixed(2) + "Mb</span>";
}
},
{
field: "begin",
title: "抓拍时间",
unresize: true,
sort: true,
minWidth: 200,
align: "center",
templet: function (d) {
return "<span>" + timestamp(d.begin) + "</span>";
}
},
{
fixed: 'right',
title: "操作",
align: 'center',
minWidth: 200,
toolbar: '#barDemo'
}
],
],
done: function (res, curr, count) {
$(".layui-laypage-skip").css("display", "none");
}
});
}
/**
* 视频列表
*/
function initVideoTable(videoTableData) {
videoTable.render({
elem: "#videoTable",
id: "videoTable",
height: "full-80",
data: videoTableData,
page: true, //开启分页
limit: 10, //默认十条数据一页
limits: [10, 20, 30], //数据分页条
loading: false,
cols: [
[//表头
{
type: 'checkbox'
},
{
field: "number",
type: "numbers",
title: "序号",
minWidth: 200,
unresize: true,
align: "center",
},
{
field: "name",
title: "文件名称",
unresize: true,
sort: true,
minWidth: 200,
align: "center"
},
{
field: "size",
title: "文件大小",
unresize: true,
sort: true,
minWidth: 200,
align: "center",
templet: function (d) {
return "<span>" + (d.size / 1024 / 1024).toFixed(2) + "Mb</span>";
}
},
{
field: "begin",
title: "录像时间",
unresize: true,
sort: true,
minWidth: 200,
align: "center",
templet: function (d) {
return "<span>" + timestamp(d.begin) + "~" + timestamp(d.end) + "</span>";
}
},
{
fixed: 'right',
title: "操作",
align: 'center',
minWidth: 200,
toolbar: '#barDemo'
}
],
],
done: function (res, curr, count) {
$(".layui-laypage-skip").css("display", "none");
}
});
}
function initRecordTable(recordTableData) {
recordTable.render({
elem: "#recordTable",
id: "recordTable",
height: "full-80",
data: recordTableData,
page: true, //开启分页
limit: 10, //默认十条数据一页
limits: [10, 20, 30], //数据分页条
cols: [
[//表头
{
type: 'checkbox'
},
{
field: "number",
type: "numbers",
title: "序号",
minWidth: 200,
unresize: true,
align: "center",
},
{
field: "name",
title: "所在工程",
unresize: true,
sort: true,
minWidth: 100,
align: "center"
},
{
field: "puid",
title: "PUID",
unresize: true,
sort: true,
minWidth: 100,
align: "center"
},
{
field: "onLineTime",
title: "时间",
unresize: true,
sort: true,
minWidth: 100,
align: "center"
},
{
field: "type",
title: "类型",
unresize: true,
sort: true,
minWidth: 100,
align: "center"
}
],
],
done: function (res, curr, count) {
$(".layui-laypage-skip").css("display", "none");
}
});
}
/**
* 地市树
* @param keyWord
*/
function initTreeCity(keyWord) {
arr = [];
Ajax().post({
headers: {
"encrypt": sm3(JSON.stringify({
keyWord: $('#keyWord').val()
}))
},
url: dataUrl + 'proteam/pot/video/getMenuListCity',
data: {
keyWord: $('#keyWord').val()
},
success: function (data) {
console.log(data);
calleArr(data.data);
let treeData = [{
id: "top",
title: '<span style="font-size: 18px">球机</span><span style="font-size: 16px;">&nbsp;&nbsp;(在线:<span style="color: green">' + num + '&nbsp;&nbsp;</span>' + " 不在线:" + '<span style="color: red">' + noNum + '&nbsp;&nbsp;</span>' + " 总数:" + all + ')</span>',
parentId: "-1",
children: data.data,
iconClass: 'iconfont icon-shexiangtou',
spread: true,
}];
console.log(treeData);
dtree.reload(tree, {
data: treeData
});
}
});
}
/**
* 风险等级树
* @param keyWord
*/
function initTreeRisk(keyWord) {
arr = [];
Ajax().post({
headers: {
"encrypt": sm3(JSON.stringify({
keyWord: keyWord
}))
},
url: dataUrl + 'proteam/pot/video/getMenuListRisk',
data: {
keyWord: keyWord
},
success: function (data) {
calleArr(data.data);
let treeData = [{
id: "top",
title: '<span style="font-size: 18px">球机&nbsp;&nbsp;(在线:' + '<span style="color: green">' + num + '&nbsp;&nbsp;</span>' + " 不在线:" + '<span style="color: red">' + noNum + '&nbsp;&nbsp;</span>' + " 总数:" + all + ')</span>',
parentId: "-1",
children: data.data,
iconClass: 'iconfont icon-shexiangtou',
spread: true,
}];
dtree.reload(tree, {
data: treeData
});
}
});
}
// 固定球机树
function initTreeRegular() {
arr = [];
Ajax().post({
headers: {
"encrypt": sm3(JSON.stringify({
keyWord: $('#keyWord').val()
}))
},
url: dataUrl + 'proteam/pot/video/getMenuListRegular',
data: {
keyWord: $('#keyWord').val()
},
success: function (data) {
calleArr(data.data);
let treeData = [{
id: "top",
title: '<span style="font-size: 18px">球机&nbsp;&nbsp;(在线:' + '<span style="color: green">' + num + '&nbsp;&nbsp;</span>' + " 不在线:" + '<span style="color: red">' + noNum + '&nbsp;&nbsp;</span>' + " 总数:" + all + ')</span>',
parentId: "-1",
children: data.data,
iconClass: 'iconfont icon-shexiangtou',
spread: true,
}];
dtree.reload(tree, {
data: treeData
});
}
});
}
/**
* 遍历树数据
* @param treeData
*/
function calleArr(treeData) {
num = 0;
noNum = 0;
all = 0;
for (let i in treeData) {
let obj = treeData[i];
obj.iconClass = 'iconfont icon-dingwei';
if (obj.children) {
for (let i in obj.children) {
obj.children[i].checkArr = "0";
obj.children[i].iconClass = "none";
if (!isEmpty(obj.children[i].puid)) {
//判断球机图标
if (!isEmpty(obj.children[i].state) && obj.children[i].state === '1') {
//在线图标
num++;
} else {
//不在线图标
noNum++;
}
//人员图标
if (obj.children[i].children) {
for (let a in obj.children[i].children) {
obj.children[a].children[a].iconClass = 'iconfont icon-renyuan';
}
}
all++;
}
}
}
}
}
/**
* 改变底部按钮样式
*/
function changBtn(dom, parentDom, css) {
let button = $(dom);
if (!button.hasClass(css)) {
$.each(parentDom.children(), function (index, item) {
$(item).removeClass(css);
});
}
button.addClass(css);
}
/**
* 改变右侧显示
*/
function changContentRight(dom) {
let content = $('.' + dom);
if (!content.hasClass('list-show')) {
$.each($('.list'), function (index, item) {
$(item).removeClass('list-show');
});
}
content.addClass('list-show');
}
function inputTime() {
$.each($('.time'), function (index, item) {
$(item).attr('value', getNowDate() + " ~ " + getNowDate());
});
}
function getNowDate() {
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (month < 10) {
month = "0" + month;
}
if (day < 10) {
day = "0" + day;
}
return year + "-" + month + "-" + day;
}
function timestamp(time) {
let date = new Date(time * 1000);
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
let hours = date.getHours();
let minutes = date.getMinutes();
let seconds = date.getSeconds()
if (month < 10) {
month = "0" + month;
}
if (day < 10) {
day = "0" + day;
}
if (hours < 10) {
hours = "0" + hours;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds
}
function GetDateDiff(startTime, endTime, diffType) {
//将xxxx-xx-xx的时间格式转换为 xxxx/xx/xx的格式
startTime = startTime.replace(/\-/g, "/");
endTime = endTime.replace(/\-/g, "/");
//将计算间隔类性字符转换为小写
diffType = diffType.toLowerCase();
let sTime = new Date(startTime); //开始时间
let eTime = new Date(endTime); //结束时间
//作为除数的数字
let timeType = 1;
switch (diffType) {
case"second":
timeType = 1000;
break;
case"minute":
timeType = 1000 * 60;
break;
case"hour":
timeType = 1000 * 3600;
break;
case"day":
timeType = 1000 * 3600 * 24;
break;
default:
break;
}
return parseInt((eTime.getTime() - sTime.getTime()) / parseInt(timeType));
}
/**
* 跳转点播页面
* @param teamId 班组id
*/
function toPage(item) {
let width = '65%', height = '90%';
layer.open({
title: ['视频点播', 'font-size:18px;'],
type: 2,
skin: 'shadows',
content: '../../html/video/flvStart.html',
area: [width, height],
maxmin: false,
success: function (layero, index) {
let body = layer.getChildFrame('body', index);
let iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象执行iframe页的方法
iframeWin.setForm(item);//调用子页面的方法,页面锁定
}
});
}