From 0ee5fb34623360eb8b43a8a032023890de1401d8 Mon Sep 17 00:00:00 2001
From: dubin <bindu_bean@163.com>
Date: 星期四, 20 十一月 2025 17:40:28 +0800
Subject: [PATCH] #1
---
src/main/webapp/static/js/basSensor/basSensor.js | 117 ++++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 97 insertions(+), 20 deletions(-)
diff --git a/src/main/webapp/static/js/basSensor/basSensor.js b/src/main/webapp/static/js/basSensor/basSensor.js
index d4501d1..e4701c7 100644
--- a/src/main/webapp/static/js/basSensor/basSensor.js
+++ b/src/main/webapp/static/js/basSensor/basSensor.js
@@ -9,8 +9,82 @@
var form = layui.form;
var admin = layui.admin;
+ // 棰滆壊鍒ゆ柇鍑芥暟
+ function applyColorStyles() {
+ // 浣跨敤鏇寸簿纭殑閫夋嫨鍣�
+ $('.layui-table-box .layui-table-body table tbody tr').each(function() {
+ var $tr = $(this);
+ // 璺宠繃琛ㄥご琛�
+ if ($tr.hasClass('layui-table-header') || $tr.find('td').length === 0) return;
+
+ var $tempCell = $tr.find('td').eq(3); // 绗�3鍒楋細娓╁害
+ var $humiCell = $tr.find('td').eq(4); // 绗�4鍒楋細婀垮害
+
+ if ($tempCell.length && $humiCell.length) {
+ var tempText = $tempCell.text().trim();
+ var humiText = $humiCell.text().trim();
+
+// console.log('娓╁害:', tempText, '婀垮害:', humiText); // 璋冭瘯鐢�
+
+ // 閲嶇疆鏍峰紡
+ $tempCell.css({
+ 'background-color': '',
+ 'color': '',
+ 'font-weight': ''
+ });
+ $humiCell.css({
+ 'background-color': '',
+ 'color': '',
+ 'font-weight': ''
+ });
+
+ // 娓╁害鍒ゆ柇
+ if (tempText) {
+ var temp = parseFloat(tempText);
+ if (!isNaN(temp)) {
+ if (temp > 25 || temp < 15) {
+ $tempCell.css({
+ 'background-color': 'red',
+ 'color': 'white',
+ 'font-weight': 'bold'
+ });
+// console.log('娓╁害瓒呭嚭鑼冨洿:', temp); // 璋冭瘯鐢�
+ }else {
+ $tempCell.css({
+ 'background-color': 'green',
+ 'color': 'white',
+ 'font-weight': 'bold'
+ });
+ }
+ }
+ }
+
+ // 婀垮害鍒ゆ柇
+ if (humiText) {
+ var humi = parseFloat(humiText);
+ if (!isNaN(humi)) {
+ if (humi > 60) {
+ $humiCell.css({
+ 'background-color': 'red',
+ 'color': 'white',
+ 'font-weight': 'bold'
+ });
+// console.log('婀垮害瓒呭嚭鑼冨洿:', humi); // 璋冭瘯鐢�
+ }else {
+ $humiCell.css({
+ 'background-color': 'green',
+ 'color': 'white',
+ 'font-weight': 'bold'
+ });
+ }
+ }
+ }
+ }
+ });
+ }
+
// 鏁版嵁娓叉煋
- var timer = setInterval(function () {
+ var timer = setInterval(function () {
tableIns = table.render({
elem: '#basSensor',
headers: {token: localStorage.getItem('token')},
@@ -27,9 +101,6 @@
,{field: 'location', align: 'center',title: '浼犳劅鍣ㄤ綅缃�'}
,{field: 'temperature', align: 'center',title: '浼犳劅鍣ㄦ俯搴�(掳c)'}
,{field: 'humidity', align: 'center',title: '浼犳劅鍣ㄦ箍搴�(%)'}
- // ,{field: 'createTime', align: 'center',title: '鍒涘缓鏃堕棿'}
-
- // ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:120}
]],
request: {
pageName: 'curr',
@@ -52,10 +123,16 @@
}
pageCurr=curr;
limit();
+
+ // 搴旂敤棰滆壊鏍峰紡 - 浣跨敤澶氫釜setTimeout纭繚DOM瀹屽叏娓叉煋
+ setTimeout(function() {
+ setTimeout(function() {
+ applyColorStyles();
+ }, 200);
+ }, 100);
}
});
- },1000);
-// clearInterval(timer);
+ },3000);
// 鐩戝惉鎺掑簭浜嬩欢
table.on('sort(basSensor)', function (obj) {
@@ -79,14 +156,14 @@
showEditModel();
break;
case 'deleteData':
- if (checkStatus.length === 0) {
- layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁', {icon: 2});
- return;
- }
- del(checkStatus.map(function (d) {
- return d.id;
- }));
- break;
+ if (checkStatus.length === 0) {
+ layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁', {icon: 2});
+ return;
+ }
+ del(checkStatus.map(function (d) {
+ return d.id;
+ }));
+ break;
case 'exportData':
admin.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){
var titles=[];
@@ -211,6 +288,8 @@
form.on('submit(search)', function (data) {
pageCurr = 1;
tableReload(false);
+ // 鎼滅储鍚庨噸鏂板簲鐢ㄦ牱寮�
+ setTimeout(applyColorStyles, 500);
});
// 閲嶇疆
@@ -218,6 +297,8 @@
pageCurr = 1;
clearFormVal($('#search-box'));
tableReload(false);
+ // 閲嶇疆鍚庨噸鏂板簲鐢ㄦ牱寮�
+ setTimeout(applyColorStyles, 500);
});
// 鏃堕棿閫夋嫨鍣�
@@ -228,7 +309,6 @@
,type: 'datetime'
,range: true
});
-
}, 300);
}
layDateRender();
@@ -248,10 +328,7 @@
tableIns.reload({
where: searchData,
page: {curr: pageCurr}
- });
+ });
}
-// let timer = setInterval(function () {
-// $(".layui-laypage-btn")[0].click();
-// },1000);
-clearInterval(timer);
+clearInterval(timer);
\ No newline at end of file
--
Gitblit v1.9.1