From 9573c661d293c30d27fd5906e4ca5a2a7f76e694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=82=E7=B3=96?= Date: Wed, 14 Jan 2026 14:40:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(wms/report):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E6=95=B0=E6=8D=AE=E6=8E=92=E5=BA=8F=E5=B9=B6?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=BC=BA=E5=88=B6=E6=98=BE=E7=A4=BAX?= =?UTF-8?q?=E8=BD=B4=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 对图表数据进行浅拷贝并按日期排序,确保数据展示顺序正确 - 移除强制显示所有X轴标签的配置,让图表自动处理标签显示 --- .../src/views/wms/receive/report/charts/bar.vue | 2 +- .../views/wms/receive/report/charts/line.vue | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/klp-ui/src/views/wms/receive/report/charts/bar.vue b/klp-ui/src/views/wms/receive/report/charts/bar.vue index 6afe2a02..dd2c858f 100644 --- a/klp-ui/src/views/wms/receive/report/charts/bar.vue +++ b/klp-ui/src/views/wms/receive/report/charts/bar.vue @@ -80,7 +80,7 @@ export default { { type: 'category', data: xAxisData, - axisLabel: { interval: 0 }, // 强制显示所有X轴标签,不隐藏 + // axisLabel: { interval: 0 }, // 强制显示所有X轴标签,不隐藏 axisTick: { show: false } // 隐藏X轴刻度线,美化 } ], diff --git a/klp-ui/src/views/wms/receive/report/charts/line.vue b/klp-ui/src/views/wms/receive/report/charts/line.vue index 48eb0997..560e3a5e 100644 --- a/klp-ui/src/views/wms/receive/report/charts/line.vue +++ b/klp-ui/src/views/wms/receive/report/charts/line.vue @@ -58,11 +58,14 @@ export default { // 初始化图表实例 this.chartInstance = echarts.init(chartDom) - // 从props接收的data中提取图表所需数据 - const xAxisData = this.data.map(item => item.productName) - const coilCountData = this.data.map(item => item.coilCount) - // 总重量是字符串格式,强制转数字,保证图表能正常渲染 - const totalWeightData = this.data.map(item => Number(item.totalWeight)) + // 1. 浅拷贝原数组 + 按planDate日期升序排序,生成新数组,不修改原this.data + const sortedData = [...this.data].sort((a, b) => new Date(a.planDate) - new Date(b.planDate)) + + // 2. 从排序后的新数组中,提取图表所需数据 + const xAxisData = sortedData.map(item => item.productName) + const coilCountData = sortedData.map(item => item.coilCount) + // 总重量字符串转数字,保证图表渲染正常 + const totalWeightData = sortedData.map(item => Number(item.totalWeight)) // echarts核心配置项 - 双Y轴折线图 const option = { @@ -85,7 +88,7 @@ export default { type: 'category', data: xAxisData, axisLabel: { - interval: 0, // 强制显示所有X轴标签,不隐藏 + // interval: 0, // 强制显示所有X轴标签,不隐藏 fontSize: 12 } } @@ -131,7 +134,7 @@ export default { symbolSize: 6, lineStyle: { width: 2, color: '#ff6600' }, itemStyle: { color: '#ff6600' } - } + }, ] } // 设置配置项并渲染图表