From ff95d207d2eb9a7c63f21cc88be31aa1131ce895 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 31 Oct 2024 17:53:10 +0700 Subject: [PATCH 01/30] feat: add notification type --- src/stores/notification/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/stores/notification/index.ts b/src/stores/notification/index.ts index 1243de88..5aa43fe5 100644 --- a/src/stores/notification/index.ts +++ b/src/stores/notification/index.ts @@ -4,7 +4,12 @@ import { api } from 'src/boot/axios'; import { PaginationResult } from 'src/types'; import { createDataRefBase } from '../utils'; -export type Notification = {}; +export type Notification = { + title: string; + detail: string; + receiverId?: string; + groupId?: string[]; +}; export const useNotification = defineStore('noti-store', () => { const state = createDataRefBase(); From 838490d90d974258a2016f780987191bfed3afa7 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 31 Oct 2024 17:56:46 +0700 Subject: [PATCH 02/30] fix: get possibly undefined type --- src/stores/utils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/utils/index.ts b/src/stores/utils/index.ts index 109bce33..84f504a7 100644 --- a/src/stores/utils/index.ts +++ b/src/stores/utils/index.ts @@ -532,7 +532,7 @@ export function createDataRefBase( defaultPageSize = 30, ) { return { - data: ref(), + data: ref([]), page: ref(defaultPage), pageMax: ref(defaultPageMax), pageSize: ref(defaultPageSize), From 74d80a163de55a936cd39f0acb53fb38993ff38f Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 31 Oct 2024 17:59:51 +0700 Subject: [PATCH 03/30] feat: fetch notification from api --- src/layouts/MainLayout.vue | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 168b895d..edee3b05 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -17,6 +17,7 @@ import { useConfigStore } from 'src/stores/config'; import { useNavigator } from 'src/stores/navigator'; import { initLang, initTheme, Lang, setLang } from 'src/utils/ui'; import { baseUrl } from 'stores/utils'; +import { useNotification } from 'src/stores/notification'; const useMyBranch = useMyBranchStore(); const { fetchListMyBranch } = useMyBranch; @@ -37,8 +38,11 @@ interface Notification { const $q = useQuasar(); const loaderStore = useLoader(); const navigatorStore = useNavigator(); +const notificationStore = useNotification(); const configStore = useConfigStore(); +const { data: notificationData } = storeToRefs(notificationStore); + const { visible } = storeToRefs(loaderStore); const { t } = useI18n({ useScope: 'global' }); const userStore = useUserStore(); @@ -129,6 +133,14 @@ onMounted(async () => { await configStore.getConfig(); + { + const noti = await notificationStore.getNotificationList(); + + if (noti) { + notificationData.value = noti.result; + } + } + await fetchListMyBranch(getUserId() ?? ''); leftDrawerOpen.value = $q.screen.gt.xs ? true : false; @@ -324,10 +336,10 @@ onMounted(async () => { clickable class="q-py-sm" v-ripple - v-for="item in !filterUnread - ? notification - : notification.filter((v) => !v.read)" - :key="item.id" + v-for="(item, i) in !filterUnread + ? notificationData + : notificationData" + :key="i" > { {{ item.title }} - {{ item.content }} + {{ item.detail }} @@ -356,7 +368,7 @@ onMounted(async () => { :delay="1000" :offset="[10, 10]" > - {{ item.content }} + {{ item.detail }} From 9c04b209926f3d7b2837d1f0ad70c5a3d0624b97 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Fri, 8 Nov 2024 09:23:53 +0700 Subject: [PATCH 04/30] fix: wrong variable name --- src/stores/notification/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/stores/notification/index.ts b/src/stores/notification/index.ts index 5aa43fe5..a1b2593c 100644 --- a/src/stores/notification/index.ts +++ b/src/stores/notification/index.ts @@ -33,9 +33,12 @@ export const useNotification = defineStore('noti-store', () => { return res.data; } - async function updateNotification(paymentId: string, payload: Notification) { + async function updateNotification( + notificationId: string, + payload: Notification, + ) { const res = await api.put( - `/notification/${paymentId}`, + `/notification/${notificationId}`, payload, ); if (res.status >= 400) return null; From 80cb67323b01827816f81de169ad31277a5c3722 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 5 Mar 2025 11:10:45 +0700 Subject: [PATCH 05/30] refactor: update data receive from backend --- src/layouts/MainLayout.vue | 43 ++++++-------------------------- src/stores/notification/index.ts | 5 ++-- 2 files changed, 11 insertions(+), 37 deletions(-) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index edee3b05..be00b93f 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -18,6 +18,7 @@ import { useNavigator } from 'src/stores/navigator'; import { initLang, initTheme, Lang, setLang } from 'src/utils/ui'; import { baseUrl } from 'stores/utils'; import { useNotification } from 'src/stores/notification'; +import moment from 'moment'; const useMyBranch = useMyBranchStore(); const { fetchListMyBranch } = useMyBranch; @@ -28,13 +29,6 @@ interface NotificationButton { active: boolean; } -interface Notification { - id: string; - title: string; - content: string; - read: boolean; -} - const $q = useQuasar(); const loaderStore = useLoader(); const navigatorStore = useNavigator(); @@ -82,20 +76,6 @@ const notiMenu = ref([ active: false, }, ]); -const notification = ref([ - { - id: '1', - title: 'Unread', - content: 'Unread', - read: false, - }, - { - id: '3', - title: 'Read', - content: 'Already read', - read: true, - }, -]); function setActive(button: NotificationButton) { notiMenu.value = notiMenu.value.map((current) => ({ @@ -290,7 +270,7 @@ onMounted(async () => {
- + { From ace2aec85b4747ae7148e10b39f687f3e87567e6 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 5 Mar 2025 13:28:50 +0700 Subject: [PATCH 06/30] feat: unread count --- src/layouts/MainLayout.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index be00b93f..11bb48e7 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -19,6 +19,7 @@ import { initLang, initTheme, Lang, setLang } from 'src/utils/ui'; import { baseUrl } from 'stores/utils'; import { useNotification } from 'src/stores/notification'; import moment from 'moment'; +import { computed } from 'vue'; const useMyBranch = useMyBranchStore(); const { fetchListMyBranch } = useMyBranch; @@ -47,7 +48,9 @@ const leftDrawerOpen = ref(false); const leftDrawerMini = ref(false); const filterUnread = ref(false); -const unread = ref(1); +const unread = computed( + () => notificationData.value.filter((v) => !v.read).length || 0, +); // const filterRole = ref(); const userImage = ref(); const userGender = ref(''); @@ -316,9 +319,9 @@ onMounted(async () => { clickable class="q-py-sm" v-ripple - v-for="(item, i) in !filterUnread + v-for="(item, i) in filterUnread ? notificationData.filter((v) => !v.read) - : notificationData.filter((v) => v.read)" + : notificationData" @click="notificationStore.getNotification(item.id)" :key="i" > From ac0d3649d4c6031457e8a77639bb1933eabaa074 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 5 Mar 2025 15:26:22 +0700 Subject: [PATCH 07/30] chore: clean --- src/layouts/MainLayout.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 11bb48e7..f1f2f470 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -344,7 +344,6 @@ onMounted(async () => {
{{ moment(item.createdAt).fromNow() }} - 5 s Date: Wed, 5 Mar 2025 17:33:26 +0700 Subject: [PATCH 08/30] fix: system cannot see some report --- src/pages/14_report/MainPage.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/14_report/MainPage.vue b/src/pages/14_report/MainPage.vue index 9c72fdee..e59a3f55 100644 --- a/src/pages/14_report/MainPage.vue +++ b/src/pages/14_report/MainPage.vue @@ -64,7 +64,7 @@ onMounted(async () => { const isExecutive = computed(() => { const roles = userRoles.value; - return roles.includes('executive'); + return roles.includes('executive') || roles.includes('system'); }); const filteredTabs = computed(() => { From 18b686e0466714a9798becf4087714beb06260de Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Wed, 5 Mar 2025 17:34:13 +0700 Subject: [PATCH 09/30] refactor: hide btn preview on tab receipt --- src/components/05_quotation/TableQuotation.vue | 2 ++ src/pages/05_quotation/MainPage.vue | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/components/05_quotation/TableQuotation.vue b/src/components/05_quotation/TableQuotation.vue index e3d46c56..a80a4e40 100644 --- a/src/components/05_quotation/TableQuotation.vue +++ b/src/components/05_quotation/TableQuotation.vue @@ -18,6 +18,7 @@ const props = withDefaults( hideEdit?: boolean; page?: number; pageSize?: number; + hideBtnPreview?: boolean; }>(), { row: () => [], @@ -127,6 +128,7 @@ defineEmits<{ Date: Thu, 6 Mar 2025 10:05:09 +0700 Subject: [PATCH 10/30] fix: wrong api case --- src/stores/report/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/report/index.ts b/src/stores/report/index.ts index 7686236c..6ba9ce2f 100644 --- a/src/stores/report/index.ts +++ b/src/stores/report/index.ts @@ -47,7 +47,7 @@ export async function getReportSale() { } export async function getReportProduct() { - const res = await api.get(`/${ENDPOINT}/Product`); + const res = await api.get(`/${ENDPOINT}/product`); if (res.status < 400) { return res.data; } From f9077cc03017286cf7be6ff4e5cfd561b318dd89 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 6 Mar 2025 10:46:39 +0700 Subject: [PATCH 11/30] feat: add notification translations for English and Thai --- src/i18n/eng.ts | 11 +++++++++++ src/i18n/tha.ts | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/i18n/eng.ts b/src/i18n/eng.ts index c822240c..e65a0688 100644 --- a/src/i18n/eng.ts +++ b/src/i18n/eng.ts @@ -240,6 +240,16 @@ export default { }, }, + noti: { + title: 'Notification', + caption: 'All Notification', + unread: 'Unread', + all: 'All', + read: 'Read', + viewALL: 'View All', + markAsRead: 'Mark as Read', + }, + form: { tm6: { transportation: 'Flight/Vehicle', @@ -1139,6 +1149,7 @@ export default { taskListNotFound: 'Task list cannot be found.', creditNoteNotFound: 'Credit note cannot be found.', debitNoteNotFound: 'Debit note cannot be found.', + notificationNotFound: 'Notification cannot be found.', productGroupIsUsed: 'Product group is in used.', productIsUsed: 'Product is in used.', diff --git a/src/i18n/tha.ts b/src/i18n/tha.ts index c3205cbc..fa792f43 100644 --- a/src/i18n/tha.ts +++ b/src/i18n/tha.ts @@ -240,6 +240,16 @@ export default { }, }, + noti: { + title: 'การแจ้งเตือน', + caption: 'การแจ้งเตือนทั้งหมด', + unread: 'ยังไม่ได้อ่าน', + all: 'ทั้งหมด', + read: 'อ่าน', + viewAll: 'ดูทั้งหมด', + markAsRead: 'ทำเครื่องหมายว่าอ่านแล้ว', + }, + form: { tm6: { transportation: 'เที่ยวบิน/พาหนะ', @@ -1117,6 +1127,7 @@ export default { taskListNotFound: 'ไม่พบใบสั่งงาน', creditNoteNotFound: 'ไม่พบใบลดหนี้', debitNoteNotFound: 'ไม่พบใบเพิ่มหนี้', + notificationNotFound: 'ไม่พบการแจ้งเตือน', productGroupIsUsed: 'กลุ่มสินค้าและบริการที่ใช้งานอยู่', productIsUsed: 'สินค้าและบริการใช้งานอยู่', From ede8e8018192e90bde936e82339fd183fdf08e1a Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 6 Mar 2025 10:46:53 +0700 Subject: [PATCH 12/30] feat: add notification route and functions to delete and mark notifications as read --- src/router/routes.ts | 6 +++++- src/stores/notification/index.ts | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/router/routes.ts b/src/router/routes.ts index 6d752495..2f7405d1 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -135,6 +135,11 @@ const routes: RouteRecordRaw[] = [ name: 'dashBoard', component: () => import('pages/15_dash-board/MainPage.vue'), }, + { + path: '/notification', + name: 'Notification', + component: () => import('pages/00_notification/MainPage.vue'), + }, ], }, @@ -208,7 +213,6 @@ const routes: RouteRecordRaw[] = [ name: 'DebitNoteView', component: () => import('pages/12_debit-note/FormPage.vue'), }, - { path: '/debit-note/document-view', name: 'DebitNoteDocumentView', diff --git a/src/stores/notification/index.ts b/src/stores/notification/index.ts index 4f3d4cfe..cfeb63ba 100644 --- a/src/stores/notification/index.ts +++ b/src/stores/notification/index.ts @@ -54,6 +54,26 @@ export const useNotification = defineStore('noti-store', () => { return res.data; } + async function deleteMultiNotification(notificationId: string[]) { + const res = await api.delete( + '/notification', + { + data: notificationId, + }, + ); + if (res.status >= 400) return null; + return true; + } + + async function markReadNotification(notificationId: string[]) { + const res = await api.post( + '/notification/mark-read', + { id: notificationId }, + ); + if (res.status >= 400) return null; + return true; + } + return { ...state, @@ -61,5 +81,7 @@ export const useNotification = defineStore('noti-store', () => { getNotificationList, updateNotification, deleteNotification, + deleteMultiNotification, + markReadNotification, }; }); From 65bf510386955fe229f3c0892b5e4e8865462a09 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 6 Mar 2025 10:47:57 +0700 Subject: [PATCH 13/30] feat: add notification dialog component and integrate with main layout --- src/layouts/MainLayout.vue | 84 ++++++-- src/pages/00_notification/MainPage.vue | 243 +++++++++++++++++++++++ src/pages/00_notification/NotiDialog.vue | 65 ++++++ 3 files changed, 370 insertions(+), 22 deletions(-) create mode 100644 src/pages/00_notification/MainPage.vue create mode 100644 src/pages/00_notification/NotiDialog.vue diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index f1f2f470..e84c65ff 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -1,10 +1,11 @@ + + diff --git a/src/pages/00_notification/NotiDialog.vue b/src/pages/00_notification/NotiDialog.vue new file mode 100644 index 00000000..63a37f9d --- /dev/null +++ b/src/pages/00_notification/NotiDialog.vue @@ -0,0 +1,65 @@ + + From e6f2a8df4e2c93c8c5bcb431f72c4c5014ef6af1 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 6 Mar 2025 11:11:17 +0700 Subject: [PATCH 14/30] feat: download report --- src/components/14_report/Expansion.vue | 4 +- src/pages/14_report/MainPage.vue | 61 +++++++++++++++++++++++--- src/stores/report/index.ts | 50 ++++++++++++++++++++- 3 files changed, 106 insertions(+), 9 deletions(-) diff --git a/src/components/14_report/Expansion.vue b/src/components/14_report/Expansion.vue index 581c677b..9f119bbf 100644 --- a/src/components/14_report/Expansion.vue +++ b/src/components/14_report/Expansion.vue @@ -15,9 +15,7 @@ defineProps<{ :default-opened="defaultOpened" >
diff --git a/src/pages/14_report/MainPage.vue b/src/pages/14_report/MainPage.vue index e59a3f55..c96fbe2d 100644 --- a/src/pages/14_report/MainPage.vue +++ b/src/pages/14_report/MainPage.vue @@ -24,6 +24,7 @@ import useFlowStore from 'src/stores/flow'; import { useReportStore } from 'src/stores/report'; import BadgeComponent from 'src/components/BadgeComponent.vue'; import Expansion from 'src/components/14_report/Expansion.vue'; +import { SaveButton } from 'src/components/button'; // NOTE: Variable const navigatorStore = useNavigator(); @@ -166,7 +167,17 @@ watch([() => pageState.currentTab], async () => { - +