|
|
@@ -1,243 +1,203 @@
|
|
|
<script setup lang="ts">
|
|
|
-import EventCard from '@/components/NotificationMessageCard/src/components/EventCard.vue'
|
|
|
+import NotificationMessageCard from '@/components/NotificationMessageCard/src/NotificationMessageCard.vue'
|
|
|
+import { useNotificationMessage } from '@/stores/modules/notificationMessage'
|
|
|
|
|
|
+const activeCardTypeName = ref(sessionStorage.getItem('activeCardTypeName') || 'Milestone Update')
|
|
|
+
|
|
|
+const notificationMsgStore = useNotificationMessage()
|
|
|
const collapseVModel = ref<string[]>(['1'])
|
|
|
|
|
|
-const navList = [
|
|
|
- {
|
|
|
- title: 'Milestone Update',
|
|
|
- count: 2
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'Container Status Update',
|
|
|
- count: 1
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'Departure/Arrival Delay',
|
|
|
- count: '99+'
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'ETD/ETA Change',
|
|
|
- count: 0
|
|
|
+const tabCountList = ref([0, 0, 0, 0, 0])
|
|
|
+const curTabCount = ref([])
|
|
|
+
|
|
|
+const handleCount = (count: number) => {
|
|
|
+ if (!count) return ''
|
|
|
+ return count > 99 ? '99+' : count
|
|
|
+}
|
|
|
+const handleShowCount = (typeName: string, index: number) => {
|
|
|
+ // 在切换type类型时,防止点击的类型值为点击之前类型的值
|
|
|
+ if (curTabCount.value?.[index] > -1) {
|
|
|
+ return curTabCount.value[index]
|
|
|
}
|
|
|
+ const count = tabCountList.value[index]
|
|
|
+ if (typeName === activeCardTypeName.value) {
|
|
|
+ return handleCount(unreadNotificationList.value.length)
|
|
|
+ }
|
|
|
+ return handleCount(count)
|
|
|
+}
|
|
|
+
|
|
|
+const navList = [
|
|
|
+ 'Milestone Update',
|
|
|
+ 'Container Status Update',
|
|
|
+ 'Departure/Arrival Delay',
|
|
|
+ 'ETD/ETA Change'
|
|
|
]
|
|
|
|
|
|
-const activeItem = ref('Milestone Update')
|
|
|
+const notificationTypeList = ref({
|
|
|
+ Milestone_Update: 'Milestone Update',
|
|
|
+ Container_Status_Update: 'Container Status Update',
|
|
|
+ Container_Arrival: 'Container Arrival',
|
|
|
+ 'Departure/Arrival_Delay': 'Departure/Arrival Delay',
|
|
|
+ 'ETD/ETA_Change': 'ETD/ETA Change',
|
|
|
+ Feature_Update: 'Feature Update'
|
|
|
+})
|
|
|
+
|
|
|
const setActiveItem = (item: string) => {
|
|
|
- activeItem.value = item
|
|
|
-}
|
|
|
+ navList.forEach((navItem, index) => {
|
|
|
+ curTabCount.value[index] = handleShowCount(navItem, index)
|
|
|
+ })
|
|
|
+ curTabCount.value[tabCountList.value.length - 1] = handleShowCount(
|
|
|
+ 'Feature Update',
|
|
|
+ tabCountList.value.length - 1
|
|
|
+ )
|
|
|
|
|
|
-// const getNotificationList = () => {
|
|
|
-// $api
|
|
|
-// .getNotificationList({
|
|
|
-// rules_type: 'Milestone_Update'
|
|
|
-// })
|
|
|
-// .then((res) => {
|
|
|
-// if (res.code === 200) {
|
|
|
-// notificationList.value = res.data.info
|
|
|
-// console.log(res, 'test')
|
|
|
-// }
|
|
|
-// })
|
|
|
-// }
|
|
|
+ activeCardTypeName.value = item
|
|
|
+ sessionStorage.setItem('activeCardTypeName', item)
|
|
|
+ activeTabName.value = 'All Notifications'
|
|
|
+ getNotificationList()
|
|
|
+}
|
|
|
|
|
|
-const activeName = ref('first')
|
|
|
+const loading = ref(false)
|
|
|
+const notificationList = ref<any[]>([])
|
|
|
|
|
|
-const handleClick = () => {}
|
|
|
+const unreadNotificationList = computed(() => {
|
|
|
+ return notificationList.value.filter((item) => !item.info.isRead)
|
|
|
+})
|
|
|
+const readNotificationList = computed(() => {
|
|
|
+ return notificationList.value.filter((item) => item.info.isRead)
|
|
|
+})
|
|
|
+const getNotificationList = async () => {
|
|
|
+ loading.value = true
|
|
|
+ const rulesType = Object.entries(notificationTypeList.value).find(
|
|
|
+ (item) => item[1] === activeCardTypeName.value
|
|
|
+ )?.[0]
|
|
|
+ try {
|
|
|
+ await notificationMsgStore.markMessageAsRead()
|
|
|
+ $api
|
|
|
+ .getSystemMessageData({
|
|
|
+ rules_type: rulesType
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ const data = res.data
|
|
|
+ notificationList.value = data.cardList
|
|
|
+ tabCountList.value = data.countList
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ loading.value = false
|
|
|
+ curTabCount.value = []
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ loading.value = false
|
|
|
+ curTabCount.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-// const notificationList = ref<any[]>([])
|
|
|
-const notificationList = [
|
|
|
- {
|
|
|
- type: 'milestone',
|
|
|
- isMultiple: true,
|
|
|
- numericRecords: 3,
|
|
|
- isRead: true,
|
|
|
- title: 'Milestone Update',
|
|
|
- mode: 'Ocean Freight',
|
|
|
- no: 'SHJN2301234',
|
|
|
- tag: 'Booking Confirmed',
|
|
|
- location: 'Hong Kong',
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'container',
|
|
|
- isRead: false,
|
|
|
- mode: '',
|
|
|
- no: 'SHJN2301234',
|
|
|
- tag: 'Unloaded From Vessel',
|
|
|
- location: 'Hong Kong',
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai',
|
|
|
- previous: 'Previous: Departure from Shanghai (08:15 UTC+8)'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'delay',
|
|
|
- numericRecords: 0,
|
|
|
- isRead: false,
|
|
|
- title: 'Delay Daily Summary (Jan 10, 2025)',
|
|
|
- mode: 'Air Freight',
|
|
|
- no: 'SHJN2301234',
|
|
|
- tag: 'Departure Delay',
|
|
|
- location: 'Hong Kong',
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai',
|
|
|
- info: {
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai',
|
|
|
- departureDelayNum: 10,
|
|
|
- arrivalDelayNum: 8
|
|
|
+const changeCardRead = () => {
|
|
|
+ const readCardMap = notificationMsgStore.readCardMap
|
|
|
+ notificationList.value.forEach((item) => {
|
|
|
+ if (readCardMap.includes(item.info.id)) {
|
|
|
+ item.info.isRead = true
|
|
|
}
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'container',
|
|
|
- isRead: false,
|
|
|
- mode: '',
|
|
|
- no: 'SHJN2301234',
|
|
|
- tag: 'Unloaded From Vessel',
|
|
|
- location: 'Hong Kong',
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai',
|
|
|
- previous: 'Previous: Departure from Shanghai (08:15 UTC+8)'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'delay',
|
|
|
- numericRecords: 0,
|
|
|
- isRead: false,
|
|
|
- title: 'Delay Daily Summary (Jan 10, 2025)',
|
|
|
- mode: 'Air Freight',
|
|
|
- no: 'SHJN2301234',
|
|
|
- tag: 'Departure Delay',
|
|
|
- location: 'Hong Kong',
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai',
|
|
|
- info: {
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai',
|
|
|
- departureDelayNum: 10,
|
|
|
- arrivalDelayNum: 8
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'container',
|
|
|
- isRead: false,
|
|
|
- mode: '',
|
|
|
- no: 'SHJN2301234',
|
|
|
- tag: 'Unloaded From Vessel',
|
|
|
- location: 'Hong Kong',
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai',
|
|
|
- previous: 'Previous: Departure from Shanghai (08:15 UTC+8)'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'delay',
|
|
|
- numericRecords: 0,
|
|
|
- isRead: false,
|
|
|
- title: 'Delay Daily Summary (Jan 10, 2025)',
|
|
|
- mode: 'Air Freight',
|
|
|
- no: 'SHJN2301234',
|
|
|
- tag: 'Departure Delay',
|
|
|
- location: 'Hong Kong',
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai',
|
|
|
- info: {
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai',
|
|
|
- departureDelayNum: 10,
|
|
|
- arrivalDelayNum: 8
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const activeTabName = ref('All Notifications')
|
|
|
+const handleTabChange = () => {
|
|
|
+ // 当前tab页切换时,更新数据
|
|
|
+ const readCardMap = notificationMsgStore.readCardMap
|
|
|
+ notificationList.value.forEach((item) => {
|
|
|
+ if (readCardMap.includes(item.info.id)) {
|
|
|
+ item.info.isRead = true
|
|
|
}
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'change',
|
|
|
- numericRecords: 0,
|
|
|
- isRead: false,
|
|
|
- title: 'ETD/ETA Change Weekly Summary (Jan 4- 10, 2025) ',
|
|
|
- mode: 'Air Freight',
|
|
|
- no: 'SHJN2301234',
|
|
|
- tag: 'ETD Change',
|
|
|
- info: {
|
|
|
- etdChangeNum: 20,
|
|
|
- etaChangeNum: 10,
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai'
|
|
|
- },
|
|
|
- location: 'Hong Kong',
|
|
|
- changeTime: 'Updated ETD: Jan 17, 15:00',
|
|
|
- timeLabel: 'ATA: ',
|
|
|
- time: '2510-12-1 14:30 UTC+8',
|
|
|
- timezone: 'Asia/Shanghai'
|
|
|
- }
|
|
|
-]
|
|
|
-// onMounted(() => {
|
|
|
-// getNotificationList()
|
|
|
-// })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getNotificationList()
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <div class="Title">System Message</div>
|
|
|
- <div class="system-message">
|
|
|
- <div class="left-nav">
|
|
|
- <el-collapse v-model="collapseVModel">
|
|
|
- <el-collapse-item title="Event Notifications" name="1">
|
|
|
- <div
|
|
|
- @click="setActiveItem(item.title)"
|
|
|
- class="collapse-item"
|
|
|
- :class="{ 'is-active': item.title === activeItem }"
|
|
|
- v-for="item in navList"
|
|
|
- :key="item.title"
|
|
|
- >
|
|
|
- <div v-if="item.title === activeItem" class="active-sign"></div>
|
|
|
- <span>{{ item.title }}</span>
|
|
|
- <div class="count" v-if="item.count">
|
|
|
- <span>{{ item.count }}</span>
|
|
|
+ <div v-vloading="loading" style="height: 100%; width: 100%">
|
|
|
+ <div class="Title">System Message</div>
|
|
|
+ <div class="system-message">
|
|
|
+ <div class="left-nav">
|
|
|
+ <el-collapse v-model="collapseVModel">
|
|
|
+ <el-collapse-item title="Event Notifications" name="1">
|
|
|
+ <div
|
|
|
+ @click="setActiveItem(item)"
|
|
|
+ class="collapse-item"
|
|
|
+ :class="{ 'is-active': item === activeCardTypeName }"
|
|
|
+ v-for="(item, index) in navList"
|
|
|
+ :key="item"
|
|
|
+ >
|
|
|
+ <div v-if="item === activeCardTypeName" class="active-sign"></div>
|
|
|
+ <span>{{ item }}</span>
|
|
|
+ <div class="count" v-if="handleShowCount(item, index)">
|
|
|
+ <span>{{ handleShowCount(item, index) }}</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+ </el-collapse-item>
|
|
|
+ </el-collapse>
|
|
|
+ <div
|
|
|
+ @click="setActiveItem('Feature Update')"
|
|
|
+ class="collapse-item"
|
|
|
+ style="margin-top: 4px; font-weight: 700"
|
|
|
+ :class="{ 'is-active': activeCardTypeName === 'Feature Update' }"
|
|
|
+ >
|
|
|
+ <div v-if="activeCardTypeName === 'Feature Update'" class="active-sign"></div>
|
|
|
+ <span>Feature Update</span>
|
|
|
+ <div class="count" v-if="handleShowCount('Feature Update', tabCountList.length - 1)">
|
|
|
+ <span>{{ handleShowCount('Feature Update', tabCountList.length - 1) }}</span>
|
|
|
</div>
|
|
|
- </el-collapse-item>
|
|
|
- </el-collapse>
|
|
|
- <div
|
|
|
- @click="setActiveItem('Feature Update')"
|
|
|
- class="collapse-item"
|
|
|
- style="margin-top: 4px; font-weight: 700"
|
|
|
- :class="{ 'is-active': activeItem === 'Feature Update' }"
|
|
|
- >
|
|
|
- <div v-if="activeItem === 'Feature Update'" class="active-sign"></div>
|
|
|
- <span>Feature Update</span>
|
|
|
- <div class="count">
|
|
|
- <span>33</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <div class="right-content">
|
|
|
- <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
|
|
|
- <el-tab-pane label="All Notifications" name="first">
|
|
|
- <div style="padding: 10px 140px 0px 16px">
|
|
|
- <EventCard
|
|
|
- v-for="(item, index) in notificationList"
|
|
|
- :key="index"
|
|
|
- :data="item"
|
|
|
- ></EventCard>
|
|
|
- </div>
|
|
|
- </el-tab-pane>
|
|
|
- <el-tab-pane label="Unread" name="second">
|
|
|
- <template #label>
|
|
|
- <span style="margin-right: 4px">Unread</span>
|
|
|
- <div class="count">
|
|
|
- <span>33</span>
|
|
|
+ <div class="right-content">
|
|
|
+ <el-tabs v-model="activeTabName" @tab-change="handleTabChange" class="demo-tabs">
|
|
|
+ <el-tab-pane label="All Notifications" name="All Notifications">
|
|
|
+ <template #label>
|
|
|
+ <span style="margin-right: 4px">All Notifications</span>
|
|
|
+ </template>
|
|
|
+ <div style="padding: 10px 140px 0px 16px" v-if="activeTabName === 'All Notifications'">
|
|
|
+ <NotificationMessageCard
|
|
|
+ v-if="activeTabName === 'All Notifications'"
|
|
|
+ :data="notificationList"
|
|
|
+ @hasCardRead="changeCardRead"
|
|
|
+ :updateReadCardsOnChange="false"
|
|
|
+ ></NotificationMessageCard>
|
|
|
</div>
|
|
|
- </template>
|
|
|
- </el-tab-pane>
|
|
|
- <el-tab-pane label="Read" name="third">Role</el-tab-pane>
|
|
|
- </el-tabs>
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane label="Unread" name="Unread">
|
|
|
+ <template #label>
|
|
|
+ <span style="margin-right: 4px">Unread</span>
|
|
|
+ <div class="count" v-if="unreadNotificationList.length">
|
|
|
+ <span>{{ handleCount(unreadNotificationList.length) }}</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div style="padding: 10px 140px 0px 16px" v-if="activeTabName === 'Unread'">
|
|
|
+ <NotificationMessageCard
|
|
|
+ v-if="activeTabName === 'Unread'"
|
|
|
+ :data="unreadNotificationList"
|
|
|
+ :updateReadCardsOnChange="false"
|
|
|
+ ></NotificationMessageCard>
|
|
|
+ </div>
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane label="Read" name="Read">
|
|
|
+ <template #label><span style="margin-right: 4px">Read</span> </template>
|
|
|
+ <div style="padding: 10px 140px 0px 16px" v-if="activeTabName === 'Read'">
|
|
|
+ <NotificationMessageCard
|
|
|
+ v-if="activeTabName === 'Read'"
|
|
|
+ :updateReadCardsOnChange="false"
|
|
|
+ :data="readNotificationList"
|
|
|
+ >
|
|
|
+ </NotificationMessageCard>
|
|
|
+ </div>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -257,10 +217,10 @@ const notificationList = [
|
|
|
height: calc(100% - 68px);
|
|
|
.count {
|
|
|
display: inline-flex;
|
|
|
- justify-content: center;
|
|
|
height: 18px;
|
|
|
min-width: 18px;
|
|
|
- padding-left: 4px;
|
|
|
+ padding-top: 1px;
|
|
|
+ padding-left: 5px;
|
|
|
padding-right: 5px;
|
|
|
background-color: var(--color-theme);
|
|
|
border-radius: 9px;
|