feat: refresh business home with Tabler workflow visuals
This commit is contained in:
1 parent
069a69af93
commit
1cacbec132
11 files changed
+165
-11
No files matched your search
@@ -0,0 +1,14 @@
|
||||
.business-home{--home-blue:#206bc4;--home-ink:#183153;--home-muted:#62748b;--home-border:#e2e9f2;display:grid;gap:20px;color:var(--home-ink)}
|
||||
.business-home .home-icon{width:22px;height:22px;flex:0 0 auto;vertical-align:middle}.business-home .card{border-color:var(--home-border);border-radius:14px;box-shadow:0 3px 16px rgba(30,60,100,.025)}
|
||||
.home-hero{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(260px,.9fr);overflow:hidden;background:linear-gradient(112deg,#fff 25%,#f0f7ff 100%)}.home-hero-content{padding:30px 32px 28px;position:relative;z-index:1}.home-eyebrow{display:flex;align-items:center;gap:9px;font-size:14px;color:#4b6c92;font-weight:600}.home-eyebrow .home-icon{width:19px;height:19px}.home-send-time{display:flex;align-items:baseline;gap:16px;margin:9px 0 8px;flex-wrap:wrap}.home-send-time>strong{font-size:64px;line-height:1.08;letter-spacing:-3px;font-weight:650;font-variant-numeric:tabular-nums;color:#173e70}.home-send-time>span{font-size:14px;color:var(--home-muted)}.home-window-state{display:flex;gap:9px;flex-wrap:wrap;font-size:14px;line-height:1.6}.home-window-state>[data-home-phase]{font-weight:600}.home-separator{color:#93a9c2}.home-cutoff{margin:9px 0 20px;font-size:13px;color:var(--home-muted)}.home-cutoff span{margin-left:8px;font-size:11px;color:#788aa0}.home-hero-actions{display:flex;align-items:center;gap:22px;flex-wrap:wrap}.home-hero-actions .btn{padding:10px 16px;border-radius:8px;box-shadow:0 4px 12px #206bc420}.home-hero-actions .btn .home-icon{width:18px;height:18px;margin-right:7px}.home-text-link{font-size:12px;color:#386898;text-decoration:none;display:inline-flex;align-items:center;gap:4px;white-space:nowrap}.home-text-link .home-icon{width:15px;height:15px}.home-text-link:hover{color:#1458a7;text-decoration:underline}
|
||||
.home-hero-footer{grid-column:1/-1;display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;padding:13px 32px;border-top:1px solid #dde8f4;background:#ffffffa6;font-size:12px;color:var(--home-muted)}.home-live{display:inline-flex;align-items:center;gap:8px;color:#88712e}.home-live.is-live{color:#207e61}.home-switches{display:flex;gap:20px;flex-wrap:wrap}.home-switches b{font-weight:500;margin-left:5px;color:#425c7b}.home-stale .home-live{color:#88712e}.home-update{margin:0;display:flex;justify-content:space-between;align-items:center;gap:12px}
|
||||
.home-scene{position:relative;width:360px;height:230px;max-width:100%;align-self:center;justify-self:center;color:#6395ce;background-image:radial-gradient(#a8c4e24d 1px,transparent 1px);background-size:18px 18px;margin:10px 20px}.home-scene-orbit{position:absolute;width:210px;height:210px;left:80px;top:0;border:1px solid #bfd4ee75;border-radius:50%;background:radial-gradient(circle,#dfedff8c,transparent 68%)}.home-scene-orbit:after{content:'';position:absolute;inset:20px;border:1px solid #c2d7f24d;border-radius:50%}.home-scene-path{position:absolute;inset:0;width:100%;height:100%;color:#93b6df}.home-scene-source,.home-scene-mail{position:absolute;z-index:2;display:flex;align-items:center;background:#fff;border:1px solid #dbe6f3;border-radius:11px;box-shadow:0 9px 22px #315b9210}.home-scene-source{left:2px;top:142px;padding:12px 13px;gap:8px;font-size:11px;color:#4e709a}.home-scene-source .home-icon{width:19px;height:19px}.home-scene-source i{width:5px;height:5px;background:#99b7d9;border-radius:50%;margin-left:5px}.home-scene-sheet{position:absolute;top:23px;left:124px;width:127px;height:151px;background:white;border:1px solid #cddff3;border-radius:11px;padding:17px;transform:rotate(-6deg);box-shadow:6px 10px 0 -2px #e2edfa,6px 10px 0 -1px #c6daef,0 14px 30px #315b9210;transition:transform .2s ease}.home-hero:hover .home-scene-sheet{transform:translateY(-3px) rotate(-4deg)}.home-paper-icon{display:flex;align-items:center;justify-content:center;width:35px;height:35px;background:#eaf3ff;border-radius:9px;color:#377ac6;margin-bottom:10px}.home-paper-icon .home-icon{width:23px;height:23px}.home-scene-sheet>b{font-size:11px;color:#365b89;display:block}.home-paper-line{display:block;height:4px;margin-top:7px;border-radius:3px;background:#e5edf7;width:100%}.home-paper-line.short{width:65%}.home-paper-bottom{display:flex;align-items:center;gap:5px;font-size:9px;color:#7890ac;margin-top:10px}.home-paper-bottom .home-icon{width:12px;height:12px}.home-scene-mail{right:0;top:164px;gap:10px;padding:12px 15px;min-width:145px}.home-scene-mail>.home-icon{width:28px;height:28px;color:#377ac6}.home-scene-mail b{font-size:12px;color:#365b89;display:block}.home-scene-mail small{display:block;font-size:10px;margin-top:2px;color:#8395ad}.is-scanning .home-scene-path path{animation:home-flow 18s linear infinite}@keyframes home-flow{to{stroke-dashoffset:-100}}
|
||||
.home-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}.home-kpi{padding:20px 21px;color:inherit;text-decoration:none;min-width:0;transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease}.home-kpi:hover{color:inherit;border-color:#bed2eb!important;transform:translateY(-3px);box-shadow:0 8px 24px #315b9212!important}.home-kpi:focus-visible,.home-batch:focus-visible{outline:3px solid #91b8ed;outline-offset:3px}.home-kpi-top{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:12px;color:var(--home-muted)}.home-symbol{display:inline-flex;align-items:center;justify-content:center;width:37px;height:37px;border-radius:10px;flex:0 0 auto}.home-symbol-blue{background:#edf4fe;color:#3475c4}.home-symbol-cyan{background:#eaf8fb;color:#288b9f}.home-symbol-amber{background:#fff5e6;color:#b47b24}.home-symbol-violet{background:#f1edfc;color:#8065b3}.home-symbol .home-icon{width:21px;height:21px}.home-kpi-value{display:flex;align-items:baseline;gap:8px;margin:8px 0 14px}.home-kpi-value strong{font-size:34px;line-height:1.2;font-weight:650;letter-spacing:-.7px;font-variant-numeric:tabular-nums}.home-kpi-value span{font-size:11px;color:#8391a4}.home-kpi-note{display:flex;justify-content:space-between;align-items:center;border-top:1px solid #edf1f6;padding-top:11px;font-size:11px;color:#7b8ca2}.home-kpi-note .home-icon{width:14px;height:14px}
|
||||
.home-main-grid{display:grid;grid-template-columns:minmax(0,1.65fr) minmax(260px,1fr);gap:20px}.home-card{overflow:hidden;min-width:0}.home-card-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:22px 24px 18px}.home-card-heading h2{display:flex;align-items:center;gap:8px;font-size:15px;font-weight:650;margin:0}.home-card-heading h2>.home-icon{width:19px;height:19px;color:#6c88ab}.home-card-heading p{font-size:11px;color:#8190a3;margin:6px 0 0}.home-window-track{margin:0 24px 14px;padding:14px 16px;background:#f6f9fd;border:1px solid #edf2f8;border-radius:9px}.home-window-labels{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap;color:#627991;font-size:11px;margin-bottom:10px}.home-window-track .progress{height:5px;background:#e3ecf7}.home-window-track .progress-bar{background:#659bda;transition:width .4s ease}.home-window-help{display:flex;justify-content:space-between;gap:6px;flex-wrap:wrap;margin-top:9px;font-size:10px;color:#8191a6}.home-window-help>span{color:#5a7da6}.home-batch-list{padding:0 24px 10px}.home-batch{display:flex;align-items:center;gap:12px;padding:17px 0;border-bottom:1px solid #edf1f6;text-decoration:none;color:inherit}.home-batch:last-child{border-bottom:0}.home-batch:hover{color:inherit}.home-batch:hover .home-batch-copy strong{color:#206bc4}.home-batch-copy{flex:1;min-width:0}.home-batch-copy strong{display:block;font-size:12px;font-weight:600;overflow-wrap:anywhere}.home-batch-copy small{display:block;font-size:10px;color:#8291a4;margin-top:5px;overflow-wrap:anywhere}.home-batch-count{font-size:23px;color:#274e7d;font-variant-numeric:tabular-nums;white-space:nowrap}.home-batch-count small{font-size:10px;margin-left:4px;color:#8c9aab}.home-batch>.home-icon{width:15px;height:15px;color:#9badc1}.home-mini-empty{padding:23px 12px 30px;text-align:center;color:#8aa0ba}.home-mini-empty>.home-icon{width:34px;height:34px;margin:0 0 10px}.home-mini-empty p{font-size:13px;margin:0 0 6px;color:#566f8b}.home-mini-empty span{font-size:11px}.home-conditions{padding:0 24px}.home-condition{display:flex;align-items:center;gap:10px;padding:13px 0;color:inherit;text-decoration:none;font-size:12px;border-bottom:1px solid #edf1f6}.home-condition:last-child{border-bottom:0}.home-condition-icon{display:flex;color:#7591b3}.home-condition-icon .home-icon{width:18px;height:18px}.home-condition .badge{margin-left:auto;font-size:10px;font-weight:500}.home-scan-note{background:#f8fafc;border-radius:8px;padding:12px 14px;margin:13px 24px;font-size:10px;line-height:1.8;color:#8593a5}.home-scan-note strong{font-size:11px;font-weight:500;color:#5c718b}.home-condition-foot{margin:0 24px 20px;color:#8b98aa;font-size:10px;line-height:1.9}.home-condition-foot .home-icon{width:12px;height:12px}
|
||||
.home-issue-count{display:inline-flex;align-items:center;justify-content:center;min-width:21px;height:21px;border-radius:6px;background:#f0f4f9;font-size:11px;color:#7188a4;margin-left:2px}.home-clear-state{display:flex;align-items:center;gap:18px;padding:7px 26px 28px}.home-clear-symbol{display:flex;align-items:center;justify-content:center;width:62px;height:62px;flex-shrink:0;border-radius:18px;background:linear-gradient(135deg,#f2f7ff,#eaf2fd);color:#6396d2;box-shadow:inset 0 0 0 1px #dfeafa}.home-clear-symbol .home-icon{width:32px;height:32px}.home-clear-state h3{font-size:14px;margin:0 0 6px}.home-clear-state p{color:#8190a4;font-size:11px;margin:0}.home-clear-state .btn{margin-left:auto;font-size:12px;border-color:#c9d9ec;color:#527aa9;flex-shrink:0}.home-issue-list{padding:0 24px 12px}.home-issue-list article{display:flex;align-items:flex-start;gap:13px;padding:15px 0;border-top:1px solid #edf1f6;overflow-wrap:anywhere}.home-issue-list strong{font-size:13px}.home-issue-list p,.home-issue-list a{font-size:11px}.home-issue-list p{margin:6px 0;color:var(--home-muted)}
|
||||
.home-stale *, .home-stale *::before,.home-stale *::after{animation-play-state:paused!important}
|
||||
@media(min-width:1400px){.home-hero-content{padding-left:36px}.home-scene{margin-right:50px}.home-kpi{padding:22px 24px}}
|
||||
@media(max-width:991px){.home-main-grid{grid-template-columns:minmax(0,1fr)}.home-hero{grid-template-columns:minmax(0,1fr) minmax(210px,.8fr)}.home-scene{width:280px;transform:scale(.84);transform-origin:center}.home-hero-content{padding:26px 24px}.home-hero-footer{padding:13px 24px}.home-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.home-clear-state{flex-wrap:wrap}.home-clear-state .btn{margin-left:80px}}
|
||||
@media(max-width:575px){.business-home{gap:14px}.home-hero{grid-template-columns:minmax(0,1fr)}.home-hero-content{padding:24px 22px 19px}.home-send-time>strong{font-size:56px}.home-send-time{gap:12px}.home-scene{display:none}.home-window-state{font-size:12px;gap:6px}.home-hero-footer{padding:12px 22px;gap:8px}.home-switches{gap:12px;font-size:10px}.home-kpis{gap:10px}.home-kpi{padding:15px 14px}.home-kpi-top{font-size:11px;gap:5px;align-items:flex-start}.home-kpi-top .home-symbol{width:28px;height:28px;border-radius:8px}.home-kpi-top .home-icon{width:17px;height:17px}.home-kpi-value strong{font-size:29px}.home-kpi-note{font-size:10px}.home-card-heading{padding:18px 18px 14px}.home-window-track{margin:0 18px 9px;padding:12px}.home-batch-list,.home-conditions,.home-issue-list{padding-left:18px;padding-right:18px}.home-batch{gap:9px}.home-batch-copy strong{font-size:11px}.home-batch-copy small{font-size:10px}.home-batch .home-symbol{width:30px;height:30px}.home-batch>.home-icon{display:none}.home-batch-count{font-size:20px}.home-scan-note{margin:12px 18px}.home-condition-foot{margin:0 18px 18px}.home-clear-state{padding:4px 18px 22px;gap:12px}.home-clear-symbol{width:45px;height:45px;border-radius:12px}.home-clear-symbol .home-icon{width:25px;height:25px}.home-clear-state>div{flex:1;min-width:170px}.home-clear-state h3{font-size:12px}.home-clear-state .btn{margin-left:57px}.home-update{align-items:flex-start;font-size:12px}.home-hero-actions{gap:14px}}
|
||||
@media(prefers-reduced-motion:reduce){.business-home *, .business-home *::before,.business-home *::after,.home-loading *, .home-loading *::before,.home-loading *::after{animation:none!important;transition:none!important}.home-kpi:hover,.home-hero:hover .home-scene-sheet{transform:none}}
|
||||
.business-home .home-hero-actions .btn-primary{background:#206bc4;border-color:#206bc4;color:#fff}.business-home .home-hero-actions .btn-primary:hover{background:#185ba9;border-color:#185ba9}.home-live .status-dot{background:currentColor}.home-live.is-live .status-dot-animated::before{animation-duration:2.4s}
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
window.BusinessHome=(()=>{
|
||||
// Tabler Icons (MIT), copyright Paweł Kuna. See licenses/Tabler-Icons-MIT.txt.
|
||||
const icons={"alert-circle":"<path d=\"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0\" />\n <path d=\"M12 8v4\" />\n <path d=\"M12 16h.01\" />","arrow-right":"<path d=\"M5 12l14 0\" />\n <path d=\"M13 18l6 -6\" />\n <path d=\"M13 6l6 6\" />","check":"<path d=\"M5 12l5 5l10 -10\" />","clock-hour-4":"<path d=\"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0\" />\n <path d=\"M12 12l3 2\" />\n <path d=\"M12 7v5\" />","database":"<path d=\"M4 6a8 3 0 1 0 16 0a8 3 0 1 0 -16 0\" />\n <path d=\"M4 6v6a8 3 0 0 0 16 0v-6\" />\n <path d=\"M4 12v6a8 3 0 0 0 16 0v-6\" />","file-type-pdf":"<path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4\" />\n <path d=\"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6\" />\n <path d=\"M17 18h2\" />\n <path d=\"M20 15h-3v6\" />\n <path d=\"M11 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1\" />","mail-forward":"<path d=\"M12 18h-7a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7.5\" />\n <path d=\"M3 6l9 6l9 -6\" />\n <path d=\"M15 18h6\" />\n <path d=\"M18 15l3 3l-3 3\" />","route":"<path d=\"M3 19a2 2 0 1 0 4 0a2 2 0 0 0 -4 0\" />\n <path d=\"M19 7a2 2 0 1 0 0 -4a2 2 0 0 0 0 4\" />\n <path d=\"M11 19h5.5a3.5 3.5 0 0 0 0 -7h-8a3.5 3.5 0 0 1 0 -7h4.5\" />","shield-check":"<path d=\"M11.46 20.846a12 12 0 0 1 -7.96 -14.846a12 12 0 0 0 8.5 -3a12 12 0 0 0 8.5 3a12 12 0 0 1 -.09 7.06\" />\n <path d=\"M15 19l2 2l4 -4\" />"};
|
||||
const icon=name=>'<svg class="home-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.65" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">'+(icons[name]||icons['route'])+'</svg>';
|
||||
const number=value=>Number.isSafeInteger(value)&&value>=0?String(value):'—';
|
||||
const valid=value=>typeof value==='string'&&Number.isFinite(Date.parse(value));
|
||||
const time=value=>valid(value)?new Intl.DateTimeFormat('zh-CN',{timeZone:'Asia/Shanghai',hour:'2-digit',minute:'2-digit',hour12:false}).format(new Date(value)):'—';
|
||||
const day=value=>new Intl.DateTimeFormat('en-CA',{timeZone:'Asia/Shanghai',year:'numeric',month:'2-digit',day:'2-digit'}).format(new Date(value));
|
||||
const short=value=>valid(value)?new Intl.DateTimeFormat('zh-CN',{timeZone:'Asia/Shanghai',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hour12:false}).format(new Date(value)):'未提供';
|
||||
const on=value=>value===true?'已启用':value===false?'已暂停':'未取得';
|
||||
function loading(){return '<div class="home-loading" aria-label="正在读取业务首页"><div class="card p-4 placeholder-wave"><span class="placeholder col-3 mb-4"></span><span class="placeholder col-5 mb-3"></span><span class="placeholder col-8"></span></div><div class="home-kpis mt-3">'+Array.from({length:4},()=>'<div class="card p-4 placeholder-wave"><span class="placeholder col-8 mb-3"></span><span class="placeholder col-4"></span></div>').join('')+'</div></div>';}
|
||||
function mount(container,data,{esc,formatDate,isActive}){
|
||||
const c=data.counts||{},h=data.home||{},w=data.window,s=data.settings||{},caps=data.capabilities||{},issues=(data.issues||[]).filter(i=>!['resolved','retired'].includes(i.status));
|
||||
const ready=['liveTodo','pdfExport','automaticArchive'].every(k=>caps[k]===true),live=s.enabled===true&&s.processingEnabled===true&&ready&&!issues.length&&!c.blocked&&!c.unknown;
|
||||
const state=typeof s.enabled!=='boolean'?'设置状态未取得':!s.enabled?'自动邮件已暂停':!s.processingEnabled?'自动处理已暂停':!ready?'运行条件待验证':issues.length||c.blocked||c.unknown?'有事项待处理':'自动通知已启用';
|
||||
const collectingLink='#notification-batches?scope=active&status=collecting';
|
||||
const metric=(key,title,value,symbol,tone,href,note)=>'<a class="home-kpi card" href="'+href+'"><div class="home-kpi-top"><span>'+title+'</span><span class="home-symbol home-symbol-'+tone+'">'+icon(symbol)+'</span></div><div class="home-kpi-value"><strong data-home-metric="'+key+'">'+number(value)+'</strong><span>项</span></div><div class="home-kpi-note">'+note+icon('arrow-right')+'</div></a>';
|
||||
const scene='<div class="home-scene" aria-hidden="true"><div class="home-scene-orbit"></div><svg class="home-scene-path" viewBox="0 0 360 230" fill="none"><path d="M65 155 C65 88 126 102 155 88 M205 117 C266 117 250 165 300 165" stroke="currentColor" stroke-width="2" stroke-dasharray="4 6"/></svg><div class="home-scene-source">'+icon('route')+'<span>BPM 通知</span><i></i></div><div class="home-scene-sheet"><span class="home-paper-icon">'+icon('file-type-pdf')+'</span><b>订单通知书</b><span class="home-paper-line"></span><span class="home-paper-line short"></span><span class="home-paper-bottom">'+icon('database')+' PDF 归档</span></div><div class="home-scene-mail">'+icon('mail-forward')+'<div><b>分类汇总</b><small>按计划发送</small></div></div></div>';
|
||||
container.innerHTML='<div class="business-home" data-business-home><section class="home-hero card"><div class="home-hero-content"><div class="home-eyebrow">'+icon('clock-hour-4')+' 下一批通知</div><div class="home-send-time"><strong data-home-next-send>'+time(w?.end)+'</strong><span data-home-send-day></span></div><div class="home-window-state"><span data-home-phase></span><span class="home-separator">·</span><span data-home-countdown></span></div><p class="home-cutoff" data-home-cutoff>到达截止 '+time(w?.collectionEnd||w?.end)+' <span>北京时间</span></p><div class="home-hero-actions"><a class="btn btn-primary" href="#notification-batches?scope=active">'+icon('mail-forward')+' 查看邮件批次</a><a class="home-text-link" href="#schedule">发送计划 '+icon('arrow-right')+'</a></div></div>'+scene+'<div class="home-hero-footer"><span class="home-live '+(live?'is-live':'')+'"><span class="status-dot '+(live?'status-dot-animated':'')+'"></span><span data-home-live-label>'+esc(state)+'</span></span><div class="home-switches"><span>自动处理 <b>'+on(s.processingEnabled)+'</b></span><span>自动邮件 <b>'+on(s.enabled)+'</b></span></div></div></section><div class="alert alert-info home-update" data-business-updates hidden><span data-update-text>业务状态有更新。</span><button class="btn btn-sm" type="button">刷新业务首页</button></div><div class="home-kpis">'+metric('pending','本轮待汇总订单',h.pendingOrders,'file-type-pdf','blue',collectingLink,'查看本轮订单')+metric('batches','收集中批次',h.collectingBatches,'mail-forward','cyan',collectingLink,'按分类汇总')+metric('blocked','受阻 / 失败订单',c.blocked,'alert-circle','amber','#notification-orders','查看处理状态')+metric('unknown','结果待核实批次',c.unknown,'shield-check','violet','#notification-batches?scope=active&status=unknown','核对发送结果')+'</div><div class="home-main-grid"><section class="home-card card"><div class="home-card-heading"><div><h2>'+icon('mail-forward')+'本轮批次</h2><p>到达收集时段,按北京时间计算</p></div><a class="home-text-link" href="#notification-batches">查看全部批次 '+icon('arrow-right')+'</a></div><div class="home-window-track"><div class="home-window-labels"><span>'+short(w?.collectionStart||w?.start)+'</span><span>'+short(w?.collectionEnd||w?.end)+' 截止</span></div><div class="progress progress-sm" role="progressbar" aria-label="本轮收集时段的时间进度" aria-valuemin="0" aria-valuemax="100" data-home-progress><div class="progress-bar"></div></div><div class="home-window-help">发送前 5 分钟截止到达收集'+(h.carriedOrders?'<span>含 '+number(h.carriedOrders)+' 单顺延,原到达时间保留</span>':'')+'</div></div><div class="home-batch-list">'+(h.batches?.length?h.batches.map(b=>'<a class="home-batch" data-home-batch href="#notification-batches?scope=active&q='+encodeURIComponent(b.id)+'"><span class="home-symbol home-symbol-blue">'+icon('mail-forward')+'</span><div class="home-batch-copy"><strong>'+esc(b.categoryName||b.categoryId)+'</strong><small>'+(b.notificationMode==='huizhou'?'惠州通知':'普通通知')+' · '+time(b.cutoff)+' 计划发送'+(b.carryCount?' · 含 '+number(b.carryCount)+' 单顺延':'')+'</small>'+(b.error?'<small class="text-warning">'+esc(b.error)+'</small>':'')+'</div><span class="home-batch-count">'+number(b.orderCount)+'<small>单</small></span>'+icon('arrow-right')+'</a>').join(''):'<div class="home-mini-empty">'+icon('mail-forward')+'<p>本轮暂无待汇总订单</p><span>符合规则的订单处理完成后会出现在这里。</span></div>')+'</div></section><section class="home-card card"><div class="home-card-heading"><div><h2>'+icon('shield-check')+'运行条件</h2><p>依据最近一次实际检查</p></div><a class="home-text-link" href="#health">详情</a></div><div class="home-conditions">'+[['liveTodo','BPM 待办读取','route','#bpm'],['pdfExport','通知书 PDF 生成','file-type-pdf','#rule-fields'],['automaticArchive','文件自动归档','database','#storage']].map(([key,label,symbol,href])=>'<a class="home-condition" href="'+href+'"><span class="home-condition-icon">'+icon(symbol)+'</span><span>'+label+'</span><span class="badge bg-'+(caps[key]===true?'green':'yellow')+'-lt">'+(caps[key]===true?'已就绪':'待验证')+'</span></a>').join('')+'</div><div class="home-scan-note">最近成功扫描<br><strong>'+esc(h.lastScanAt?formatDate(h.lastScanAt):'尚无成功扫描记录')+'</strong></div><div class="home-condition-foot">BPM 节点仍由人工办理。<br><a href="#notification-settings">处理与邮件设置 '+icon('arrow-right')+'</a></div></section></div><section class="home-card home-issues card"><div class="home-card-heading"><div><h2>'+icon('alert-circle')+'待处理事项 <span class="home-issue-count">'+issues.length+'</span></h2><p>受阻原因与需要人工核验的结果</p></div><a class="home-text-link" href="#exceptions">异常Line truncated
|
||||
const root=container.querySelector('[data-business-home]');let disposed=false,timer;
|
||||
function tick(){if(disposed||!isActive()||!root.isConnected)return;const now=Date.now(),end=valid(w?.end)?Date.parse(w.end):NaN,start=Date.parse(w?.collectionStart||w?.start),cut=Date.parse(w?.collectionEnd||w?.end);const next=root.querySelector('[data-home-send-day]');next.textContent=Number.isFinite(end)?(day(end)===day(now)?'今天':new Intl.DateTimeFormat('zh-CN',{timeZone:'Asia/Shanghai',month:'numeric',day:'numeric'}).format(new Date(end)))+'计划发送':'暂无可用时点';let phase='等待发送窗口',countdown='请检查发送计划';if(Number.isFinite(end)){phase=now>=end?'已到计划发送时间':now>=cut?'本轮到达收集已截止':'本轮收集中';const minutes=Math.max(1,Math.ceil((end-now)/60000));countdown=now>=end?'请刷新确认发送结果':'距计划发送 '+(minutes>=60?Math.floor(minutes/60)+' 小时 ':'')+(minutes%60)+' 分钟';}if(s.enabled===false){phase='等待恢复';countdown='恢复后按已配置计划执行';}root.querySelector('[data-home-phase]').textContent=phase;root.querySelector('[data-home-countdown]').textContent=countdown;const progress=root.querySelector('[data-home-progress]'),ratio=Number.isFinite(start)&&Number.isFinite(cut)&&cut>start?Math.min(100,Math.max(0,(now-start)/(cut-start)*100)):0;progress.setAttribute('aria-valuenow',String(Math.round(ratio)));progress.querySelector('.progress-bar').style.width=ratio+'%';timer=setTimeout(tick,30000);}
|
||||
root.classList.toggle('is-scanning',s.processingEnabled===true&&(data.scans||[]).some(scan=>scan.status==='scanning'));tick();
|
||||
return {setStale(stale,failed=false){root.classList.toggle('home-stale',stale);root.querySelector('[data-home-live-label]').textContent=stale?(failed?'状态读取失败,显示上次结果':'有新状态待刷新'):state;},dispose(){disposed=true;clearTimeout(timer);}};
|
||||
}
|
||||
return {mount,loading};
|
||||
})();
|
||||
@@ -1,18 +1,18 @@
|
||||
'use strict';
|
||||
window.OrderNotificationViews=(()=>{
|
||||
let helpers,homeDispose;
|
||||
async function render(container,isActive=()=>true,section='workbench'){
|
||||
async function render(container,isActive=()=>true,section='workbench',prepared=null){
|
||||
homeDispose?.();homeDispose=null;
|
||||
const {api,esc,formatDate,user}=helpers;
|
||||
if(['execution','orders','pending','history'].includes(section))return window.BusinessRecordViews.render(container,{...helpers,isActive},['execution','orders'].includes(section)?'orders':'batches');
|
||||
const data=await api('/order-rules?view=summary');if(!isActive())return;
|
||||
if(section!=='settings')container.innerHTML=window.BusinessHome.loading();
|
||||
const data=prepared||await api('/order-rules?view=summary');if(!isActive())return;
|
||||
if(section==='settings')return settings(container,data,isActive);
|
||||
const shared=window.OrderNotificationShared.create({esc}),w=data.window,c=data.counts||{};
|
||||
container.innerHTML=`<div class="alert alert-info">自动处理:${data.settings.processingEnabled?'已启用':'已暂停'} · 自动邮件:${data.settings.enabled?'已启用':'已暂停'}。BPM 节点由人工办理。</div><div class="alert alert-info" data-business-updates hidden>业务状态有更新。<button class="btn btn-sm" type="button">刷新业务首页</button></div><div class="workspace-metrics">${[['订单中心',c.orders,'notification-orders'],['受阻订单',c.blocked,'notification-orders?status=blocked'],['结果待核实',c.unknown,'notification-batches?status=unknown'],['未终结批次',c.activeBatches,'notification-batches']].map(([label,count,href])=>`<div class="card"><div class="card-body"><a href="#${href}">${label}</a><div class="metric-number">${Number(count||0)}<span>项</span></div></div></div>`).join('')}</div><section class="card mb-3"><div class="card-body"><h2 class="h3">连续业务窗口</h2><p>${w?esc(formatDate(w.collectionStart||w.start))+' 至 '+esc(formatDate(w.collectionEnd||w.end)): '当前发送窗口不可用'}</p><p class="small text-secondary">按到达时间连续积累,发送前五分钟截止,本时点前最后五分钟归下一批。已冻结批次跨窗口继续显示;历史受阻任务需要明确处理,不自动补发。</p><p>下个发送时点:${esc(formatDate(w?.end))}</p><a href="#schedule">发送计划</a> · <a href="#calendar">业务日历</a> · <a href="#notification-settings">处理与邮件设置</a></div></section><section class="card mb-3"><div class="card-body"><h2 class="h3">未配置项与运行条件</h2>${shared.capabilities(data.capabilities)}${shared.capabilityBlockers(data.capabilities)}<a href="#order-rules">分类规则</a> · <a href="#rule-fields">字段映射</a> · <a href="#bpm">BPM 连接</a> · <a href="#mail">邮箱</a></div></section><section class="card"><div class="card-header"><h2 class="card-title">业务受阻与待核验</h2></div><div class="list-group list-group-flush">${(data.issues||[]).filter(i=>!['resolved','retired'].includes(i.status)).map(i=>`<div class="list-group-item"><strong>${esc(i.error||i.message||i.type||'业务受阻')}</strong><p class="small mb-1">${esc(({open:'待处理',unassigned:'待分配',awaiting_verification:'待人工核验',in_progress:'处理中',verifying:'待核验'})[i.status]||i.status||'待处理')} · 负责人:${esc(i.owner||(i.owners||[]).join('、')||'未分配')}</p><a href="#exceptions${i.exceptionId?'?id='+encodeURIComponent(i.exceptionId):''}">处理 / 核验异常</a>${i.batchId?` · <a href="#notification-batches?scope=all&q=${encodeURIComponent(i.batchId)}">查看原批次</a>`:''}</div>`).join('')||'<div class="list-group-item text-secondary">暂无已记录的业务阻塞。实际就绪仍以运行条件与订单状态为准。</div>'}</div></section>`;
|
||||
let disposed=false,timer,controller;const notice=container.querySelector('[data-business-updates]'),signature=JSON.stringify(data);
|
||||
notice.querySelector('button').onclick=()=>render(container,isActive,'workbench');
|
||||
async function poll(){if(disposed||!isActive())return;try{controller=new AbortController();const fresh=await api('/order-rules?view=summary',undefined,{signal:controller.signal});if(!disposed&&isActive())notice.hidden=JSON.stringify(fresh)===signature;}catch{}finally{if(!disposed&&isActive())timer=setTimeout(poll,15000);}}
|
||||
timer=setTimeout(poll,15000);homeDispose=()=>{disposed=true;clearTimeout(timer);controller?.abort();};window.PageLifecycle.onDispose(homeDispose);
|
||||
const home=window.BusinessHome.mount(container,data,{esc,formatDate,isActive});
|
||||
let disposed=false,timer,controller,refreshController;const notice=container.querySelector('[data-business-updates]'),signature=JSON.stringify(data);
|
||||
notice.querySelector('button').onclick=async event=>{const button=event.currentTarget;if(button.disabled)return;button.disabled=true;refreshController=new AbortController();try{const fresh=await api('/order-rules?view=summary',undefined,{signal:refreshController.signal});if(!disposed&&isActive())await render(container,isActive,'workbench',fresh);}catch(error){if(!disposed&&isActive()){notice.hidden=false;notice.querySelector('[data-update-text]').textContent='刷新失败:'+error.message+';仍显示上次结果。';home.setStale(true,true);}}finally{if(button.isConnected)button.disabled=false;}};
|
||||
async function poll(){if(disposed||!isActive())return;try{controller=new AbortController();const fresh=await api('/order-rules?view=summary',undefined,{signal:controller.signal});if(!disposed&&isActive()){const changed=JSON.stringify(fresh)!==signature;notice.hidden=!changed;notice.querySelector('[data-update-text]').textContent='业务状态有更新。';home.setStale(changed);}}catch{if(!disposed&&isActive()){notice.hidden=false;notice.querySelector('[data-update-text]').textContent='状态读取失败,仍显示上次结果。';home.setStale(true,true);}}finally{if(!disposed&&isActive())timer=setTimeout(poll,15000);}}
|
||||
timer=setTimeout(poll,15000);homeDispose=()=>{disposed=true;clearTimeout(timer);controller?.abort();refreshController?.abort();home.dispose();};window.PageLifecycle.onDispose(homeDispose);
|
||||
}
|
||||
async function settings(container,data,isActive){
|
||||
const {api,esc,user,formatDate}=helpers,config=data.settings,admin=user.role==='admin',mail=await api('/mail').catch(error=>({channels:[],error:error.message}));if(!isActive())return;
|
||||
|
||||
Reference in new issue
Block a user