From 0739f2b9d7ffdb2a7c45b2b6526ba5ee9150fc42 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 7 May 2026 10:40:58 +0700 Subject: [PATCH 01/41] feat(receive): add input rank --- .../components/Receive/ReceiveAddPerson.vue | 72 ++++++++++++++++--- .../components/Receive/receiveDetail.vue | 68 +++++++++++++++++- .../interface/index/ProfileType.ts | 3 + 3 files changed, 132 insertions(+), 11 deletions(-) diff --git a/src/modules/05_placement/components/Receive/ReceiveAddPerson.vue b/src/modules/05_placement/components/Receive/ReceiveAddPerson.vue index e6d2da0ce..fa0551e99 100644 --- a/src/modules/05_placement/components/Receive/ReceiveAddPerson.vue +++ b/src/modules/05_placement/components/Receive/ReceiveAddPerson.vue @@ -48,6 +48,7 @@ const informaData = ref({ employeeType: null, employeeClass: null, profileType: null, + rank: "", }); // รายการข้อมูลทั้งหมด @@ -60,6 +61,7 @@ const Ops = ref({ religionOps: [], employeeClassOps: [], employeeTypeOps: [], + rankOps: [], }); // ข้อมูลเมื่อเลือกแล้ว const OpsFilter = ref({ @@ -71,6 +73,7 @@ const OpsFilter = ref({ religionOps: [], employeeClassOps: [], employeeTypeOps: [], + rankOps: [], }); // รูป profile @@ -135,6 +138,16 @@ async function fetchPerson() { }); Ops.value.religionOps = optionreligions; OpsFilter.value.religionOps = optionreligions; + + let rank: DataOption[] = []; + data.rank.map((r: DataOptioninfo) => { + rank.push({ + id: r.id.toString(), + name: r.name.toString(), + }); + }); + Ops.value.rankOps = rank; + OpsFilter.value.rankOps = rank; }) .catch((e) => { messageError($q, e); @@ -204,7 +217,13 @@ function filterSelector(val: string, update: Function, refData: string) { ); }); break; - + case "rankOps": + update(() => { + Ops.value.rankOps = OpsFilter.value.rankOps.filter( + (v: DataOption) => v.name.toLowerCase().indexOf(newVal) > -1 + ); + }); + break; default: break; } @@ -227,7 +246,7 @@ function onSubmit() { if (fileData.value != null) formData.append("File", fileData.value); //แก้ไขรูป if (informaData.value.citizenId != undefined) formData.append("citizenId", informaData.value.citizenId); - if (informaData.value.prefix != undefined) + if (informaData.value.prefix != undefined && informaData.value.prefix != "") formData.append("prefix", informaData.value.prefix); if (informaData.value.firstName != undefined) formData.append("firstName", informaData.value.firstName); @@ -256,6 +275,8 @@ function onSubmit() { formData.append("employeeType", informaData.value.employeeType); if (informaData.value.employeeClass != undefined) formData.append("employeeClass", informaData.value.employeeClass); + if (informaData.value.rank != undefined && informaData.value.rank != "") + formData.append("rank", informaData.value.rank); dialogConfirm($q, async () => { showLoader(); @@ -289,6 +310,15 @@ function updateBirthDate(v: Date) { age.value = calculateAge(v); } +function prefixRankRule() { + return [ + () => + !!informaData.value.rank || + !!informaData.value.prefix || + "กรุณาเลือกคำนำหน้าชื่อ หรือยศ", + ]; +} + /** * ทำงานเมื่อมีการเรียกใช้ Components */ @@ -383,7 +413,7 @@ onMounted(async () => {
-
+
{ mask="#############" />
-
+
{ option-value="name" map-options hide-bottom-space - :rules="[ - (val:string) => { - return val.length > 0 || 'กรุณาเลือกคำนำหน้าชื่อ'; - }, - ]" + :rules="prefixRankRule()" + reactive-rules emit-value use-input hide-selected @@ -432,6 +460,32 @@ onMounted(async () => { )" />
+
+ +
({ { id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" }, { id: "bkk", name: "งบประมาณกรุงเทพมหานคร" }, ], + rankOps: [], }); const OpsFilter = ref({ prefixOps: [], @@ -129,6 +130,7 @@ const OpsFilter = ref({ { id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" }, { id: "bkk", name: "งบประมาณกรุงเทพมหานคร" }, ], + rankOps: [], }); /** ฟังก์ชันดึงข้อมูลรายการข้อมูลเกี่ยวกับบุคคล (dropdown list)*/ @@ -186,6 +188,16 @@ async function fetchPerson() { }); Ops.value.religionOps = optionreligions; OpsFilter.value.religionOps = optionreligions; + + let rank: DataOption[] = []; + data.rank.map((r: DataOptioninfo) => { + rank.push({ + id: r.id.toString(), + name: r.name.toString(), + }); + }); + Ops.value.rankOps = rank; + OpsFilter.value.rankOps = rank; }) .catch((e) => { messageError($q, e); @@ -230,6 +242,7 @@ async function getData() { (data.prefix == "00000000-0000-0000-0000-000000000000" ? null : data.prefix) ?? "", + rank: data.rank ?? "", firstname: data.firstName ?? "", lastname: data.lastName ?? "", birthDate: @@ -295,6 +308,7 @@ async function fetchData(data: any) { (data.prefix == "00000000-0000-0000-0000-000000000000" ? null : data.prefix) ?? "", + rank: data.rank ?? "", firstname: data.firstName ?? "", lastname: data.lastName ?? "", birthDate: data.dateOfBirth !== null ? new Date(data.dateOfBirth) : null, @@ -436,6 +450,14 @@ function filterSelector(val: string, update: Function, refData: string) { }); break; + case "rankOps": + update(() => { + Ops.value.rankOps = OpsFilter.value.rankOps.filter( + (v: DataOption) => v.name.toLowerCase().indexOf(newVal) > -1 + ); + }); + break; + default: break; } @@ -470,6 +492,7 @@ function saveData() { positionNumberOld: posNo.value, amount: 0, amountOld: salary.value, + rank: informaData.value.rank, }; showLoader(); http @@ -517,6 +540,15 @@ function updateBirthDate(v: Date) { informaData.value.age = calculateAge(v); } +function prefixRankRule() { + return [ + () => + !!informaData.value.rank || + !!informaData.value.prefixId || + "กรุณาเลือกคำนำหน้าชื่อ หรือยศ", + ]; +} + /** ทำงานเมื่อมีการเรียกใช้ Components*/ onMounted(async () => { await fetchPerson(); @@ -598,7 +630,7 @@ onMounted(async () => {
ข้อมูลส่วนตัว
-
+
{ mask="#############" />
-
+
{ option-value="name" :label="`${'คำนำหน้าชื่อ'}`" use-input + clearable input-debounce="0" + :rules="prefixRankRule()" + reactive-rules @filter="(inputValue:string, doneFn:Function) => filterSelector(inputValue, doneFn,'prefixOps' ) " />
+ +
+ +
+
Date: Thu, 7 May 2026 16:24:30 +0700 Subject: [PATCH 02/41] refactor(timestamp-special): filter date and status --- .../09_leave/stores/SpecialTimeStore.ts | 10 +- .../09_leave/views/04_SpecialTimeMain.vue | 146 +++++++++++------- 2 files changed, 97 insertions(+), 59 deletions(-) diff --git a/src/modules/09_leave/stores/SpecialTimeStore.ts b/src/modules/09_leave/stores/SpecialTimeStore.ts index 4196c93b6..83024a8ef 100644 --- a/src/modules/09_leave/stores/SpecialTimeStore.ts +++ b/src/modules/09_leave/stores/SpecialTimeStore.ts @@ -11,7 +11,14 @@ export const useSpecialTimeStore = defineStore("LeaveSpecialTime", () => { { id: "NOT_COMPLETE", name: "ปฏิบัติงานไม่ครบตามกำหนดเวลา" }, ]); - // convertSatatus + const optionStatusMain = ref([ + { id: "ALL", name: "ทั้งหมด" }, + { id: "PENDING", name: "รอดำเนินการ" }, + { id: "APPROVE", name: "อนุมัติ" }, + { id: "REJECT", name: "ไม่อนุมัติ" }, + ]); + + // convertStatus function convertStatus(val: string) { const value = val ? val.toUpperCase() : null; switch (value) { @@ -29,5 +36,6 @@ export const useSpecialTimeStore = defineStore("LeaveSpecialTime", () => { return { optionStatus, convertStatus, + optionStatusMain, }; }); diff --git a/src/modules/09_leave/views/04_SpecialTimeMain.vue b/src/modules/09_leave/views/04_SpecialTimeMain.vue index 10b9dc8df..1ea9ec44b 100644 --- a/src/modules/09_leave/views/04_SpecialTimeMain.vue +++ b/src/modules/09_leave/views/04_SpecialTimeMain.vue @@ -10,8 +10,10 @@ import { useSpecialTimeStore } from "@/modules/09_leave/stores/SpecialTimeStore" import { checkPermission } from "@/utils/permissions"; import { usePagination } from "@/composables/usePagination"; -import type { DataDateMonthObject } from "@/modules/09_leave/interface/request/specialTime"; -import type { DataSpecialTime } from "@/modules/09_leave/interface/index/Main"; +import type { + DataSpecialTime, + DataOption, +} from "@/modules/09_leave/interface/index/Main"; import DialogReason from "@/components/Dialogs/PopupReason.vue"; import DialogApprove from "@/modules/09_leave/components/04_SpecialTime/DialogApprove.vue"; @@ -21,23 +23,17 @@ const mixin = useCounterMixin(); const store = useSpecialTimeStore(); const { hideLoader, - monthYear2Thai, messageError, showLoader, success, date2Thai, dialogConfirm, + dateToISO, } = mixin; const { pagination, params, onRequest } = usePagination("", fetchData); const emit = defineEmits(["update:change-page"]); -const toDay = ref(new Date()); -const monthToday = toDay.value.getMonth(); -const yearToday = toDay.value.getFullYear(); - -const month = ref(monthToday + 1); -const year = ref(yearToday); const description = ref(""); /**ตัวแปรที่ใช้ */ @@ -51,16 +47,12 @@ const name = ref(""); const id = ref(""); const dateDialog = ref(""); const dateFixDialog = ref(""); -const dateYear = ref(new Date().getFullYear()); - -/** Function Date */ -const dateMonth = ref({ - month: new Date().getMonth(), - year: new Date().getFullYear(), -}); // ค้นหาในตาราง const filterKeyword = ref(""); +const filterStatus = ref("PENDING"); +const filterDate = ref<[Date, Date] | null>([new Date(), new Date()]); //วันที่ประกาศ +const optionStatus = ref(store.optionStatusMain); const rows = ref([]); const visibleColumns = ref([ "no", @@ -144,9 +136,10 @@ async function fetchData() { .get(config.API.specialTime(), { params: { ...params.value, - year: year.value, - month: month.value, keyword: filterKeyword.value.trim(), + status: filterStatus.value != "ALL" ? filterStatus.value : null, + startDate: filterDate.value ? dateToISO(filterDate.value[0]) : null, + endDate: filterDate.value ? dateToISO(filterDate.value[1]) : null, }, }) .then(async (res) => { @@ -246,40 +239,43 @@ async function clickSave(reason: string) { }); } -/** - * ดึงข้อมูลตามปี - * @param e ปี - */ -async function updateMonth(e: DataDateMonthObject) { - if (e != null) { - dateYear.value = e.year; - dateYear.value = year.value; - month.value = dateMonth.value.month + 1; - year.value = dateMonth.value.year; - onSearchData(); - } -} - -//แปลงเดือนเป็นไทย -function monthYearThai(val: DataDateMonthObject) { - if (val == null) return ""; - else return monthYear2Thai(val.month, val.year); -} - /** ฟังก์ชั่นค้นหาข้อมูล */ function onSearchData() { pagination.value.page = 1; fetchData(); } +/** + * ฟังก์ชั่นค้นหาข้อมูลของ Option Filter + * @param val คำที่ค้นหา + * @param update Function + * @param typeOp ประเภทของ Select + */ +function filterOption(val: string, update: Function) { + update(() => { + const needle = val.toLowerCase(); + optionStatus.value = store.optionStatusMain.filter( + (v: DataOption) => v.name.toLowerCase().indexOf(needle) > -1 + ); + }); +} + +/** + * แปลงช่วงวันที่ถ้า2ค่าเป็นวันเดียวกันจะโชววันเดียวแต่ถ้าไม่เท่ากันจะแสดงเป็นช่วง + * @param val ช่วงวันที่ + */ +function dateThaiRange(val: [Date, Date]) { + if (val === null) { + return ""; + } else if (date2Thai(val[0], true) === date2Thai(val[1], true)) { + return `${date2Thai(val[0], true)}`; + } else { + return `${date2Thai(val[0], true)} - ${date2Thai(val[1], true)}`; + } +} + /**Hook */ onMounted(async () => { - //อัพเดทเป็นวันปัจจุบันเมื่อเข้าหน้านี้ - const toDay = ref(new Date()); - const monthToday = toDay.value.getMonth(); - const yearToday = toDay.value.getFullYear(); - month.value = monthToday + 1; - year.value = yearToday; await fetchData(); }); @@ -291,25 +287,31 @@ onMounted(async () => {
-
+
- - + + From 8dc473eec0f99d6bbfe5ae7a104e6362124a07a7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 11 May 2026 15:54:10 +0700 Subject: [PATCH 07/41] refactor(leave): validate isAct commander --- .../components/05_Leave/DetailLeavePage.vue | 33 +++++++++++++++---- .../05_Leave/Dialog/DialogAddCommander.vue | 11 +++++-- .../09_leave/interface/response/leave.ts | 2 ++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue b/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue index 4f4b2ee46..b74df44e6 100644 --- a/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue +++ b/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue @@ -150,21 +150,41 @@ const rows = ref(); // เช็คสิทธิ์การอนุมัติ const idCheck = computed(() => { if (typeAdd.value == "COMMANDER") { - return rows.value?.commanders.map((items: SeqTypeRow) => items.profileId); + return rows.value?.commanders.map((items: SeqTypeRow) => items.keyId); } else if (typeAdd.value == "APPROVER") { - return rows.value?.approvers.map((items: SeqTypeRow) => items.profileId); + return rows.value?.approvers.map((items: SeqTypeRow) => items.keyId); } }); // เช็คสิทธิ์การเลือกผู้มีอำนาจ const commanderList = computed(() => { - if (typeAdd.value == "COMMANDER") { - return rows.value?.approvers.map((items: SeqTypeRow) => items.profileId); - } else if (typeAdd.value == "APPROVER") { - return rows.value?.commanders.map((items: SeqTypeRow) => items.profileId); + if (typeAdd.value === "COMMANDER") { + return rows.value?.approvers.map((items: SeqTypeRow) => ({ + profileId: items.profileId, + isAct: items.isAct, + })); + } else if (typeAdd.value === "APPROVER") { + return rows.value?.commanders.map((items: SeqTypeRow) => ({ + profileId: items.profileId, + isAct: items.isAct, + })); } + return []; }); +// +const isAct = computed(() => { + if (typeAdd.value === "COMMANDER") { + return rows.value?.commanders && rows.value.commanders.length > 0 + ? rows.value.commanders[0].isAct + : false; + } else if (typeAdd.value === "APPROVER") { + return rows.value?.approvers && rows.value.approvers.length > 0 + ? rows.value.approvers[0].isAct + : false; + } + return false; +}); // เช็คว่าผู้ใช้มีสิทธิ์อนุมัติหรือไม่ const approveCheck = computed(() => { const commanders = rows.value?.commanders; @@ -1272,5 +1292,6 @@ onMounted(async () => { :id-check="idCheck" :keycloak-user-id="keycloakUserId" :commanders-list="commanderList" + :commanders-is-act="isAct" /> diff --git a/src/modules/09_leave/components/05_Leave/Dialog/DialogAddCommander.vue b/src/modules/09_leave/components/05_Leave/Dialog/DialogAddCommander.vue index c3eac2353..f3c2e682f 100644 --- a/src/modules/09_leave/components/05_Leave/Dialog/DialogAddCommander.vue +++ b/src/modules/09_leave/components/05_Leave/Dialog/DialogAddCommander.vue @@ -30,6 +30,7 @@ const props = defineProps({ fetchDetailLeave: Function, idCheck: Array, commandersList: Array, + commandersIsAct: Boolean, }); const pageId = ref(route.params.id as string); @@ -117,7 +118,7 @@ async function getData() { total.value = data.total; rows.value = data.data; selected.value = data.data.filter((items: any) => { - return props.idCheck?.some((i: any) => i === items.id); + return props.idCheck?.some((i: any) => i === items.key); }); }) .catch((err) => { @@ -153,10 +154,14 @@ function onSubmit() { ] .filter(Boolean) .join(" "), + isAct: isAct.value, + keyId: items.key, })); const hasCommander = selected.value.some((e) => - props.commandersList?.some((i: any) => i === e.id) + props.commandersList?.some( + (i: any) => i.profileId === e.id && i.isAct === isAct.value + ) ); if (hasCommander) { @@ -205,6 +210,7 @@ watch( () => modal.value, () => { if (modal.value) { + isAct.value = props.commandersIsAct ?? false; getSearch(); } } @@ -233,6 +239,7 @@ watch( label="ค้นหา" v-model="keyword" style="width: 300px" + @keydown.enter.prevent="onSearchData()" >