diff --git a/src/views/plan/EquipmentStatus.vue b/src/views/plan/EquipmentStatus.vue
index c19deaa..b5012d3 100644
--- a/src/views/plan/EquipmentStatus.vue
+++ b/src/views/plan/EquipmentStatus.vue
@@ -116,11 +116,13 @@
@@ -408,7 +410,7 @@ const selectedEquipmentCode = ref('');
// 历史数据相关状态
const historyDataLoading = ref(false);
const historyData = ref([]);
-const selectedTimeRange = ref('近1天');
+const selectedTimeRange = ref('近1周');
const activeChartTab = ref('totalNumber');
const hasHistoryData = ref(false);
@@ -424,30 +426,25 @@ let totalGrossWeightChart = null;
// 显示轴详情对话框
const showAxleDetails = (record, equipmentCode) => {
- console.log('显示轴详情对话框, record:', record);
selectedAxle.value = { ...record };
selectedEquipmentCode.value = equipmentCode;
dialogVisible.value = true;
// 如果轴在运行且有规格和线盘信息,则获取历史数据
if (record.update_time && record.specification && record.wire_disc) {
- console.log('获取历史数据, model:', record.model, 'specification:', record.specification, 'wire_disc:', record.wire_disc);
fetchHistoryData(record.model, record.specification, record.wire_disc);
} else {
- console.log('不获取历史数据, update_time:', record.update_time, 'specification:', record.specification, 'wire_disc:', record.wire_disc);
hasHistoryData.value = false;
}
// 在对话框显示后初始化图表
nextTick(() => {
- console.log('初始化图表');
initCharts();
});
};
// 关闭对话框
const handleClose = () => {
- console.log('关闭对话框');
dialogVisible.value = false;
// 销毁图表实例
if (totalNumberChart) {
@@ -466,18 +463,15 @@ const handleClose = () => {
// 监听对话框打开状态
watch(dialogVisible, (newValue) => {
- console.log('对话框状态变化:', newValue);
if (newValue) {
// 对话框打开后,确保图表容器已渲染
setTimeout(() => {
- console.log('对话框打开,延迟初始化图表');
initCharts();
// 如果已有历史数据,则更新图表
if (hasHistoryData.value && historyData.value.length > 0) {
// 再次延迟以确保图表容器完全初始化
setTimeout(() => {
- console.log('对话框打开,延迟更新图表');
updateCharts();
}, 300);
}
@@ -487,7 +481,6 @@ watch(dialogVisible, (newValue) => {
// 时间范围改变时获取新的历史数据
const onTimeRangeChange = () => {
- console.log('时间范围改变, 新范围:', selectedTimeRange.value);
if (selectedAxle.value && selectedAxle.value.update_time &&
selectedAxle.value.specification && selectedAxle.value.wire_disc) {
fetchHistoryData(
@@ -500,33 +493,25 @@ const onTimeRangeChange = () => {
// 选项卡切换处理函数
const handleTabClick = (tab) => {
- console.log('选项卡切换, 当前选项卡:', tab.props.name);
-
// 使用setTimeout确保DOM完全渲染后再操作图表
setTimeout(() => {
if (tab.props.name === 'totalNumber' && !totalNumberChart && totalNumberChartRef.value) {
- console.log('选项卡切换时初始化总箱数图表');
totalNumberChart = echarts.init(totalNumberChartRef.value);
updateCharts();
} else if (tab.props.name === 'totalNetWeight' && !totalNetWeightChart && totalNetWeightChartRef.value) {
- console.log('选项卡切换时初始化总净重图表');
totalNetWeightChart = echarts.init(totalNetWeightChartRef.value);
updateCharts();
} else if (tab.props.name === 'totalGrossWeight' && !totalGrossWeightChart && totalGrossWeightChartRef.value) {
- console.log('选项卡切换时初始化总毛重图表');
totalGrossWeightChart = echarts.init(totalGrossWeightChartRef.value);
updateCharts();
}
// 强制图表重新渲染
if (tab.props.name === 'totalNumber' && totalNumberChart) {
- console.log('重新渲染总箱数图表');
totalNumberChart.resize();
} else if (tab.props.name === 'totalNetWeight' && totalNetWeightChart) {
- console.log('重新渲染总净重图表');
totalNetWeightChart.resize();
} else if (tab.props.name === 'totalGrossWeight' && totalGrossWeightChart) {
- console.log('重新渲染总毛重图表');
totalGrossWeightChart.resize();
}
}, 100);
@@ -534,45 +519,33 @@ const handleTabClick = (tab) => {
// 获取历史数据
const fetchHistoryData = (model, specification, wireDisc) => {
- console.log('开始获取历史数据, model:', model, 'specification:', specification, 'wireDisc:', wireDisc);
historyDataLoading.value = true;
// 获取日期范围
const dateRange = getDateRangeByTimeRange(selectedTimeRange.value);
- console.log('日期范围:', dateRange);
// 构建API URL
let apiUrl = `${API_CONFIG.BASE_URL}/api/plan/wms/history?model=${model}&specification=${specification}&wire_disc=${wireDisc}&start_date=${dateRange.start_date}&end_date=${dateRange.end_date}`;
- console.log('API URL:', apiUrl);
fetch(apiUrl)
- .then(response => {
- console.log('API响应状态:', response.status);
- return response.json();
- })
+ .then(response => response.json())
.then(data => {
- console.log('API响应数据:', data);
if (data.code === 200 && data.data && data.data.records) {
historyData.value = data.data.records;
hasHistoryData.value = historyData.value.length > 0;
- console.log('历史数据获取成功, 记录数:', historyData.value.length);
if (hasHistoryData.value) {
- console.log('准备更新图表');
// 使用setTimeout确保DOM完全渲染后再初始化图表
setTimeout(() => {
- console.log('延迟初始化图表');
initCharts();
// 再次延迟以确保图表容器完全初始化
setTimeout(() => {
- console.log('延迟更新图表');
updateCharts();
}, 300);
}, 300);
}
} else {
- console.log('历史数据格式不正确或无记录');
historyData.value = [];
hasHistoryData.value = false;
}
@@ -589,11 +562,6 @@ const fetchHistoryData = (model, specification, wireDisc) => {
// 初始化图表
const initCharts = () => {
- console.log('初始化图表开始');
- console.log('totalNumberChartRef.value:', totalNumberChartRef.value);
- console.log('totalNetWeightChartRef.value:', totalNetWeightChartRef.value);
- console.log('totalGrossWeightChartRef.value:', totalGrossWeightChartRef.value);
-
// 销毁已有图表实例
if (totalNumberChart) {
totalNumberChart.dispose();
@@ -610,34 +578,21 @@ const initCharts = () => {
// 初始化新图表实例
if (totalNumberChartRef.value) {
- console.log('初始化总箱数图表');
totalNumberChart = echarts.init(totalNumberChartRef.value);
- } else {
- console.error('totalNumberChartRef.value不存在');
}
if (totalNetWeightChartRef.value) {
- console.log('初始化总净重图表');
totalNetWeightChart = echarts.init(totalNetWeightChartRef.value);
- } else {
- console.error('totalNetWeightChartRef.value不存在');
}
if (totalGrossWeightChartRef.value) {
- console.log('初始化总毛重图表');
totalGrossWeightChart = echarts.init(totalGrossWeightChartRef.value);
- } else {
- console.error('totalGrossWeightChartRef.value不存在');
}
-
- console.log('初始化图表结束, totalNumberChart:', totalNumberChart, 'totalNetWeightChart:', totalNetWeightChart, 'totalGrossWeightChart:', totalGrossWeightChart);
};
// 更新图表数据
const updateCharts = () => {
- console.log('更新图表开始, historyData.value:', historyData.value);
if (!historyData.value || historyData.value.length === 0) {
- console.log('无历史数据,不更新图表');
return;
}
@@ -651,34 +606,21 @@ const updateCharts = () => {
const totalNetWeightData = historyData.value.map(item => item.total_net_weight);
const totalGrossWeightData = historyData.value.map(item => item.total_gross_weight);
- console.log('准备好的数据:', {
- timeData,
- totalNumberData,
- totalNetWeightData,
- totalGrossWeightData
- });
-
// 确保图表容器已经渲染完成
nextTick(() => {
- console.log('在nextTick中更新图表');
-
// 初始化或重新初始化图表实例
if (!totalNumberChart && totalNumberChartRef.value) {
- console.log('重新初始化总箱数图表');
totalNumberChart = echarts.init(totalNumberChartRef.value);
}
if (!totalNetWeightChart && totalNetWeightChartRef.value) {
- console.log('重新初始化总净重图表');
totalNetWeightChart = echarts.init(totalNetWeightChartRef.value);
}
if (!totalGrossWeightChart && totalGrossWeightChartRef.value) {
- console.log('重新初始化总毛重图表');
totalGrossWeightChart = echarts.init(totalGrossWeightChartRef.value);
}
// 更新总箱数图表
if (totalNumberChart) {
- console.log('更新总箱数图表');
const totalNumberOption = {
title: {
text: '总箱数变化趋势',
@@ -719,15 +661,11 @@ const updateCharts = () => {
}
}]
};
- console.log('设置总箱数图表选项');
totalNumberChart.setOption(totalNumberOption, true); // true表示不合并选项
- } else {
- console.error('总箱数图表实例不存在');
}
// 更新总净重图表
if (totalNetWeightChart) {
- console.log('更新总净重图表');
const totalNetWeightOption = {
title: {
text: '总净重变化趋势',
@@ -773,15 +711,11 @@ const updateCharts = () => {
}
}]
};
- console.log('设置总净重图表选项');
totalNetWeightChart.setOption(totalNetWeightOption, true); // true表示不合并选项
- } else {
- console.error('总净重图表实例不存在');
}
// 更新总毛重图表
if (totalGrossWeightChart) {
- console.log('更新总毛重图表');
const totalGrossWeightOption = {
title: {
text: '总毛重变化趋势',
@@ -827,13 +761,8 @@ const updateCharts = () => {
}
}]
};
- console.log('设置总毛重图表选项');
totalGrossWeightChart.setOption(totalGrossWeightOption, true); // true表示不合并选项
- } else {
- console.error('总毛重图表实例不存在');
}
-
- console.log('图表更新完成');
});
};