@@ -54,7 +54,7 @@
@@ -65,7 +65,7 @@
|
@@ -77,7 +77,7 @@
|
@@ -85,7 +85,7 @@
|
@@ -96,7 +96,7 @@
|
@@ -104,7 +104,7 @@
|
@@ -115,7 +115,7 @@
|
@@ -123,7 +123,7 @@
|
@@ -134,7 +134,7 @@
|
@@ -142,7 +142,7 @@
|
@@ -158,7 +158,7 @@
|
@@ -172,7 +172,7 @@
|
@@ -186,7 +186,7 @@
|
@@ -199,7 +199,7 @@
|
@@ -216,7 +216,7 @@
|
@@ -230,7 +230,7 @@
|
@@ -247,7 +247,7 @@
|
@@ -260,7 +260,7 @@
|
@@ -274,7 +274,7 @@
|
@@ -287,7 +287,7 @@
|
@@ -295,7 +295,7 @@
|
@@ -367,57 +367,81 @@ 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]) {
+ // 找到對應的 displayName
+ const displayName = Object.keys(displayNameToIndex).find((key) => {
+ const index = displayNameToIndex[key];
+ if (typeof index === "number") {
+ return index === i;
+ } else if (Array.isArray(index)) {
+ return index.includes(i);
+ }
+ return false;
+ });
- // 循環遍歷所有值,找出修改過的
- for (let i = 0; i < stand3Value.value.length; i++) {
- if (stand3Value.value[i] !== beforeEditValues.value[i]) {
- // 找到對應的 displayName
- const displayName = Object.keys(displayNameToIndex).find((key) => {
- const index = displayNameToIndex[key];
- if (typeof index === "number") {
- return index === i;
- } else if (Array.isArray(index)) {
- return index.includes(i);
- }
- return false;
- });
-
- if (displayName) {
- // 查找 elecData 中對應的 item
- 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]);
- if (!success) {
- failedUpdates.push({
- slotPath: item.slotPath,
- out: stand3Value.value[i],
- });
+ if (displayName) {
+ // 查找 elecData 中對應的 item
+ 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
+ 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: Number(stand3Value.value[i]),
+ });
+ }
+ } else {
+ console.warn(`找不到 displayName 為 ${displayName} 的 elecData`);
}
} else {
- console.warn(`找不到 displayName 為 ${displayName} 的 elecData`);
+ console.warn(`找不到 index 為 ${i} 的 displayName`);
}
- } else {
- console.warn(`找不到 index 為 ${i} 的 displayName`);
}
}
- }
- if (failedUpdates.length > 0) {
- console.error("以下更新失敗:", failedUpdates);
- } else {
- console.log("所有更新成功");
+ if (failedUpdates.length > 0) {
+ // @ts-ignore
+ ElMessage.error("更新失敗");
+ console.error("以下更新失敗:", failedUpdates);
+ } else {
+ // @ts-ignore
+ ElMessage({
+ message: "更新成功",
+ type: "success",
+ });
+ console.log("所有更新成功");
+ }
+ initialStand3Values.value = [...stand3Value.value];
+ } finally {
+ loading.close();
}
-
- // 更新 initialStand3Values
- initialStand3Values.value = [...stand3Value.value];
};
const onCancel = () => {
@@ -515,4 +539,4 @@ td {
.bg-lightyellow {
background: #f3e5a3;
}
-
\ No newline at end of file
+
diff --git a/src/views/MonthlyReport.vue b/src/views/MonthlyReport.vue
index 87ec679..f4664db 100644
--- a/src/views/MonthlyReport.vue
+++ b/src/views/MonthlyReport.vue
@@ -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,8 +121,12 @@ const handleClose = () => {
// 觸發 PDF 生成和下載
const generatePDF = async () => {
- if (html2Pdf.value) {
- await html2Pdf.value.generatePdf();
+ try {
+ if (html2Pdf.value) {
+ await html2Pdf.value.generatePdf();
+ }
+ } catch (error) {
+ console.error("PDF生成失敗:", error);
}
};
diff --git a/vite.config.ts b/vite.config.ts
index 70b077e..df239bd 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -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,
|