From c417262c6ab81a40357b0ad95f04ad1dd0949394 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:51:13 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20=E0=B8=A5=E0=B8=9A=20=20backUp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/cardBackupRestore.vue | 10 +++++----- src/modules/04_system/stores/main.ts | 20 +++++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/modules/04_system/components/cardBackupRestore.vue b/src/modules/04_system/components/cardBackupRestore.vue index 17b6bcc4..90fdf943 100644 --- a/src/modules/04_system/components/cardBackupRestore.vue +++ b/src/modules/04_system/components/cardBackupRestore.vue @@ -21,7 +21,7 @@ import { storeToRefs } from "pinia"; const $q = useQuasar(); const { showLoader, hideLoader, date2Thai, dialogRemove, dialogConfirm } = useCounterMixin(); -const { fetchListBackup, createBackUp, restore } = useDataStore(); +const { fetchListBackup, createBackUp, restore, deleteBackUp } = useDataStore(); const storeData = useDataStore(); const { dataBackUp } = storeToRefs(storeData); @@ -83,10 +83,10 @@ function onCreateBackup() { * function ลบรายการข้อมูสำรอง * @param id รายการสำรอง */ -function onDelete(id: string) { - dialogRemove($q, () => { +function onDelete(name: string) { + dialogRemove($q, async () => { showLoader(); - fetchListBackup(); + deleteBackUp(name); }); } @@ -184,7 +184,7 @@ onMounted(async () => { icon="delete" color="red" size="12px" - @click.petvent="onDelete(props.row.id)" + @click.petvent="onDelete(props.row.name)" > ลบข้อมูลสำรอง diff --git a/src/modules/04_system/stores/main.ts b/src/modules/04_system/stores/main.ts index 5e7287af..d43c7683 100644 --- a/src/modules/04_system/stores/main.ts +++ b/src/modules/04_system/stores/main.ts @@ -41,7 +41,20 @@ export const useDataStore = defineStore("storeData", () => { fetchListBackup(); }) .finally(() => { - console.log("aye"); + hideLoader(); + }); + } + + async function deleteBackUp(filename: string) { + showLoader(); + await http + .delete(config.API.backup + "/delete", { + data: { filename: filename }, + }) + .then(async (res) => { + fetchListBackup(); + }) + .finally(() => { hideLoader(); }); } @@ -49,7 +62,9 @@ export const useDataStore = defineStore("storeData", () => { async function restore(filename: string) { showLoader(); await http - .post(config.API.restore + "?filename=" + filename + "") + .post(config.API.restore, { + filename: filename, + }) .then((res) => { fetchListBackup(); }) @@ -64,5 +79,6 @@ export const useDataStore = defineStore("storeData", () => { fetchListBackup, createBackUp, restore, + deleteBackUp, }; });