| | |
| | | <template> |
| | | <el-dialog |
| | | title="采集值" |
| | | title="预测数据" |
| | | :close-on-click-modal="false" |
| | | width="50%" |
| | | v-model="visible" |
| | |
| | | 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) { |
| | | getDataList(); |
| | | } |
| | | } |
| | | |
| | | defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
| | |
| | | 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, |
| | | }, |
| | | }, |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | myChart = echarts.init(chartDomPre.value); |
| | | const option = { |
| | | title: { |
| | | text: dataForm.value.pointName, |
| | | text: dataForm.value.itemName, |
| | | top: 0, |
| | | left: "1%", |
| | | textStyle: { |
| | |
| | | }, |
| | | }, |
| | | legend: { |
| | | show: false, |
| | | top: 10, |
| | | show: true, |
| | | top: 20, |
| | | data: legendData |
| | | }, |
| | | grid: { |
| | | top: 30, |
| | | top: "20%", |
| | | left: "3%", |
| | | right: "5%", |
| | | bottom: 10, |
| | |
| | | ], |
| | | series: seriesData, |
| | | }; |
| | | myChart.clear() |
| | | myChart.setOption(option); |
| | | } catch (error) { |
| | | console.error(error) |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** 导出按钮操作 */ |
| | | 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 { |