fix: 修改刷新逻辑
parent
cdd54168f6
commit
aaaf1808ce
|
|
@ -40,9 +40,11 @@
|
|||
function debounce(fn, delay) {
|
||||
let time = null;
|
||||
return function () {
|
||||
let _this = this;
|
||||
let args = arguments;
|
||||
if (time !== null) clearTimeout(time);
|
||||
time = setTimeout(function () {
|
||||
fn.call(this);
|
||||
fn.apply(_this, args);
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -455,12 +455,12 @@
|
|||
|
||||
function searchDeviceInfo(dataParam, callBack) {
|
||||
postAjax(localUrl + "/page/node/sensor/list.json", dataParam, function (data) {
|
||||
$(".sceneList-info").empty();
|
||||
if (isOK(data)) {
|
||||
var dataObj = data.data;
|
||||
if (callBack) {
|
||||
callBack(dataObj)
|
||||
} else {
|
||||
$(".sceneList-info").empty();
|
||||
for (var i = 0; i < dataObj.length; i++) {
|
||||
const contentHTML = $("#template0").html().format(
|
||||
dataObj[i].name,
|
||||
|
|
@ -522,7 +522,6 @@
|
|||
getDisInfo(dataT[i]));
|
||||
} else if (dataT[i].iot_sensor_type == 90) {
|
||||
// gps定位数据
|
||||
|
||||
str += $("#template6").html().format(disvalue(dataT[i].name, 9),
|
||||
dataT[i].iot_sensor_status,
|
||||
timeStamp2String(dataT[i].mtime, 'yyyy/MM/dd hh:mm:ss'),
|
||||
|
|
@ -652,6 +651,23 @@
|
|||
//客户端
|
||||
var client;
|
||||
|
||||
var sensorChangeFn = debounce(function (params) {
|
||||
searchDeviceInfo(params, function (result) {
|
||||
let deviceHTML = '';
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
deviceHTML = getSensorListHtml(result[i].iotSensorList, params.scene_id, result[i].iot_node_status);
|
||||
}
|
||||
if (deviceHTML.length > 0) {
|
||||
const sensorDOM = $(".sceneList-info .sensor_info_container div[id=sensor" + params.sensor_id + "]").parent();
|
||||
sensorDOM.hide();
|
||||
sensorDOM.after(deviceHTML);
|
||||
// sensorDOM.next().css('border','2px red solid')
|
||||
sensorDOM.remove();
|
||||
}
|
||||
})
|
||||
}, 1000)
|
||||
|
||||
|
||||
function mqttInit() {
|
||||
// 连接选项
|
||||
const options = {
|
||||
|
|
@ -684,31 +700,18 @@
|
|||
reportFlag = '0'
|
||||
}
|
||||
if (reportFlag == '0') {
|
||||
if (lastTime + 3 * 1000 < new Date().getTime()) {
|
||||
if (lastTime + 60 * 5 * 1000 < new Date().getTime()) {
|
||||
reflash(sceneId);
|
||||
lastTime = new Date().getTime();
|
||||
}
|
||||
} else if (reportFlag == '1' && sensorID != null && sensorID != '') {
|
||||
debounce(function () {
|
||||
searchDeviceInfo({
|
||||
scene_id: sceneId,
|
||||
node_data_type: 0,
|
||||
device_code: device_code,
|
||||
sensor_id: sensorID,
|
||||
limit: 1
|
||||
}, function (result) {
|
||||
let deviceHTML = '';
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
deviceHTML = getSensorListHtml(result[i].iotSensorList, sceneId, result[i].iot_node_status);
|
||||
}
|
||||
if (deviceHTML.length > 0) {
|
||||
const sensorDOM = $(".sceneList-info .sensor_info_container div[id=sensor" + sensorID + "]").parent();
|
||||
sensorDOM.hide();
|
||||
sensorDOM.after(deviceHTML);
|
||||
sensorDOM.remove();
|
||||
}
|
||||
})
|
||||
}, 2000)
|
||||
sensorChangeFn({
|
||||
scene_id: sceneId,
|
||||
node_data_type: 0,
|
||||
device_code: device_code,
|
||||
sensor_id: sensorID,
|
||||
limit: 1
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue