| 123456789101112131415161718192021222324252627282930 |
- // 通知归属于当前员工;只保存演示内容。正式实现需在服务端检查接收人与业务权限。
- const notificationItems = [
- { id: 'admin-knowledge', recipient: 'merchant', kind: '待办', title: '知识资料等待发布', summary: '《键盘售后说明》草稿已更新,请检查正文和发布范围。', page: 'knowledge', action: '查看知识资料', time: '今天 09:40' },
- { id: 'admin-budget', recipient: 'merchant', kind: '系统', title: '模型预算配置提醒', summary: '请检查当前预算与费用申请。费用审批需要独立授权。', page: 'billing', action: '查看模型费用', time: '今天 09:30' },
- { id: 'admin-channel', recipient: 'merchant', kind: '异常', title: '渠道接入检查待完成', summary: '售后渠道应用的结果回调需要检查配置与接入记录。', page: 'channels', action: '检查渠道配置', time: '今天 09:20' },
- { id: 'staff-handoff', recipient: 'staff', kind: '待办', title: '客户 A01 请求人工协助', summary: '配件店 H5 会话有待接待请求,请查看最新会话状态。', page: 'conversation', action: '查看会话', time: '今天 09:40' },
- { id: 'staff-message', recipient: 'staff', kind: '客户消息', title: '客户 A01 有新消息', summary: '当前授权店铺的客户补充了咨询信息。', page: 'conversation', action: '查看客户消息', time: '今天 09:35' },
- { id: 'staff-ticket', recipient: 'staff', kind: '业务进度', title: '售后工单状态更新', summary: '工单 SH-001 的处理状态已变化,请查看最新确认与履约记录。', page: 'ticket', action: '查看工单', time: '今天 09:25' },
- { id: 'supervisor-review', recipient: 'supervisor', kind: '待办', title: '售后审批待处理', summary: '请核对客户确认记录和当前方案版本后处理审批。', page: 'approvals', action: '查看审批待办', time: '今天 09:40' },
- ];
- const notificationRead = new Set();
- let notificationFilter = '全部';
- let selectedNotification = null;
- function employeeNotifications() { return notificationItems.filter(item => item.recipient === merchantRole); }
- function unreadCount() { return employeeNotifications().filter(item => !notificationRead.has(item.id)).length; }
- function markNotificationNew(id) { notificationRead.delete(id); }
- function notificationList() {
- const items = employeeNotifications().filter(item => notificationFilter !== '未读' || !notificationRead.has(item.id));
- return desktop(`<div class="toolbar">${['全部', '未读'].map(label => `<button data-action="notification-filter" data-filter="${label}" ${notificationFilter === label ? 'aria-current="page"' : ''}>${label}</button>`).join('')}<span>未读 ${unreadCount()} 条</span>${button('全部标为已读', 'notifications-read-all', unreadCount() ? '' : 'disabled')}</div>${items.length ? table(['状态', '类型', '通知', '时间', '操作'], items.map(item => [notificationRead.has(item.id) ? '已读' : '未读', item.kind, `<strong>${item.title}</strong><p>${item.summary}</p>`, item.time, `<button data-action="notification-open" data-id="${item.id}">查看详情</button>`])) : '<div class="empty">暂无未读通知。</div>'}<p class="muted">以上为通知设计示例。已读表示已查看,业务处理状态以对应页面为准。</p>`);
- }
- function notificationDetail() {
- const item = employeeNotifications().find(entry => entry.id === selectedNotification);
- if (!item) return desktop(`${hint('通知不存在或当前员工无权查看。')}${link('返回通知中心', 'notifications')}`);
- return desktop(`${tag(item.kind)}${tag('已读')}<h2>${item.title}</h2><p class="muted">${item.time} · A 商家 / 配件店</p><p>${item.summary}</p>${hint('进入业务页面时重新检查当前权限和状态;通知不代表任务已经完成。')}${actions(`${link(item.action, item.page)}${link('返回通知中心', 'notifications')}`)}`);
- }
- for (const role of ['merchant', 'staff', 'supervisor']) {
- menuGroups[role].push(['消息与通知', [['notifications', '通知中心']]]);
- register(role, 'notifications', 'N01', '通知中心', notificationList, ['仅展示当前员工接收且有权限查看的通知,切换角色后未读数量分别计算。', '列表区分已读、未读和通知类型;查看详情标记已读,全部已读需要确认。', '通知中的业务入口重新检查权限,已读不自动接管、审批、发布或完成工单。']);
- register(role, 'notification-detail', 'N02', '通知详情', notificationDetail, ['客户消息摘要默认不显示敏感正文,进入授权会话后查看。', '已失效或无权访问的通知提供提示,不能通过通知扩大权限。']);
- }
|