修改时间选择

main
夜笙歌 2 years ago
parent 02ce084f8e
commit fce82d7d91

@ -158,11 +158,12 @@ const onSearchByCollectTime = function (obj) {
setTimeout(function () { setTimeout(function () {
var storeId = document.getElementById('table'); var storeId = document.getElementById('table');
var rowsLength = storeId.rows.length; var rowsLength = storeId.rows.length;
var key = obj.value; var [startTime,endTime] = obj.value.split(' - ');
var searchCol = storeId.rows.item(0).cells.length-3; var searchCol = storeId.rows.item(0).cells.length-3;
for (var i = 1; i < rowsLength; i++) { for (var i = 1; i < rowsLength; i++) {
var searchText = storeId.rows[i].cells[searchCol].innerHTML; var searchText = storeId.rows[i].cells[searchCol].innerHTML;
if (searchText.match(key)) { console.log(searchText)
if ((new Date(searchText).getTime() >= new Date(startTime).getTime()) && (new Date(searchText).getTime() <= new Date(endTime).getTime())) {
storeId.rows[i].style.display = ''; storeId.rows[i].style.display = '';
} else { } else {
storeId.rows[i].style.display = 'none'; storeId.rows[i].style.display = 'none';
@ -173,4 +174,4 @@ const onSearchByCollectTime = function (obj) {
const historyButton = function(id) { const historyButton = function(id) {
location.href = '/record/recordSensorData/getPage?id='+id; location.href = '/record/recordSensorData/getPage?id='+id;
} }

@ -1,49 +1,52 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> <html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:th="http://www.thymeleaf.org">
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>传感器汇总</title> <title>传感器汇总</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="IE=edge" http-equiv="X-UA-Compatible">
<link th:href="@{favicon.ico}" rel="shortcut icon"/> <link rel="shortcut icon" th:href="@{favicon.ico}"/>
<!--<link rel="stylesheet" th:href="@{/css/lot-ui/bootstrap.min.css}"/>--> <!--<link rel="stylesheet" th:href="@{/css/lot-ui/bootstrap.min.css}"/>-->
<link rel="stylesheet" th:href="@{/css/lot-ui/bootstrap.min.css}"/> <link rel="stylesheet" th:href="@{/css/lot-ui/bootstrap.min.css}"/>
<link rel="stylesheet" th:href="@{/css/lot-ui/bootstrap-table.css}"/> <link rel="stylesheet" th:href="@{/css/lot-ui/bootstrap-table.css}"/>
<link rel="stylesheet" th:href="@{/css/lot-ui/Iot-sensorSummaryStyle.css}"/> <link rel="stylesheet" th:href="@{/css/lot-ui/Iot-sensorSummaryStyle.css}"/>
</head> </head>
<style> <style>
.bootstrap-table .fixed-table-container .fixed-table-body{ .bootstrap-table .fixed-table-container .fixed-table-body {
height: calc(91vh - 100px); height: calc(91vh - 100px);
} }
</style> </style>
<body> <body>
<!--传感器类型--> <!--传感器类型-->
<iframe id="sensorType" name="a_iframe" width="100%" height="100%" frameborder="1" align="middle" <iframe align="middle" frameborder="1" height="100%" id="sensorType" name="a_iframe" scrolling="auto"
scrolling="auto" src="about:blank" style="overflow-x: hidden; src="about:blank" style="overflow-x: hidden;
overflow-y: scroll;"> overflow-y: scroll;" width="100%">
</iframe> </iframe>
<!-- 搜索框 --> <!-- 搜索框 -->
<div class="sensorHistoryData searchBox" style="height:6%;top: 3%"> <div class="sensorHistoryData searchBox" style="height:6%;top: 3%">
<form action="#" class="search-form"> <form action="#" class="search-form">
<input id="sensorTypeId" type="hidden" name="sensorTypeId"> <input id="sensorTypeId" name="sensorTypeId" type="hidden">
<div style="width: 90%;height: 100%;border: 0px solid red;"> <div style="width: 90%;height: 100%;border: 0px solid red;">
<label class="search-label" style="padding-left: 0%;">监测位置:</label> <label class="search-label" style="padding-left: 0%;">监测位置:</label>
<input type="text" class="form-control" onkeydown="onSearchByMonitorLocation(this)" id="monitorLocation" <input class="form-control" id="monitorLocation" name="monitorLocation"
name="monitorLocation" placeholder="请输入监测位置"> onkeydown="onSearchByMonitorLocation(this)"
placeholder="请输入监测位置" type="text">
<label class="search-label">传感器编号:</label> <label class="search-label">传感器编号:</label>
<input type="text" class="form-control" onkeydown="onSearchBySensorId(this)" id="sensorId" name="sensorId" <input class="form-control" id="sensorId" name="sensorId" onkeydown="onSearchBySensorId(this)"
placeholder="请输入传感器编号"> placeholder="请输入传感器编号"
type="text">
<label class="search-label">时间:</label> <label class="search-label">时间:</label>
<input type="text" class="form-control" onkeydown="onSearchByCollectTime(this)" id="collectTime" name="collectTime" placeholder="请输入时间"> <input class="form-control" id="collectTime" name="collectTime" onkeydown="onSearchByCollectTime(this)"
</div> placeholder="请输入时间" type="text" style="width:250px">
</form> </div>
</form>
</div> </div>
<div class="sensorHistoryData sensorDataTable"> <div class="sensorHistoryData sensorDataTable">
<table id="table"></table> <table id="table"></table>
</div> </div>
<th:block th:include="include :: footer"/> <th:block th:include="include :: footer"/>
<script th:src="@{/js/jquery.min.js}"></script> <script th:src="@{/js/jquery.min.js}"></script>
@ -56,19 +59,20 @@
<th:block th:include="include :: footer"/> <th:block th:include="include :: footer"/>
<script> <script>
<!-- laydate示例 --> <!-- laydate示例 -->
layui.use('laydate', function () { layui.use('laydate', function () {
var laydate = layui.laydate; var laydate = layui.laydate;
laydate.render({ laydate.render({
elem: '#collectTime', elem: '#collectTime',
type: 'datetime', type: 'datetime',
trigger: 'click', range: true,
done: (value) => { trigger: 'click',
onSearchByCollectTime(document.getElementById("collectTime")); done: (value) => {
} onSearchByCollectTime(document.getElementById("collectTime"));
}); }
}); });
});
</script> </script>
</body> </body>

@ -6,37 +6,37 @@
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-recordAlarm-add"> <form class="form-horizontal m" id="form-recordAlarm-add">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">传感器:</label> <label class="col-sm-3 control-label">传感器:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="sensorId" class="form-control" type="text"> <input name="sensorId" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">报警类型:</label> <label class="col-sm-3 control-label">报警类型:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="alarmtypeId" class="form-control" type="text"> <input name="alarmtypeId" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">最小值:</label> <label class="col-sm-3 control-label">最小值:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="minValue" class="form-control" type="text"> <input name="minValue" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">异常值:</label> <label class="col-sm-3 control-label">异常值:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="alarmValue" class="form-control" type="text"> <input name="alarmValue" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">最大值:</label> <label class="col-sm-3 control-label">最大值:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="maxValue" class="form-control" type="text"> <input name="maxValue" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">采集时间:</label> <label class="col-sm-3 control-label">采集时间:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="collectTime" class="form-control" type="text"> <input name="collectTime" class="form-control" type="text">
@ -58,4 +58,4 @@
} }
</script> </script>
</body> </body>
</html> </html>

@ -276,4 +276,4 @@
} }
</style> </style>
</body> </body>
</html> </html>

@ -1,217 +1,220 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> <html lang="zh" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:th="http://www.thymeleaf.org">
<head> <head>
<th:block th:include="include :: header('历史记录')"/> <th:block th:include="include :: header('历史记录')"/>
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
<div class="container-div"> <div class="container-div">
<div class="row"> <div class="row">
<div class="col-sm-12 search-collapse"> <div class="col-sm-12 search-collapse">
<form id="formId"> <form id="formId">
<div class="select-list"> <div class="select-list">
<ul> <div style="position: absolute;top:50%;right:12px;transform: translateY(-50%)">
<li> <a class="btn btn-primary btn-rounded btn-sm" onclick="window.history.back()">返回</a>
<input type="hidden" id="sensorId" name="sensorId"/> </div>
</li> <ul>
<li class="select-time"> <li>
<label>采集时间:</label> <input id="sensorId" name="sensorId" type="hidden"/>
<input type="text" class="time-input" id="startTime" placeholder="开始时间" </li>
name="beginCollectTime"/> <li class="select-time">
<span>-</span> <label>采集时间:</label>
<input type="text" class="time-input" id="endTime" placeholder="结束时间" <input class="time-input" id="startTime" name="beginCollectTime" placeholder="开始时间"
name="endCollectTime"/> type="text"/>
</li> <span>-</span>
<li> <input class="time-input" id="endTime" name="endCollectTime" placeholder="结束时间"
<a class="btn btn-primary btn-rounded btn-sm" onclick="tableRefresh()"><i type="text"/>
class="fa fa-search"></i>&nbsp;搜索</a> </li>
<li>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i <a class="btn btn-primary btn-rounded btn-sm" onclick="tableRefresh()"><i
class="fa fa-refresh"></i>&nbsp;重置</a> class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="exportData()"> <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
<i class="fa fa-download"></i> 导出 class="fa fa-refresh"></i>&nbsp;重置</a>
</a>
</li> <a class="btn btn-warning btn-rounded btn-sm" onclick="exportData()">
</ul> <i class="fa fa-download"></i> 导出
</div> </a>
</form> </li>
</ul>
</div> </div>
</form>
</div>
<div class="col-sm-12 select-table table-striped"> <div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table> <table id="bootstrap-table"></table>
</div>
</div> </div>
</div>
</div> </div>
<th:block th:include="include :: footer"/> <th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/> <th:block th:include="include :: datetimepicker-js"/>
<!--表格导出--> <!--表格导出-->
<th:block th:include="include :: bootstrap-table-export-js" /> <th:block th:include="include :: bootstrap-table-export-js"/>
<th:block th:include="include :: FileSaver-xlsx-Base64-js" /> <th:block th:include="include :: FileSaver-xlsx-Base64-js"/>
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "record/recordSensorData"; var prefix = ctx + "record/recordSensorData";
$(() => { $(() => {
tableRefresh(); tableRefresh();
}) })
const tableRefresh = function () { const tableRefresh = function () {
let sensorId = [[${sensorId}]].split(","); let sensorId = [[${sensorId}]].split(",");
let formData = new FormData(); let formData = new FormData();
formData.append("sensorId", sensorId[0]); formData.append("sensorId", sensorId[0]);
formData.append("sensorType", sensorId[1]); formData.append("sensorType", sensorId[1]);
formData.append("beginCollectTime", $("#startTime").val()); formData.append("beginCollectTime", $("#startTime").val());
formData.append("endCollectTime", $("#endTime").val()); formData.append("endCollectTime", $("#endTime").val());
$.ajax({ $.ajax({
type: "post", type: "post",
url: "/record/recordSensorData/list", url: "/record/recordSensorData/list",
contentType: "application/json;charset=utf-8", contentType: "application/json;charset=utf-8",
dataType: "json", dataType: "json",
data: formData, data: formData,
json: 'callback', json: 'callback',
processData: false, processData: false,
contentType: false, contentType: false,
success: function (json) { success: function (json) {
const sensorTypeArray = getparamsFunction(sensorId[1]); const sensorTypeArray = getparamsFunction(sensorId[1]);
const columnsArray = []; const columnsArray = [];
if (sensorTypeArray.length > 0) { if (sensorTypeArray.length > 0) {
columnsArray.push({ columnsArray.push({
field: "uid", field: "uid",
title: "设备UID", title: "设备UID",
width: 160, width: 160,
height: 60, height: 60,
colspan: 1, colspan: 1,
rowspan: 1, rowspan: 1,
align: "center" align: "center"
}); });
columnsArray.push({ columnsArray.push({
field: "sensorId", field: "sensorId",
title: "传感器编号", title: "传感器编号",
width: 160, width: 160,
height: 60, height: 60,
colspan: 1, colspan: 1,
rowspan: 1, rowspan: 1,
align: "center" align: "center"
}); });
columnsArray.push({ columnsArray.push({
field: "datatype", field: "datatype",
title: "类型", title: "类型",
width: 160, width: 160,
height: 60, height: 60,
colspan: 1, colspan: 1,
rowspan: 1, rowspan: 1,
align: "center" align: "center"
}); });
if (json.length > 0) { if (json.length > 0) {
const jsonObj = Object.keys(json[0]); const jsonObj = Object.keys(json[0]);
for (let i = 0; i < jsonObj.length; i++) {//Object.keys(obj) key for (let i = 0; i < jsonObj.length; i++) {//Object.keys(obj) key
let property = jsonObj[i]; let property = jsonObj[i];
if (property != "uid" && property != "sensorId" && property != "collectTime" && property != "datatype") { if (property != "uid" && property != "sensorId" && property != "collectTime" && property != "datatype") {
columnsArray.push({ columnsArray.push({
field: property, field: property,
title: typeof (sensorTypeArray.find(x => x.paramTitle.includes(property))) == "undefined" ? property : sensorTypeArray.find(x => x.paramTitle.includes(property)).paramText, title: typeof (sensorTypeArray.find(x => x.paramTitle.includes(property))) == "undefined" ? property : sensorTypeArray.find(x => x.paramTitle.includes(property)).paramText,
width: 140, width: 140,
align: "center" align: "center"
});
}
}
}
columnsArray.push({
field: "collectTime",
title: "采集时间",
width: 160,
height: 60,
colspan: 1,
rowspan: 1,
align: "center",
formatter: function(value, row, index) {
return value.replace("T"," ");
}
});
}
$('#bootstrap-table').bootstrapTable('destroy');
$('#bootstrap-table').bootstrapTable({
data: json,
striped: true,
cache: false,
pageNumber: 1,
pagination: true,
showColumns: true,
sidePagination: 'client',
pageSize: 10,
pageList: [5, 10, 15, 20, 25, 50],
showRefresh: true,
columns: columnsArray
}); });
}
columnsArray.push();
},
error: function () {
alert("错误");
} }
}) }
}
columnsArray.push({
const getparamsFunction = function (sensorTypeId) { field: "collectTime",
var returnData; title: "采集时间",
let formData = new FormData(); width: 160,
formData.append("sensorTypeId", sensorTypeId); height: 60,
$.ajax({ colspan: 1,
type: "post", rowspan: 1,
url: "/base/sysParamConfig/getParameterNotVisibleFlag", align: "center",
data: formData, formatter: function (value, row, index) {
contentType: "application/json;charset=utf-8", return value.replace("T", " ");
dataType: "json",
json: 'callback',
processData: false,
contentType: false,
async: false,
success: function (json) {
returnData = json;
},
error: function () {
alert("错误");
} }
});
}
$('#bootstrap-table').bootstrapTable('destroy');
$('#bootstrap-table').bootstrapTable({
data: json,
striped: true,
cache: false,
pageNumber: 1,
pagination: true,
showColumns: true,
sidePagination: 'client',
pageSize: 10,
pageList: [5, 10, 15, 20, 25, 50],
showRefresh: true,
columns: columnsArray
}); });
return returnData;
}
// 自定义按钮导出数据
function exportData(){
$('#bootstrap-table').tableExport({
type: 'excel',
exportDataType: "basic",
fileName: '历史数据报表',//下载文件名称
});
}
<!-- laydate示例 --> columnsArray.push();
layui.use('laydate', function () { },
var laydate = layui.laydate; error: function () {
alert("错误");
}
})
}
const getparamsFunction = function (sensorTypeId) {
var returnData;
let formData = new FormData();
formData.append("sensorTypeId", sensorTypeId);
$.ajax({
type: "post",
url: "/base/sysParamConfig/getParameterNotVisibleFlag",
data: formData,
contentType: "application/json;charset=utf-8",
dataType: "json",
json: 'callback',
processData: false,
contentType: false,
async: false,
success: function (json) {
returnData = json;
},
error: function () {
alert("错误");
}
});
return returnData;
}
// 自定义按钮导出数据
function exportData() {
$('#bootstrap-table').tableExport({
type: 'excel',
exportDataType: "basic",
fileName: '历史数据报表',//下载文件名称
});
}
laydate.render({ <!-- laydate示例 -->
elem: '#startTime', layui.use('laydate', function () {
type: 'datetime', var laydate = layui.laydate;
trigger: 'click'
});
laydate.render({ laydate.render({
elem: '#endTime', elem: '#startTime',
type: 'datetime', type: 'datetime',
trigger: 'click' trigger: 'click'
}); });
laydate.render({
elem: '#endTime',
type: 'datetime',
trigger: 'click'
}); });
});
</script> </script>
</body> </body>
</html> </html>

@ -405,4 +405,4 @@
}); });
</script> </script>
</body> </body>
</html> </html>

Loading…
Cancel
Save