Refactoring code module 05_leave

This commit is contained in:
STW_TTTY\stwtt 2024-09-03 17:36:59 +07:00
parent 763ec2fd95
commit 4253226ac3
23 changed files with 383 additions and 532 deletions

View file

@ -1,39 +1,28 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useRouter, useRoute } from "vue-router";
/** import type*/
import type { LeaveType } from "@/modules/05_leave/interface/response/leave";
/** import componest*/
import DialogDetail from "@/modules/05_leave/components/DialogDetail.vue";
import Table from "@/modules/05_leave/components/Table.vue";
/** import stort*/
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useLeaveStore } from "@/modules/05_leave/store";
import type { LeaveType } from "@/modules/05_leave/interface/response/leave";
import DialogDetail from "@/modules/05_leave/components/DialogDetail.vue";
import Table from "@/modules/05_leave/components/Table.vue";
/**ตัวแปรที่ใช้ */
const mixin = useCounterMixin();
const {
showLoader,
hideLoader,
messageError,
date2Thai,
monthYear2Thai,
dialogRemove,
success,
} = mixin;
const LeaveData = useLeaveStore();
const router = useRouter();
const route = useRoute();
const $q = useQuasar();
const leaveType = ref<LeaveType[]>();
const mixin = useCounterMixin();
const router = useRouter();
const LeaveData = useLeaveStore();
const { showLoader, hideLoader, messageError, dialogRemove, success } = mixin;
const modal = ref<boolean>(false);
const leaveId = ref<string>("");
const leaveType = ref<LeaveType[]>();
const leaveStatus = ref<string>("");
/** filter */
@ -91,30 +80,30 @@ async function fectOptionType() {
* @param id การลา
* @param status การลา
*/
const onClickView = async (id: string, status: string) => {
async function onClickView(id: string, status: string) {
modal.value = true;
leaveId.value = id;
leaveStatus.value = status;
};
}
/**
* function ไปหน edit
* @param id
*/
const onClickEdit = async (id: string) => {
async function onClickEdit(id: string) {
router.push(`/leave/edit/${id}`);
};
}
//
const clickDelete = (id: string) => {
function clickDelete(id: string) {
dialogRemove($q, () => onClickDelete(id));
};
}
/**
* function ลบรายการ
* @param id
*/
const onClickDelete = async (id: string) => {
async function onClickDelete(id: string) {
await http
.delete(config.API.leaveUserId(id))
.then(async (res) => {
@ -124,7 +113,7 @@ const onClickDelete = async (id: string) => {
.catch((err) => {
messageError($q, err);
});
};
}
/** function closePopup*/
async function onClickClose() {