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/components/Dialogs/PopupPersonalNew.vue b/src/components/Dialogs/PopupPersonalNew.vue index 4afdf0b48..504fde1ed 100644 --- a/src/components/Dialogs/PopupPersonalNew.vue +++ b/src/components/Dialogs/PopupPersonalNew.vue @@ -487,7 +487,7 @@ async function fetchProfile(id: string, avatarName: string) { diff --git a/src/interface/response/main.ts b/src/interface/response/main.ts index e49121332..561af060e 100644 --- a/src/interface/response/main.ts +++ b/src/interface/response/main.ts @@ -43,4 +43,4 @@ interface DataRoles { parentNode: string; } -export type { ListMenu, ChildLevelTree, ChildConfig, DataPermissions }; +export type { ListMenu, ChildLevelTree, ChildConfig, DataPermissions,DataRoles }; 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..d8b8d7b85 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/07_Position.vue @@ -18,6 +18,7 @@ import type { ResListSalary, ResType, } from "@/modules/04_registryPerson/interface/response/Salary"; +import type { DataCardPos } from "@/modules/04_registryPerson/interface/index/government"; import DialogHeader from "@/components/DialogHeader.vue"; import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/07_PositionHistory.vue"; @@ -47,6 +48,7 @@ const { success, pathRegistryEmp, onSearchDataTable, + formatDatePosition, } = useCounterMixin(); const empType = ref(pathRegistryEmp(route.name?.toString() ?? "")); @@ -289,30 +291,23 @@ const posExecutiveOptionMain = ref([]); const docOption = ref(store.optionTemplateDoc); -const cardData = ref([ +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: [], }, ]); /** function fetch รายการ ตำแหน่งเงินเดือน*/ async function fetchListSalary() { - showLoader(); await http .get( config.API.profileListSalaryPositionNew(profileId.value, empType.value) @@ -323,9 +318,6 @@ async function fetchListSalary() { }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); } @@ -558,13 +550,13 @@ function onSubmit() { : config.API.profileSalaryPositionNew(empType.value); const method = isStatusEdit.value ? "patch" : "post"; await http[method](url, formData); - await onClickCloseDialog(); await fetchListSalary(); + await onClickCloseDialog(); success($q, "บันทึกข้อมูลสำเร็จ"); } catch (e) { messageError($q, e); - hideLoader(); } finally { + hideLoader(); } }); } @@ -731,14 +723,56 @@ function serchDataTable() { ); } +async function fetchDataTenure() { + await http + .get(config.API.salaryTenurePosition(profileId.value, empType.value)) + .then((res) => { + const data = res.data.result; + if (data) { + // map ข้อมูลระยะเวลาดำรงตำแหน่ง + const formatData = (list: any) => + list.map((e: any) => ({ + name: e.name ?? "", + time: formatDatePosition(e.year, e.month, e.day), + })); + + // แปลงข้อมูลจาก data + const position = formatData(data.position); //ระยะเวลาดำรงตำแหน่งในสายงาน + const posLevel = formatData(data.posLevel); //ระยะเวลาดำรงตำแหน่งตามระดับ + const posExecutive = formatData(data.posExecutive); //ระยะเวลาดำรงตำแหน่งทางการบริหาร + + // นำข้อมูลไปใส่ใน cardData + cardData.value[0].data = position; + cardData.value[1].data = posLevel; + cardData.value[2].data = posExecutive; + + //เช็คค่า ระยะเวลาดำรงตำแหน่งทางการบริหาร ถ้าไม่มีให้ลบออกจาก cardData + if (posExecutive.length === 0) { + cardData.value.splice(2, 2); + } + } + }) + .catch((err) => { + messageError($q, err); + }); +} + /** ทำงานเมื่อ Components ถูกเรียกใช้งาน*/ -onMounted(() => { - fetchListSalary(); +onMounted(async () => { + try { + showLoader(); + await Promise.all([ + fetchListSalary(), + empType.value === "" ? fetchDataTenure() : Promise.resolve(), + ]); + } finally { + hideLoader(); + } });