From e4cb83a9b3cccc80e54eb6c93e4bfd5677871b33 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Tue, 29 Apr 2025 22:07:31 +0700 Subject: [PATCH] =?UTF-8?q?updated=20=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A?= =?UTF-8?q?=E0=B8=A5=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../09_leave/components/05_Leave/Calendar.vue | 14 ++++++++------ .../components/05_Leave/DetailLeaveReject.vue | 4 +++- .../09_leave/components/05_Leave/Tab1.vue | 17 +++++++++-------- .../09_leave/components/05_Leave/Tab2.vue | 17 +++++++++-------- .../09_leave/interface/response/leave.ts | 9 +++++---- src/modules/09_leave/stores/LeaveStore.ts | 18 +++++++++++++++++- 6 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/modules/09_leave/components/05_Leave/Calendar.vue b/src/modules/09_leave/components/05_Leave/Calendar.vue index cca0bc450..14665b235 100644 --- a/src/modules/09_leave/components/05_Leave/Calendar.vue +++ b/src/modules/09_leave/components/05_Leave/Calendar.vue @@ -89,8 +89,9 @@ async function fetchDataCalendar(type: string) { ]; filterLists.value = []; - for (let i = 1; i <= double_name.length; i++) { - const name = double_name[i - 1]; + + for (let i = 0; i < double_name.length; i++) { + const name = double_name[i]; const filterName = { id: name, name: convertKeycloakId(name), @@ -98,7 +99,9 @@ async function fetchDataCalendar(type: string) { }; filterLists.value.push(filterName); - type === "onMounted" && filterVal.value.push(name); + if (type === "onMounted") { + filterVal.value.push(name); + } } const eventData = filterVal.value.map((item: any) => { return mainData.value @@ -115,7 +118,7 @@ async function fetchDataCalendar(type: string) { }); const allEventData = [].concat(...eventData); calendarOptions.value.events = allEventData; - await fetchDataHoliday(calendarOptions.value.events); + fetchDataHoliday(calendarOptions.value.events); }) .catch((err) => { @@ -141,8 +144,6 @@ async function fetchDataHoliday(optionsCalendaMain: any) { ) ) .then((res) => { - console.log(res); - const dataNormal = res.data.result.normal; const data = dataNormal; const event = data.map((e: any) => ({ @@ -220,6 +221,7 @@ watch( onMounted(async () => { const user = await tokenParsed(); keycloakId.value = user?.sub; + leaveStore.leaveTypeList(); await fetchDataCalendar("onMounted"); }); diff --git a/src/modules/09_leave/components/05_Leave/DetailLeaveReject.vue b/src/modules/09_leave/components/05_Leave/DetailLeaveReject.vue index b3eba1706..71b1d9836 100644 --- a/src/modules/09_leave/components/05_Leave/DetailLeaveReject.vue +++ b/src/modules/09_leave/components/05_Leave/DetailLeaveReject.vue @@ -81,6 +81,7 @@ const formDataReject = reactive({ leaveTotal: 0, //จำนวนวันที่ลา leaveStartDate: new Date(), //วัน เดือน ปีเริ่มต้นลา leaveEndDate: new Date(), //วัน เดือน ปีสิ้นสุดลา + leaveDirectorComment: "", //ความคิดเห็นของผู้บังคับบัญชา }); const formData = reactive({ @@ -195,6 +196,7 @@ async function fetchDetailDeleteLeave(paramsId: string) { formDataReject.leaveTotal = data.leaveTotal; formDataReject.leaveStartDate = data.leaveStartDate; formDataReject.leaveEndDate = data.leaveEndDate; + formDataReject.leaveDirectorComment = data.leaveDirectorComment; }) .catch((err) => { messageError($q, err); @@ -778,7 +780,7 @@ async function checkOfficer() { {{ formDataReject.status == "NEW" ? "-" - : formDataReject.leaveReasonDelete + : formDataReject.leaveDirectorComment }} diff --git a/src/modules/09_leave/components/05_Leave/Tab1.vue b/src/modules/09_leave/components/05_Leave/Tab1.vue index 9454ec890..df7195136 100644 --- a/src/modules/09_leave/components/05_Leave/Tab1.vue +++ b/src/modules/09_leave/components/05_Leave/Tab1.vue @@ -73,14 +73,15 @@ async function fecthLeaveList() { /** function เรียกข้อมูลสถานะ*/ async function fetchOption() { if (leaveStore.dataToobar.length == 0) { - await http - .get(config.API.leaveType()) - .then((res) => { - leaveStore.leaveTypeOption(res.data.result); - }) - .catch((err) => { - messageError($q, err); - }); + leaveStore.leaveTypeList(); + // await http + // .get(config.API.leaveType()) + // .then((res) => { + // leaveStore.leaveTypeOption(res.data.result); + // }) + // .catch((err) => { + // messageError($q, err); + // }); } } diff --git a/src/modules/09_leave/components/05_Leave/Tab2.vue b/src/modules/09_leave/components/05_Leave/Tab2.vue index 4856f69dc..125b54e32 100644 --- a/src/modules/09_leave/components/05_Leave/Tab2.vue +++ b/src/modules/09_leave/components/05_Leave/Tab2.vue @@ -73,14 +73,15 @@ async function fecthLeaveList() { /** function เรียกข้อมูลสถานะ*/ async function fetchOption() { if (leaveStore.dataToobar.length == 0) { - await http - .get(config.API.leaveType()) - .then((res) => { - leaveStore.leaveTypeOption(res.data.result); - }) - .catch((err) => { - messageError($q, err); - }); + leaveStore.leaveTypeList(); + // await http + // .get(config.API.leaveType()) + // .then((res) => { + // leaveStore.leaveTypeOption(res.data.result); + // }) + // .catch((err) => { + // messageError($q, err); + // }); } } diff --git a/src/modules/09_leave/interface/response/leave.ts b/src/modules/09_leave/interface/response/leave.ts index ee2a84858..990c6f4fc 100644 --- a/src/modules/09_leave/interface/response/leave.ts +++ b/src/modules/09_leave/interface/response/leave.ts @@ -34,9 +34,9 @@ interface FormData { status: string; } -interface RowsType{ - commanders:SeqTypeRow[] - approvers:SeqTypeRow[] +interface RowsType { + commanders: SeqTypeRow[]; + approvers: SeqTypeRow[]; } interface SeqTypeRow { seq: number; @@ -80,6 +80,7 @@ interface FormReject { leaveTotal: number; //จำนวนวันที่ลา leaveStartDate: Date; //วัน เดือน ปีเริ่มต้นลา leaveEndDate: Date; //วัน เดือน ปีสิ้นสุดลา + leaveDirectorComment?: string; //ความคิดเห็นของผู้บังคับบัญชา } interface ResCalendar { @@ -103,5 +104,5 @@ export type { FormReject, ResCalendar, SeqTypeRow, - RowsType + RowsType, }; diff --git a/src/modules/09_leave/stores/LeaveStore.ts b/src/modules/09_leave/stores/LeaveStore.ts index 781aba60d..f1c3552b4 100644 --- a/src/modules/09_leave/stores/LeaveStore.ts +++ b/src/modules/09_leave/stores/LeaveStore.ts @@ -10,6 +10,8 @@ import type { ListLeave, } from "@/modules/09_leave/interface/response/leave"; import type { FremData } from "@/modules/09_leave/interface/request/leave"; +import http from "@/plugins/http"; +import config from "@/app.config"; const mixin = useCounterMixin(); const { date2Thai } = mixin; @@ -162,6 +164,19 @@ export const useLeavelistDataStore = defineStore("leave", () => { } } + /** function ข้อมูลประเภทการลา*/ + async function leaveTypeList() { + if (leaveType.value.length == 0) { + await http.get(config.API.leaveType()).then((res) => { + leaveType.value = res.data.result; + leaveTypeOption(res.data.result); + return res.data.result; + }); + } else { + return leaveType.value; + } + } + function colorType(val: string) { const dataType = leaveType.value.find((item: any) => item.id === val); switch (dataType.code) { @@ -191,7 +206,7 @@ export const useLeavelistDataStore = defineStore("leave", () => { } function leaveTypeOption(val: any) { - dataToobar.value = val.map((e: any) => ({ + dataToobar.value = leaveType.value.map((e: any) => ({ id: e.id, name: e.name, code: e.code, @@ -214,5 +229,6 @@ export const useLeavelistDataStore = defineStore("leave", () => { colorType, converstType, leaveTypeOption, + leaveTypeList, }; });