拿掉下載預覽、夏月時間區間修改

This commit is contained in:
huliang 2025-06-17 16:57:38 +08:00
parent 0616a0d783
commit 60985145f7
4 changed files with 144 additions and 79 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div v-loading="loading" element-loading-text="資料加載中..."> <div v-loading="loading" element-loading-text="資料加載中...">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="7"> <el-col :span="6">
<el-descriptions class="margin-top" title="報表資訊" :column="1" border> <el-descriptions class="margin-top" title="報表資訊" :column="1" border>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
@ -29,7 +29,7 @@
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</el-col> </el-col>
<el-col :span="11"> <el-col :span="13">
<el-descriptions <el-descriptions
class="margin-top" class="margin-top"
:title="priceTitle" :title="priceTitle"
@ -42,79 +42,115 @@
</template> </template>
{{ Three_Phase }} {{ Three_Phase }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item v-if="isSummerMonth">
<template #label>
<div class="cell-item">基本電費-經常契約</div>
</template>
{{ Regular_Contract_Summer }}
</el-descriptions-item>
<el-descriptions-item v-if="!isSummerMonth">
<template #label>
<div class="cell-item">基本電費-經常契約</div>
</template>
{{ Regular_Contract_Non_Summer }}
</el-descriptions-item>
<el-descriptions-item v-if="isSummerMonth">
<template #label>
<div class="cell-item">流動電價-平日尖峰單價</div>
</template>
{{ Summer_Peak_Prices }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">流動電價-平日半尖峰單價</div>
</template>
{{
isSummerMonth
? Summer_HalfPeak_Prices_Weekday
: Non_Summer_HalfPeak_Prices_Weekday
}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">流動電價-平日離峰單價</div>
</template>
{{
isSummerMonth
? Summer_Off_Prices_Weekday
: Non_Summer_Off_Prices_Weekday
}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">流動電價-週六半尖峰單價</div>
</template>
{{
isSummerMonth
? Summer_HalfPeak_Prices_Saturday
: Non_Summer_HalfPeak_Prices_Saturday
}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">流動電價-週六離峰單價</div>
</template>
{{
isSummerMonth
? Summer_Off_Prices_Saturday
: Non_Summer_Off_Prices_Saturday
}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">流動電價-週日離峰單價</div>
</template>
{{ isSummerMonth ? Summer_Off_Prices : Non_Summer_Off_Prices }}
</el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
<div class="cell-item">契約容量</div> <div class="cell-item">契約容量</div>
</template> </template>
{{ ContractUse }} {{ ContractUse }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item v-if="isSummerMonth != 'non-summer'">
<template #label>
<div class="cell-item">
流動電價-平日尖峰單價
<!-- {{ isSummerMonth == "half-summer" ? "(夏月)" : "" }} -->
</div>
</template>
{{ Summer_Peak_Prices }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
基本電費-經常契約
<!-- {{ isSummerMonth == "half-summer" ? "(夏月/非夏月)" : "" }} -->
</div>
</template>
{{
isSummerMonth === "summer"
? Regular_Contract_Summer
: isSummerMonth === "non-summer"
? Regular_Contract_Non_Summer
: `${Regular_Contract_Summer} / ${Regular_Contract_Non_Summer}`
}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
流動電價-平日半尖峰單價
<!-- {{ isSummerMonth == "half-summer" ? "(夏月/非夏月)" : "" }} -->
</div>
</template>
{{
isSummerMonth === "summer"
? Summer_HalfPeak_Prices_Weekday
: isSummerMonth === "non-summer"
? Non_Summer_HalfPeak_Prices_Weekday
: `${Summer_HalfPeak_Prices_Weekday} / ${Non_Summer_HalfPeak_Prices_Weekday}`
}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
流動電價-平日離峰單價
<!-- {{ isSummerMonth == "half-summer" ? "(夏月/非夏月)" : "" }} -->
</div>
</template>
{{
isSummerMonth === "summer"
? Summer_Off_Prices_Weekday
: isSummerMonth === "non-summer"
? Non_Summer_Off_Prices_Weekday
: `${Summer_Off_Prices_Weekday} / ${Non_Summer_Off_Prices_Weekday}`
}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
流動電價-週六半尖峰單價
<!-- {{ isSummerMonth == "half-summer" ? "(夏月/非夏月)" : "" }} -->
</div>
</template>
{{
isSummerMonth === "summer"
? Summer_HalfPeak_Prices_Saturday
: isSummerMonth === "non-summer"
? Non_Summer_HalfPeak_Prices_Saturday
: `${Summer_HalfPeak_Prices_Saturday} / ${Non_Summer_HalfPeak_Prices_Saturday}`
}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
流動電價-週六離峰單價
<!-- {{ isSummerMonth == "half-summer" ? "(夏月/非夏月)" : "" }} -->
</div>
</template>
{{
isSummerMonth === "summer"
? Summer_Off_Prices_Saturday
: isSummerMonth === "non-summer"
? Non_Summer_Off_Prices_Saturday
: `${Summer_Off_Prices_Saturday} / ${Non_Summer_Off_Prices_Saturday}`
}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<div class="cell-item">
流動電價-週日離峰單價
<!-- {{ isSummerMonth == "half-summer" ? "(夏月/非夏月)" : "" }} -->
</div>
</template>
{{
isSummerMonth === "summer"
? Summer_Off_Prices
: isSummerMonth === "non-summer"
? Non_Summer_Off_Prices
: `${Summer_Off_Prices} / ${Non_Summer_Off_Prices}`
}}
</el-descriptions-item>
</el-descriptions> </el-descriptions>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="5">
<el-descriptions class="margin-top" title="總計" :column="1" border> <el-descriptions class="margin-top" title="總計" :column="1" border>
<el-descriptions-item> <el-descriptions-item>
<template #label> <template #label>
@ -199,6 +235,11 @@
<EnergyPie :chartData="elecCostData" /> <EnergyPie :chartData="elecCostData" />
</el-card> </el-card>
</el-col> </el-col>
<el-col :span="24">
<p style="margin: 0; padding-top: 15px; opacity: 0.8">
本系統所提供之時間電價計算結果係以未超過契約容量為前提所進行之估算僅供用電分析與管理參考之用
</p>
</el-col>
</el-row> </el-row>
</div> </div>
</template> </template>
@ -239,12 +280,26 @@ const loading = computed(() => {
}); });
const isSummerMonth = computed(() => { const isSummerMonth = computed(() => {
const month = dayjs(props.form?.date).month(); // month() 0-11 const date = dayjs(props.form?.date);
return month >= 5 && month <= 8; // 6 59 8 const month = date.month() + 1; //
if (month > 5 && month < 10) {
return "summer";
} else if (month === 5 || month === 10) {
return "half-summer";
} else {
return "non-summer";
}
}); });
const priceTitle = computed(() => { const priceTitle = computed(() => {
return isSummerMonth.value ? "單價(NTD/kWh)-夏月" : "單價(NTD/kWh)-非夏月"; if (isSummerMonth.value === "summer") {
return "單價(NTD/kWh)-夏月";
} else if (isSummerMonth.value === "non-summer") {
return "單價(NTD/kWh)-非夏月";
} else {
return "單價(NTD/kWh)-夏月/非夏月";
}
}); });
const formattedElecCostSummary = computed(() => { const formattedElecCostSummary = computed(() => {

View File

@ -60,7 +60,9 @@ export const CalcuEleCost = (input: Map<string, number>): ElecCostSummary => {
const sampleDate = entries[0].time; const sampleDate = entries[0].time;
const dayOfWeek = sampleDate.getDay(); const dayOfWeek = sampleDate.getDay();
const month = sampleDate.getMonth() + 1; const year = sampleDate.getFullYear();
const summerStart = new Date(`${year}-05-16`);
const summerEnd = new Date(`${year}-10-15`);
let off = 0; //離峰用電 let off = 0; //離峰用電
let half = 0; //半尖峰用電 let half = 0; //半尖峰用電
@ -71,7 +73,7 @@ export const CalcuEleCost = (input: Map<string, number>): ElecCostSummary => {
let dailyFlowCost = 0; //當日電價 let dailyFlowCost = 0; //當日電價
let dailyEleCost = 0; //當日用電 let dailyEleCost = 0; //當日用電
const isSummer = month >= 6 && month <= 9; const isSummer = sampleDate >= summerStart && sampleDate <= summerEnd;
entries.forEach(({ time, value }) => { entries.forEach(({ time, value }) => {
const hour = time.getHours(); const hour = time.getHours();
@ -191,10 +193,14 @@ export const CalcuEleStandCost = (
for (const [ym, entries] of monthMap.entries()) { for (const [ym, entries] of monthMap.entries()) {
if (!entries || entries.length === 0) continue; if (!entries || entries.length === 0) continue;
const sampleDate = entries[0].time; const sampleDate = entries[0].time;
const month = sampleDate.getMonth() + 1; //const month = sampleDate.getMonth() + 1;
const isSummer = month >= 6 && month <= 9; // 修改 isSummer 判斷方式:從月改為日期範圍 5/16 ~ 10/15
const year = sampleDate.getFullYear();
const summerStart = new Date(`${year}-05-16`);
const summerEnd = new Date(`${year}-10-15`);
const isSummer = sampleDate >= summerStart && sampleDate <= summerEnd;
let Phase = Three_Phase; let Phase = Three_Phase;
let Contract = isSummer ? Summer_Regular_Use : Non_Summer_Regular_Use; let Contract = isSummer ? Summer_Regular_Use : Non_Summer_Regular_Use;

View File

@ -43,7 +43,7 @@
<tbody> <tbody>
<tr> <tr>
<td colspan="6" class="">分類</td> <td colspan="6" class="">分類</td>
<td class="">夏月<br />(6/1~9/30)</td> <td class="">夏月<br />(5/16~10/15)</td>
<td class="">非夏月<br />(夏月以外的時間)</td> <td class="">非夏月<br />(夏月以外的時間)</td>
</tr> </tr>
<tr> <tr>

View File

@ -52,7 +52,7 @@
:show-layout="false" :show-layout="false"
:float-layout="true" :float-layout="true"
:enable-download="true" :enable-download="true"
:preview-modal="true" :preview-modal="false"
:filename="pdfFileName" :filename="pdfFileName"
:pdf-quality="2" :pdf-quality="2"
:manual-pagination="false" :manual-pagination="false"
@ -121,8 +121,12 @@ const handleClose = () => {
// PDF // PDF
const generatePDF = async () => { const generatePDF = async () => {
if (html2Pdf.value) { try {
await html2Pdf.value.generatePdf(); if (html2Pdf.value) {
await html2Pdf.value.generatePdf();
}
} catch (error) {
console.error("PDF生成失敗:", error);
} }
}; };