fix บัญชีแสดงวันลา

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-12-18 13:18:18 +07:00
parent 7c1f4502ec
commit 02bfb6387c

View file

@ -24,14 +24,8 @@ import LoadView from "@/components/LoadView.vue";
const $q = useQuasar();
const route = useRoute();
const { fetchStructureTree } = useStructureTree();
const {
showLoader,
hideLoader,
date2Thai,
dateToISO,
messageError,
monthYear2Thai,
} = useCounterMixin();
const { date2Thai, dateToISO, messageError, monthYear2Thai } =
useCounterMixin();
const year = ref<number>(new Date().getFullYear());
const dateStart = ref<Date>(new Date(year.value - 1, 9, 1));
@ -77,17 +71,26 @@ const nodeLevel = ref<number>(0);
const node = ref<DataStructureTree[]>([]);
const expanded = ref<string[]>([]);
/** ฟังก์ชันเรียกข้อมูลโครงสร้างหน่วยงาน*/
async function fetchDataTree() {
node.value = await fetchStructureTree(route.meta.Key as string, true);
}
/**
* งกนเลอกหนวยงานทองการดอม
* @param id id หนวยงาน
* @param level node ของหนวงงานทเลอก
*/
function onSelectedNode(id: string, level: number) {
nodeId.value = id;
nodeLevel.value = level;
updateLeaveday();
}
/** function อัปเดทบัญชีแสดงวันลา */
/**
* งกนอปเดทบญชแสดงวนลา
* และเรยกขอมลรายงาน
*/
async function updateLeaveday() {
switch (yearType.value) {
case "FULL":
@ -125,23 +128,17 @@ async function updateLeaveday() {
isLoadPDF.value = true;
pdfSrc.value = undefined;
typeReport.value === "1"
? fetchLeaveday(
employeeClass.value,
yearType.value,
dateStart.value,
dateEnd.value
)
: fetchLeaveday2(
employeeClass.value,
yearType.value,
dateStart.value,
dateEnd.value
);
// fetchLeaveday
fetchLeaveday(
employeeClass.value,
yearType.value,
dateStart.value,
dateEnd.value
);
}
/**
* function เรยกขอมลบญชแสดงวนลา
* งกนเรยกขอมลรายงาน
* @param type สถานภาพ
* @param year
* @param startDate นเรมต
@ -161,38 +158,13 @@ async function fetchLeaveday(
node: nodeLevel.value,
};
await http
.post(config.API.leaveReportLeaveday(type), body)
.then(async (res) => {
const data = res.data.result;
data && (await fetchDocumentTemplate(data));
isReport.value = data ? true : false;
detailReport.value = data;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
isLoadPDF.value = false;
});
}
async function fetchLeaveday2(
type: string,
year: string,
startDate: Date,
endDate: Date
) {
const body = {
type: year === "FULL" ? "FULL" : year === "MONTH" ? "MONTH" : "HAFT",
startDate: dateToISO(startDate),
endDate: dateToISO(endDate),
nodeId: nodeId.value,
node: nodeLevel.value,
};
const pathAPI =
typeReport.value === "1"
? config.API.leaveReportLeaveday(type)
: config.API.leaveReportLeave2(type);
await http
.post(config.API.leaveReportLeave2(type), body)
.post(pathAPI, body)
.then(async (res) => {
const data = res.data.result;
data && (await fetchDocumentTemplate(data));
@ -233,12 +205,10 @@ async function fetchDocumentTemplate(data: any) {
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
setTimeout(() => {
hideLoader();
}, 2000);
});
.finally(() => {});
}
// PDF
const numOfPages = ref<number>(0);
const page = ref<number>(1);
const pdfSrc = ref<any>();
@ -366,7 +336,7 @@ onMounted(() => {
<div class="row col-12 q-col-gutter-sm">
<div class="col-md-3 col-xs-12">
<q-select
class="bg-white"
class="bg-white select_ellipsis3"
hide-bottom-space
outlined
dense