From 8b40f521b99ba9e5af7bb38587e4a4a4a0599193 Mon Sep 17 00:00:00 2001 From: houzhongjian <houzhongyi@126.com> Date: 星期四, 02 一月 2025 09:41:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/views/model/pre/item/MmPredictItemChart.vue | 148 +++++++++++++++++++++++++++++++++++-------------- 1 files changed, 106 insertions(+), 42 deletions(-) diff --git a/src/views/model/pre/item/MmPredictItemChart.vue b/src/views/model/pre/item/MmPredictItemChart.vue index 215c854..14afaed 100644 --- a/src/views/model/pre/item/MmPredictItemChart.vue +++ b/src/views/model/pre/item/MmPredictItemChart.vue @@ -1,6 +1,6 @@ <template> <el-dialog - title="采集值" + title="预测数据" :close-on-click-modal="false" width="50%" v-model="visible" @@ -39,47 +39,50 @@ plain @click="handleExport" :loading="exportLoading" - v-hasPermi="['data:point:export']" > - <Icon icon="ep:download" />导出 + <Icon icon="ep:download"/> + 导出 </el-button> </el-form-item> </el-form> - <div ref="chartDom" class="result-chart"></div> + <div ref="chartDomPre" class="result-chart"></div> </el-dialog> </template> <script lang="ts" setup> import {ref} from 'vue'; import * as echarts from 'echarts'; -import * as DaPoint from '@/api/data/da/point/daPointChart' +import * as McsApi from '@/api/model/mcs' import {getYMDHM0} from "@/utils/dateUtil" import download from "@/utils/download"; + const message = useMessage() // 消息弹窗 const visible = ref(false); -const chartDom = ref(null); -let myChart = null; +const chartDomPre = ref(); +let myChart = undefined; const chartParams = reactive({ - codes:[], - startDate : undefined, - endDate: undefined, + itemId: undefined, + startTime: undefined, + endTime: undefined, }) const dataForm = ref({ id: "", - pointNo: "", - pointName: "", - pointTypeName: "", + itemName: "", startTime: getYMDHM0(new Date() - 60 * 60 * 1000), - endTime: "", + endTime: getYMDHM0(new Date() + 60 * 60 * 1000), }); /** 打开弹窗 */ const open = async (row: object) => { visible.value = true + resetForm() dataForm.value.id = row.id; - dataForm.value.pointNo = row.pointNo; - dataForm.value.pointName = row.pointName; - getDataList(); + dataForm.value.itemName = row.itemname; + if (row.id) { + myChart = echarts.init(chartDomPre.value); + myChart.clear() + getDataList(); + } } defineExpose({open}) // 提供 open 方法,用于打开弹窗 @@ -88,31 +91,80 @@ visible.value = true; if (dataForm.value.id) { try { - chartParams.codes=[dataForm.value.pointNo]; - chartParams.startDate = dataForm.value.startTime; - chartParams.endDate = dataForm.value.endTime; - const data = await DaPoint.getPointDaChart(chartParams) + chartParams.itemId = dataForm.value.id; + chartParams.startTime = dataForm.value.startTime; + 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 + ":" + '预测值') + }) + } + let seriesData = [] - data.series.forEach(item => { + if (data.predictTime) { seriesData.push({ - name: item.name, - type: "line", - data: item.data, - showSymbol: true, - smooth: false, - lineStyle: { - normal: { - color: "#5B8FF9", - width: 1, + name: '', + data: [null], + type: 'line', + smooth: true, + color: 'green', + markLine: { + silent: true, + lineStyle: { + color: '#32a487', + width: 2 }, + data: [{ + xAxis: data.predictTime + }], + label: { + normal: { + formatter: data.predictTime + } + }, + symbol: ['circle', 'none'], }, }); - }) + } - myChart = echarts.init(chartDom.value); + if (data.viewMap) { + Object.keys(data.viewMap).forEach(key => { + let viewData = data.viewMap[key] + if(viewData.realData) { + seriesData.push({ + name: key + ":" + '真实值', + type: "line", + data: viewData.realData, + showSymbol: false, + smooth: false, + lineStyle: { + normal: { + width: 1, + }, + }, + }) + } + seriesData.push({ + name: key + ":" + '预测值', + type: "line", + data: viewData.preDataN, + showSymbol: false, + smooth: false, + lineStyle: { + normal: { + width: 1, + }, + }, + }) + }) + } + const option = { title: { - text: dataForm.value.pointName, + text: dataForm.value.itemName, top: 0, left: "1%", textStyle: { @@ -131,11 +183,12 @@ }, }, legend: { - show: false, - top: 10, + show: true, + top: 20, + data: legendData }, grid: { - top: 30, + top: "20%", left: "3%", right: "5%", bottom: 10, @@ -162,24 +215,35 @@ } } } + /** 导出按钮操作 */ const exportLoading = ref(false) const handleExport = async () => { - chartParams.codes=[dataForm.value.pointNo]; - chartParams.startDate = dataForm.value.startTime; - chartParams.endDate = dataForm.value.endTime; + chartParams.itemId = dataForm.value.id; + chartParams.startTime = dataForm.value.startTime?dataForm.value.startTime:""; + chartParams.endTime = dataForm.value.endTime?dataForm.value.endTime:""; try { // 导出的二次确认 await message.exportConfirm() // 发起导出 exportLoading.value = true - const data = await DaPoint.exportDaPointValue(chartParams) - download.excel(data, dataForm.value.pointName +'.xls') + const data = await McsApi.exportPredictValue(chartParams) + download.excel(data, dataForm.value.itemName + '.xls') } catch { } finally { exportLoading.value = false } } + +/** 重置表单 */ +const resetForm = () => { + dataForm.value = { + id: undefined, + itemName: undefined, + startTime: undefined, + endTime: undefined + } +} </script> <style> .el-select { -- Gitblit v1.9.3