by ข้อมูล backUp
This commit is contained in:
parent
f28d426b17
commit
662d8fa7b3
1 changed files with 14 additions and 44 deletions
|
|
@ -12,6 +12,8 @@ import type { DataBackup } from "@/modules/04_system/interface/response/Main";
|
||||||
* importStore
|
* importStore
|
||||||
*/
|
*/
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { useDataStore } from "@/modules/04_system/stores/main";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* use
|
* use
|
||||||
|
|
@ -19,6 +21,9 @@ import { useCounterMixin } from "@/stores/mixin";
|
||||||
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 storeData = useDataStore();
|
||||||
|
const { dataBackUp } = storeToRefs(storeData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* props
|
* props
|
||||||
|
|
@ -28,7 +33,6 @@ const tab = defineModel<string>("tab", { required: true });
|
||||||
/**
|
/**
|
||||||
* Table
|
* Table
|
||||||
*/
|
*/
|
||||||
const rows = ref<DataBackup[]>([]);
|
|
||||||
const filter = ref<string>("");
|
const filter = ref<string>("");
|
||||||
const visibleColumns = ref<string[]>(["name", "createAt", "status"]);
|
const visibleColumns = ref<string[]>(["name", "createAt", "status"]);
|
||||||
const baseColumns = ref<QTableProps["columns"]>([
|
const baseColumns = ref<QTableProps["columns"]>([
|
||||||
|
|
@ -50,15 +54,6 @@ const baseColumns = ref<QTableProps["columns"]>([
|
||||||
headerStyle: "font-size: 14px",
|
headerStyle: "font-size: 14px",
|
||||||
style: "font-size: 14px",
|
style: "font-size: 14px",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "status",
|
|
||||||
align: "left",
|
|
||||||
label: "สถานะ",
|
|
||||||
sortable: true,
|
|
||||||
field: "status",
|
|
||||||
headerStyle: "font-size: 14px",
|
|
||||||
style: "font-size: 14px",
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
const columns = computed(() => {
|
const columns = computed(() => {
|
||||||
if (tab.value === "restore") {
|
if (tab.value === "restore") {
|
||||||
|
|
@ -69,40 +64,15 @@ const columns = computed(() => {
|
||||||
return baseColumns.value;
|
return baseColumns.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* function เรียกข้อมูลรายการสำรอง
|
|
||||||
*/
|
|
||||||
function fetchListBackup() {
|
|
||||||
showLoader();
|
|
||||||
const data: DataBackup[] = [
|
|
||||||
{
|
|
||||||
id: "1",
|
|
||||||
name: "สำรอง1",
|
|
||||||
createAt: new Date(),
|
|
||||||
status: "ดำเนินการ",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2",
|
|
||||||
name: "สำรอง2",
|
|
||||||
createAt: new Date(),
|
|
||||||
status: "ดำเนินการ",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
rows.value = data;
|
|
||||||
setTimeout(() => {
|
|
||||||
hideLoader();
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function สร้างรายการข้อมูสำรอง
|
* function สร้างรายการข้อมูสำรอง
|
||||||
*/
|
*/
|
||||||
function onCreateBackup() {
|
function onCreateBackup() {
|
||||||
dialogConfirm(
|
dialogConfirm(
|
||||||
$q,
|
$q,
|
||||||
() => {
|
async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
fetchListBackup();
|
await createBackUp();
|
||||||
},
|
},
|
||||||
"ยืนยันการสร้างข้อมูสำรอง",
|
"ยืนยันการสร้างข้อมูสำรอง",
|
||||||
"ต้องการยืนยันการสร้างข้อมูสำรองใช่หรือไม่?"
|
"ต้องการยืนยันการสร้างข้อมูสำรองใช่หรือไม่?"
|
||||||
|
|
@ -124,20 +94,20 @@ function onDelete(id: string) {
|
||||||
* function คืนค่าข้อมูสำรอง
|
* function คืนค่าข้อมูสำรอง
|
||||||
* @param id ข้อมูสำรอง
|
* @param id ข้อมูสำรอง
|
||||||
*/
|
*/
|
||||||
function onRestore(id: string) {
|
function onRestore(name: string) {
|
||||||
dialogConfirm(
|
dialogConfirm(
|
||||||
$q,
|
$q,
|
||||||
() => {
|
async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
fetchListBackup();
|
await restore(name);
|
||||||
},
|
},
|
||||||
"ยืนยันการคืนค่าข้อมูสำรอง",
|
"ยืนยันการคืนค่าข้อมูสำรอง",
|
||||||
"ต้องการยืนยันการคืนค่าข้อมูสำรองนี้ใช่หรือไม่?"
|
"ต้องการยืนยันการคืนค่าข้อมูสำรองนี้ใช่หรือไม่?"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
fetchListBackup();
|
await fetchListBackup();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -184,7 +154,7 @@ onMounted(() => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<d-table
|
<d-table
|
||||||
:rows="rows"
|
:rows="dataBackUp"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
row-key="name"
|
row-key="name"
|
||||||
:visible-columns="visibleColumns"
|
:visible-columns="visibleColumns"
|
||||||
|
|
@ -227,7 +197,7 @@ onMounted(() => {
|
||||||
icon="restore"
|
icon="restore"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="12px"
|
size="12px"
|
||||||
@click.petvent="onRestore(props.row.id)"
|
@click.petvent="onRestore(props.row.name)"
|
||||||
>
|
>
|
||||||
<q-tooltip>คืนค่า </q-tooltip>
|
<q-tooltip>คืนค่า </q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue