From c6c55fcb1b4d89b64ca3e88c761813bedb1ebac8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 19 Jan 2024 15:13:14 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=81=E0=B8=88?= =?UTF-8?q?=E0=B9=89=E0=B8=87=E0=B9=80=E0=B8=95=E0=B8=B7=E0=B8=AD=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/MainLayout.vue | 181 ++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 96 deletions(-) diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 76e43c9..f2e453a 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -45,7 +45,6 @@ async function fetchTotolNotificate() { .get(config.API.msgNotificateTotal) .then((res) => { totalNoti.value = res.data.result; - console.log(totalNoti.value); }) .catch((err) => { messageError($q, err); @@ -54,12 +53,12 @@ async function fetchTotolNotificate() { const fetchlistNotification = async (index: number, type: string) => { await http - .get(config.API.msgNotificate + `?page=${index}&pageSize=${20}`) + .get(config.API.msgNotificate + `?page=${index}&pageSize=${15}`) .then((res: any) => { const data = res.data.result.data; totalInbox.value = res.data.result.total; let list: any[] = []; - if (type === "DEL") { + if (type === "DEL" || index === 1) { notiList.value = []; } data.map((e: any) => { @@ -76,6 +75,7 @@ const fetchlistNotification = async (index: number, type: string) => { }); }); notiList.value.push(...list); + totalInbox.value = res.data.result.total; }) .catch((err) => { @@ -101,7 +101,7 @@ const doLogout = () => { const clickDelete = async (id: string, index: number) => { dialogRemove($q, async () => { - showLoader(); + // showLoader(); await http .delete(config.API.msgId(id)) .then(() => { @@ -113,21 +113,20 @@ const clickDelete = async (id: string, index: number) => { messageError($q, e); }) .finally(async () => { - notiList.value.length === 15 && fetchlistNotification(1, "DEL"); - hideLoader(); + notiList.value.length === 12 && fetchlistNotification(1, "DEL"); + // hideLoader(); }); }); }; const totalInbox = ref(0); -const round = ref(0); -function onLoad(index: any, done: any) { - if (notiList.value.length < totalInbox.value) { - setTimeout(() => { - fetchlistNotification(index + 1, "NOMAL"); - done(); - }, 3000); - } +const page = ref(0); +async function onLoad(index: any, done: any) { + page.value++; + setTimeout(async () => { + await fetchlistNotification(page.value, "NOMAL"); + done(); + }, 1500); } watch( @@ -140,9 +139,6 @@ watch( })); notiList.value = updatedNotifications; fetchTotolNotificate(); - } else { - round.value++; - round.value == 1 && fetchlistNotification(round.value, "NOMAL"); } } ); @@ -218,6 +214,7 @@ const thaiOptions: Intl.DateTimeFormatOptions = { size="13px" :class="$q.screen.gt.xs ? 'bg-white-btn q-mx-md' : 'q-mr-sm'" :color="totalNoti === 0 ? 'grey-6' : 'grey-8'" + no-caps > {{ totalNoti }} - - -
- -
-
- การแจ้งเตือน -
- -
- ทั้งหมด {{ totalInbox }} ข้อความ -
-
-
- - - - {{ - item.body[0] - }} - - - - - {{ date2Thai(item.receiveDate) }} - {{ - new Date(item.receiveDate).toLocaleTimeString( - "th-TH", - thaiOptions - ) - }} - น. - - {{ item.body }} - {{ item.timereceive }} - -
- -
-
-
- -
+ +
+
การแจ้งเตือน
+ +
+ ทั้งหมด {{ totalInbox }} ข้อความ
-
- +
+ +
+ + + + {{ + item.body[0] + }} + + + + + {{ date2Thai(item.receiveDate) }} + {{ + new Date(item.receiveDate).toLocaleTimeString( + "th-TH", + thaiOptions + ) + }} + น. + + {{ item.body }} + {{ item.timereceive }} + +
+ +
+
- + + +