修改时间选择

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

@ -158,11 +158,12 @@ const onSearchByCollectTime = function (obj) {
setTimeout(function () {
var storeId = document.getElementById('table');
var rowsLength = storeId.rows.length;
var key = obj.value;
var [startTime,endTime] = obj.value.split(' - ');
var searchCol = storeId.rows.item(0).cells.length-3;
for (var i = 1; i < rowsLength; i++) {
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 = '';
} else {
storeId.rows[i].style.display = 'none';

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

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