feat: new
This commit is contained in:
@@ -104,6 +104,9 @@
|
||||
<RenewalPaymentPopup ref="renewalPopupRef" :identifier="userStore.state.identifier"
|
||||
paymentRefreshTarget="home" @completed="loadAssetInfo" />
|
||||
|
||||
<PopupCandidate v-if='popupCandidateShow' page='home' :identifier='userStore.state.identifier'
|
||||
@close='onPopupCandidateClose' />
|
||||
|
||||
<!-- 日期选择器弹窗 -->
|
||||
<up-datetime-picker v-if="!userInfo.isDevice" :show="showStartDatePicker" v-model="startDateTimestamp"
|
||||
mode="date" @confirm="onStartDateConfirm" @cancel="showStartDatePicker=false"
|
||||
@@ -134,6 +137,7 @@
|
||||
import FloatingButton from '@/components/FloatingButton.vue';
|
||||
import NotificationPopup from '@/components/NotificationPopup.vue';
|
||||
import RenewalPaymentPopup from '@/components/RenewalPaymentPopup.vue';
|
||||
import PopupCandidate from '@/components/PopupCandidate.vue';
|
||||
import {
|
||||
assetApi,
|
||||
deviceApi,
|
||||
@@ -238,6 +242,7 @@
|
||||
let notificationPopupCurrent = ref(0);
|
||||
let renewalPopupRef = ref(null);
|
||||
const notificationReadPending = new Set();
|
||||
let popupCandidateShow = ref(false);
|
||||
|
||||
const formatDate = (dateStr) => {
|
||||
if (!dateStr) return '-';
|
||||
@@ -862,11 +867,10 @@
|
||||
|
||||
const loadUnreadNotifications = async () => {
|
||||
try {
|
||||
const data = await notificationApi.getList(1, 50, false);
|
||||
const items = (data?.items || [])
|
||||
.filter(item => !item.is_read)
|
||||
.sort((a, b) => getNotificationPriority(b) - getNotificationPriority(a));
|
||||
if (!items.length) return;
|
||||
const data = await notificationApi.getList(1, 50, false);
|
||||
const items = (data?.items || [])
|
||||
.filter(item => !item.is_read);
|
||||
if (!items.length) return;
|
||||
|
||||
notificationItems.value = items;
|
||||
notificationPopupCurrent.value = 0;
|
||||
@@ -885,17 +889,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
const getNotificationPriority = (item) => {
|
||||
const severityRank = { info: 10, warning: 20, error: 30, critical: 40 };
|
||||
const remainingDays = Number(item?.days_until_expiry ?? item?.days_remaining ?? item?.remaining_days);
|
||||
const expiryLevel = String(item?.expiry_level || '').toLowerCase();
|
||||
if (item?.category === 'expiry' && ((Number.isFinite(remainingDays) && remainingDays >= 0 && remainingDays <= 3) ||
|
||||
['0_3', '0-3', '0~3', 'critical'].includes(expiryLevel))) {
|
||||
return 100;
|
||||
}
|
||||
return severityRank[item?.severity] || 0;
|
||||
};
|
||||
|
||||
const onNotificationChange = (event) => {
|
||||
const index = Number(event?.detail?.current ?? event?.current ?? 0);
|
||||
notificationPopupCurrent.value = index;
|
||||
@@ -906,6 +899,18 @@
|
||||
notificationPopupShow.value = false;
|
||||
};
|
||||
|
||||
const runPopupCandidate = () => {
|
||||
popupCandidateShow.value = true;
|
||||
};
|
||||
|
||||
const onPopupCandidateClose = (reason) => {
|
||||
popupCandidateShow.value = false;
|
||||
if (reason === 'empty' || reason === 'invisible') {
|
||||
loadUnreadNotifications();
|
||||
}
|
||||
loadNotificationUnreadCount();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
initCurrentMonth();
|
||||
});
|
||||
@@ -916,7 +921,7 @@
|
||||
}
|
||||
handleIndexEntry();
|
||||
loadNotificationUnreadCount();
|
||||
loadUnreadNotifications();
|
||||
runPopupCandidate();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user