From 932c3ab49ea4e911fb2c2531c29d6609ac5afefd Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期四, 02 一月 2025 10:51:37 +0800 Subject: [PATCH] itemchart bug修复。 页面优化 --- src/views/model/pre/item/MmPredictItemChart.vue | 28 ++++++++++++++++++---------- 1 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/views/model/pre/item/MmPredictItemChart.vue b/src/views/model/pre/item/MmPredictItemChart.vue index 14afaed..4d24c06 100644 --- a/src/views/model/pre/item/MmPredictItemChart.vue +++ b/src/views/model/pre/item/MmPredictItemChart.vue @@ -3,6 +3,7 @@ title="预测数据" :close-on-click-modal="false" width="50%" + @close="dialogClose" v-model="visible" > <el-form @@ -12,7 +13,6 @@ > <el-form-item label="开始时间"> <el-date-picker - size="mini" v-model="dataForm.startTime" format="YYYY-MM-DD HH:mm:00" value-format="YYYY-MM-DD HH:mm:00" @@ -22,7 +22,6 @@ </el-form-item> <el-form-item label="结束时间"> <el-date-picker - size="mini" v-model="dataForm.endTime" format="YYYY-MM-DD HH:mm:00" value-format="YYYY-MM-DD HH:mm:00" @@ -79,9 +78,16 @@ dataForm.value.id = row.id; dataForm.value.itemName = row.itemname; if (row.id) { - myChart = echarts.init(chartDomPre.value); - myChart.clear() + nextTick(() => { + myChart = echarts.init(chartDomPre.value); + }); getDataList(); + } +} + +const dialogClose = () => { + if (myChart) { + myChart.dispose(); // 组件卸载时销毁实例 } } @@ -96,12 +102,12 @@ chartParams.endTime = dataForm.value.endTime; const data = await McsApi.getPreDataItemChart(chartParams) let legendData = [] - if (data.legend && data.legend.length > 0) { - data.legend.forEach(item => { - legendData.push(item + ":" + '真实值') - legendData.push(item + ":" + '预测值') - }) - } + // if (data.legend && data.legend.length > 0) { + // data.legend.forEach(item => { + // legendData.push(item + ":" + '真实值') + // legendData.push(item + ":" + '预测值') + // }) + // } let seriesData = [] if (data.predictTime) { @@ -134,6 +140,7 @@ Object.keys(data.viewMap).forEach(key => { let viewData = data.viewMap[key] if(viewData.realData) { + legendData.push(key + ":" + '真实值') seriesData.push({ name: key + ":" + '真实值', type: "line", @@ -147,6 +154,7 @@ }, }) } + legendData.push(key + ":" + '预测值') seriesData.push({ name: key + ":" + '预测值', type: "line", -- Gitblit v1.9.3