From 5a8f6d643421f2ba6ed907c44f4c313c2f6f3507 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 18 Jun 2024 10:17:43 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A=20=3D>=20?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B9=80=E0=B8=A3=E0=B8=B5=E0=B8=A2=E0=B8=81=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B9=80=E0=B8=A0=E0=B8=97=E0=B9=80=E0=B8=84=E0=B8=A3?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/02_organizational/api.organization.ts | 2 + .../07_insignia/components/2_Manage/Tab1.vue | 1 - .../components/2_Manage/listManage.vue | 55 ++++++++++++------- .../components/4_Allocate/Main.vue | 4 +- .../07_insignia/components/5_Borrow/Main.vue | 4 +- src/modules/07_insignia/storeAllocate.ts | 2 +- src/modules/07_insignia/storeBrrow.ts | 2 +- src/modules/07_insignia/storeResult.ts | 3 +- src/modules/07_insignia/views/ResultPage.vue | 5 +- 9 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 3e642aa5a..f63a60e0f 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -6,6 +6,8 @@ const orgProfile = `${env.API_URI}/org/profile`; const orgEmployeePos = `${env.API_URI}/org/employee/pos`; export default { + keycloakPosition: () => `${organization}/profile/keycloak/position`, + /** โครงสร้างอัตรากำลัง*/ activeOrganization: `${organization}/active`, orgByid: (id: string) => `${organization}/${id}`, diff --git a/src/modules/07_insignia/components/2_Manage/Tab1.vue b/src/modules/07_insignia/components/2_Manage/Tab1.vue index 41321aad3..aee88b5bd 100644 --- a/src/modules/07_insignia/components/2_Manage/Tab1.vue +++ b/src/modules/07_insignia/components/2_Manage/Tab1.vue @@ -743,7 +743,6 @@ function clearInsigniaFilters(name: string) { onMounted(async () => { organizationOptions.value = await DataStore.optionsTypeOc; organization.value = await DataStore.typeOc; - console.log(organization.value); if (organization.value !== "" || organization.value !== undefined) { if (props.fecthInsigniaByOc) { diff --git a/src/modules/07_insignia/components/2_Manage/listManage.vue b/src/modules/07_insignia/components/2_Manage/listManage.vue index 9d8fa1ce7..612b57e11 100644 --- a/src/modules/07_insignia/components/2_Manage/listManage.vue +++ b/src/modules/07_insignia/components/2_Manage/listManage.vue @@ -63,7 +63,7 @@ async function fecthlistRound() { DataStore.roundId = round.value; roundName.value = lastValue.name; await fecthStat(round.value); - await fecthAgency(); + // await fecthAgency(); } }) .catch((err) => { @@ -92,47 +92,59 @@ const fecthStat = async (id: string) => { /** funcion เช็คหน่วยงาน*/ async function fecthAgency() { - showLoader(); await http - .get(config.API.insigniaAgency()) + .get(config.API.keycloakPosition()) .then(async (res) => { loadview.value = true; - DataStore.agency = res.data.result; + DataStore.agency = res.data.result.rootId; DataStore.typeOc = DataStore.agency; - if (roleDataStore.adminRole) { - await fecthType(); // ถ้าไม่มีหนวยงานจะเรียกหน่วยงานทั้งหมด - } else { - } }) .catch((err) => { messageError($q, err); }) .finally(() => { loading.value = true; - hideLoader(); }); } -/** funcion เรียกหน่อยวงาน*/ -async function fecthType() { - await http - .get(config.API.typeOc()) +function fetchActiveId() { + http + .get(config.API.activeOrganization) .then((res) => { - optiontypeOc.value = res.data.result.map((e: any) => ({ - id: e.organizationId, - name: e.organizationName, - })); - DataStore.fetchOption(optiontypeOc.value); //ค่าของหน่วยงานทั้งหมดไว้ที่ DataStore + const data = res.data.result; + fetchListOrg(data.activeId); }) .catch((err) => { messageError($q, err); }); } +function fetchListOrg(id: string) { + showLoader(); + http + .get(config.API.orgByid(id)) + .then(async (res) => { + const data = await res.data.result.map((item: any) => ({ + id: item.orgTreeId, + name: item.orgName, + })); + optiontypeOc.value = data; + DataStore.fetchOption(optiontypeOc.value); //ค่าของหน่วยงานทั้งหมดไว้ที่ DataStore + fecthAgency(); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + + /**function เรียกประเภทเครื่องราช*/ async function fecthInsignia() { await http - .get(config.API.insignia) + .get(config.API.insigniaOrg) .then((res) => { let data = res.data.result; DataStore.fetchInsigniaType(data); @@ -397,6 +409,7 @@ async function uploadFile(event: any) { onMounted(async () => { tab.value = DataStore.mainTab; await fecthlistRound(); + await fetchActiveId(); DataStore.dataInsigniaType.length === 0 && (await fecthInsignia()); }); @@ -652,13 +665,13 @@ onMounted(async () => { { let data = res.data.result; DataStore.fetchDatainsignia(data); @@ -151,7 +151,7 @@ async function fecthInsignia() { /** function เรียก Tab*/ const fecthInsigniaType = async () => { - await http(config.API.insigniaType) + await http(config.API.insigniaTypeOrg) .then((res) => { let data = res.data.result; DataStore.fetchDatainsigniaType(data); diff --git a/src/modules/07_insignia/components/5_Borrow/Main.vue b/src/modules/07_insignia/components/5_Borrow/Main.vue index f9cb701b9..36646d4e0 100644 --- a/src/modules/07_insignia/components/5_Borrow/Main.vue +++ b/src/modules/07_insignia/components/5_Borrow/Main.vue @@ -307,7 +307,7 @@ async function fecthRound() { /** function เรียกประเภทเครื่องราชฯ*/ async function fecthInsignia() { await http - .get(config.API.insignia) + .get(config.API.insigniaOrg) .then((res) => { let data = res.data.result; DataStore.fetchDataInsignia(data); @@ -324,7 +324,7 @@ async function fecthInsignia() { /** function เรียกระดับเครื่องราชฯ Tab*/ async function fecthInsigniaType() { - await http(config.API.insigniaType) + await http(config.API.insigniaTypeOrg) .then(async (res) => { let data = res.data.result; DataStore.fetchDatainsigniaType(data); diff --git a/src/modules/07_insignia/storeAllocate.ts b/src/modules/07_insignia/storeAllocate.ts index a217bd841..3413c5f33 100644 --- a/src/modules/07_insignia/storeAllocate.ts +++ b/src/modules/07_insignia/storeAllocate.ts @@ -23,7 +23,7 @@ export const useAllocateDataStore = defineStore("insigniaallocate", () => { insigniaOp.value.push({ name: `${e.name} (${e.shortName})`, id: e.id, - type: e.insigniaType.id, + type: e.insigniaTypeId, }); }); data.forEach((e: any) => { diff --git a/src/modules/07_insignia/storeBrrow.ts b/src/modules/07_insignia/storeBrrow.ts index dcc46b22e..27f7d8791 100644 --- a/src/modules/07_insignia/storeBrrow.ts +++ b/src/modules/07_insignia/storeBrrow.ts @@ -41,7 +41,7 @@ export const useBrrowDataStore = defineStore("insigniaBrrow", () => { insigniaOp.value.push({ name: `${e.name} (${e.shortName})`, id: e.id, - type: e.insigniaType.id, + type: e.insigniaTypeId, }); }); data.forEach((e: any) => { diff --git a/src/modules/07_insignia/storeResult.ts b/src/modules/07_insignia/storeResult.ts index c798aab84..a2a3c8806 100644 --- a/src/modules/07_insignia/storeResult.ts +++ b/src/modules/07_insignia/storeResult.ts @@ -43,9 +43,10 @@ export const useResultDataStore = defineStore("insigniaResult", () => { insigniaOp.value.push({ name: `${e.name} (${e.shortName})`, id: e.id, - insigniaType: e.insigniaType.id, + insigniaType: e.insigniaTypeId, }); }); + data.forEach((e: any) => { insigniaOp2.value.push({ name: `${e.name} (${e.shortName})`, id: e.id }); }); diff --git a/src/modules/07_insignia/views/ResultPage.vue b/src/modules/07_insignia/views/ResultPage.vue index 1d5b908e1..38f55ea6a 100644 --- a/src/modules/07_insignia/views/ResultPage.vue +++ b/src/modules/07_insignia/views/ResultPage.vue @@ -254,7 +254,7 @@ async function fecthRound() { /** function เรียกประเภทเครื่องราช*/ async function fecthInsignia() { await http - .get(config.API.insignia) + .get(config.API.insigniaOrg) .then((res) => { let data = res.data.result; DataStore.fetchDatainsignia(data); @@ -266,7 +266,7 @@ async function fecthInsignia() { /** function เรียกระดับเครื่องราช*/ async function fecthInsigniaType() { - await http(config.API.insigniaType) + await http(config.API.insigniaTypeOrg) .then((res) => { let data = res.data.result; DataStore.fetchDatainsigniaType(data); @@ -299,6 +299,7 @@ watch(tab, () => { if (tab.value !== "doc") { DataStore.insignia = ""; fecthlistInsignia(); + insigniaTypeOption.value = DataStore.insigniaOp.filter( (e: any) => e.insigniaType == tab.value || e.name == "ทั้งหมด" );