feat: unify order workbench and stable paged evidence views

This commit is contained in:
abaishu0730 committed 2026-10-21 11:04:43 +08:00
1 parent 10eac70745
commit 84e2f0d9ba
30 files changed
+543 -294

No files matched your search

+22 -15
View File
@@ -5,7 +5,7 @@ const formatDate=value=>{const date=new Date(value);return value&&!Number.isNaN(
const roles={admin:'管理员',operator:'操作员',viewer:'只读成员'};
const statusMap={running:['处理中','blue'],success:['已完成','green'],error:['失败','red'],interrupted:['已中断','orange']};
let currentUser=null,settings=null,currentView='overview',overview=null,refreshTimer=null,viewGeneration=0,historyIndex=0,historyTransition=null,automationRevision=0,overviewRevision=0;
const views={'records-pdf':['订单与导出记录','查询PDF导出结果、文件可用性与存储归档记录'],'order-notifications':['通知总览','查看当前发送时段、待发订单及接入阻塞'],'notification-execution':['订单执行','扫描真实待办,查看归档进度与受控恢复'],'notification-orders':['通知订单','查看订单分类、归档证据及所属邮件批次'],'notification-batches':['待发批次','按发送时段检查分类汇总和冻结内容'],'notification-history':['发送记录','核对发送结果、冻结内容和人工恢复记录'],'notification-settings':['发送设置','维护发件邮箱、邮件限制与自动通知开关'],'rule-fields':['字段映射','从真实 BPM 样本选择字段,按表单版本保存对应关系'],'assistant-settings':['助手设置','配置 ZCode 运行包、模型与受控操作权限'],'business-settings':['业务设置','维护 Excel 分类规则、收件人和真实字段对应'],'system-settings':['系统设置','集中管理服务连接、运行维护和团队权限'],account:['个人账号','维护自己的登录密码与访问安全'],'order-rules':['分类通知规则','按 Excel 类别维护匹配、归档、收件人与通知正文'],health:['系统健康','查看服务守护、登录自启和各模块最近检查结果'],assistant:['ZCode 助手','对话查询运行状态、分析异常与执行受控恢复'],storage:['存储服务器','配置 SMB 共享目录、检查连接与管理 PDF 归档'],notifications:['兼容业务通知','原来源映射、产业接口人与通知队列'],overview:['工作总览','团队工作一目了然,每一次协作都有记录'],calendar:['业务日历','按公司实际安排设置工作日、休息日与暂停日期'],exceptions:['异常待办','认领、转交和跟进异常'],bpm:['BPM 连接','管理连接及负责人'],supervisor:['运行监管','配置负责人、通知方式与重试上限'],records:['订单与导出记录','查询已经采集的订单,下载已完成的 PDF'],rules:['分类通知规则','按 Excel 类别维护匹配、归档、收件人与通知正文'],schedule:['发送计划','设置每日两个发送时间及周末安排'],templates:['邮件模板','管理模板及 Excel 类别关联;收件名单在分类规则维护'],mail:['邮箱管理','维护托管邮箱、模板收信与连接状态'],connections:['服务接入','查看各个环节的接入情况'],users:['团队账号','为局域网内的同事分配访问权限'],audit:['操作记录','查看配置变更和导出任务的处理记录']};
const views={tools:['工具','手工导出、文件查看与助手'],'records-pdf':['订单与导出记录','查询PDF导出结果、文件可用性与存储归档记录'],'order-notifications':['通知总览','查看当前发送时段、待发订单及接入阻塞'],'notification-execution':['订单执行','扫描真实待办,查看归档进度与受控恢复'],'notification-orders':['订单中心','查看订单分类、归档证据及所属邮件批次'],'notification-batches':['邮件批次','按发送时段检查分类汇总和冻结内容'],'notification-history':['发送记录','核对发送结果、冻结内容和人工恢复记录'],'notification-settings':['发送设置','维护发件邮箱、邮件限制与自动通知开关'],'rule-fields':['字段映射','从真实 BPM 样本选择字段,按表单版本保存对应关系'],'assistant-settings':['助手设置','配置 ZCode 运行包、模型与受控操作权限'],'business-settings':['业务设置','维护 Excel 分类规则、收件人和真实字段对应'],'system-settings':['系统设置','集中管理服务连接、运行维护和团队权限'],account:['个人账号','维护自己的登录密码与访问安全'],'order-rules':['分类通知规则','按 Excel 类别维护匹配、归档、收件人与通知正文'],health:['系统健康','查看服务守护、登录自启和各模块最近检查结果'],assistant:['ZCode 助手','对话查询运行状态、分析异常与执行受控恢复'],storage:['存储服务器','配置 SMB 共享目录、检查连接与管理 PDF 归档'],notifications:['兼容业务通知','原来源映射、产业接口人与通知队列'],overview:['业务首页','订单处理、邮件窗口、业务阻塞与待核验'],calendar:['业务日历','按公司实际安排设置工作日、休息日与暂停日期'],exceptions:['异常待办','认领、转交和跟进异常'],bpm:['BPM 连接','管理连接及负责人'],supervisor:['运行监管','配置负责人、通知方式与重试上限'],records:['订单与导出记录','查询已经采集的订单,下载已完成的 PDF'],rules:['分类通知规则','按 Excel 类别维护匹配、归档、收件人与通知正文'],schedule:['发送计划','设置每日两个发送时间及周末安排'],templates:['邮件模板','管理模板及 Excel 类别关联;收件名单在分类规则维护'],mail:['邮箱管理','维护托管邮箱、模板收信与连接状态'],connections:['服务接入','查看各个环节的接入情况'],users:['团队账号','为局域网内的同事分配访问权限'],audit:['操作记录','查看配置变更和导出任务的处理记录']};
const pendingWrites=new Map();
async function api(route,body,{signal,ownerCheck,managedOutcome=false}={}) {
const originGeneration=viewGeneration,originUser=currentUser,originRevision=window.PageLifecycle?.revision;const originActive=()=>viewGeneration===originGeneration&&currentUser===originUser&&window.PageLifecycle?.revision===originRevision;const submission=window.PageLifecycle?.submission,hasBody=body!==undefined,write=hasBody&&route!=='/order-rules/field-mappings/propose',key=originGeneration+':'+originRevision+':'+route+':'+JSON.stringify(body);const pending=pendingWrites.get(key);if(write&&pending?.user===originUser)return pending.work;
@@ -35,7 +35,7 @@ function navItem(id,symbol){return `<li class="nav-item"><a class="nav-link ${cu
function shell() {
root.innerHTML=`<div class="page"><aside class="navbar navbar-vertical navbar-expand-lg"><div class="container-fluid"><button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#sidebar-menu" aria-controls="sidebar-menu" aria-label="展开菜单"><span class="navbar-toggler-icon"></span></button><a class="navbar-brand" href="#overview"><span class="brand-mark">单</span>订单通知中心</a><div class="collapse navbar-collapse" id="sidebar-menu"><ul class="navbar-nav pt-lg-3">${window.AppNavigation.primary.map(([id,symbol])=>navItem(id,symbol)).join('')}</ul><div class="mt-auto p-3 text-secondary small d-none d-lg-block">团队共享工作台<br><span class="sidebar-status"><i></i> 本地运行 · 北京时间</span></div></div></div></aside><header class="navbar d-print-none"><div class="container-xl"><div class="d-flex gap-2 flex-wrap"><a class="badge bg-secondary-lt text-decoration-none" id="automation-status" href="#notification-settings" title="正在读取服务端通知状态" aria-live="polite">通知状态待确认</a></div><div class="navbar-nav flex-row order-md-last ms-auto align-items-center gap-3"><div><div class="account-name">${esc(currentUser.username)}</div><div class="small text-secondary">${roles[currentUser.role]}</div></div><a class="btn btn-sm" href="#account">修改密码</a><button class="btn btn-sm" id="logout">退出</button></div></div></header><div class="page-wrapper"><div class="page-header d-print-none"><div class="container-xl"><div class="row g-2 align-items-center"><div class="col"><div class="page-pretitle">订单通知自动化</div><nav id="view-breadcrumb" class="mb-2" aria-label="设置导航" hidden></nav><h1 class="page-title" id="view-title"></h1><div class="text-secondary mt-2" id="view-description"></div></div><div class="col-auto ms-auto"><button class="btn" id="refresh">刷新数据</button></div></div></div></div><div class="page-body"><div class="container-xl"><nav class="nav nav-segmented settings-tabs" id="settings-tabs" aria-label="页面导航" hidden></nav><div id="content"></div></div></div><footer class="footer footer-transparent d-print-none"><div class="container-xl"><div class="row text-secondary align-items-center"><div class="col">订单通知中心 · 局域网工作台</div><div class="col-auto">UI 基于 <a href="https://tabler.io" target="_blank" rel="noreferrer">Tabler</a> · MIT</div></div></div></footer></div></div>`;
document.querySelector('#logout').onclick=()=>window.PageLifecycle.guard(async()=>{++viewGeneration;await window.BpmLogin?.dispose();await api('/logout',{});window.RecordState.clear();currentUser=null;clearInterval(refreshTimer);await window.PageLifecycle.dispose();await boot();});
document.querySelector('#refresh').onclick=()=>window.PageLifecycle.guard(()=>window.RecordTable?.active?window.RecordTable.active.refresh():renderView()).catch(error=>notify(error.message,'danger'));
document.querySelector('#refresh').onclick=()=>window.PageLifecycle.guard(()=>{const generation=viewGeneration;void updateAutomationStatus(()=>generation===viewGeneration&&!!currentUser);return window.RecordTable?.active?window.RecordTable.active.refresh():renderView();}).catch(error=>notify(error.message,'danger'));
document.querySelectorAll('[data-view]').forEach(link=>link.onclick=()=>{const menu=document.querySelector('#sidebar-menu');menu.classList.remove('show');if(menu.classList.contains('collapsing'))menu.addEventListener('shown.bs.collapse',()=>menu.classList.remove('show'),{once:true});document.querySelector('.navbar-toggler').setAttribute('aria-expanded','false');});
}
function empty(title,text){return `<div class="empty-state"><div class="avatar avatar-lg bg-blue-lt mb-3">▤</div><h3>${title}</h3><p class="text-secondary">${text}</p></div>`;}
@@ -45,9 +45,7 @@ function jobTable(jobs){return `<div class="table-responsive"><table class="tabl
async function viewOverview(container,isActive=()=>true) {
const revision=++overviewRevision,ownsResponse=()=>revision===overviewRevision&&isActive();
try{
if(window.WorkspaceViews)return await window.WorkspaceViews.overview(container,ownsResponse);
await api('/workspace');if(!ownsResponse())return;
container.innerHTML=empty('工作台模块未加载','请刷新页面后重试。');
return await window.OrderNotificationViews.render(container,ownsResponse,'workbench');
}catch(error){if(ownsResponse())throw error;}
}
function recordHistory(container,isActive){const history=document.createElement('section');history.className='mt-3';history.innerHTML='<button class="btn btn-sm mb-3" id="legacy-notifications-open">查看旧通知历史(只读)</button><div id="legacy-notification-history"></div>';container.append(history);history.querySelector('button').onclick=async event=>{const button=event.currentTarget;button.disabled=true;try{await window.NotificationViews.history(history.querySelector('#legacy-notification-history'),isActive);}catch(error){if(isActive())notify(error.message,'danger');}finally{if(button.isConnected)button.disabled=false;}};}
@@ -58,12 +56,16 @@ async function viewSchedule(container,isActive=()=>true) {
container.innerHTML=`<div class="settings-width">${readOnlyNote()}<div class="alert alert-info">收件人及类别要求在 <a href="#order-rules">分类通知规则</a> 维护。按北京时间和业务日历生成发送时段,更早历史不自动补发。</div><form id="schedule-form"><div class="card"><div class="card-header"><h2 class="card-title">每日两次通知</h2><span class="badge bg-blue-lt">北京时间</span></div><div class="card-body"><div class="row g-4"><div class="col-sm-6"><label class="form-label required" for="time-first">第一个发送时间</label><input class="form-control schedule-time" id="time-first" type="time" value="${s.times[0]}" required ${disabled}></div><div class="col-sm-6"><label class="form-label required" for="time-second">第二个发送时间</label><input class="form-control schedule-time" id="time-second" type="time" value="${s.times[1]}" required ${disabled}></div><div class="col-12"><label class="form-check form-switch"><input class="form-check-input" type="checkbox" id="weekends" ${s.weekends?'checked':''} ${disabled}><span class="form-check-label">周六、周日照常发送</span></label><div class="form-hint">关闭后仅在周一至周五发送;公司调休与暂停安排可在 <a href="#calendar">业务日历</a> 中按日期覆盖。</div></div></div></div><div class="card-footer d-flex align-items-center"><span class="text-secondary small">配置供整个团队共用</span>${currentUser.role==='admin'?'<button class="btn btn-primary ms-auto" type="submit">保存发送计划</button>':''}</div></div></form></div>`;
document.querySelector('#schedule-form').onsubmit=async event=>{event.preventDefault();try{const updated=await api('/settings',{version:draft.version,schedule:{...draft.schedule,times:[document.querySelector('#time-first').value,document.querySelector('#time-second').value],timezone:'Asia/Shanghai',weekends:document.querySelector('#weekends').checked}});if(!isActive())return;draft=updated;notify('发送计划已保存。');}catch(error){if(isActive())notify(error.message,'danger');}};
}
async function viewTemplates(container,isActive=()=>true) {
container.innerHTML=`<div class="settings-width">${readOnlyNote()}<div class="alert alert-info">收件人与抄送名单统一在 <a href="#order-rules">分类规则</a> 维护。类别关联仅使用显式保存的映射,不按名称推断。</div><div id="mail-templates"></div><div id="category-templates"></div></div>`;
async function viewTemplates(container,isActive=()=>true){
container.innerHTML='<div class="alert alert-info">模板仅维护内容。有效模板选择统一在 <a href="#order-rules">分类规则</a> 保存并发布。</div><div id="mail-templates"></div><div id="category-templates"></div>';
await window.MailViews.templates(container.querySelector('#mail-templates'),isActive);if(!isActive())return;
let catalog,mail;try{[catalog,mail]=await Promise.all([api('/mail/templates/categories'),api('/mail')]);}catch(error){if(isActive())container.querySelector('#category-templates').innerHTML='<div class="alert alert-warning">类别关联暂不可用:'+esc(error.message)+'</div>';return;}if(!isActive())return;
const host=container.querySelector('#category-templates');host.innerHTML=`<section class="card"><div class="card-header"><h2 class="card-title">类别模板关联</h2></div><div class="card-body">${catalog.categories.map(c=>{const binding=catalog.bindings.find(b=>b.categoryId===c.id);return `<form data-category="${esc(c.id)}" class="mb-3"><label class="form-label" for="category-${esc(c.id)}">${esc(c.name)}</label><div class="d-flex gap-2"><select class="form-select" id="category-${esc(c.id)}" name="templateId" ${currentUser.role==='admin'?'':'disabled'}><option value="">使用分类规则正文</option>${mail.templates.filter(t=>t.status==='active').map(t=>`<option value="${esc(t.id)}" ${binding?.templateId===t.id?'selected':''}>${esc(t.subject)}</option>`).join('')}</select>${currentUser.role==='admin'?'<button class="btn" type="submit">保存关联</button>':''}</div><div class="small text-secondary mt-1">来源:${binding?.templateId?'已保存类别映射':'未关联'}</div><div role="alert" class="text-danger"></div></form>`;}).join('')}</div></section>`;
host.querySelectorAll('form').forEach(form=>form.onsubmit=async event=>{event.preventDefault();const binding=catalog.bindings.find(b=>b.categoryId===form.dataset.category);try{const result=await api('/mail/templates/categories',{categoryId:form.dataset.category,templateId:form.elements.templateId.value,version:binding?.version??0});if(!isActive())return;catalog.bindings=catalog.bindings.filter(b=>b.categoryId!==result.categoryId).concat(result);form.querySelector('[role="alert"]').textContent='';await window.PageLifecycle.afterSave(async()=>{const fresh=await api('/mail/templates/categories');if(isActive())catalog.bindings=fresh.bindings;},'类别模板关联已保存。',notify,isActive);}catch(error){if(isActive())form.querySelector('[role="alert"]').textContent=error.message;}});
const data=await api('/order-rules?view=summary');if(!isActive())return;
const usage=data.templateUsage||[];
if(usage.some(r=>r.legacyBinding)){
try{const legacy=await api('/mail/templates/categories');if(!isActive())return;for(const row of usage)if(row.legacyBinding)row.templateId=legacy.bindings.find(b=>b.categoryId===row.categoryId)?.templateId||'';}
catch{for(const row of usage)if(row.legacyBinding)row.templateId='旧类别关联读取失败,请核实';}
}
container.querySelector('#category-templates').innerHTML='<section class="card mt-3"><div class="card-header"><h2 class="card-title">有效使用情况(只读)</h2></div><div class="list-group list-group-flush">'+(data.templateUsage||[]).map(r=>'<div class="list-group-item">'+esc(r.name||r.categoryId)+' · '+esc(r.templateId||'使用分类规则正文')+(r.legacyBinding?'(旧类别关联,只读兼容)':'')+' · '+esc(r.status==='enabled'?'已启用':r.status==='paused'?'已暂停':'尚未发布')+' · 已发布版本 '+esc(r.publishedVersion||'无')+'</div>').join('')+'</div></section>';
}
async function viewAudit(container,isActive=()=>true){const [legacy,workspace]=await Promise.all([api('/audit'),api('/workspace')]);if(!isActive())return;const audit=[...legacy.audit,...workspace.audit].sort((a,b)=>new Date(b.at)-new Date(a.at));container.innerHTML=`<div class="card"><div class="card-header"><h2 class="card-title">最近操作记录</h2><span class="text-secondary ms-auto">按时间展示最近 200 条</span></div>${audit.length?`<div class="table-responsive"><table class="table card-table"><thead><tr><th>时间(北京时间)</th><th>操作人</th><th>操作</th><th>详情</th></tr></thead><tbody>${audit.slice(0,200).map(item=>`<tr><td class="small text-secondary">${formatDate(item.at)}</td><td>${esc(item.actor)}</td><td>${esc(window.WorkspaceViews.activityText(item.action))}</td><td class="audit-detail text-secondary">${esc(item.detail)}</td></tr>`).join('')}</tbody></table></div>`:empty('暂无操作记录','保存设置或导出订单后,可在这里查看。')}</div>`;}
function viewRules(container,isActive){return window.OrderRuleViews.render(container,isActive,'rules');}
@@ -71,7 +73,7 @@ async function updateAutomationStatus(isActive){
const request=++automationRevision,node=document.querySelector('#automation-status');if(!node||!isActive())return;
const apply=(label,color,detail)=>{if(!isActive()||request!==automationRevision||!node.isConnected)return;node.textContent=label;node.className='badge bg-'+color+'-lt text-decoration-none';node.title=detail;};
try{
const data=await api('/order-rules',undefined,{ownerCheck:isActive});if(!isActive())return;
const data=await api('/order-rules?view=summary',undefined,{ownerCheck:isActive});if(!isActive())return;
if(typeof data?.settings?.enabled!=='boolean')throw Error('服务端未返回有效通知开关');
const missing=Object.entries({liveTodo:'实时待办接入',pdfExport:'PDF 导出',automaticArchive:'自动归档'}).filter(([key])=>data.capabilities?.[key]!==true).map(([,label])=>label);
if(!data.settings.enabled)apply('自动通知已暂停','secondary','自动发信保持暂停;请完成类别字段、目录、邮箱与预览核验。'+(missing.length?' 待检查:'+missing.join('、'):' 点击查看发送设置。'));
@@ -87,17 +89,22 @@ function configurationHost(container){
async function renderView() {
if(!currentUser)return;
const routeId=window.RecordState.route(location.hash)||'overview',resolved=window.AppNavigation.resolve(routeId);
if(window.RecordState.isRecord(location.hash)&&currentView===resolved&&window.RecordTable?.active?.view===resolved){historyIndex=Number.isInteger(history.state?.appIndex)?history.state.appIndex:historyIndex;return window.RecordTable.active.navigate();}
if(routeId!==resolved&&['notification-orders','notification-batches'].includes(resolved)){
const params=new URLSearchParams(location.hash.split('?')[1]||'');if(routeId==='notification-history'&&!params.has('scope'))params.set('scope','all');
history.replaceState(history.state,'',window.RecordState.serialize(resolved,Object.fromEntries(params)));
}
if(window.RecordState.isRecord(location.hash)&&currentView===resolved&&window.RecordTable?.active?.view===resolved){historyIndex=Number.isInteger(history.state?.appIndex)?history.state.appIndex:historyIndex;void updateAutomationStatus(()=>!!currentUser&&currentView===resolved);return window.RecordTable.active.navigate();}
const wasRecord=['records','records-pdf'].includes(currentView);
const generation=++viewGeneration;const isActive=()=>generation===viewGeneration && !!currentUser;
await window.PageLifecycle?.dispose();
await window.BpmLogin?.dispose();if(!isActive())return;
const requested=resolved;currentView=Object.hasOwn(views,requested)?requested:'overview';
if(currentView==='users' && currentUser.role!=='admin')currentView='overview';
historyIndex=Number.isInteger(history.state?.appIndex)?history.state.appIndex:historyIndex;history.replaceState({...history.state,appIndex:historyIndex},'',window.RecordState.isRecord(location.hash)?location.hash:'#'+currentView);
historyIndex=Number.isInteger(history.state?.appIndex)?history.state.appIndex:historyIndex;history.replaceState({...history.state,appIndex:historyIndex},'',window.RecordState.isRecord(location.hash)?location.hash:'#'+currentView+(['exceptions'].includes(currentView)&&location.hash.includes('?')?location.hash.slice(location.hash.indexOf('?')):''));
const section=window.AppNavigation.sectionFor(currentView);
window.AppNavigation.renderTabs(document.querySelector('#settings-tabs'),{id:currentView,user:currentUser,views,esc});
document.querySelectorAll('[data-view]').forEach(link=>{const active=link.dataset.view===(section||currentView);link.classList.toggle('active',active);if(active)link.setAttribute('aria-current','page');else link.removeAttribute('aria-current');});
document.querySelectorAll('[data-view]').forEach(link=>{const active=link.dataset.view===(['notification-orders','notification-batches'].includes(currentView)?currentView:section==='order-notifications'?'notification-batches':section||currentView);link.classList.toggle('active',active);if(active)link.setAttribute('aria-current','page');else link.removeAttribute('aria-current');});
const sectionTitle=section==='order-notifications'?'订单通知管理':views[section]?.[0];
const breadcrumb=document.querySelector('#view-breadcrumb');breadcrumb.hidden=!section||section===currentView||section==='records';breadcrumb.innerHTML=breadcrumb.hidden?'':`<a href="#${section}" aria-label="返回${sectionTitle}">← ${sectionTitle}</a> <span class="text-secondary"> / ${esc(views[currentView][0])}</span>`;
document.querySelector('#view-title').textContent=views[currentView][0];document.querySelector('#view-description').textContent=views[currentView][1];
@@ -115,7 +122,7 @@ async function authScreen() {
}
async function passwordChanged(actorId){if(currentUser&&currentUser.id!==actorId)return false;currentUser=null;++viewGeneration;clearInterval(refreshTimer);await window.PageLifecycle?.dispose();await window.BpmLogin?.dispose().catch(()=>{});await boot();return true;}
function enter(){window.RecordState.configure(currentUser,({hash,push})=>{if(push&&location.hash!==hash)history.pushState({appIndex:++historyIndex},'',hash);else history.replaceState({...history.state,appIndex:historyIndex},'',hash);});window.PdfRecordViews?.configure({api,esc,formatDate,notify,user:currentUser});window.AccountViews?.configure({api,esc,formatDate,notify,user:currentUser,onPasswordChanged:passwordChanged});window.OrderRuleViews?.configure({api,esc,formatDate,notify,user:currentUser});window.OrderNotificationViews?.configure({api,esc,formatDate,notify,user:currentUser});window.HealthViews?.configure({api,esc,formatDate});window.AssistantViews?.configure({api,esc,formatDate,notify,user:currentUser});window.StorageViews?.configure({api,esc,formatDate,notify,user:currentUser});window.NotificationViews?.configure({api,esc,formatDate,notify,user:currentUser});window.OrderViews?.configure({api,esc,formatDate,notify,user:currentUser});window.MailViews?.configure({api,esc,formatDate,notify,user:currentUser});window.WorkspaceViews?.configure({api,esc,formatDate,notify,user:currentUser});shell();renderView();clearInterval(refreshTimer);refreshTimer=setInterval(()=>{if(currentUser&&!document.hidden){const statusGeneration=viewGeneration,statusUser=currentUser;void updateAutomationStatus(()=>statusGeneration===viewGeneration&&statusUser===currentUser);}if(currentUser && currentView==='overview' && !document.hidden){const generation=viewGeneration;viewOverview(document.querySelector('#content'),()=>generation===viewGeneration && !!currentUser && currentView==='overview').catch(()=>{});}},15000);}
function enter(){window.RecordState.configure(currentUser,({hash,push})=>{if(push&&location.hash!==hash)history.pushState({appIndex:++historyIndex},'',hash);else history.replaceState({...history.state,appIndex:historyIndex},'',hash);});window.PdfRecordViews?.configure({api,esc,formatDate,notify,user:currentUser});window.AccountViews?.configure({api,esc,formatDate,notify,user:currentUser,onPasswordChanged:passwordChanged});window.OrderRuleViews?.configure({api,esc,formatDate,notify,user:currentUser});window.OrderNotificationViews?.configure({api,esc,formatDate,notify,user:currentUser});window.HealthViews?.configure({api,esc,formatDate,user:currentUser});window.AssistantViews?.configure({api,esc,formatDate,notify,user:currentUser});window.StorageViews?.configure({api,esc,formatDate,notify,user:currentUser});window.NotificationViews?.configure({api,esc,formatDate,notify,user:currentUser});window.OrderViews?.configure({api,esc,formatDate,notify,user:currentUser});window.MailViews?.configure({api,esc,formatDate,notify,user:currentUser});window.WorkspaceViews?.configure({api,esc,formatDate,notify,user:currentUser});shell();renderView();clearInterval(refreshTimer);refreshTimer=setInterval(()=>{if(currentUser&&!document.hidden){const statusGeneration=viewGeneration,statusUser=currentUser;void updateAutomationStatus(()=>statusGeneration===viewGeneration&&statusUser===currentUser);}},15000);}
async function boot(){try{const setup=await api('/bootstrap/status');currentUser=(await api('/me')).user;enter();}catch{await authScreen();}}
window.addEventListener('page-operation-error',event=>notify(event.detail.message,'danger'));
window.addEventListener('pagehide',()=>{window.BpmLogin?.dispose({unload:true});});