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,11 +53,13 @@ function initEcharts() {
const url = commonUrl + "screen/largeScreen/environment/getEnvironmentList?currentDay=" + currentDay + "&hour=" + hour + "&proId=" + bidCode; const url = commonUrl + "screen/largeScreen/environment/getEnvironmentList?currentDay=" + currentDay + "&hour=" + hour + "&proId=" + bidCode;
ajaxRequest(url, "get", null , true, function () { ajaxRequest(url, "get", null , true, function () {
}, function (result) { }, function (result) {
if (result.code === 200) { if (result.code === 200 && result.data) {
console.log(result.data);
initEchartsOne(result.data); initEchartsOne(result.data);
} else if (result.code === 500) { } else {
layer.msg(result.msg, { icon: 2 }); layer.msg('<span style="color:#00C6BE">暂无数据</span>', {
icon: 0
});
clearEchartsAndData();
} }
}, function (xhr) { }, function (xhr) {
layer.msg(xhr, { icon: 2 }); layer.msg(xhr, { icon: 2 });
@ -65,6 +67,35 @@ function initEcharts() {
} }
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() { // $(document).on('change', '#layuiDate', function() {
// initEcharts(); // initEcharts();
@ -83,9 +114,9 @@ function initEchartsOne(obj) {
const gisOption = getGisOption(obj); const gisOption = getGisOption(obj);
const spaceOption = getSpaceOption(obj); const spaceOption = getSpaceOption(obj);
const trendChart = echarts.init(document.getElementById('trendChart')); window.trendChart = echarts.init(document.getElementById('trendChart'));
const gisChart = echarts.init(document.getElementById('gisChart')); window.gisChart = echarts.init(document.getElementById('gisChart'));
const spaceChart = echarts.init(document.getElementById('spaceChart')); window.spaceChart = echarts.init(document.getElementById('spaceChart'));
const lineChartBtn = document.getElementById('lineChartBtn'); const lineChartBtn = document.getElementById('lineChartBtn');
const barChartBtn = document.getElementById('barChartBtn'); const barChartBtn = document.getElementById('barChartBtn');