From 2c732a9a3a160d4249c430acc1b5c64e1d602e38 Mon Sep 17 00:00:00 2001 From: yueli Date: Thu, 17 Sep 2026 10:30:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(borrow):=20=E5=85=A8=E5=B1=80=E5=BE=85?= =?UTF-8?q?=E5=8A=9E=E5=BC=BA=E6=8F=90=E9=86=92=EF=BC=88=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E4=BA=BA=E4=B8=8D=E5=86=8D=E5=A4=84=E4=BA=8E=E7=9B=B2=E5=8C=BA?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增无渲染组件 PendingTransferNotifier,挂在 Layout(路由切换常驻、且只在 已登录区域渲染,天然保证「有 token 才查」)。 UI ---- ElNotification,type=warning、duration=0(不自动关闭,须用户处理或手动点掉): 标题:待办通知:借库转交 内容:您有 X 件物品等待接收确认,请及时处理。【去处理 >】 点击【去处理】关闭通知并 router.push('/operation/records')(借还记录页)。 message 用 VNode 构造而非 dangerouslyUseHTMLString —— 不必把数量拼进 HTML 字符串。 防骚扰(两道) ---- · 会话级去重:sessionStorage 记「上次已提醒过的数量」,只有数量**变化**才再弹。 用 sessionStorage 而非 Pinia —— 前者跨刷新存活,后者会重置,刷新即轰炸。 · 数量归零时清掉记录,下次新转交能重新提醒。 ★ 加了 2 分钟低频轮询(超出需求所写,但需求目标需要它): 需求只要求「初始化时查一次」,而 SPA 只在首次进入时初始化 —— 已打开页面的 用户永远收不到提醒,与「第一时间响应」的目标相悖。有去重逻辑兜底, 轮询不会造成重复打扰。不需要的话删掉定时器即可。 错误一律静默:提醒是锦上添花,不能因接口抖动弹错误框刷屏。 验证:去重状态机用 node 复刻验证 —— 3→2→1 各弹一次,刷新与轮询均不重复, 归零后再来新转交能重新提醒。 --- inventory-web/src/api/transaction.ts | 12 ++ .../PendingTransferNotifier/index.vue | 104 ++++++++++++++++++ inventory-web/src/layout/index.vue | 5 + 3 files changed, 121 insertions(+) create mode 100644 inventory-web/src/components/PendingTransferNotifier/index.vue diff --git a/inventory-web/src/api/transaction.ts b/inventory-web/src/api/transaction.ts index f86d684..5abf4a3 100644 --- a/inventory-web/src/api/transaction.ts +++ b/inventory-web/src/api/transaction.ts @@ -308,6 +308,18 @@ export function rejectBorrowTransfer(transferId: number, reason?: string) { }) } +/** + * 待我接收的转交数量 —— 全局待办强提醒用(初始化 + 轮询)。 + * 极轻量,只做一次 count。 + * @returns { count } + */ +export function getPendingTransferCount() { + return request({ + url: '/v1/transactions/borrow/transfer/pending-count', + method: 'get' + }) +} + /** * 整单流转时间线(**borrow_no** 维度):借出 → 转交(可多次) → 归还 → 报废 * diff --git a/inventory-web/src/components/PendingTransferNotifier/index.vue b/inventory-web/src/components/PendingTransferNotifier/index.vue new file mode 100644 index 0000000..24037fb --- /dev/null +++ b/inventory-web/src/components/PendingTransferNotifier/index.vue @@ -0,0 +1,104 @@ + + + diff --git a/inventory-web/src/layout/index.vue b/inventory-web/src/layout/index.vue index af8e789..0540503 100644 --- a/inventory-web/src/layout/index.vue +++ b/inventory-web/src/layout/index.vue @@ -8,6 +8,10 @@ + + + @@ -15,6 +19,7 @@ import Sidebar from './components/Sidebar/index.vue' import AppMain from './components/AppMain.vue' import SpecHelper from '@/components/SpecHelper/index.vue' +import PendingTransferNotifier from '@/components/PendingTransferNotifier/index.vue'