代码提交

This commit is contained in:
lixiaobang 2024-03-18 13:52:38 +08:00
parent 3a2e9f757b
commit 1921755332
2 changed files with 26 additions and 7 deletions

View File

@ -20,12 +20,12 @@ const dateValues = ref([
//
function energyCalendar() {
let date = moment(calendarDate.value).format("YYYY-MM");
let month = moment(calendarDate.value).format("MM")
let month = moment(calendarDate.value).format("MM");
getEnergyCalendar({ date })
.then((res) => {
if (res.code == 200) {
dateValues.value = res.data;
getDateValue(date,month)
getDateValue(date, month);
} else {
return false;
}
@ -34,15 +34,29 @@ function energyCalendar() {
console.log(err);
});
}
function getDateValue(date,month) {
let month1 = moment(calendarDate.value).format("MM")
function getDateValue(date, month) {
let month1 = moment(calendarDate.value).format("MM");
if (dateValues.value != undefined && month == month1) {
const foundDate = dateValues.value.find((item) => item.time === date);
if (foundDate) {
return foundDate ? foundDate.EH : "";
return foundDate ? formatNumber(Number(foundDate.EH)) : "";
}
}
}
//
function formatNumber(num) {
if (typeof num === "number" && !isNaN(num)) {
//
if (Number.isInteger(num)) {
return num; //
} else {
return Number.parseFloat(num).toFixed(2); //
}
} else {
throw new Error("Invalid input"); //
}
}
//
onMounted(() => {
energyCalendar();
});
@ -80,7 +94,12 @@ onMounted(() => {
<template #date-cell="{ data }">
<p class="day">{{ data.day.split("-").slice(1)[1] }}</p>
<p class="value">
{{ getDateValue(data.day.split("-").slice(1)[1],data.day.split("-").slice(1)[0])}}
{{
getDateValue(
data.day.split("-").slice(1)[1],
data.day.split("-").slice(1)[0]
)
}}
</p>
</template>
</el-calendar>

View File

@ -1026,7 +1026,7 @@ const energyIndexingInterface = () => {
});
};
//
const systemEnergyInterface = () => {
const systemEnergyInterface = () => {
let params = {
name: systemTabName.value,
};