Refactoring code module 06_retirement

This commit is contained in:
STW_TTTY\stwtt 2024-09-18 15:18:57 +07:00
parent 1225254062
commit ea921b39b0
29 changed files with 730 additions and 823 deletions

View file

@ -2,17 +2,17 @@
import { ref, onMounted } from "vue";
import { useQuasar, QForm } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
/**Import type */
import type { QTableProps } from "quasar";
import type { ResponseItems } from "@/modules/06_retirement/interface/response/exitInterview";
import DialogFooter from "@/modules/05_placement/components/PersonalList/DialogFooter.vue";
import DialogHeader from "@/components/DialogHeader.vue";
import { checkPermission } from "@/utils/permissions";
import DialogHeader from "@/components/DialogHeader.vue";
/** use */
const $q = useQuasar(); // noti quasar
@ -157,16 +157,8 @@ const modal = ref<boolean>(false);
const filterKeyword = ref<string>("");
const filterRef = ref<any>(null);
/** HOOK */
onMounted(async () => {
await fecthlist();
if (columns.value) {
visibleColumns.value = columns.value.map((r: any) => r.name);
}
});
// API
const fecthlist = async () => {
async function fecthlist() {
showLoader();
await http
.get(config.API.listExitInterview())
@ -202,10 +194,10 @@ const fecthlist = async () => {
.finally(() => {
hideLoader();
});
};
}
//
const saveAppoint = async () => {
async function saveAppoint() {
await myForm.value!.validate().then(async (result: boolean) => {
if (result) {
dialogConfirm($q, async () => {
@ -229,13 +221,13 @@ const saveAppoint = async () => {
});
}
});
};
}
/**
* งก validate DATE ไทย
* @param thaiDate นทไทย
*/
const validationDate = (thaiDate: string | null) => {
function validationDate(thaiDate: string | null) {
if (thaiDate && daterow.value) {
let a = convertThaiDateToNumeric(thaiDate);
let b = daterow.value;
@ -243,10 +235,10 @@ const validationDate = (thaiDate: string | null) => {
return a > b;
}
}
};
}
//
const convertThaiDateToNumeric = (thaiDate: string) => {
function convertThaiDateToNumeric(thaiDate: string) {
const parts = thaiDate.split(" ");
if (parts.length !== 3) return null;
const [day, month, year] = parts;
@ -267,22 +259,31 @@ const convertThaiDateToNumeric = (thaiDate: string) => {
if (!(month in monthMap)) return null;
const numericDate = `${year}${monthMap[month]}${day}`;
return numericDate;
};
}
/**
* modal Setting
*/
const openModal = () => (modal.value = true);
const closeModal = () => (modal.value = false);
const resetFilter = () => {
function resetFilter() {
filterKeyword.value = "";
filterRef.value.focus();
};
const openModalCalendar = (rows: any) => {
}
function openModalCalendar(rows: any) {
openModal();
dateBreak.value = null;
id.value = rows.id;
daterow.value = convertThaiDateToNumeric(rows.datetext);
};
}
/** HOOK */
onMounted(async () => {
await fecthlist();
if (columns.value) {
visibleColumns.value = columns.value.map((r: any) => r.name);
}
});
</script>
<template v-slot:body="props">
<div class="toptitle text-dark col-12 row items-center">
@ -445,9 +446,7 @@ const openModalCalendar = (rows: any) => {
</div>
</q-td>
<q-td key="appointDate" :props="props">
{{
props.row.appointDate ? props.row.appointDate : "-"
}}
{{ props.row.appointDate ? props.row.appointDate : "-" }}
</q-td>
<q-td key="datetext" :props="props">
{{ props.row.datetext ? props.row.datetext : "-" }}