feat(通知): task_failed 带 ref_json 定位锚点,明细可点直达任务详情
用户原话「都没体现哪个任务id/店铺/用户,咋排查」:通知表只有 title/content, 失败任务又按「用户×模块×自然日」聚合成一条,明细被 5 个 taskNo 预览 + 512 字截断吃掉。 - V162 给 biz_user_notification 加 ref_json(TEXT,可重跑迁移,存量不回填) - 扫描器把桶内每个失败任务写成锚点(taskId/taskNo/moduleType/reason/updatedAt/ deviceId),上限 20 条;品牌任务无 task_no 用 #<id> 兜底,保证至少一条可定位 - 详情接口回传 refs;同键刷新时锚点变化也更新,且不重新点亮已读 - 后台铃铛「展开明细」渲染成可点行,跳任务中心 ?taskNo= 自动开详情抽屉 - 新增判据 taskFailedAdminNotificationCarriesUidAndTaskNoAnchor:管理端正文必须含 uid、每个桶的 ref_json 至少一条非空 taskNo
This commit is contained in:
@@ -140,6 +140,18 @@
|
||||
<span class="bell-item-time">{{ formatTime(item.createdAt) }}</span>
|
||||
</div>
|
||||
<div class="bell-item-content">{{ item.content }}</div>
|
||||
<div v-if="item.refs && item.refs.length" class="bell-ref-list">
|
||||
<button
|
||||
v-for="ref in item.refs"
|
||||
:key="`${item.id}-${ref.taskNo}`"
|
||||
type="button"
|
||||
class="bell-ref-link"
|
||||
:title="ref.reason || `查看任务 ${ref.taskNo}`"
|
||||
@click.stop="openTaskRef(item, ref)"
|
||||
>
|
||||
{{ ref.taskNo }}<span v-if="ref.reason" class="bell-ref-reason">:{{ ref.reason }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
<li v-if="!detailLoading && detailTotal > details.length" class="bell-detail-more">
|
||||
另有 {{ detailTotal - details.length }} 条未列出,可缩小日期范围后查看
|
||||
@@ -175,14 +187,17 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import type { AdminNotificationItem, AdminNotificationRef } from '@/api/notifications'
|
||||
import {
|
||||
NOTIFICATION_POLL_INTERVAL_MS,
|
||||
formatDayLabel,
|
||||
formatGroupCounts,
|
||||
formatNotificationTime,
|
||||
notificationGroupKey,
|
||||
taskCenterRouteForRef,
|
||||
} from '@/layout/notification-bell-model'
|
||||
import { todayDateInput } from '@/utils/datetime'
|
||||
import {
|
||||
@@ -194,6 +209,7 @@ import {
|
||||
} from '@/layout/notification-bell-panel'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const router = useRouter()
|
||||
|
||||
/**
|
||||
* 面板的数据流(聚合组、明细、两个计数、防抖与取数)整块在 notification-bell-panel.ts。
|
||||
@@ -231,6 +247,16 @@ const {
|
||||
unreadCount,
|
||||
} = useNotificationBellPanel({ uid: () => session.user?.id ?? 0, today: () => todayDateInput() })
|
||||
|
||||
/** 点锚点:先按原逻辑标已读,再跳任务中心(路由带 taskNo,页面进来自动开详情抽屉)。 */
|
||||
function openTaskRef(item: AdminNotificationItem, ref: AdminNotificationRef): void {
|
||||
const target = taskCenterRouteForRef(ref)
|
||||
if (!target) {
|
||||
return
|
||||
}
|
||||
void onItemClick(item)
|
||||
void router.push(target)
|
||||
}
|
||||
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
const panelRef = ref<HTMLElement | null>(null)
|
||||
const panelStyle = ref<Record<string, string>>({})
|
||||
@@ -592,6 +618,12 @@ onUnmounted(() => {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* 定位锚点:任务号可点,直达任务详情。压低视觉权重,不与正文抢注意力。 */
|
||||
.bell-ref-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
|
||||
.bell-ref-link { padding: 0; border: none; background: none; color: var(--admin-primary, #2f5d8b); font-family: inherit; font-size: 12px; line-height: 1.5; text-align: left; word-break: break-all; cursor: pointer; }
|
||||
.bell-ref-link:hover { text-decoration: underline; }
|
||||
.bell-ref-reason { color: #8a94a6; }
|
||||
|
||||
.bell-search {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user