From 5d33b1babb865d70fb126dd2b76e7a04e60adcbe Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 26 Sep 2024 15:56:13 +0700 Subject: [PATCH] =?UTF-8?q?fix=20load=20=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 --- .../07_insignia/views/02_ManageMain.vue | 176 +++++++++--------- .../07_insignia/views/03_ResultMain.vue | 1 - 2 files changed, 91 insertions(+), 86 deletions(-) diff --git a/src/modules/07_insignia/views/02_ManageMain.vue b/src/modules/07_insignia/views/02_ManageMain.vue index b4dfa0c6c..0ecca978e 100644 --- a/src/modules/07_insignia/views/02_ManageMain.vue +++ b/src/modules/07_insignia/views/02_ManageMain.vue @@ -37,7 +37,6 @@ const { messageError, dialogConfirm, showLoader, hideLoader, success } = mixin; /** * ตัวแปร */ -const loading = ref(false); //การโหลด const loadview = ref(false); //แสดง View const hideBottom = ref(false); const round = ref(""); //รอยการเสนอขอ @@ -64,10 +63,12 @@ const modalbackInsignia2Role = ref(false); // popup หมายเห * function เรียกรอบการเสนอขอพระราชทานเครื่อง */ async function fecthlistRound() { + showLoader(); + loadview.value = false; await http .get(config.API.listRoundInsignia(), { params: { path: "MANAGE" } }) .then(async (res) => { - optionRound.value = res.data.result.map((e: ResponsePeriod) => ({ + optionRound.value = await res.data.result.map((e: ResponsePeriod) => ({ id: e.period_id, year: e.period_year, name: e.period_name, @@ -84,14 +85,15 @@ async function fecthlistRound() { } DataStore.roundId = round.value; roundName.value = lastValue.name; + loadview.value = true; await fecthStat(round.value); } else { - loadview.value = false; - loading.value = false; + hideLoader(); } }) .catch((err) => { messageError($q, err); + hideLoader(); }); } @@ -109,23 +111,6 @@ async function fecthStat(id: string) { }); } -/** - * funcion เช็คหน่วยงาน - */ -async function fecthAgency() { - await http - .get(config.API.keycloakPosition()) - .then((res) => { - loadview.value = true; - DataStore.agency = res.data.result.rootId; - DataStore.typeOc = DataStore.agency; - loading.value = true; - }) - .catch((err) => { - messageError($q, err); - }); -} - /** * function fetch โครองสร้างปัจจุบัน */ @@ -145,9 +130,8 @@ function fetchActiveId() { * function fetch ข้อมูลโครองสร้างปัจจุบัน * @param id โครงสร้างปัจจุบัน */ -function fetchListOrg(id: string) { - showLoader(); - http +async function fetchListOrg(id: string) { + await http .get(config.API.orgByIdSystem(id, route.meta.Key as string)) .then(async (res) => { const data = await res.data.result.map((item: DataStructureTree) => ({ @@ -156,11 +140,24 @@ function fetchListOrg(id: string) { })); optiontypeOc.value = data; DataStore.fetchOption(optiontypeOc.value); //ค่าของหน่วยงานทั้งหมดไว้ที่ DataStore - await fecthAgency(); }) .catch((err) => { messageError($q, err); - hideLoader(); + }); +} + +/** + * funcion เช็คหน่วยงาน + */ +async function fecthAgency() { + await http + .get(config.API.keycloakPosition()) + .then((res) => { + DataStore.agency = res.data.result.rootId; + DataStore.typeOc = DataStore.agency; + }) + .catch((err) => { + messageError($q, err); }); } @@ -191,7 +188,7 @@ async function changround() { DataStore.agency != null //ถ้ามี agency เรียกข้อมูลตาม agency ถ้าไม่มีเรียนตาม Oc ที่เลือก ? DataStore.agency : DataStore.typeOc; - fecthInsigniaByOc(round.value, organization, "officer", tab.value); // เรียกข้อมูลรายชื่อข้าราชการสามัญฯ ที่มีสิทธิ์ยื่นขอพระราชทานเครื่องราชอิสริยาภรณ์ + await fecthInsigniaByOc(round.value, organization, "officer", tab.value); // เรียกข้อมูลรายชื่อข้าราชการสามัญฯ ที่มีสิทธิ์ยื่นขอพระราชทานเครื่องราชอิสริยาภรณ์ // get round name const roundFilter = optionRound.value.find((x: any) => round.value === x.id); if (roundFilter) { @@ -214,6 +211,7 @@ async function fecthInsigniaByOc( role: string, status: string ) { + DataStore.rows = []; if (roundId && ocId && role && status) { showLoader(); await http @@ -225,7 +223,6 @@ async function fecthInsigniaByOc( document.value = res.data.result.document; await DataStore.fetchData(res.data.result.items); // ส่งรายชื่อข้าราชการสามัญฯ await DataStore.fetchDataInsignia(res.data.result); // ส่งข้อมูลรอบบการแสดง - loading.value = true; // แสดงปุมล็อกข้อมูล if (res.data.result.items !== null) { if (res.data.result.items.length !== 0) { @@ -434,7 +431,13 @@ async function uploadFile(event: any) { */ onMounted(async () => { tab.value = DataStore.mainTab ?? ""; - Promise.all([fecthInsignia(), fecthlistRound(), fetchActiveId()]); + await Promise.all([ + fecthlistRound(), + fecthInsignia(), + fecthInsignia(), + fetchActiveId(), + fecthAgency(), + ]); }); @@ -506,6 +509,7 @@ onMounted(async () => { +
@@ -514,7 +518,7 @@ onMounted(async () => {
- +
{ label="หน่วยงานที่ยังไม่ได้ส่งรายชื่อ" /> + +
+ + + + + + + + + + + + + + + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - { @click="popupBackToInsignia2Role" /> - - - -
+ + + +