เพิ่ม ลบ backUp

This commit is contained in:
Net 2024-07-10 17:51:13 +07:00
parent 662d8fa7b3
commit c417262c6a
2 changed files with 23 additions and 7 deletions

View file

@ -21,7 +21,7 @@ import { storeToRefs } from "pinia";
const $q = useQuasar(); const $q = useQuasar();
const { showLoader, hideLoader, date2Thai, dialogRemove, dialogConfirm } = const { showLoader, hideLoader, date2Thai, dialogRemove, dialogConfirm } =
useCounterMixin(); useCounterMixin();
const { fetchListBackup, createBackUp, restore } = useDataStore(); const { fetchListBackup, createBackUp, restore, deleteBackUp } = useDataStore();
const storeData = useDataStore(); const storeData = useDataStore();
const { dataBackUp } = storeToRefs(storeData); const { dataBackUp } = storeToRefs(storeData);
@ -83,10 +83,10 @@ function onCreateBackup() {
* function ลบรายการขอมสำรอง * function ลบรายการขอมสำรอง
* @param id รายการสำรอง * @param id รายการสำรอง
*/ */
function onDelete(id: string) { function onDelete(name: string) {
dialogRemove($q, () => { dialogRemove($q, async () => {
showLoader(); showLoader();
fetchListBackup(); deleteBackUp(name);
}); });
} }
@ -184,7 +184,7 @@ onMounted(async () => {
icon="delete" icon="delete"
color="red" color="red"
size="12px" size="12px"
@click.petvent="onDelete(props.row.id)" @click.petvent="onDelete(props.row.name)"
> >
<q-tooltip>ลบขอมลสำรอง </q-tooltip> <q-tooltip>ลบขอมลสำรอง </q-tooltip>
</q-btn> </q-btn>

View file

@ -41,7 +41,20 @@ export const useDataStore = defineStore("storeData", () => {
fetchListBackup(); fetchListBackup();
}) })
.finally(() => { .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(); hideLoader();
}); });
} }
@ -49,7 +62,9 @@ export const useDataStore = defineStore("storeData", () => {
async function restore(filename: string) { async function restore(filename: string) {
showLoader(); showLoader();
await http await http
.post(config.API.restore + "?filename=" + filename + "") .post(config.API.restore, {
filename: filename,
})
.then((res) => { .then((res) => {
fetchListBackup(); fetchListBackup();
}) })
@ -64,5 +79,6 @@ export const useDataStore = defineStore("storeData", () => {
fetchListBackup, fetchListBackup,
createBackUp, createBackUp,
restore, restore,
deleteBackUp,
}; };
}); });