Merge branch 'feature/dateChange'
This commit is contained in:
		
						commit
						13e1fbbf4e
					
				
							
								
								
									
										3
									
								
								auto-imports.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								auto-imports.d.ts
									
									
									
									
										vendored
									
									
								
							@ -6,5 +6,6 @@
 | 
			
		||||
// biome-ignore lint: disable
 | 
			
		||||
export {}
 | 
			
		||||
declare global {
 | 
			
		||||
 | 
			
		||||
  const ElLoading: typeof import('element-plus/es')['ElLoading']
 | 
			
		||||
  const ElMessage: typeof import('element-plus/es')['ElMessage']
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
<html lang="en">
 | 
			
		||||
  <head>
 | 
			
		||||
    <meta charset="UTF-8" />
 | 
			
		||||
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
 | 
			
		||||
    <link rel="icon" type="image/svg+xml" href="./vite.svg" />
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | 
			
		||||
    <title>EMS</title>
 | 
			
		||||
    <script type="text/javascript" src="/requirejs/config.js?"></script>
 | 
			
		||||
 | 
			
		||||
@ -41,8 +41,7 @@ const initChart = () => {
 | 
			
		||||
      type: "value",
 | 
			
		||||
    },
 | 
			
		||||
    series: props.chartData.series.map((item) => ({
 | 
			
		||||
      ...item,
 | 
			
		||||
      stack: "total",
 | 
			
		||||
      ...item
 | 
			
		||||
    })),
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
@ -63,8 +62,11 @@ watch(
 | 
			
		||||
        },
 | 
			
		||||
        series: newChartData.series.map((item) => ({
 | 
			
		||||
          ...item,
 | 
			
		||||
          stack: "total",
 | 
			
		||||
        })),
 | 
			
		||||
        legend: {
 | 
			
		||||
          data: newChartData.series.map((item) => item.name),
 | 
			
		||||
          bottom: "0%",
 | 
			
		||||
        },
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,9 @@ const seriesData = ref({
 | 
			
		||||
  kWAlarmRest: [], // 復歸值
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
// 限制資料筆數
 | 
			
		||||
const MAX_DATA_LENGTH = 10;
 | 
			
		||||
 | 
			
		||||
// 使用 dayjs 生成當前時間戳(格式:HH:mm:ss)
 | 
			
		||||
const getCurrentTimestamp = () => {
 | 
			
		||||
  return dayjs().format("HH:mm:ss");
 | 
			
		||||
@ -55,6 +58,14 @@ const updateChartData = (elecData) => {
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
   // 限制資料筆數
 | 
			
		||||
  if (categories.value.length > MAX_DATA_LENGTH) {
 | 
			
		||||
    categories.value.shift(); // 移除第一個元素
 | 
			
		||||
    Object.keys(seriesData.value).forEach((key) => {
 | 
			
		||||
      seriesData.value[key].shift(); // 移除第一個元素
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // 更新圖表
 | 
			
		||||
  if (chartInstance) {
 | 
			
		||||
    chartInstance.setOption({
 | 
			
		||||
 | 
			
		||||
@ -14,17 +14,25 @@ const updateChart = (elecData) => {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // 總用電量
 | 
			
		||||
  // const totalElectricity = elecData.reduce((sum, item) => sum + item.out, 0);
 | 
			
		||||
  const totalElectricity = elecData.reduce((sum, item) => sum + item.out, 0);
 | 
			
		||||
 | 
			
		||||
  // 動態生成 data 和 links
 | 
			
		||||
  const chartData = [
 | 
			
		||||
    { name: "總用電", itemStyle: { color: "#038a77" } },
 | 
			
		||||
    ...elecData.map((item) => ({ name: item.displayName })),
 | 
			
		||||
    ...elecData.map((item) => {
 | 
			
		||||
      const percentage = ((item.out / totalElectricity) * 100).toFixed(2);
 | 
			
		||||
      return {
 | 
			
		||||
        name: `${item.displayName} (${percentage}%)`, // 顯示百分比
 | 
			
		||||
      };
 | 
			
		||||
    }),
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  const chartLinks = elecData.map((item) => ({
 | 
			
		||||
    source: "總用電",
 | 
			
		||||
    target: item.displayName,
 | 
			
		||||
    target: `${item.displayName} (${(
 | 
			
		||||
      (item.out / totalElectricity) *
 | 
			
		||||
      100
 | 
			
		||||
    ).toFixed(2)}%)`,
 | 
			
		||||
    value: Number(item.out),
 | 
			
		||||
  }));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -5,36 +5,33 @@
 | 
			
		||||
    mode="horizontal"
 | 
			
		||||
    @select="handleSelect"
 | 
			
		||||
  >
 | 
			
		||||
    <el-menu-item index="chart">能源圖表</el-menu-item>
 | 
			
		||||
    <el-menu-item index="EnergyChart">能源圖表</el-menu-item>
 | 
			
		||||
    <el-menu-item index="elecPricing">電價表</el-menu-item>
 | 
			
		||||
    <el-menu-item index="monthlyReport">能源報表</el-menu-item>
 | 
			
		||||
  </el-menu>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script setup lang="ts">
 | 
			
		||||
import { ref } from "vue";
 | 
			
		||||
import { useRouter } from "vue-router";
 | 
			
		||||
import { ref, onMounted } from "vue";
 | 
			
		||||
import { useRouter, useRoute } from "vue-router";
 | 
			
		||||
 | 
			
		||||
const router = useRouter();
 | 
			
		||||
const activeIndex = ref("chart"); // Set initial active index
 | 
			
		||||
const handleSelect = (key: string, keyPath: string[]) => {
 | 
			
		||||
  console.log(key, keyPath);
 | 
			
		||||
const route = useRoute();
 | 
			
		||||
 | 
			
		||||
  switch (key) {
 | 
			
		||||
    case "chart":
 | 
			
		||||
      router.push({ name: "EnergyChart" });
 | 
			
		||||
      activeIndex.value = "chart";
 | 
			
		||||
      break;
 | 
			
		||||
    case "elecPricing":
 | 
			
		||||
      router.push({ name: "elecPricing" });
 | 
			
		||||
      activeIndex.value = "elecPricing";
 | 
			
		||||
      break;
 | 
			
		||||
    case "monthlyReport":
 | 
			
		||||
      router.push({ name: "monthlyReport" });
 | 
			
		||||
      activeIndex.value = "monthlyReport";
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
const activeIndex = ref(""); 
 | 
			
		||||
 | 
			
		||||
const updateActiveIndex = () => {
 | 
			
		||||
  activeIndex.value = String(route.name || "");
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const handleSelect = (key: string) => {
 | 
			
		||||
  router.push({ name: key }); 
 | 
			
		||||
  activeIndex.value = key;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
onMounted(() => {
 | 
			
		||||
  updateActiveIndex(); 
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style scoped></style>
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div v-loading="loading" element-loading-text="資料加載中...">
 | 
			
		||||
    <el-row :gutter="20">
 | 
			
		||||
      <el-col :span="7">
 | 
			
		||||
      <el-col :span="6">
 | 
			
		||||
        <el-descriptions class="margin-top" title="報表資訊" :column="1" border>
 | 
			
		||||
          <el-descriptions-item>
 | 
			
		||||
            <template #label>
 | 
			
		||||
@ -29,7 +29,7 @@
 | 
			
		||||
          </el-descriptions-item>
 | 
			
		||||
        </el-descriptions>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="11">
 | 
			
		||||
      <el-col :span="13">
 | 
			
		||||
        <el-descriptions
 | 
			
		||||
          class="margin-top"
 | 
			
		||||
          :title="priceTitle"
 | 
			
		||||
@ -42,79 +42,115 @@
 | 
			
		||||
            </template>
 | 
			
		||||
            {{ Three_Phase }}
 | 
			
		||||
          </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>
 | 
			
		||||
            <template #label>
 | 
			
		||||
              <div class="cell-item">契約容量</div>
 | 
			
		||||
            </template>
 | 
			
		||||
            {{ ContractUse }}
 | 
			
		||||
          </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-col>
 | 
			
		||||
      <el-col :span="6">
 | 
			
		||||
      <el-col :span="5">
 | 
			
		||||
        <el-descriptions class="margin-top" title="總計" :column="1" border>
 | 
			
		||||
          <el-descriptions-item>
 | 
			
		||||
            <template #label>
 | 
			
		||||
@ -199,6 +235,11 @@
 | 
			
		||||
          <EnergyPie :chartData="elecCostData" />
 | 
			
		||||
        </el-card>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="24">
 | 
			
		||||
        <p style="margin: 0; padding-top: 15px; opacity: 0.8">
 | 
			
		||||
          本系統所提供之時間電價計算結果,係以未超過契約容量為前提所進行之估算,僅供用電分析與管理參考之用。
 | 
			
		||||
        </p>
 | 
			
		||||
      </el-col>
 | 
			
		||||
    </el-row>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
@ -239,12 +280,26 @@ const loading = computed(() => {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const isSummerMonth = computed(() => {
 | 
			
		||||
  const month = dayjs(props.form?.date).month(); // month() 返回 0-11,代表一月到十二月
 | 
			
		||||
  return month >= 5 && month <= 8; // 月份範圍,6月是 5,9月是 8
 | 
			
		||||
  const date = dayjs(props.form?.date);
 | 
			
		||||
  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(() => {
 | 
			
		||||
  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(() => {
 | 
			
		||||
@ -392,18 +447,21 @@ const elecUsageData = computed(() => {
 | 
			
		||||
        type: "bar",
 | 
			
		||||
        data: peakData,
 | 
			
		||||
        itemStyle: { color: "#5470c6" },
 | 
			
		||||
        stack: "total",
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        name: "半尖峰用電",
 | 
			
		||||
        type: "bar",
 | 
			
		||||
        data: halfPeakData,
 | 
			
		||||
        itemStyle: { color: "#91cc75" },
 | 
			
		||||
        stack: "total",
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        name: "離峰用電",
 | 
			
		||||
        type: "bar",
 | 
			
		||||
        data: offPeakData,
 | 
			
		||||
        itemStyle: { color: "#fac858" },
 | 
			
		||||
        stack: "total",
 | 
			
		||||
      },
 | 
			
		||||
    ],
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
import { createRouter, createWebHistory } from "vue-router";
 | 
			
		||||
import { createRouter, createWebHashHistory } from "vue-router";
 | 
			
		||||
import type { RouteRecordRaw } from "vue-router";
 | 
			
		||||
 | 
			
		||||
const routes: Array<RouteRecordRaw> = [
 | 
			
		||||
@ -37,7 +37,7 @@ const routes: Array<RouteRecordRaw> = [
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
const router = createRouter({
 | 
			
		||||
  history: createWebHistory(),
 | 
			
		||||
  history: createWebHashHistory(import.meta.env.BASE_URL),
 | 
			
		||||
  routes,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,7 @@ const useElecDemandStore = defineStore("elecDemand", () => {
 | 
			
		||||
      window.requirejs(["baja!"], (baja: any) => {
 | 
			
		||||
        let eleclist: NiagaraElecDemandData[] = [];
 | 
			
		||||
        baja.Ord.make(
 | 
			
		||||
          `local:|foxs:4918|station:|neql:EMS:kw|bql:select slotPath,parent.displayName,name,out`
 | 
			
		||||
          `local:|foxs:|station:|neql:EMS:kw|bql:select slotPath,parent.displayName,name,out`
 | 
			
		||||
        ).get({
 | 
			
		||||
          cursor: {
 | 
			
		||||
            before: () => {},
 | 
			
		||||
@ -41,7 +41,7 @@ const useElecDemandStore = defineStore("elecDemand", () => {
 | 
			
		||||
 | 
			
		||||
  const subscribeToHistory = (item: NiagaraElecDemandData, index: number) => {
 | 
			
		||||
    const slotPath = item.slotPath;
 | 
			
		||||
    const ordString = `local:|foxs:4918|station:|${slotPath}`;
 | 
			
		||||
    const ordString = `local:|foxs:|station:|${slotPath}`;
 | 
			
		||||
 | 
			
		||||
    // @ts-ignore
 | 
			
		||||
    window.require &&
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@ const useElecStore = defineStore("elecDist", () => {
 | 
			
		||||
        console.log("進入 bajaSubscriber 準備執行 BQL 訂閱");
 | 
			
		||||
 | 
			
		||||
        // 定義BQL 查詢
 | 
			
		||||
        const subSysKwhBql = `local:|foxs:4918|station:|neql:EMS:SubSys_kwh|bql:select slotPath,parent.displayName,displayName,NumericInterval.historyConfig.id`;
 | 
			
		||||
        const subSysKwhBql = `local:|foxs:|station:|neql:EMS:SubSys_kwh|bql:select slotPath,parent.displayName,displayName,NumericInterval.historyConfig.id`;
 | 
			
		||||
 | 
			
		||||
        // 執行各電表的 BQL 查詢
 | 
			
		||||
        fetchElecData(baja, subSysKwhBql);
 | 
			
		||||
@ -51,12 +51,12 @@ const useElecStore = defineStore("elecDist", () => {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  const subscribeToHistory = (item: NiagaraElecData) => {
 | 
			
		||||
    const startTime = dayjs()
 | 
			
		||||
    const startTime = dayjs("2025-05-08T16:30:00.000+08:00")
 | 
			
		||||
      .subtract(2, "hour")
 | 
			
		||||
      .format("YYYY-MM-DDTHH:mm:ss.000+08:00"); // 現在時間前2個小時
 | 
			
		||||
    const endTime = dayjs().format("YYYY-MM-DDTHH:mm:ss.000+08:00"); // 現在的時間
 | 
			
		||||
    const endTime = dayjs("2025-05-08T16:30:00.000+08:00").format("YYYY-MM-DDTHH:mm:ss.000+08:00"); // 現在的時間
 | 
			
		||||
    const id = item.id;
 | 
			
		||||
    const ordString = `local:|foxs:4918|history:${id}?period=timerange;start=${startTime};end=${endTime}|bql:history:HistoryRollup.rollup(baja:RelTime '3600000')`;
 | 
			
		||||
    const ordString = `local:|foxs:|history:${id}?period=timerange;start=${startTime};end=${endTime}|bql:history:HistoryRollup.rollup(baja:RelTime '3600000')`;
 | 
			
		||||
     console.log(ordString);
 | 
			
		||||
    // @ts-ignore
 | 
			
		||||
    window.require &&
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@ const useElecPriceStore = defineStore("elecPriceData", () => {
 | 
			
		||||
        console.log("進入 bajaSubscriber 準備執行 BQL 訂閱");
 | 
			
		||||
 | 
			
		||||
        // 定義BQL 查詢
 | 
			
		||||
        const Total_kwhBql = `local:|foxs:4918|station:|neql:EMS:parameter|bql:select slotPath,parent.displayName,displayName,NumericInterval.historyConfig.id,out`;
 | 
			
		||||
        const Total_kwhBql = `local:|foxs:|station:|neql:EMS:parameter|bql:select slotPath,parent.displayName,displayName,NumericInterval.historyConfig.id,out`;
 | 
			
		||||
 | 
			
		||||
        // 執行查詢
 | 
			
		||||
        fetchElecData(baja, Total_kwhBql);
 | 
			
		||||
@ -51,7 +51,7 @@ const useElecPriceStore = defineStore("elecPriceData", () => {
 | 
			
		||||
 | 
			
		||||
  const subscribeToCost = (item: NiagaraElecData, index: number) => {
 | 
			
		||||
    const slotPath = item.slotPath;
 | 
			
		||||
    const ordString = `local:|foxs:4918|station:|${slotPath}`;
 | 
			
		||||
    const ordString = `local:|foxs:|station:|${slotPath}`;
 | 
			
		||||
 | 
			
		||||
    // @ts-ignore
 | 
			
		||||
    window.require &&
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@ const useElecReportStore = defineStore("elecReportData", () => {
 | 
			
		||||
        console.log("進入 bajaSubscriber 準備執行用電度數 BQL 訂閱");
 | 
			
		||||
 | 
			
		||||
        // 定義BQL 查詢
 | 
			
		||||
        const Total_kwhBql = `local:|foxs:4918|station:|neql:EMS:SubSys_kwh|bql:select slotPath,parent.displayName,displayName,NumericInterval.historyConfig.id,out`;
 | 
			
		||||
        const Total_kwhBql = `local:|foxs:|station:|neql:EMS:SubSys_kwh|bql:select slotPath,parent.displayName,displayName,NumericInterval.historyConfig.id,out`;
 | 
			
		||||
 | 
			
		||||
        // 執行各電表的 BQL 查詢
 | 
			
		||||
        fetchElecData(baja, Total_kwhBql);
 | 
			
		||||
@ -99,7 +99,7 @@ const useElecReportStore = defineStore("elecReportData", () => {
 | 
			
		||||
      endTimeValue = dayjs(endTime.value).subtract(1, 'month').endOf('month').format("YYYY-MM-DDTHH:mm:ss.000+08:00");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const ordString = `local:|foxs:4918|history:${id}?period=timerange;start=${startTimeValue};end=${endTimeValue}|bql:history:HistoryRollup.rollup(baja:RelTime '3600000')`; //每小时一个rollup
 | 
			
		||||
    const ordString = `local:|foxs:|history:${id}?period=timerange;start=${startTimeValue};end=${endTimeValue}|bql:history:HistoryRollup.rollup(baja:RelTime '3600000')`; //每小时一个rollup
 | 
			
		||||
    console.log(ordString);
 | 
			
		||||
    // @ts-ignore
 | 
			
		||||
    window.require &&
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,7 @@ const useElecStore = defineStore("elecData", () => {
 | 
			
		||||
        console.log("進入 bajaSubscriber 準備執行用電度數 BQL 訂閱");
 | 
			
		||||
 | 
			
		||||
        // 定義BQL 查詢
 | 
			
		||||
        const Total_kwhBql = `local:|foxs:4918|station:|neql:EMS:Total_kwh|bql:select slotPath,parent.displayName,displayName,NumericInterval.historyConfig.id,out`;
 | 
			
		||||
        const Total_kwhBql = `local:|foxs:|station:|neql:EMS:Total_kwh|bql:select slotPath,parent.displayName,displayName,NumericInterval.historyConfig.id,out`;
 | 
			
		||||
 | 
			
		||||
        // 執行各電表的 BQL 查詢
 | 
			
		||||
        fetchElecData(baja, Total_kwhBql);
 | 
			
		||||
@ -65,7 +65,7 @@ const useElecStore = defineStore("elecData", () => {
 | 
			
		||||
    ).format("YYYY-MM-DDTHH:mm:ss.000+08:00");
 | 
			
		||||
    const endTime = dayjs().format("YYYY-MM-DDTHH:mm:ss.000+08:00");
 | 
			
		||||
 | 
			
		||||
    const ordString = `local:|foxs:4918|history:${id}?period=timerange;;start=${startTime};end=${endTime}|bql:history:HistoryRollup.rollup(baja:RelTime '3600000')`; //每小时一个rollup
 | 
			
		||||
    const ordString = `local:|foxs:|history:${id}?period=timerange;;start=${startTime};end=${endTime}|bql:history:HistoryRollup.rollup(baja:RelTime '3600000')`; //每小时一个rollup
 | 
			
		||||
    console.log(ordString);
 | 
			
		||||
    // @ts-ignore
 | 
			
		||||
    window.require &&
 | 
			
		||||
 | 
			
		||||
@ -60,7 +60,9 @@ export const CalcuEleCost = (input: Map<string, number>): ElecCostSummary => {
 | 
			
		||||
 | 
			
		||||
    const sampleDate = entries[0].time;
 | 
			
		||||
    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 half = 0; //半尖峰用電
 | 
			
		||||
@ -71,7 +73,7 @@ export const CalcuEleCost = (input: Map<string, number>): ElecCostSummary => {
 | 
			
		||||
    let dailyFlowCost = 0; //當日電價
 | 
			
		||||
    let dailyEleCost = 0; //當日用電
 | 
			
		||||
 | 
			
		||||
    const isSummer = month >= 6 && month <= 9;
 | 
			
		||||
    const isSummer = sampleDate >= summerStart && sampleDate <= summerEnd;
 | 
			
		||||
 | 
			
		||||
    entries.forEach(({ time, value }) => {
 | 
			
		||||
      const hour = time.getHours();
 | 
			
		||||
@ -193,8 +195,12 @@ export const CalcuEleStandCost = (
 | 
			
		||||
    if (!entries || entries.length === 0) continue;
 | 
			
		||||
    
 | 
			
		||||
    const sampleDate = entries[0].time;
 | 
			
		||||
    const month = sampleDate.getMonth() + 1;
 | 
			
		||||
    const isSummer = month >= 6 && month <= 9;
 | 
			
		||||
    //const month = sampleDate.getMonth() + 1;
 | 
			
		||||
    // 修改 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 Contract = isSummer ? Summer_Regular_Use : Non_Summer_Regular_Use;
 | 
			
		||||
 | 
			
		||||
@ -58,7 +58,10 @@
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="16">
 | 
			
		||||
        <el-card style="border-radius: 8px">
 | 
			
		||||
          <h3 class="">區間計費度數 {{ billingDateRange }}</h3>
 | 
			
		||||
          <h3 class="">
 | 
			
		||||
            區間計費度數 2025/05/01 - 2025/05/16
 | 
			
		||||
            <!-- {{ billingDateRange }} -->
 | 
			
		||||
          </h3>
 | 
			
		||||
          <EnergyBar :chartData="areaBillingData" />
 | 
			
		||||
        </el-card>
 | 
			
		||||
      </el-col>
 | 
			
		||||
@ -115,7 +118,7 @@ const loading = computed(() => {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const statisticData = computed(() => {
 | 
			
		||||
  const currentMonth = dayjs().format("YYYY-MM");
 | 
			
		||||
  const currentMonth = "2025-05";
 | 
			
		||||
 | 
			
		||||
  let intervalFlowCost = 0;
 | 
			
		||||
  let intervalEleCost = 0;
 | 
			
		||||
@ -135,14 +138,14 @@ const statisticData = computed(() => {
 | 
			
		||||
      value: storeElecTotal.elecFlowCostSummary?.totalFlowCost || 0,
 | 
			
		||||
      unit: "元",
 | 
			
		||||
    },
 | 
			
		||||
    { title: "區間電費", value: intervalFlowCost, unit: "元" },
 | 
			
		||||
    { title: "當月電費", value: intervalFlowCost, unit: "元" },
 | 
			
		||||
    {
 | 
			
		||||
      title: "今年碳排當量累計",
 | 
			
		||||
      value: storeElecTotal.elecFlowCostSummary?.totalEleCost * 0.424,
 | 
			
		||||
      unit: "公斤 CO2e/度",
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      title: "區間碳排當量",
 | 
			
		||||
      title: "當月碳排當量",
 | 
			
		||||
      value: intervalEleCost * 0.424,
 | 
			
		||||
      unit: "公斤 CO2e/度",
 | 
			
		||||
    },
 | 
			
		||||
@ -151,7 +154,7 @@ const statisticData = computed(() => {
 | 
			
		||||
      value: storeElecTotal.elecFlowCostSummary?.totalEleCost || 0,
 | 
			
		||||
      unit: "kWh",
 | 
			
		||||
    },
 | 
			
		||||
    { title: "區間用電度數", value: intervalEleCost, unit: "kWh" },
 | 
			
		||||
    { title: "當月用電度數", value: intervalEleCost, unit: "kWh" },
 | 
			
		||||
  ];
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -197,12 +200,16 @@ const monthlyElectricityData = computed(() => {
 | 
			
		||||
    dayjs().month(month).valueOf()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const baseElecData = storeElecTotal.elecStandCostSummary.StandResults.map(item => item.StandCost); 
 | 
			
		||||
  const flowElecData = sortedCategories.map(
 | 
			
		||||
    (month) => groupedData[month].totalCost
 | 
			
		||||
  const baseElecData = storeElecTotal.elecStandCostSummary.StandResults.map(
 | 
			
		||||
    (item) => Number(item.StandCost.toFixed(2))
 | 
			
		||||
  );
 | 
			
		||||
  const flowElecData = sortedCategories.map((month) =>
 | 
			
		||||
    Number(groupedData[month].totalCost.toFixed(2))
 | 
			
		||||
  );
 | 
			
		||||
  const totalElecData = sortedCategories.map((month, index) => {
 | 
			
		||||
    return (baseElecData[index] || 0) + (flowElecData[index] || 0);
 | 
			
		||||
    const base = baseElecData[index] || 0;
 | 
			
		||||
    const flow = flowElecData[index] || 0;
 | 
			
		||||
    return Number((base + flow).toFixed(2));
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  return {
 | 
			
		||||
@ -212,16 +219,19 @@ const monthlyElectricityData = computed(() => {
 | 
			
		||||
        name: "基本電費",
 | 
			
		||||
        type: "bar",
 | 
			
		||||
        data: baseElecData,
 | 
			
		||||
        stack: "total",
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        name: "流動電費",
 | 
			
		||||
        type: "bar",
 | 
			
		||||
        data: flowElecData,
 | 
			
		||||
        stack: "total",
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        name: "總電費",
 | 
			
		||||
        type: "bar",
 | 
			
		||||
        type: "line",
 | 
			
		||||
        data: totalElecData,
 | 
			
		||||
        lineStyle: { width: 3 },
 | 
			
		||||
      },
 | 
			
		||||
    ],
 | 
			
		||||
  };
 | 
			
		||||
@ -252,6 +262,7 @@ const monthlyCarbonData = computed(() => {
 | 
			
		||||
        name: "碳排當量",
 | 
			
		||||
        type: "bar",
 | 
			
		||||
        data: carbonData,
 | 
			
		||||
        stack: "total",
 | 
			
		||||
      },
 | 
			
		||||
    ],
 | 
			
		||||
  };
 | 
			
		||||
@ -278,9 +289,9 @@ const monthlyBillingData = computed(() => {
 | 
			
		||||
  return {
 | 
			
		||||
    categories: sortedCategories,
 | 
			
		||||
    series: [
 | 
			
		||||
      { name: "尖峰", type: "bar", data: peakData },
 | 
			
		||||
      { name: "半尖峰", type: "bar", data: halfData },
 | 
			
		||||
      { name: "離峰", type: "bar", data: offData },
 | 
			
		||||
      { name: "尖峰", type: "bar", data: peakData, stack: "total" },
 | 
			
		||||
      { name: "半尖峰", type: "bar", data: halfData, stack: "total" },
 | 
			
		||||
      { name: "離峰", type: "bar", data: offData, stack: "total" },
 | 
			
		||||
    ],
 | 
			
		||||
  };
 | 
			
		||||
});
 | 
			
		||||
@ -290,10 +301,12 @@ const areaBillingData = computed(() => {
 | 
			
		||||
    return { categories: [], series: [] };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const today = dayjs();
 | 
			
		||||
  const currentMonth = today.format("YYYY-MM");
 | 
			
		||||
  const startDate = dayjs(`${currentMonth}-01`); // Get the first day of the current month
 | 
			
		||||
  const endDate = today;
 | 
			
		||||
  // const today = dayjs();
 | 
			
		||||
  // const currentMonth = today.format("YYYY-MM");
 | 
			
		||||
  // const startDate = dayjs(`${currentMonth}-01`); // Get the first day of the current month
 | 
			
		||||
  // const endDate = today;
 | 
			
		||||
  const startDate = dayjs("2025-05-01");
 | 
			
		||||
  const endDate = dayjs("2025-05-31");
 | 
			
		||||
 | 
			
		||||
  // Filter daily results within the specified date range
 | 
			
		||||
  const areaResults = storeElecTotal.elecFlowCostSummary.dailyResults.filter(
 | 
			
		||||
@ -331,9 +344,9 @@ const areaBillingData = computed(() => {
 | 
			
		||||
  return {
 | 
			
		||||
    categories: sortedCategories,
 | 
			
		||||
    series: [
 | 
			
		||||
      { name: "尖峰", type: "bar", data: peakData },
 | 
			
		||||
      { name: "半尖峰", type: "bar", data: halfData },
 | 
			
		||||
      { name: "離峰", type: "bar", data: offData },
 | 
			
		||||
      { name: "尖峰", type: "bar", data: peakData, stack: "total" },
 | 
			
		||||
      { name: "半尖峰", type: "bar", data: halfData, stack: "total" },
 | 
			
		||||
      { name: "離峰", type: "bar", data: offData, stack: "total" },
 | 
			
		||||
    ],
 | 
			
		||||
  };
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -43,7 +43,7 @@
 | 
			
		||||
        <tbody>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <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>
 | 
			
		||||
          </tr>
 | 
			
		||||
          <tr>
 | 
			
		||||
@ -54,7 +54,7 @@
 | 
			
		||||
            <td colspan="2" class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[0]"
 | 
			
		||||
                v-model="stand3Value[0]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -65,7 +65,7 @@
 | 
			
		||||
            <td colspan="2" class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[1]"
 | 
			
		||||
                v-model="stand3Value[1]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -77,7 +77,7 @@
 | 
			
		||||
            <td class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[2]"
 | 
			
		||||
                v-model="stand3Value[2]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -85,7 +85,7 @@
 | 
			
		||||
            <td class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[3]"
 | 
			
		||||
                v-model="stand3Value[3]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -96,7 +96,7 @@
 | 
			
		||||
            <td class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[4]"
 | 
			
		||||
                v-model="stand3Value[4]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -104,7 +104,7 @@
 | 
			
		||||
            <td class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[5]"
 | 
			
		||||
                v-model="stand3Value[5]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -115,7 +115,7 @@
 | 
			
		||||
            <td class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[6]"
 | 
			
		||||
                v-model="stand3Value[6]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -123,7 +123,7 @@
 | 
			
		||||
            <td class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[7]"
 | 
			
		||||
                v-model="stand3Value[7]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -134,7 +134,7 @@
 | 
			
		||||
            <td class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[8]"
 | 
			
		||||
                v-model="stand3Value[8]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -142,7 +142,7 @@
 | 
			
		||||
            <td class="bg-brown">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[9]"
 | 
			
		||||
                v-model="stand3Value[9]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -158,7 +158,7 @@
 | 
			
		||||
            <td class="bg-lightred">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[10]"
 | 
			
		||||
                v-model="stand3Value[10]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -172,7 +172,7 @@
 | 
			
		||||
            <td class="bg-lightyellow">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[11]"
 | 
			
		||||
                v-model="stand3Value[11]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -186,7 +186,7 @@
 | 
			
		||||
            <td class="bg-lightyellow">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[12]"
 | 
			
		||||
                v-model="stand3Value[12]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -199,7 +199,7 @@
 | 
			
		||||
            <td class="bg-lightgreen">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[13]"
 | 
			
		||||
                v-model="stand3Value[13]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -216,7 +216,7 @@
 | 
			
		||||
            <td class="bg-lightgreen">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[14]"
 | 
			
		||||
                v-model="stand3Value[14]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -230,7 +230,7 @@
 | 
			
		||||
            <td class="bg-lightyellow">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[15]"
 | 
			
		||||
                v-model="stand3Value[15]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -247,7 +247,7 @@
 | 
			
		||||
            <td class="bg-lightyellow">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[16]"
 | 
			
		||||
                v-model="stand3Value[16]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -260,7 +260,7 @@
 | 
			
		||||
            <td class="bg-lightgreen">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[17]"
 | 
			
		||||
                v-model="stand3Value[17]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -274,7 +274,7 @@
 | 
			
		||||
            <td class="bg-lightgreen">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[18]"
 | 
			
		||||
                v-model="stand3Value[18]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -287,7 +287,7 @@
 | 
			
		||||
            <td class="bg-lightgreen">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[19]"
 | 
			
		||||
                v-model="stand3Value[19]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -295,7 +295,7 @@
 | 
			
		||||
            <td class="bg-lightgreen">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="number"
 | 
			
		||||
                v-model.number="stand3Value[20]"
 | 
			
		||||
                v-model="stand3Value[20]"
 | 
			
		||||
                style="width: 140px"
 | 
			
		||||
                :disabled="!stand3isEditing"
 | 
			
		||||
              />
 | 
			
		||||
@ -367,10 +367,20 @@ const confirmChanges = async () => {
 | 
			
		||||
  const failedUpdates: { slotPath: string; out: number }[] = [];
 | 
			
		||||
 | 
			
		||||
  if (!elecData || elecData.length === 0) {
 | 
			
		||||
    console.warn("useElecPriceStore.elecData 為空,無法更新 stand3Value");
 | 
			
		||||
    // @ts-ignore
 | 
			
		||||
    ElMessage({
 | 
			
		||||
      message: "資料為空,無法更新",
 | 
			
		||||
      type: "warning",
 | 
			
		||||
    });
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
// @ts-ignore
 | 
			
		||||
  const loading = ElLoading.service({
 | 
			
		||||
    lock: true,
 | 
			
		||||
    text: "更新中,請稍候...",
 | 
			
		||||
    background: "rgba(255, 255, 255, 0.7)",
 | 
			
		||||
  });
 | 
			
		||||
  try {
 | 
			
		||||
    // 循環遍歷所有值,找出修改過的
 | 
			
		||||
    for (let i = 0; i < stand3Value.value.length; i++) {
 | 
			
		||||
      if (stand3Value.value[i] !== beforeEditValues.value[i]) {
 | 
			
		||||
@ -387,18 +397,24 @@ const confirmChanges = async () => {
 | 
			
		||||
 | 
			
		||||
        if (displayName) {
 | 
			
		||||
          // 查找 elecData 中對應的 item
 | 
			
		||||
        const item = elecData.find((item) => item.displayName === displayName);
 | 
			
		||||
          const item = elecData.find(
 | 
			
		||||
            (item) => item.displayName === displayName
 | 
			
		||||
          );
 | 
			
		||||
          if (item) {
 | 
			
		||||
            // 移除 "slot:/" 前綴
 | 
			
		||||
            const slotPath = item.slotPath.startsWith("slot:/")
 | 
			
		||||
              ? item.slotPath.slice(6) // 移除 "slot:/"
 | 
			
		||||
              : item.slotPath; // 如果没有前綴,則保持不變
 | 
			
		||||
            // 更新 Niagara
 | 
			
		||||
          const success = await storeElecPrice.updatePrice(slotPath, stand3Value.value[i]);
 | 
			
		||||
            console.log("即將更新", slotPath, Number(stand3Value.value[i]));
 | 
			
		||||
            const success = await storeElecPrice.updatePrice(
 | 
			
		||||
              slotPath,
 | 
			
		||||
              Number(stand3Value.value[i])
 | 
			
		||||
            );
 | 
			
		||||
            if (!success) {
 | 
			
		||||
              failedUpdates.push({
 | 
			
		||||
                slotPath: item.slotPath,
 | 
			
		||||
              out: stand3Value.value[i],
 | 
			
		||||
                out: Number(stand3Value.value[i]),
 | 
			
		||||
              });
 | 
			
		||||
            }
 | 
			
		||||
          } else {
 | 
			
		||||
@ -411,13 +427,21 @@ const confirmChanges = async () => {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (failedUpdates.length > 0) {
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      ElMessage.error("更新失敗");
 | 
			
		||||
      console.error("以下更新失敗:", failedUpdates);
 | 
			
		||||
    } else {
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      ElMessage({
 | 
			
		||||
        message: "更新成功",
 | 
			
		||||
        type: "success",
 | 
			
		||||
      });
 | 
			
		||||
      console.log("所有更新成功");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  // 更新 initialStand3Values
 | 
			
		||||
    initialStand3Values.value = [...stand3Value.value];
 | 
			
		||||
  } finally {
 | 
			
		||||
    loading.close();
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const onCancel = () => {
 | 
			
		||||
 | 
			
		||||
@ -52,7 +52,7 @@
 | 
			
		||||
    :show-layout="false"
 | 
			
		||||
    :float-layout="true"
 | 
			
		||||
    :enable-download="true"
 | 
			
		||||
    :preview-modal="true"
 | 
			
		||||
    :preview-modal="false"
 | 
			
		||||
    :filename="pdfFileName"
 | 
			
		||||
    :pdf-quality="2"
 | 
			
		||||
    :manual-pagination="false"
 | 
			
		||||
@ -121,9 +121,13 @@ const handleClose = () => {
 | 
			
		||||
 | 
			
		||||
// 觸發 PDF 生成和下載
 | 
			
		||||
const generatePDF = async () => {
 | 
			
		||||
   try {
 | 
			
		||||
    if (html2Pdf.value) {
 | 
			
		||||
      await html2Pdf.value.generatePdf();
 | 
			
		||||
    }
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    console.error("PDF生成失敗:", error);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
watch(
 | 
			
		||||
 | 
			
		||||
@ -4,12 +4,8 @@ import AutoImport from "unplugin-auto-import/vite";
 | 
			
		||||
import Components from "unplugin-vue-components/vite";
 | 
			
		||||
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
 | 
			
		||||
 | 
			
		||||
// https://vite.dev/config/
 | 
			
		||||
export default defineConfig({
 | 
			
		||||
  base:
 | 
			
		||||
    process.env.NODE_ENV === "production"
 | 
			
		||||
      ? "https://192.168.0.206:8500/file/ems_dist/"
 | 
			
		||||
      : "/",
 | 
			
		||||
  base: "./",
 | 
			
		||||
  build: {
 | 
			
		||||
    outDir: process.env.NODE_ENV === "production" ? "../ems_dist" : "./dist",
 | 
			
		||||
    emptyOutDir: true,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user