/* 评审数据只存在页面内存中;角色切换用于检查同一业务的交互,不提供实际授权。 */ const initialState = () => ({ loggedIn: false, ticket: 'NONE', version: 1, reason: '键盘空格键无法使用', quantity: 1, owner: 'AGENT', humanRequested: false, connected: true, blocked: false, empty: false, replyActive: false, stale: false, expired: false, selfApproval: false, customerConfirmed: false, memoryConsent: false, memorySaved: false, memoryStyle: '简洁回复', memoryLanguage: '中文', linked: false, identityVerified: false, ruleVersion: 1, ruleActive: true, ruleSaved: false, proposalRuleVersion: 1, ruleDays: 7, proposalRuleDays: 7, knowledge: 'DRAFT', knowledgeTitle: '键盘售后说明', knowledgeVersion: 1, staffEnabled: true, storeEnabled: true, channelEnabled: true, tenantEnabled: true, delivery: 'FAILED', budgetRequest: 'NONE', budget: 100, pendingBudget: 100, messages: [], audit: [], lastAction: '', release: '草稿', formValues: {}, invites: [], tenantRegistrations: [], billingReviewer: false, returnPage: 'home', orderFilter: '全部', aiContext: '', }); let state = initialState(); let currentRole = 'customer'; let merchantRole = 'merchant'; const adminAuth = { merchant: false, platform: false }; const adminReturn = { merchant: null, platform: null }; let currentPage = 'home'; let notice = ''; let pendingConfirmation = null; const screens = {}; const roleLabels = { customer: '购物商城 H5', staff: '商家后台', supervisor: '商家后台', merchant: '商家后台', platform: '平台后台' }; const statusLabels = { NONE: '尚未申请', DRAFT: '待客户确认', WAITING_REVIEW: '等待主管审批', APPROVED: '审批通过,准备提交', PROCESSING: '换货处理中', RESULT_UNKNOWN: '正在核实受理结果', COMPLETED: '换货完成', REJECTED: '审批未通过', NEEDS_REVISION: '需要修订方案', CANCELLED: '申请已取消', FAILED: '换货申请失败' }; const escapeHtml = value => String(value ?? '').replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char])); const button = (label, action, extra = '') => ``; const link = (label, page, role = currentRole) => { const restricted = ['merchant', 'staff', 'supervisor'].includes(role) && role !== merchantRole; return ``; }; const tag = text => `${escapeHtml(text)}`; const hint = text => `
| ${h} | `).join('')}
|---|
| ${cell} | `).join('')}
订单 A-20260918-001
键盘 × 1 · 签收后第 2 天
可申请数量:1
`; } function proposalSummary() { return `${orderSummary()}申请数量:${state.quantity}
故障描述:${escapeHtml(state.reason)}
方案版本:V${state.version}
依据:《键盘换货规则》V${state.proposalRuleVersion},签收后 ${state.proposalRuleDays} 天内功能故障可申请,需客户确认及主管审批。
`; } function ticketSummary() { return `${tag(statusLabels[state.ticket])}工单 SH-001 · 当前方案 V${state.version}
${proposalSummary()}`; } function record(text) { state.audit.unshift(text); state.lastAction = text; } function confirmAction(title, body, callback) { pendingConfirmation = callback; document.getElementById('dialog-title').textContent = title; document.getElementById('dialog-body').textContent = body; document.getElementById('confirm-dialog').showModal(); }