Refactoring code module 04_system

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-09 16:21:28 +07:00
parent 2e9bbe3dd1
commit 6154ebf41d
5 changed files with 95 additions and 115 deletions

View file

@ -1,12 +1,11 @@
<script setup lang="ts">
import { ref, onMounted, computed } from "vue";
import { ref } from "vue";
import { useQuasar } from "quasar";
/**
* importType
*/
import type { QTableProps } from "quasar";
import type { DataBackup } from "@/modules/04_system/interface/response/Main";
/**
* importStore
@ -19,25 +18,12 @@ import { storeToRefs } from "pinia";
* use
*/
const $q = useQuasar();
const { showLoader, hideLoader, date2Thai, dialogRemove, dialogConfirm } =
const { showLoader, date2Thai, dialogRemove, dialogConfirm } =
useCounterMixin();
const {
fetchListBackup,
createBackUp,
restore,
deleteBackUp,
backupRunningList,
restoreRunningList,
getSize,
} = useDataStore();
const { createBackUp, restore, deleteBackUp } = useDataStore();
const storeData = useDataStore();
const { dataBackUp, backupRunTotal, restoreRunTotal } = storeToRefs(storeData);
/**
* props
*/
const tab = defineModel<string>("tab", { required: true });
/**
* Table
*/
@ -49,7 +35,7 @@ const visibleColumns = ref<string[]>([
"storageSize",
"status",
]);
const baseColumns = ref<QTableProps["columns"]>([
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
@ -64,32 +50,12 @@ const baseColumns = ref<QTableProps["columns"]>([
align: "center",
label: "วันที่สร้าง",
sortable: true,
// field: (v) => date2Thai(v, false, true),
field: "timestamp",
format: (v) => date2Thai(v, false, true),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
// {
// name: "databaseSize",
// align: "center",
// label: " ",
// sortable: true,
// // field: (v) => date2Thai(v, false, true),
// field: "databaseSize",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// },
// {
// name: "storageSize",
// align: "center",
// label: " ",
// sortable: true,
// // field: (v) => date2Thai(v, false, true),
// field: "storageSize",
// headerStyle: "font-size: 14px",
// style: "font-size: 14px",
// },
{
name: "status",
align: "center",
@ -100,9 +66,6 @@ const baseColumns = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const columns = computed(() => {
return baseColumns.value;
});
/**
* function สรางรายการขอมลสำรอง

View file

@ -35,32 +35,14 @@ const {
dialogMessageNotify,
} = useCounterMixin();
const {
fetchListBackup,
createBackUp,
restore,
deleteBackUp,
backupRunningList,
restoreRunningList,
getSize,
getSchedule,
createSchedule,
editSchedule,
deleteSchedule,
toggleSchedule,
} = useDataStore();
const storeData = useDataStore();
const { dataBackUp, restoreRunTotal, dataSchedule } = storeToRefs(storeData);
/**
* props
*/
/**
* ref
*/
const { restoreRunTotal, dataSchedule } = storeToRefs(storeData);
const idEditSchedule = ref<string>("");
const openDialog = ref<boolean>(false);
@ -94,7 +76,7 @@ const visibleColumns = ref<string[]>([
"startAt",
"status",
]);
const baseColumns = ref<QTableProps["columns"]>([
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
@ -145,14 +127,6 @@ const baseColumns = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const columns = computed(() => {
return baseColumns.value;
});
/**
* function assignDataformDataschedule() iรบคาเข formDataschedule
*
*/
function assignDataformDataschedule(data: Schedule) {
typeTime.value = data.time !== "" ? "set" : "start";
@ -251,25 +225,8 @@ function onDelete(id: string) {
});
}
/**
* function นคาขอมลสำรอง
* @param id อมลสำรอง
*/
function onRestore(id: string) {
dialogConfirm(
$q,
async () => {
await restore(id);
},
"ยืนยันการคืนค่าข้อมูลสำรอง",
"ต้องการยืนยันการคืนค่าข้อมูลสำรองนี้ใช่หรือไม่?"
);
}
const typeOnSubmit = ref<"edit" | "create">("create");
const dateStart = ref<string>("");
const typeTime = ref<string>("set");
const timeStartEvery = ref<number>();
const tab = ref<string>("daily");
const tabItems = ref<ItemsTeb[]>([
{ name: "daily", label: "ทุกวัน", icon: "" },
@ -312,10 +269,6 @@ function clearForm() {
formDataschedule.value.schedule = "";
}
onMounted(async () => {
getSchedule();
});
watch(tab, () => {
if (tab.value === formDataschedule.value.type) {
formDataschedule.value = { ...prevFormDataschedule.value };
@ -327,6 +280,10 @@ watch(tab, () => {
typeTime.value = "set";
}
});
onMounted(async () => {
getSchedule();
});
</script>
<template>

View file

@ -1,16 +1,16 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { watch } from "vue";
import { useCounterMixin } from "@/stores/mixin";
const { date2Thai } = useCounterMixin();
const name = defineModel<string>("name");
const name = defineModel<string>("name"); //
const typeTime = defineModel<string>("typeTime", { default: "set" });
const time = defineModel<string>("time");
const time = defineModel<string>("time"); //
const timeStartEvery = defineModel<string>("timeStartEvery");
const startAt = defineModel<any>("startAt", { default: new Date() });
const selectDate = defineModel<string[]>("date", { default: [] });
const tab = defineModel<string>("tab");
const startAt = defineModel<any>("startAt", { default: new Date() }); // -
const selectDate = defineModel<string[]>("date", { default: [] }); //
const tab = defineModel<string>("tab"); //
const timeStartEveryOptions: { value: string }[] = Array.from(
{ length: 24 },