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

明日预测更新

parent 43e22457
......@@ -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 => {
return http.post(`/api/analysis/report/TransferEnergy`, params).then(res => res).catch(function (error) {
......
<template>
<div class="contentBlock">
<div
class="contentBlock"
v-loading="loading"
element-loading-background="rgba(122, 122, 122, 0.6)"
>
<div class="contentBlockInn" id="printBlock">
<el-card class="card-contianer">
<table
......@@ -461,9 +465,14 @@ import zhCn from "element-plus/dist/locale/zh-cn.mjs";
import { ElMessage } from "element-plus";
import { saveAs } from "file-saver";
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 { htmlPdf } from "../../utils/toPDF";
const loading = ref(false);
const temp = ref([]); //24小时室外预测值
const weather = ref([]); //当日气象信息
const predTemp = ref([]); //24小时室外体感预测值
......@@ -480,7 +489,9 @@ const printObj = {
popTitle: "明日预测报表",
extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
zIndex: 20002,
openCallback: openCallback,
};
const handleExport = (name) => {
printHidden.value = false;
setTimeout(function () {
......@@ -491,6 +502,9 @@ const handleExport = (name) => {
printHidden.value = true;
}, 100);
};
function openCallback() {
postSaveHeatForecastFun();
}
function exportTableToExcel() {
const workbook = XLSX.utils.book_new();
var ws = XLSX.utils.table_to_sheet(document.getElementById("exlBlock"));
......@@ -641,49 +655,11 @@ function exportTableToExcel() {
ElMessage.success("导出成功!请稍后。。。");
}
function timeFun() {
var date = new Date();
var year = date.getFullYear();
var dateArr = [
date.getMonth() + 1,
date.getDate(),
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;
const today = new Date();
const prehour = new Date(today.getTime() - 60 * 60 * 1000);
today.setDate(today.getDate());
enertyInfo.queryTime =
today.toISOString().split("T")[0] + " " + prehour.getHours() + ":00:00";
}
function postHeatForecastFun() {
......@@ -691,6 +667,7 @@ function postHeatForecastFun() {
ElMessage.error("请选择记录时间");
return false;
}
loading.value = true;
let params = {
QueryTime: enertyInfo.queryTime,
};
......@@ -704,6 +681,7 @@ function postHeatForecastFun() {
} else {
ElMessage.error(res.message);
}
loading.value = false;
});
}
......@@ -712,6 +690,7 @@ function postPrintHeatForecastFun() {
ElMessage.error("请选择打印时间");
return false;
}
loading.value = true;
let params = {
QueryTime: enertyInfo.printTime,
};
......@@ -725,11 +704,44 @@ function postPrintHeatForecastFun() {
} else {
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(() => {
timeFun();
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(() => {});
</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