From b7de285e8dbc879f3a54bb5d9cee4c077f0050a3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Wed, 17 Jan 2024 17:34:55 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=20=E0=B8=81=E0=B8=A5=E0=B9=88=E0=B8=AD=E0=B8=87=E0=B8=82?= =?UTF-8?q?=E0=B9=89=E0=B8=AD=E0=B8=84=E0=B8=A7=E0=B8=B2=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/01_dashboard/views/Dashboard.vue | 79 ++++++++++---------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/src/modules/01_dashboard/views/Dashboard.vue b/src/modules/01_dashboard/views/Dashboard.vue index dc6608c..4d022af 100644 --- a/src/modules/01_dashboard/views/Dashboard.vue +++ b/src/modules/01_dashboard/views/Dashboard.vue @@ -87,35 +87,36 @@ onMounted(async () => { }); const fetchlistInbox = async (index: number) => { index === 1 && showLoader(); - await http - .get(config.API.msgInbox + `?page=${index}&pageSize=${10}`) - .then((res) => { - let data = res.data.result.data; - totalInbox.value = res.data.result.total; - let listItem: any = []; - data.map((e: any) => { - listItem.push({ - no: e.id ?? "", - sender: - e.createdFullName == "" || e.createdFullName == null - ? "เจ้าหน้าที่" - : e.createdFullName, - subject: e.subject ?? "", - timereceive: date2Thai(e.createdAt), - body: e.body ?? "-", - ratingModel: 0, - receiveDate: date2Thai(e.receiveDate), - payload: e.payload, + index != 0 && + (await http + .get(config.API.msgInbox + `?page=${index}&pageSize=${10}`) + .then((res) => { + let data = res.data.result.data; + totalInbox.value = res.data.result.total; + let listItem: any = []; + data.map((e: any) => { + listItem.push({ + no: e.id ?? "", + sender: + e.createdFullName == "" || e.createdFullName == null + ? "เจ้าหน้าที่" + : e.createdFullName, + subject: e.subject ?? "", + timereceive: date2Thai(e.createdAt), + body: e.body ?? "-", + ratingModel: 0, + receiveDate: date2Thai(e.receiveDate), + payload: e.payload, + }); }); - }); - inboxList.value.push(...listItem); - }) - .catch((err) => { - console.log(err); - }) - .finally(() => { - hideLoader(); - }); + inboxList.value.push(...listItem); + }) + .catch((err) => { + console.log(err); + }) + .finally(() => { + hideLoader(); + })); }; const transferToPage = (path?: string) => { @@ -149,23 +150,16 @@ function updateModalDetail(val: boolean) { const scrollTargetRef = ref(null); const totalInbox = ref(0); -function onLoad(index: number, done: any) { +async function onLoad(index: number, done: any) { + const num = index === 1 ? 0 : index++; + if (inboxList.value.length < totalInbox.value) { setTimeout(() => { - fetchlistInbox(index + 1); + fetchlistInbox(num); done(); }, 2000); } } - -// function onLoadRef(index: number, done: any) { -// if (inboxList.value.length < totalInbox.value) { -// setTimeout(() => { -// fetchlistInbox(index + 1); -// done(); -// }, 2000); -// } -// }