Refactoring code module 03_retire

This commit is contained in:
STW_TTTY\stwtt 2024-09-03 11:48:07 +07:00
parent 9fbbbd753f
commit 763ec2fd95
6 changed files with 171 additions and 224 deletions

View file

@ -1,13 +1,19 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import type { QForm } from "quasar";
import { useRouter, useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QForm } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import Dialog from "@/modules/03_retire/views/DialogRetire.vue";
const $q = useQuasar();
const route = useRoute();
const router = useRouter();
const routeName = router.currentRoute.value.name;
const mixin = useCounterMixin();
const {
date2Thai,
@ -18,21 +24,15 @@ const {
hideLoader,
dialogConfirm,
} = mixin;
const router = useRouter();
const route = useRoute();
const $q = useQuasar();
const routeName = router.currentRoute.value.name;
/**
* วแปรทใชงาน
*/
const id = ref<string>("");
const myform = ref<QForm | null>(null);
const tranferOrg = ref("");
const dateCommand = ref<Date>(new Date());
const dateLeave = ref<Date>(new Date());
const noteReason = ref("");
const modal = ref<boolean>(false);
const id = ref<string>(""); // id path
const myform = ref<QForm | null>(null); //form
const tranferOrg = ref(""); //
const dateCommand = ref<Date>(new Date()); //
const dateLeave = ref<Date>(new Date()); //
const noteReason = ref(""); //
const modal = ref<boolean>(false); // dialog
/** ข้อมูล v-model ของฟอร์ม */
const dataDetail = ref<any>({
datetext: "",
@ -57,40 +57,23 @@ const dataDetail = ref<any>({
fullname: "",
});
/**
* งกนยอนกลบไปยงหนารายการลาออก
*/
const clickBack = () => {
router.push(`/retire`);
};
/**
* งกนเปลยนเป string ของ status
* @param val value ของ status true/false
*/
const statusOrder = (val: boolean) => {
function statusOrder(val: boolean) {
switch (val) {
case true:
return "ยับยั้ง";
case false:
return "อนุญาต";
}
};
/**
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/
onMounted(() => {
if (route.params.id !== undefined) {
id.value = route.params.id.toString();
fectDataresign(id.value);
}
});
}
/**
* นทกขอมลการลาออก
*/
const onSubmit = async () => {
async function onSubmit() {
dialogConfirm(
$q,
() => {
@ -119,21 +102,21 @@ const onSubmit = async () => {
"ยืนยันการยื่นข้อมูลลาออก",
"ต้องการยื่นข้อมูลลาออกนี้ใช่หรือไม่"
);
};
}
const files = ref<any>();
const checkCancleLeave = ref<boolean>(false);
//
const cancelResing = () => {
function cancelResing() {
modal.value = true;
};
}
const checkCancleLeave = ref<boolean>(false);
/**
* งกนเรยกขอมลจาก Api
* @param id ไอดของขอม
*/
const fectDataresign = async (id: string) => {
async function fectDataresign(id: string) {
showLoader();
await http
.get(config.API.resingByid(id))
@ -158,11 +141,24 @@ const fectDataresign = async (id: string) => {
.finally(() => {
hideLoader();
});
};
}
/**
* เป tab ใหม
* @param data path file
*/
function downloadFile(data: string) {
window.open(data, "_blank");
}
/**
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/
onMounted(() => {
if (route.params.id !== undefined) {
id.value = route.params.id.toString();
fectDataresign(id.value);
}
});
</script>
<template>
<div class="col-12 row justify-center">