diff --git a/src/modules/04_system/components/cardBackupRestore.vue b/src/modules/04_system/components/cardBackupRestore.vue index 697d5cbe..af94403a 100644 --- a/src/modules/04_system/components/cardBackupRestore.vue +++ b/src/modules/04_system/components/cardBackupRestore.vue @@ -214,9 +214,9 @@ function onRestore(name: string) { ? col.value : col.value === "สำเร็จ" ? "สำเร็จ" - : i === 2 || i === 3 - ? getSize(col.value) - : "" + : // : i === 2 || i === 3 + // ? getSize(col.value) + "" }} { data: { name: filename }, }) .then(async (res) => { - await fetchListBackup(); + if (res.status < 400) { + dataBackUp.value = dataBackUp.value.filter((item) => { + if (item.name !== filename) return true; + return false; + }); + } }) .finally(() => { hideLoader(); @@ -109,8 +114,8 @@ export const useDataStore = defineStore("systemStore", () => { .then(async (res) => { backupRunTotal.value = res.data.length; - if (backupRunTotal.value === 0 && prevBackupRunTotal.value !== 0) { - cb(); + if (backupRunTotal.value === 0) { + if (prevBackupRunTotal.value !== -1) cb(); prevBackupRunTotal.value = backupRunTotal.value; return; } @@ -147,7 +152,7 @@ export const useDataStore = defineStore("systemStore", () => { .get(config.API.backup + "/restore-running-list") .then(async (res) => { restoreRunTotal.value = res.data.length; - if (restoreRunTotal.value === 0 && prevRestoreRunTotal.value !== 0) { + if (restoreRunTotal.value === 0) { cb(); prevRestoreRunTotal.value = restoreRunTotal.value; return; @@ -324,9 +329,13 @@ export const useDataStore = defineStore("systemStore", () => { return { dataBackUp, + backupRunTotal, restoreRunTotal, + prevBackupRunTotal, + prevRestoreRunTotal, + dataSchedule, fetchListBackup, diff --git a/src/modules/04_system/views/MainView.vue b/src/modules/04_system/views/MainView.vue index 63f196cf..a0cfa71c 100644 --- a/src/modules/04_system/views/MainView.vue +++ b/src/modules/04_system/views/MainView.vue @@ -13,12 +13,17 @@ import Card from "@/modules/04_system/components/cardBackupRestore.vue"; import CardAutoBackup from "@/modules/04_system/components/cardAutoBackup.vue"; import { useDataStore } from "@/modules/04_system/stores/main"; +import { storeToRefs } from "pinia"; const { fetchListBackup, backupRunningList, restoreRunningList } = useDataStore(); + /** * ตัวแปร */ +const storeData = useDataStore(); +const { prevBackupRunTotal, prevRestoreRunTotal } = storeToRefs(storeData); + const tab = ref("backup"); const tabItems = ref([ { name: "backup", label: "Backup & Restore", icon: "mdi-database" }, @@ -26,6 +31,8 @@ const tabItems = ref([ ]); onMounted(async () => { + prevBackupRunTotal.value = -1; + prevRestoreRunTotal.value = -1; await fetchListBackup(); await backupRunningList(fetchListBackup); await restoreRunningList(() => {});