能源圖表樣式修改 | 電價表input能填寫.0,時間電價更新進行時,有提示訊息 | 抓網頁路徑且改成createWebHashHistory | local:|foxs:4918改成local:|foxs:
This commit is contained in:
		
							parent
							
								
									c3ceba4433
								
							
						
					
					
						commit
						2ad24dab08
					
				
							
								
								
									
										3
									
								
								auto-imports.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								auto-imports.d.ts
									
									
									
									
										vendored
									
									
								
							@ -6,5 +6,6 @@
 | 
				
			|||||||
// biome-ignore lint: disable
 | 
					// biome-ignore lint: disable
 | 
				
			||||||
export {}
 | 
					export {}
 | 
				
			||||||
declare global {
 | 
					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">
 | 
					<html lang="en">
 | 
				
			||||||
  <head>
 | 
					  <head>
 | 
				
			||||||
    <meta charset="UTF-8" />
 | 
					    <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" />
 | 
					    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | 
				
			||||||
    <title>EMS</title>
 | 
					    <title>EMS</title>
 | 
				
			||||||
    <script type="text/javascript" src="/requirejs/config.js?"></script>
 | 
					    <script type="text/javascript" src="/requirejs/config.js?"></script>
 | 
				
			||||||
 | 
				
			|||||||
@ -41,8 +41,7 @@ const initChart = () => {
 | 
				
			|||||||
      type: "value",
 | 
					      type: "value",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    series: props.chartData.series.map((item) => ({
 | 
					    series: props.chartData.series.map((item) => ({
 | 
				
			||||||
      ...item,
 | 
					      ...item
 | 
				
			||||||
      stack: "total",
 | 
					 | 
				
			||||||
    })),
 | 
					    })),
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -63,8 +62,11 @@ watch(
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        series: newChartData.series.map((item) => ({
 | 
					        series: newChartData.series.map((item) => ({
 | 
				
			||||||
          ...item,
 | 
					          ...item,
 | 
				
			||||||
          stack: "total",
 | 
					 | 
				
			||||||
        })),
 | 
					        })),
 | 
				
			||||||
 | 
					        legend: {
 | 
				
			||||||
 | 
					          data: newChartData.series.map((item) => item.name),
 | 
				
			||||||
 | 
					          bottom: "0%",
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
				
			|||||||
@ -18,6 +18,9 @@ const seriesData = ref({
 | 
				
			|||||||
  kWAlarmRest: [], // 復歸值
 | 
					  kWAlarmRest: [], // 復歸值
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 限制資料筆數
 | 
				
			||||||
 | 
					const MAX_DATA_LENGTH = 10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 使用 dayjs 生成當前時間戳(格式:HH:mm:ss)
 | 
					// 使用 dayjs 生成當前時間戳(格式:HH:mm:ss)
 | 
				
			||||||
const getCurrentTimestamp = () => {
 | 
					const getCurrentTimestamp = () => {
 | 
				
			||||||
  return dayjs().format("HH:mm:ss");
 | 
					  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) {
 | 
					  if (chartInstance) {
 | 
				
			||||||
    chartInstance.setOption({
 | 
					    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
 | 
					  // 動態生成 data 和 links
 | 
				
			||||||
  const chartData = [
 | 
					  const chartData = [
 | 
				
			||||||
    { name: "總用電", itemStyle: { color: "#038a77" } },
 | 
					    { 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) => ({
 | 
					  const chartLinks = elecData.map((item) => ({
 | 
				
			||||||
    source: "總用電",
 | 
					    source: "總用電",
 | 
				
			||||||
    target: item.displayName,
 | 
					    target: `${item.displayName} (${(
 | 
				
			||||||
 | 
					      (item.out / totalElectricity) *
 | 
				
			||||||
 | 
					      100
 | 
				
			||||||
 | 
					    ).toFixed(2)}%)`,
 | 
				
			||||||
    value: Number(item.out),
 | 
					    value: Number(item.out),
 | 
				
			||||||
  }));
 | 
					  }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -5,36 +5,33 @@
 | 
				
			|||||||
    mode="horizontal"
 | 
					    mode="horizontal"
 | 
				
			||||||
    @select="handleSelect"
 | 
					    @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="elecPricing">電價表</el-menu-item>
 | 
				
			||||||
    <el-menu-item index="monthlyReport">能源報表</el-menu-item>
 | 
					    <el-menu-item index="monthlyReport">能源報表</el-menu-item>
 | 
				
			||||||
  </el-menu>
 | 
					  </el-menu>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script setup lang="ts">
 | 
					<script setup lang="ts">
 | 
				
			||||||
import { ref } from "vue";
 | 
					import { ref, onMounted } from "vue";
 | 
				
			||||||
import { useRouter } from "vue-router";
 | 
					import { useRouter, useRoute } from "vue-router";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const router = useRouter();
 | 
					const router = useRouter();
 | 
				
			||||||
const activeIndex = ref("chart"); // Set initial active index
 | 
					const route = useRoute();
 | 
				
			||||||
const handleSelect = (key: string, keyPath: string[]) => {
 | 
					 | 
				
			||||||
  console.log(key, keyPath);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  switch (key) {
 | 
					const activeIndex = ref(""); 
 | 
				
			||||||
    case "chart":
 | 
					
 | 
				
			||||||
      router.push({ name: "EnergyChart" });
 | 
					const updateActiveIndex = () => {
 | 
				
			||||||
      activeIndex.value = "chart";
 | 
					  activeIndex.value = String(route.name || "");
 | 
				
			||||||
      break;
 | 
					 | 
				
			||||||
    case "elecPricing":
 | 
					 | 
				
			||||||
      router.push({ name: "elecPricing" });
 | 
					 | 
				
			||||||
      activeIndex.value = "elecPricing";
 | 
					 | 
				
			||||||
      break;
 | 
					 | 
				
			||||||
    case "monthlyReport":
 | 
					 | 
				
			||||||
      router.push({ name: "monthlyReport" });
 | 
					 | 
				
			||||||
      activeIndex.value = "monthlyReport";
 | 
					 | 
				
			||||||
      break;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const handleSelect = (key: string) => {
 | 
				
			||||||
 | 
					  router.push({ name: key }); 
 | 
				
			||||||
 | 
					  activeIndex.value = key;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					onMounted(() => {
 | 
				
			||||||
 | 
					  updateActiveIndex(); 
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<style scoped></style>
 | 
					<style scoped></style>
 | 
				
			||||||
@ -392,18 +392,21 @@ const elecUsageData = computed(() => {
 | 
				
			|||||||
        type: "bar",
 | 
					        type: "bar",
 | 
				
			||||||
        data: peakData,
 | 
					        data: peakData,
 | 
				
			||||||
        itemStyle: { color: "#5470c6" },
 | 
					        itemStyle: { color: "#5470c6" },
 | 
				
			||||||
 | 
					        stack: "total",
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        name: "半尖峰用電",
 | 
					        name: "半尖峰用電",
 | 
				
			||||||
        type: "bar",
 | 
					        type: "bar",
 | 
				
			||||||
        data: halfPeakData,
 | 
					        data: halfPeakData,
 | 
				
			||||||
        itemStyle: { color: "#91cc75" },
 | 
					        itemStyle: { color: "#91cc75" },
 | 
				
			||||||
 | 
					        stack: "total",
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        name: "離峰用電",
 | 
					        name: "離峰用電",
 | 
				
			||||||
        type: "bar",
 | 
					        type: "bar",
 | 
				
			||||||
        data: offPeakData,
 | 
					        data: offPeakData,
 | 
				
			||||||
        itemStyle: { color: "#fac858" },
 | 
					        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";
 | 
					import type { RouteRecordRaw } from "vue-router";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const routes: Array<RouteRecordRaw> = [
 | 
					const routes: Array<RouteRecordRaw> = [
 | 
				
			||||||
@ -37,7 +37,7 @@ const routes: Array<RouteRecordRaw> = [
 | 
				
			|||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const router = createRouter({
 | 
					const router = createRouter({
 | 
				
			||||||
  history: createWebHistory(),
 | 
					  history: createWebHashHistory(import.meta.env.BASE_URL),
 | 
				
			||||||
  routes,
 | 
					  routes,
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,7 @@ const useElecDemandStore = defineStore("elecDemand", () => {
 | 
				
			|||||||
      window.requirejs(["baja!"], (baja: any) => {
 | 
					      window.requirejs(["baja!"], (baja: any) => {
 | 
				
			||||||
        let eleclist: NiagaraElecDemandData[] = [];
 | 
					        let eleclist: NiagaraElecDemandData[] = [];
 | 
				
			||||||
        baja.Ord.make(
 | 
					        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({
 | 
					        ).get({
 | 
				
			||||||
          cursor: {
 | 
					          cursor: {
 | 
				
			||||||
            before: () => {},
 | 
					            before: () => {},
 | 
				
			||||||
@ -41,7 +41,7 @@ const useElecDemandStore = defineStore("elecDemand", () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const subscribeToHistory = (item: NiagaraElecDemandData, index: number) => {
 | 
					  const subscribeToHistory = (item: NiagaraElecDemandData, index: number) => {
 | 
				
			||||||
    const slotPath = item.slotPath;
 | 
					    const slotPath = item.slotPath;
 | 
				
			||||||
    const ordString = `local:|foxs:4918|station:|${slotPath}`;
 | 
					    const ordString = `local:|foxs:|station:|${slotPath}`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    window.require &&
 | 
					    window.require &&
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ const useElecStore = defineStore("elecDist", () => {
 | 
				
			|||||||
        console.log("進入 bajaSubscriber 準備執行 BQL 訂閱");
 | 
					        console.log("進入 bajaSubscriber 準備執行 BQL 訂閱");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 定義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 查詢
 | 
					        // 執行各電表的 BQL 查詢
 | 
				
			||||||
        fetchElecData(baja, subSysKwhBql);
 | 
					        fetchElecData(baja, subSysKwhBql);
 | 
				
			||||||
@ -51,12 +51,12 @@ const useElecStore = defineStore("elecDist", () => {
 | 
				
			|||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const subscribeToHistory = (item: NiagaraElecData) => {
 | 
					  const subscribeToHistory = (item: NiagaraElecData) => {
 | 
				
			||||||
    const startTime = dayjs()
 | 
					    const startTime = dayjs("2025-05-08T16:30:00.000+08:00")
 | 
				
			||||||
      .subtract(2, "hour")
 | 
					      .subtract(2, "hour")
 | 
				
			||||||
      .format("YYYY-MM-DDTHH:mm:ss.000+08:00"); // 現在時間前2個小時
 | 
					      .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 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);
 | 
					     console.log(ordString);
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    window.require &&
 | 
					    window.require &&
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ const useElecPriceStore = defineStore("elecPriceData", () => {
 | 
				
			|||||||
        console.log("進入 bajaSubscriber 準備執行 BQL 訂閱");
 | 
					        console.log("進入 bajaSubscriber 準備執行 BQL 訂閱");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 定義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);
 | 
					        fetchElecData(baja, Total_kwhBql);
 | 
				
			||||||
@ -51,7 +51,7 @@ const useElecPriceStore = defineStore("elecPriceData", () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const subscribeToCost = (item: NiagaraElecData, index: number) => {
 | 
					  const subscribeToCost = (item: NiagaraElecData, index: number) => {
 | 
				
			||||||
    const slotPath = item.slotPath;
 | 
					    const slotPath = item.slotPath;
 | 
				
			||||||
    const ordString = `local:|foxs:4918|station:|${slotPath}`;
 | 
					    const ordString = `local:|foxs:|station:|${slotPath}`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    window.require &&
 | 
					    window.require &&
 | 
				
			||||||
 | 
				
			|||||||
@ -35,7 +35,7 @@ const useElecReportStore = defineStore("elecReportData", () => {
 | 
				
			|||||||
        console.log("進入 bajaSubscriber 準備執行用電度數 BQL 訂閱");
 | 
					        console.log("進入 bajaSubscriber 準備執行用電度數 BQL 訂閱");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 定義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 查詢
 | 
					        // 執行各電表的 BQL 查詢
 | 
				
			||||||
        fetchElecData(baja, Total_kwhBql);
 | 
					        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");
 | 
					      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);
 | 
					    console.log(ordString);
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    window.require &&
 | 
					    window.require &&
 | 
				
			||||||
 | 
				
			|||||||
@ -24,7 +24,7 @@ const useElecStore = defineStore("elecData", () => {
 | 
				
			|||||||
        console.log("進入 bajaSubscriber 準備執行用電度數 BQL 訂閱");
 | 
					        console.log("進入 bajaSubscriber 準備執行用電度數 BQL 訂閱");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 定義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 查詢
 | 
					        // 執行各電表的 BQL 查詢
 | 
				
			||||||
        fetchElecData(baja, Total_kwhBql);
 | 
					        fetchElecData(baja, Total_kwhBql);
 | 
				
			||||||
@ -65,7 +65,7 @@ const useElecStore = defineStore("elecData", () => {
 | 
				
			|||||||
    ).format("YYYY-MM-DDTHH:mm:ss.000+08:00");
 | 
					    ).format("YYYY-MM-DDTHH:mm:ss.000+08:00");
 | 
				
			||||||
    const endTime = dayjs().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);
 | 
					    console.log(ordString);
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    window.require &&
 | 
					    window.require &&
 | 
				
			||||||
 | 
				
			|||||||
@ -135,14 +135,14 @@ const statisticData = computed(() => {
 | 
				
			|||||||
      value: storeElecTotal.elecFlowCostSummary?.totalFlowCost || 0,
 | 
					      value: storeElecTotal.elecFlowCostSummary?.totalFlowCost || 0,
 | 
				
			||||||
      unit: "元",
 | 
					      unit: "元",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    { title: "區間電費", value: intervalFlowCost, unit: "元" },
 | 
					    { title: "當月電費", value: intervalFlowCost, unit: "元" },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      title: "今年碳排當量累計",
 | 
					      title: "今年碳排當量累計",
 | 
				
			||||||
      value: storeElecTotal.elecFlowCostSummary?.totalEleCost * 0.424,
 | 
					      value: storeElecTotal.elecFlowCostSummary?.totalEleCost * 0.424,
 | 
				
			||||||
      unit: "公斤 CO2e/度",
 | 
					      unit: "公斤 CO2e/度",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      title: "區間碳排當量",
 | 
					      title: "當月碳排當量",
 | 
				
			||||||
      value: intervalEleCost * 0.424,
 | 
					      value: intervalEleCost * 0.424,
 | 
				
			||||||
      unit: "公斤 CO2e/度",
 | 
					      unit: "公斤 CO2e/度",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@ -151,7 +151,7 @@ const statisticData = computed(() => {
 | 
				
			|||||||
      value: storeElecTotal.elecFlowCostSummary?.totalEleCost || 0,
 | 
					      value: storeElecTotal.elecFlowCostSummary?.totalEleCost || 0,
 | 
				
			||||||
      unit: "kWh",
 | 
					      unit: "kWh",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    { title: "區間用電度數", value: intervalEleCost, unit: "kWh" },
 | 
					    { title: "當月用電度數", value: intervalEleCost, unit: "kWh" },
 | 
				
			||||||
  ];
 | 
					  ];
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -197,12 +197,16 @@ const monthlyElectricityData = computed(() => {
 | 
				
			|||||||
    dayjs().month(month).valueOf()
 | 
					    dayjs().month(month).valueOf()
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const baseElecData = storeElecTotal.elecStandCostSummary.StandResults.map(item => item.StandCost); 
 | 
					  const baseElecData = storeElecTotal.elecStandCostSummary.StandResults.map(
 | 
				
			||||||
  const flowElecData = sortedCategories.map(
 | 
					    (item) => Number(item.StandCost.toFixed(2))
 | 
				
			||||||
    (month) => groupedData[month].totalCost
 | 
					  );
 | 
				
			||||||
 | 
					  const flowElecData = sortedCategories.map((month) =>
 | 
				
			||||||
 | 
					    Number(groupedData[month].totalCost.toFixed(2))
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  const totalElecData = sortedCategories.map((month, index) => {
 | 
					  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 {
 | 
					  return {
 | 
				
			||||||
@ -212,16 +216,19 @@ const monthlyElectricityData = computed(() => {
 | 
				
			|||||||
        name: "基本電費",
 | 
					        name: "基本電費",
 | 
				
			||||||
        type: "bar",
 | 
					        type: "bar",
 | 
				
			||||||
        data: baseElecData,
 | 
					        data: baseElecData,
 | 
				
			||||||
 | 
					        stack: "total",
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        name: "流動電費",
 | 
					        name: "流動電費",
 | 
				
			||||||
        type: "bar",
 | 
					        type: "bar",
 | 
				
			||||||
        data: flowElecData,
 | 
					        data: flowElecData,
 | 
				
			||||||
 | 
					        stack: "total",
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        name: "總電費",
 | 
					        name: "總電費",
 | 
				
			||||||
        type: "bar",
 | 
					        type: "line",
 | 
				
			||||||
        data: totalElecData,
 | 
					        data: totalElecData,
 | 
				
			||||||
 | 
					        lineStyle: { width: 3 },
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
@ -252,6 +259,7 @@ const monthlyCarbonData = computed(() => {
 | 
				
			|||||||
        name: "碳排當量",
 | 
					        name: "碳排當量",
 | 
				
			||||||
        type: "bar",
 | 
					        type: "bar",
 | 
				
			||||||
        data: carbonData,
 | 
					        data: carbonData,
 | 
				
			||||||
 | 
					        stack: "total",
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
@ -278,9 +286,9 @@ const monthlyBillingData = computed(() => {
 | 
				
			|||||||
  return {
 | 
					  return {
 | 
				
			||||||
    categories: sortedCategories,
 | 
					    categories: sortedCategories,
 | 
				
			||||||
    series: [
 | 
					    series: [
 | 
				
			||||||
      { name: "尖峰", type: "bar", data: peakData },
 | 
					      { name: "尖峰", type: "bar", data: peakData, stack: "total" },
 | 
				
			||||||
      { name: "半尖峰", type: "bar", data: halfData },
 | 
					      { name: "半尖峰", type: "bar", data: halfData, stack: "total" },
 | 
				
			||||||
      { name: "離峰", type: "bar", data: offData },
 | 
					      { name: "離峰", type: "bar", data: offData, stack: "total" },
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
@ -331,9 +339,9 @@ const areaBillingData = computed(() => {
 | 
				
			|||||||
  return {
 | 
					  return {
 | 
				
			||||||
    categories: sortedCategories,
 | 
					    categories: sortedCategories,
 | 
				
			||||||
    series: [
 | 
					    series: [
 | 
				
			||||||
      { name: "尖峰", type: "bar", data: peakData },
 | 
					      { name: "尖峰", type: "bar", data: peakData, stack: "total" },
 | 
				
			||||||
      { name: "半尖峰", type: "bar", data: halfData },
 | 
					      { name: "半尖峰", type: "bar", data: halfData, stack: "total" },
 | 
				
			||||||
      { name: "離峰", type: "bar", data: offData },
 | 
					      { name: "離峰", type: "bar", data: offData, stack: "total" },
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
@ -54,7 +54,7 @@
 | 
				
			|||||||
            <td colspan="2" class="bg-brown">
 | 
					            <td colspan="2" class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[0]"
 | 
					                v-model="stand3Value[0]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -65,7 +65,7 @@
 | 
				
			|||||||
            <td colspan="2" class="bg-brown">
 | 
					            <td colspan="2" class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[1]"
 | 
					                v-model="stand3Value[1]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -77,7 +77,7 @@
 | 
				
			|||||||
            <td class="bg-brown">
 | 
					            <td class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[2]"
 | 
					                v-model="stand3Value[2]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -85,7 +85,7 @@
 | 
				
			|||||||
            <td class="bg-brown">
 | 
					            <td class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[3]"
 | 
					                v-model="stand3Value[3]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -96,7 +96,7 @@
 | 
				
			|||||||
            <td class="bg-brown">
 | 
					            <td class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[4]"
 | 
					                v-model="stand3Value[4]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -104,7 +104,7 @@
 | 
				
			|||||||
            <td class="bg-brown">
 | 
					            <td class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[5]"
 | 
					                v-model="stand3Value[5]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -115,7 +115,7 @@
 | 
				
			|||||||
            <td class="bg-brown">
 | 
					            <td class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[6]"
 | 
					                v-model="stand3Value[6]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -123,7 +123,7 @@
 | 
				
			|||||||
            <td class="bg-brown">
 | 
					            <td class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[7]"
 | 
					                v-model="stand3Value[7]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -134,7 +134,7 @@
 | 
				
			|||||||
            <td class="bg-brown">
 | 
					            <td class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[8]"
 | 
					                v-model="stand3Value[8]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -142,7 +142,7 @@
 | 
				
			|||||||
            <td class="bg-brown">
 | 
					            <td class="bg-brown">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[9]"
 | 
					                v-model="stand3Value[9]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -158,7 +158,7 @@
 | 
				
			|||||||
            <td class="bg-lightred">
 | 
					            <td class="bg-lightred">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[10]"
 | 
					                v-model="stand3Value[10]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -172,7 +172,7 @@
 | 
				
			|||||||
            <td class="bg-lightyellow">
 | 
					            <td class="bg-lightyellow">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[11]"
 | 
					                v-model="stand3Value[11]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -186,7 +186,7 @@
 | 
				
			|||||||
            <td class="bg-lightyellow">
 | 
					            <td class="bg-lightyellow">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[12]"
 | 
					                v-model="stand3Value[12]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -199,7 +199,7 @@
 | 
				
			|||||||
            <td class="bg-lightgreen">
 | 
					            <td class="bg-lightgreen">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[13]"
 | 
					                v-model="stand3Value[13]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -216,7 +216,7 @@
 | 
				
			|||||||
            <td class="bg-lightgreen">
 | 
					            <td class="bg-lightgreen">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[14]"
 | 
					                v-model="stand3Value[14]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -230,7 +230,7 @@
 | 
				
			|||||||
            <td class="bg-lightyellow">
 | 
					            <td class="bg-lightyellow">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[15]"
 | 
					                v-model="stand3Value[15]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -247,7 +247,7 @@
 | 
				
			|||||||
            <td class="bg-lightyellow">
 | 
					            <td class="bg-lightyellow">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[16]"
 | 
					                v-model="stand3Value[16]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -260,7 +260,7 @@
 | 
				
			|||||||
            <td class="bg-lightgreen">
 | 
					            <td class="bg-lightgreen">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[17]"
 | 
					                v-model="stand3Value[17]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -274,7 +274,7 @@
 | 
				
			|||||||
            <td class="bg-lightgreen">
 | 
					            <td class="bg-lightgreen">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[18]"
 | 
					                v-model="stand3Value[18]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -287,7 +287,7 @@
 | 
				
			|||||||
            <td class="bg-lightgreen">
 | 
					            <td class="bg-lightgreen">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[19]"
 | 
					                v-model="stand3Value[19]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -295,7 +295,7 @@
 | 
				
			|||||||
            <td class="bg-lightgreen">
 | 
					            <td class="bg-lightgreen">
 | 
				
			||||||
              <el-input
 | 
					              <el-input
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                v-model.number="stand3Value[20]"
 | 
					                v-model="stand3Value[20]"
 | 
				
			||||||
                style="width: 140px"
 | 
					                style="width: 140px"
 | 
				
			||||||
                :disabled="!stand3isEditing"
 | 
					                :disabled="!stand3isEditing"
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
@ -367,10 +367,20 @@ const confirmChanges = async () => {
 | 
				
			|||||||
  const failedUpdates: { slotPath: string; out: number }[] = [];
 | 
					  const failedUpdates: { slotPath: string; out: number }[] = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!elecData || elecData.length === 0) {
 | 
					  if (!elecData || elecData.length === 0) {
 | 
				
			||||||
    console.warn("useElecPriceStore.elecData 為空,無法更新 stand3Value");
 | 
					    // @ts-ignore
 | 
				
			||||||
 | 
					    ElMessage({
 | 
				
			||||||
 | 
					      message: "資料為空,無法更新",
 | 
				
			||||||
 | 
					      type: "warning",
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
    return;
 | 
					    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++) {
 | 
					    for (let i = 0; i < stand3Value.value.length; i++) {
 | 
				
			||||||
      if (stand3Value.value[i] !== beforeEditValues.value[i]) {
 | 
					      if (stand3Value.value[i] !== beforeEditValues.value[i]) {
 | 
				
			||||||
@ -387,18 +397,24 @@ const confirmChanges = async () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (displayName) {
 | 
					        if (displayName) {
 | 
				
			||||||
          // 查找 elecData 中對應的 item
 | 
					          // 查找 elecData 中對應的 item
 | 
				
			||||||
        const item = elecData.find((item) => item.displayName === displayName);
 | 
					          const item = elecData.find(
 | 
				
			||||||
 | 
					            (item) => item.displayName === displayName
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
          if (item) {
 | 
					          if (item) {
 | 
				
			||||||
            // 移除 "slot:/" 前綴
 | 
					            // 移除 "slot:/" 前綴
 | 
				
			||||||
            const slotPath = item.slotPath.startsWith("slot:/")
 | 
					            const slotPath = item.slotPath.startsWith("slot:/")
 | 
				
			||||||
              ? item.slotPath.slice(6) // 移除 "slot:/"
 | 
					              ? item.slotPath.slice(6) // 移除 "slot:/"
 | 
				
			||||||
              : item.slotPath; // 如果没有前綴,則保持不變
 | 
					              : item.slotPath; // 如果没有前綴,則保持不變
 | 
				
			||||||
            // 更新 Niagara
 | 
					            // 更新 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) {
 | 
					            if (!success) {
 | 
				
			||||||
              failedUpdates.push({
 | 
					              failedUpdates.push({
 | 
				
			||||||
                slotPath: item.slotPath,
 | 
					                slotPath: item.slotPath,
 | 
				
			||||||
              out: stand3Value.value[i],
 | 
					                out: Number(stand3Value.value[i]),
 | 
				
			||||||
              });
 | 
					              });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
@ -411,13 +427,21 @@ const confirmChanges = async () => {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (failedUpdates.length > 0) {
 | 
					    if (failedUpdates.length > 0) {
 | 
				
			||||||
 | 
					      // @ts-ignore
 | 
				
			||||||
 | 
					      ElMessage.error("更新失敗");
 | 
				
			||||||
      console.error("以下更新失敗:", failedUpdates);
 | 
					      console.error("以下更新失敗:", failedUpdates);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
 | 
					      // @ts-ignore
 | 
				
			||||||
 | 
					      ElMessage({
 | 
				
			||||||
 | 
					        message: "更新成功",
 | 
				
			||||||
 | 
					        type: "success",
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
      console.log("所有更新成功");
 | 
					      console.log("所有更新成功");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  // 更新 initialStand3Values
 | 
					 | 
				
			||||||
    initialStand3Values.value = [...stand3Value.value];
 | 
					    initialStand3Values.value = [...stand3Value.value];
 | 
				
			||||||
 | 
					  } finally {
 | 
				
			||||||
 | 
					    loading.close();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const onCancel = () => {
 | 
					const onCancel = () => {
 | 
				
			||||||
 | 
				
			|||||||
@ -4,12 +4,8 @@ import AutoImport from "unplugin-auto-import/vite";
 | 
				
			|||||||
import Components from "unplugin-vue-components/vite";
 | 
					import Components from "unplugin-vue-components/vite";
 | 
				
			||||||
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
 | 
					import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// https://vite.dev/config/
 | 
					 | 
				
			||||||
export default defineConfig({
 | 
					export default defineConfig({
 | 
				
			||||||
  base:
 | 
					  base: "./",
 | 
				
			||||||
    process.env.NODE_ENV === "production"
 | 
					 | 
				
			||||||
      ? "https://192.168.0.206:8500/file/ems_dist/"
 | 
					 | 
				
			||||||
      : "/",
 | 
					 | 
				
			||||||
  build: {
 | 
					  build: {
 | 
				
			||||||
    outDir: process.env.NODE_ENV === "production" ? "../ems_dist" : "./dist",
 | 
					    outDir: process.env.NODE_ENV === "production" ? "../ems_dist" : "./dist",
 | 
				
			||||||
    emptyOutDir: true,
 | 
					    emptyOutDir: true,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user