Refactor Code ระบบลา

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-12-15 09:58:02 +07:00
parent 75dfc3b004
commit 9498748c94
16 changed files with 202 additions and 349 deletions

View file

@ -1,23 +1,29 @@
<script setup lang="ts">
import { onMounted, ref, watch } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import type { Pagination } from "@/modules/03_recruiting/interface/index/Main";
import { useSpecialTimeStore } from "@/modules/09_leave/stores/SpecialTimeStore";
import DialogReason from "@/components/Dialogs/PopupReason.vue";
import DialogApprove from "@/modules/09_leave/components/4_specialTime/DialogApprove.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import type { DataDateMonthObject } from "@/modules/09_leave/interface/request/specialTime";
import { useRouter } from "vue-router";
import { identity } from "@fullcalendar/core/internal";
/**ตัวแปรที่ใช้ */
/** importType*/
import type { DataDateMonthObject } from "@/modules/09_leave/interface/request/specialTime";
/** importComponents*/
import DialogReason from "@/components/Dialogs/PopupReason.vue";
import DialogApprove from "@/modules/09_leave/components/4_specialTime/DialogApprove.vue";
/** importStore*/
import { useCounterMixin } from "@/stores/mixin";
import { useSpecialTimeStore } from "@/modules/09_leave/stores/SpecialTimeStore";
const dataSpecialTime = useSpecialTimeStore();
const $q = useQuasar(); // show dialog
const mixin = useCounterMixin();
const router = useRouter();
const { hideLoader, monthYear2Thai, messageError, showLoader, success } = mixin;
const emit = defineEmits(["update:change-page"]);
/**ตัวแปรที่ใช้ */
const modalUnapprove = ref(false);
const modalApprove = ref(false);
const detailData = ref<any>();
@ -30,18 +36,19 @@ const dateDialog = ref<string>("");
const dateFixDialog = ref<string>("");
const dateYear = ref<number>(new Date().getFullYear());
/**ฟังก์ชั่นไม่อนุมัติ */
const unapprove = async (fullname: string, personId: string) => {
/**
* งกนไมอน
* @param fullname
* @param personId personId
*/
async function unapprove(fullname: string, personId: string) {
id.value = personId;
dialogTitle.value = " ไม่อนุมัติคำขอ"// + fullname;
dialogTitle.value = " ไม่อนุมัติคำขอ"; // + fullname;
name.value = fullname;
modalUnapprove.value = true;
}
// rejectData();
};
/** function Model */
//
/** function openDialog */
function openModal(
data: any,
check: string,
@ -58,9 +65,9 @@ function openModal(
if (check === "PENDING") {
detailData.value = data;
}
console.log(data);
}
//
/** function closeDialog */
const closeDialog = () => {
modalUnapprove.value = false;
modalApprove.value = false;
@ -69,32 +76,28 @@ const closeDialog = () => {
/** API reject */
const clickSave = async (reason: string) => {
showLoader();
modalUnapprove.value = false;
const body = {
reason: reason,
};
await http
.put(config.API.specialTimeReject(id.value), body)
.then((res) => {
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
dataSpecialTime.fetchData();
await dataSpecialTime.fetchData();
hideLoader();
});
console.log(reason);
};
// paging
const pageSize = ref<number>(10);
/**
* งก api เปลยนหน
* @param pageVal page
* @param pageSizeVal pagesize
*/
// Pagination - initial pagination
const initialPagination = ref<any>({
sortBy: null,
@ -102,7 +105,7 @@ const initialPagination = ref<any>({
page: 1,
rowsPerPage: pageSize, // set page
});
const emit = defineEmits(["update:change-page"]);
// Pagination - page & change page & get new data
const currentPage = ref<number>(1);
watch(
@ -131,6 +134,7 @@ const resetFilter = () => {
filterRef.value.focus();
}
};
/** function ค้นหาข้อมูลแล้วอัปเดท*/
function filterFn() {
updatePagination(filterKeyword.value);