Commit 380e87e7 authored by 朱超's avatar 朱超

明日预测更新

parent 43e22457
...@@ -21,6 +21,13 @@ export const postPrintHeatForecast = params => { ...@@ -21,6 +21,13 @@ export const postPrintHeatForecast = params => {
}) })
} }
//明日预测报表(保存打印记录)
export const postSaveHeatForecast = params => {
return http.post(`/api/analysis/report/SaveHeatForecast`, params).then(res => res).catch(function (error) {
console.log(error);
})
}
//换热站能耗报表 //换热站能耗报表
export const postTransferEnergy = params => { export const postTransferEnergy = params => {
return http.post(`/api/analysis/report/TransferEnergy`, params).then(res => res).catch(function (error) { return http.post(`/api/analysis/report/TransferEnergy`, params).then(res => res).catch(function (error) {
......
<template> <template>
<div class="contentBlock"> <div
class="contentBlock"
v-loading="loading"
element-loading-background="rgba(122, 122, 122, 0.6)"
>
<div class="contentBlockInn" id="printBlock"> <div class="contentBlockInn" id="printBlock">
<el-card class="card-contianer"> <el-card class="card-contianer">
<table <table
...@@ -461,9 +465,14 @@ import zhCn from "element-plus/dist/locale/zh-cn.mjs"; ...@@ -461,9 +465,14 @@ import zhCn from "element-plus/dist/locale/zh-cn.mjs";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { saveAs } from "file-saver"; import { saveAs } from "file-saver";
import XLSX from "xlsx-js-style"; import XLSX from "xlsx-js-style";
import { postHeatForecast, postPrintHeatForecast } from "../../api/report"; import {
postHeatForecast,
postPrintHeatForecast,
postSaveHeatForecast,
} from "../../api/report";
import print from "vue3-print-nb"; import print from "vue3-print-nb";
import { htmlPdf } from "../../utils/toPDF"; import { htmlPdf } from "../../utils/toPDF";
const loading = ref(false);
const temp = ref([]); //24小时室外预测值 const temp = ref([]); //24小时室外预测值
const weather = ref([]); //当日气象信息 const weather = ref([]); //当日气象信息
const predTemp = ref([]); //24小时室外体感预测值 const predTemp = ref([]); //24小时室外体感预测值
...@@ -480,7 +489,9 @@ const printObj = { ...@@ -480,7 +489,9 @@ const printObj = {
popTitle: "明日预测报表", popTitle: "明日预测报表",
extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>', extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
zIndex: 20002, zIndex: 20002,
openCallback: openCallback,
}; };
const handleExport = (name) => { const handleExport = (name) => {
printHidden.value = false; printHidden.value = false;
setTimeout(function () { setTimeout(function () {
...@@ -491,6 +502,9 @@ const handleExport = (name) => { ...@@ -491,6 +502,9 @@ const handleExport = (name) => {
printHidden.value = true; printHidden.value = true;
}, 100); }, 100);
}; };
function openCallback() {
postSaveHeatForecastFun();
}
function exportTableToExcel() { function exportTableToExcel() {
const workbook = XLSX.utils.book_new(); const workbook = XLSX.utils.book_new();
var ws = XLSX.utils.table_to_sheet(document.getElementById("exlBlock")); var ws = XLSX.utils.table_to_sheet(document.getElementById("exlBlock"));
...@@ -641,49 +655,11 @@ function exportTableToExcel() { ...@@ -641,49 +655,11 @@ function exportTableToExcel() {
ElMessage.success("导出成功!请稍后。。。"); ElMessage.success("导出成功!请稍后。。。");
} }
function timeFun() { function timeFun() {
var date = new Date(); const today = new Date();
var year = date.getFullYear(); const prehour = new Date(today.getTime() - 60 * 60 * 1000);
var dateArr = [ today.setDate(today.getDate());
date.getMonth() + 1, enertyInfo.queryTime =
date.getDate(), today.toISOString().split("T")[0] + " " + prehour.getHours() + ":00:00";
date.getHours(),
date.getMinutes(),
date.getSeconds(),
];
var endTimeHour = parseInt(dateArr[2] - 1);
if (endTimeHour < 10) {
endTimeHour = "0" + endTimeHour;
}
if (dateArr[0] < 10) {
dateArr[0] = "0" + dateArr[0];
}
if (dateArr[1] < 10) {
dateArr[1] = "0" + dateArr[1];
}
if (dateArr[2] < 10) {
dateArr[2] = "0" + dateArr[2];
}
if (dateArr[3] < 10) {
dateArr[3] = "0" + dateArr[3];
}
if (dateArr[4] < 10) {
dateArr[4] = "0" + dateArr[4];
}
let endTimes =
year + "-" + dateArr[0] + "-" + dateArr[1] + " " + endTimeHour + ":00:00";
// enertyInfo.printTime =
// year +
// "-" +
// dateArr[0] +
// "-" +
// dateArr[1] +
// " " +
// dateArr[2] +
// ":" +
// dateArr[3] +
// ":" +
// dateArr[4];
enertyInfo.queryTime = endTimes;
} }
function postHeatForecastFun() { function postHeatForecastFun() {
...@@ -691,6 +667,7 @@ function postHeatForecastFun() { ...@@ -691,6 +667,7 @@ function postHeatForecastFun() {
ElMessage.error("请选择记录时间"); ElMessage.error("请选择记录时间");
return false; return false;
} }
loading.value = true;
let params = { let params = {
QueryTime: enertyInfo.queryTime, QueryTime: enertyInfo.queryTime,
}; };
...@@ -704,6 +681,7 @@ function postHeatForecastFun() { ...@@ -704,6 +681,7 @@ function postHeatForecastFun() {
} else { } else {
ElMessage.error(res.message); ElMessage.error(res.message);
} }
loading.value = false;
}); });
} }
...@@ -712,6 +690,7 @@ function postPrintHeatForecastFun() { ...@@ -712,6 +690,7 @@ function postPrintHeatForecastFun() {
ElMessage.error("请选择打印时间"); ElMessage.error("请选择打印时间");
return false; return false;
} }
loading.value = true;
let params = { let params = {
QueryTime: enertyInfo.printTime, QueryTime: enertyInfo.printTime,
}; };
...@@ -725,11 +704,44 @@ function postPrintHeatForecastFun() { ...@@ -725,11 +704,44 @@ function postPrintHeatForecastFun() {
} else { } else {
ElMessage.error(res.message); ElMessage.error(res.message);
} }
loading.value = false;
}); });
} }
function postSaveHeatForecastFun() {
let params = {
Temp: temp.value,
Weather: weather.value,
PredTemp: "",
List: dataList.value,
Time: dataTime.value,
};
postSaveHeatForecast(params).then((res) => {
if (res.success === true) {
ElMessage.success("打印记录保存成功");
} else {
ElMessage.error("打印记录保存失败");
}
});
}
onMounted(() => { onMounted(() => {
timeFun(); timeFun();
postHeatForecastFun(); postHeatForecastFun();
// 创建定时任务
let timeOff = true;
setInterval(() => {
const time = new Date();
let minutes = time.getMinutes().toString().padStart(2, "0");
if (minutes == 15) {
if (timeOff) {
timeOff = false;
postHeatForecastFun();
}
} else {
timeOff = true;
}
}, 1000);
}); });
onUnmounted(() => {}); onUnmounted(() => {});
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment