This commit is contained in:
fl 2025-07-24 18:25:53 +08:00
parent b06473b0ea
commit 6632a03f50
1 changed files with 40 additions and 9 deletions

View File

@ -53,18 +53,49 @@ function initEcharts() {
const url = commonUrl + "screen/largeScreen/environment/getEnvironmentList?currentDay=" + currentDay + "&hour=" + hour + "&proId=" + bidCode;
ajaxRequest(url, "get", null , true, function () {
}, function (result) {
if (result.code === 200) {
console.log(result.data);
initEchartsOne(result.data);
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}
if (result.code === 200 && result.data) {
initEchartsOne(result.data);
} else {
layer.msg('<span style="color:#00C6BE">暂无数据</span>', {
icon: 0
});
clearEchartsAndData();
}
}, function (xhr) {
layer.msg(xhr, { icon: 2 });
});
}
function clearEchartsAndData() {
// 清空echarts实例
if (window.trendChart) {
window.trendChart.dispose();
window.trendChart = null;
}
if (window.gisChart) {
window.gisChart.dispose();
window.gisChart = null;
}
if (window.spaceChart) {
window.spaceChart.dispose();
window.spaceChart = null;
}
// 清空六大指标数据
$('#slopeDisplacementValue').text('--');
$('#slopeDisplacementStatus').text('--').removeClass().addClass('px-1.5 py-0.5 rounded-full text-xs bg-gray-200 text-gray-400');
$('#temperatureValue').text('--');
$('#temperatureStatus').text('--').removeClass().addClass('px-1.5 py-0.5 rounded-full text-xs bg-gray-200 text-gray-400');
$('#humidityValue').text('--');
$('#humidityStatus').text('--').removeClass().addClass('px-1.5 py-0.5 rounded-full text-xs bg-gray-200 text-gray-400');
$('#airQualityIndexValue').text('--');
$('#airQualityIndexStatus').text('--').removeClass().addClass('px-1.5 py-0.5 rounded-full text-xs bg-gray-200 text-gray-400');
$('#noiseLevelValue').text('--');
$('#noiseLevelStatus').text('--').removeClass().addClass('px-1.5 py-0.5 rounded-full text-xs bg-gray-200 text-gray-400');
$('#illuminationValue').text('--');
$('#illuminationStatus').text('--').removeClass().addClass('px-1.5 py-0.5 rounded-full text-xs bg-gray-200 text-gray-400');
}
// 监听日期和小时选择器变化,自动刷新数据
// $(document).on('change', '#layuiDate', function() {
// initEcharts();
@ -83,9 +114,9 @@ function initEchartsOne(obj) {
const gisOption = getGisOption(obj);
const spaceOption = getSpaceOption(obj);
const trendChart = echarts.init(document.getElementById('trendChart'));
const gisChart = echarts.init(document.getElementById('gisChart'));
const spaceChart = echarts.init(document.getElementById('spaceChart'));
window.trendChart = echarts.init(document.getElementById('trendChart'));
window.gisChart = echarts.init(document.getElementById('gisChart'));
window.spaceChart = echarts.init(document.getElementById('spaceChart'));
const lineChartBtn = document.getElementById('lineChartBtn');
const barChartBtn = document.getElementById('barChartBtn');