From a6293efa6999ae30a51bebfc94119051a4693752 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 27 Feb 2025 17:19:31 +0700 Subject: [PATCH] =?UTF-8?q?API=20=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1?= =?UTF-8?q?=E0=B8=B9=E0=B8=A5=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99?= =?UTF-8?q?=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/registry/api.registry.ts | 5 +- .../GovernmentInformation/07_Position.vue | 40 ++++++++++--- .../21_report/components/CardPosition.vue | 60 +++++++++++++++---- .../21_report/views/02_reportRegistry.vue | 3 + src/stores/mixin.ts | 14 +++++ 5 files changed, 99 insertions(+), 23 deletions(-) diff --git a/src/api/registry/api.registry.ts b/src/api/registry/api.registry.ts index 3d27609ca..4e026c74b 100644 --- a/src/api/registry/api.registry.ts +++ b/src/api/registry/api.registry.ts @@ -169,7 +169,8 @@ export default { `${registryNew}${type}/leave/admin/${id}`, //noPermission /** ตำแหน่ง*/ - profileSalaryPositionNew: (type: string) => `${registryNew}${type}/salary/position`, + profileSalaryPositionNew: (type: string) => + `${registryNew}${type}/salary/position`, profileListSalaryPositionNew: (id: string, type: string) => `${registryNew}${type}/salary/position/${id}`, profileListSalaryPositionHistoryNew: (profileId: string, type: string) => @@ -178,6 +179,8 @@ export default { `${registryNew}${type2}/salary/position/swap/${type}/${id}`, salaryListCardPosition: (id: string, type: string) => `${registryNew}${type}/salary/position/admin/${id}`, //noPermission + salaryTenurePosition: (id: string, type: string) => + `${registryNew}${type}/salary/tenure/${id}`, //noPermission /** ตำแหน่งเงินเดือน*/ profileSalaryNew: (type: string) => `${registryNew}${type}/salary`, diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue index e73da8886..7c6ddf9fb 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue @@ -47,6 +47,7 @@ const { success, pathRegistryEmp, onSearchDataTable, + formatDatePosition, } = useCounterMixin(); const empType = ref(pathRegistryEmp(route.name?.toString() ?? "")); @@ -292,21 +293,15 @@ const docOption = ref(store.optionTemplateDoc); const cardData = ref([ { label: "ระยะเวลาดำรงตำแหน่งในสายงาน", - data: [ - { name: "ตำแหน่ง", time: "1 ปี" }, - { name: "ตำแหน่ง", time: "1 ปี" }, - { name: "ตำแหน่ง", time: "1 ปี" }, - { name: "ตำแหน่ง", time: "1 ปี" }, - { name: "ตำแหน่ง", time: "1 ปี" }, - ], + data: [], }, { label: "ระยะเวลาดำรงตำแหน่งตามระดับ", - data: [{ name: "ละดับ", time: "1 ปี" }], + data: [], }, { label: "ระยะเวลาดำรงตำแหน่งทางการบริหาร", - data: [{ name: "ตำแหน่งทางการบริหาร", time: "1 ปี" }], + data: [], }, ]); @@ -731,9 +726,36 @@ function serchDataTable() { ); } +async function fetchDataTenure() { + await http + .get(config.API.salaryTenurePosition(profileId.value, empType.value)) + .then((res) => { + const data = res.data.result; + if (data) { + const formatData = (list: any) => + list.map((e: any) => ({ + name: e.name ?? "", + time: formatDatePosition(e.year, e.month, e.day), + })); + + const position = formatData(data.position); + const posLevel = formatData(data.posLevel); + const posExecutive = formatData(data.posExecutive); + + cardData.value[0].data = position; + cardData.value[1].data = posLevel; + cardData.value[2].data = posExecutive; + } + }) + .catch((err) => { + messageError($q, err); + }); +} + /** ทำงานเมื่อ Components ถูกเรียกใช้งาน*/ onMounted(() => { fetchListSalary(); + fetchDataTenure(); }); diff --git a/src/modules/21_report/components/CardPosition.vue b/src/modules/21_report/components/CardPosition.vue index 4d1b9a1e1..2e6e783f2 100644 --- a/src/modules/21_report/components/CardPosition.vue +++ b/src/modules/21_report/components/CardPosition.vue @@ -1,5 +1,13 @@ @@ -45,7 +79,7 @@ onMounted(() => { ข้อมูลตำแหน่ง
- + @@ -57,7 +91,7 @@ onMounted(() => { - +
diff --git a/src/modules/21_report/views/02_reportRegistry.vue b/src/modules/21_report/views/02_reportRegistry.vue index 954813e9b..a710ac5a4 100644 --- a/src/modules/21_report/views/02_reportRegistry.vue +++ b/src/modules/21_report/views/02_reportRegistry.vue @@ -522,6 +522,9 @@ async function onSearch() { sortBy: sortBy.value ? "dateAppoint" : "", sort: sortBy.value ? sortBy.value : "ASC", isRetireLaw: isRetireLaw.value, + tenureType: typeTerm.value ?? null, + tenureMin: typeTerm.value ? Number(rangeTerm.value.min) : null, + tenureMax: typeTerm.value ? Number(rangeTerm.value.max) : null, }; showLoader(); await http diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index 67349f5e7..ccba40ca0 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -1149,6 +1149,19 @@ export const useCounterMixin = defineStore("mixin", () => { }); } + function formatDatePosition(year: string, month: string, day: string) { + const y = parseInt(year); + const m = parseInt(month); + const d = parseInt(day); + + const parts = []; + if (y > 0) parts.push(`${y}ปี`); + if (m > 0) parts.push(`${m}เดือน`); + if (d > 0) parts.push(`${d}วัน`); + + return parts.length > 0 ? parts.join(" ") : ""; // กรณีที่ทั้งหมดเป็น 0 + } + return { calAge, date2Thai, @@ -1195,5 +1208,6 @@ export const useCounterMixin = defineStore("mixin", () => { downloadRenameFileByLink, onSearchDataTable, + formatDatePosition, }; });