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
@@ -1,5 +1,12 @@
|
||||
# 开发交接(2026-10-23)
|
||||
|
||||
## 2026-10-27 业务首页轻量看板
|
||||
|
||||
- 用户确认蓝白卡片、流程小场景和少量动效。新增首页独立模块及样式,突出下一计划发送时点、到达截止、时间进度、收集中批次及顺延数量;运行条件和异常独立展示,保留现有业务操作边界。
|
||||
- Tabler Icons使用MIT授权静态SVG,许可证位于licenses/Tabler-Icons-MIT.txt;未使用需购买授权的Tabler插画。现有Tabler状态点与骨架组件无需升级依赖。动画仅作状态/交互提示,扫描流动仅在实际scanning状态出现;减少动态效果时禁用动画。
|
||||
- summary追加home字段复用当前已授权收集批次,普通/惠州订单去重,预览最多4组,不返回邮件正文或收件人。倒计时到期只提示刷新确认,不能推断发送成功;暂停、加载失败及内部刷新失败均有明确状态。
|
||||
- 首页与汇总/查询/批次专项31项通过,桌面1440、窄屏674和手机390截图核验,无横向溢出;内部刷新失败保留旧数据并可重试,离页销毁倒计时与请求。仅展示改版,不更改匹配、归档、发信计划或测试期限。
|
||||
|
||||
## 2026-10-27 未发送订单顺延下一批
|
||||
|
||||
- 用户明确要求确认未发的订单恢复待汇总,下一时段重新合并;有证明的失败冻结批次保留历史后取消,新批次使用正常模板/新窗口草稿。已发送、sending/unknown、部分接受和无证明旧failed不自动重发。
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2026 Paweł Kuna
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
"service:stop": "node scripts/service.cjs stop",
|
||||
"service:restart": "node scripts/service.cjs restart",
|
||||
"test": "npm run test:business",
|
||||
"test:business": "node --test --test-concurrency=1 tests/order-rules/carry-forward-core.test.cjs tests/order-rules/carry-forward-integration.test.cjs tests/order-rules/dispatch-unsent-proof.test.cjs tests/order-rules/dismiss-task.test.cjs tests/app/carry-dismiss-ui.test.cjs tests/workspace/business-issues.test.cjs tests/mail/unified-account.test.cjs tests/mail/unified-account-ui.test.cjs tests/assistant/assistant.test.cjs tests/assistant/assistant-http-ui.test.cjs tests/assistant/controlled-operations.test.cjs tests/assistant/dsh-runtime.test.cjs tests/assistant/dsh-runtime-installer.test.cjs tests/assistant/repair-runner.test.cjs tests/app/automatic-pdf-ledger.test.cjs tests/app/job-records.test.cjs tests/order-rules/version-compatibility.test.cjs tests/bpm-display-policy.test.cjs tests/bpm-dynamicarea.test.cjs tests/bpm-readonly-form.test.cjs tests/bpm-form-contracts.test.cjs tests/bpm-obsolete-display-fields.test.cjs tests/order-rules/snapshot-read-context.test.cjs tests/order-rules/summary.test.cjs tests/order-rules/execution-single-flight.test.cjs tests/order-rules/execution-responsiveness.test.cjs tests/order-rules/readiness-pending-ui.test.cjs tests/dependency-compatibility.test.cjs tests/order-rules/slow-cutoff.test.cjs tests/order-rules/removed-discovery-barrier.test.cjs tests/mail/sample-send.test.cjs tests/mail/template-editing.test.cjs tests/mail/template-editor-ui.test.cjs tests/order-rules/scope-catalog.test.cjs tests/order-rules/field-mapping-ui.test.cjs tests/order-rules/scope-search-ui.test.cjs tests/order-rules/excel-import-contract.test.cjs tests/order-rules/excel-execution-bridge.test.cjs tests/order-rules/excel-import-flow-ui.test.cjs tests/order-rules/collecting-batches.test.cjs tests/order-rules/collecting-batches-ui.test.cjs tests/order-rules/query.test.cjs tests/order-rules/scheduled-mail-policy.test.cjs",
|
||||
"test:business": "node --test --test-concurrency=1 tests/app/business-home-ui.test.cjs tests/order-rules/home-summary.test.cjs tests/order-rules/carry-forward-core.test.cjs tests/order-rules/carry-forward-integration.test.cjs tests/order-rules/dispatch-unsent-proof.test.cjs tests/order-rules/dismiss-task.test.cjs tests/app/carry-dismiss-ui.test.cjs tests/workspace/business-issues.test.cjs tests/mail/unified-account.test.cjs tests/mail/unified-account-ui.test.cjs tests/assistant/assistant.test.cjs tests/assistant/assistant-http-ui.test.cjs tests/assistant/controlled-operations.test.cjs tests/assistant/dsh-runtime.test.cjs tests/assistant/dsh-runtime-installer.test.cjs tests/assistant/repair-runner.test.cjs tests/app/automatic-pdf-ledger.test.cjs tests/app/job-records.test.cjs tests/order-rules/version-compatibility.test.cjs tests/bpm-display-policy.test.cjs tests/bpm-dynamicarea.test.cjs tests/bpm-readonly-form.test.cjs tests/bpm-form-contracts.test.cjs tests/bpm-obsolete-display-fields.test.cjs tests/order-rules/snapshot-read-context.test.cjs tests/order-rules/summary.test.cjs tests/order-rules/execution-single-flight.test.cjs tests/order-rules/execution-responsiveness.test.cjs tests/order-rules/readiness-pending-ui.test.cjs tests/dependency-compatibility.test.cjs tests/order-rules/slow-cutoff.test.cjs tests/order-rules/removed-discovery-barrier.test.cjs tests/mail/sample-send.test.cjs tests/mail/template-editing.test.cjs tests/mail/template-editor-ui.test.cjs tests/order-rules/scope-catalog.test.cjs tests/order-rules/field-mapping-ui.test.cjs tests/order-rules/scope-search-ui.test.cjs tests/order-rules/excel-import-contract.test.cjs tests/order-rules/excel-execution-bridge.test.cjs tests/order-rules/excel-import-flow-ui.test.cjs tests/order-rules/collecting-batches.test.cjs tests/order-rules/collecting-batches-ui.test.cjs tests/order-rules/query.test.cjs tests/order-rules/scheduled-mail-policy.test.cjs",
|
||||
"test:full": "node --test --test-concurrency=2 \"tests/**/*.test.cjs\""
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -42,6 +42,8 @@ function createAssets(){
|
||||
'/modules/order-notifications/detail.js':{path:path.join(webRoot,'modules/order-notifications/detail.js'),type:'text/javascript'},
|
||||
'/modules/order-notifications/batch-editor.js':{path:path.join(webRoot,'modules/order-notifications/batch-editor.js'),type:'text/javascript'},
|
||||
'/modules/order-notifications/records.js':{path:path.join(webRoot,'modules/order-notifications/records.js'),type:'text/javascript'},
|
||||
'/business-home.js':{path:path.join(webRoot,'modules/order-notifications/home.js'),type:'text/javascript'},
|
||||
'/business-home.css':{path:path.join(webRoot,'modules/order-notifications/home.css'),type:'text/css'},
|
||||
'/order-notifications.js':{path:path.join(webRoot,'modules/order-notifications/view.js'),type:'text/javascript'},
|
||||
'/order-rules.js':{path:path.join(webRoot,'modules/order-rules/view.js'),type:'text/javascript'},
|
||||
'/notifications.js':{path:path.join(webRoot,'modules/notifications/view.js'),type:'text/javascript'},
|
||||
|
||||
@@ -132,6 +132,14 @@ function summary(context,user){
|
||||
const count=(items,status)=>items.filter(i=>status.includes(i.status)).length;
|
||||
result.scans=context.orderRules.all('execution-scans').filter(s=>canReadConnection(context.workspace,user,s.connectionId||s.id)).map(s=>pick(s,['id','connectionId','status','startedAt','finishedAt','rowCount','targetCount','error']));
|
||||
result.counts={orders:rows.length,blocked:rows.filter(row=>['blocked','failed'].includes(row.status)||row.notifications?.huizhou?.status==='blocked').length,unknown:count(batches,['unknown']),activeBatches:count(batches,['collecting','prepared','sending','unknown','failed'])};
|
||||
const authorized=new Set(batches),current=collecting.filter(batch=>authorized.has(batch));
|
||||
result.home={
|
||||
pendingOrders:new Set(current.flatMap(batch=>batch.orderIds||[])).size,
|
||||
collectingBatches:current.length,
|
||||
carriedOrders:new Set(current.flatMap(batch=>batch.carriedOrderIds||[])).size,
|
||||
batches:current.slice(0,4).map(batch=>({id:batch.id,categoryId:batch.categoryId,categoryName:batch.ruleSnapshot?.name||batch.categoryId,notificationMode:modeOf(batch),orderCount:batch.orderIds?.length||0,carryCount:batch.carriedOrderIds?.length||0,cutoff:batch.cutoff,error:batch.error||null})),
|
||||
lastScanAt:result.scans.filter(scan=>scan.status==='complete'&&Number.isFinite(Date.parse(scan.finishedAt))).sort((a,b)=>Date.parse(b.finishedAt)-Date.parse(a.finishedAt))[0]?.finishedAt||null
|
||||
};
|
||||
result.issues=data.issues.filter(issue=>!['resolved','retired'].includes(issue.status)).filter(issue=>user.role==='admin'||((issue.orderIds?.length||issue.taskIds?.length)&& (issue.orderIds||[]).every(id=>canReadOrder(context.workspace,user,context.orderRules.get('orders',id)))&&(issue.taskIds||[]).every(id=>canReadConnection(context.workspace,user,context.orderRules.get('execution-tasks',id)?.connectionId)))).slice(-50).map(i=>{const linked=context.workspace?.businessIssue?.(i.id);return pick(linked?{...i,status:linked.status,owner:linked.owner,exceptionId:linked.id}:i,['id','status','type','message','error','component','notificationMode','owner','owners','exceptionId','createdAt','batchId','orderIds','taskIds']);}).filter(i=>!['resolved','retired'].includes(i.status));
|
||||
result.templateUsage=context.orderRules.all('rules').map(r=>({categoryId:r.published?.categoryId||r.draft?.categoryId,name:r.draft?.name,templateId:r.published?.bodyTemplateId||'',huizhouEnabled:r.published?.huizhouEnabled===true,huizhouTemplateId:r.published?.huizhouTemplateId||'',legacyBinding:!!r.published&&r.published.bodyTemplateId===undefined,publishedVersion:r.published?.version||null,status:r.published?.status||'draft'}));
|
||||
result.revision=crypto.createHash('sha256').update(publicRevision(context,user)+JSON.stringify([result.window,result.issues])).digest('hex').slice(0,24);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
const test=require('node:test'),assert=require('node:assert/strict');const {orderDrivenUI}=require('../fixtures/order-driven-ui.cjs');
|
||||
function summary(){return {settings:{enabled:true,processingEnabled:true},counts:{orders:11,blocked:0,unknown:0,activeBatches:2},window:{start:'2026-10-27T03:00:00Z',end:'2026-10-27T09:00:00Z',collectionStart:'2026-10-27T02:55:00Z',collectionEnd:'2026-10-27T08:55:00Z'},capabilities:{liveTodo:true,pdfExport:true,automaticArchive:true},scans:[{status:'complete',finishedAt:'2026-10-27T03:59:00Z'}],issues:[],home:{pendingOrders:7,collectingBatches:2,carriedOrders:6,lastScanAt:'2026-10-27T03:59:00Z',batches:[{id:'collecting-test',categoryId:'overseas-change',categoryName:'海外订单更改通知书',notificationMode:'normal',orderCount:6,carryCount:6,cutoff:'2026-10-27T09:00:00Z',error:null},{id:'collecting-other',categoryName:'海外订单通知书',notificationMode:'normal',orderCount:1,carryCount:0,cutoff:'2026-10-27T09:00:00Z',error:null}]}};}
|
||||
async function setup(t){const f=await orderDrivenUI(t,'#overview'),data=summary();await f.page.clock.install({time:new Date('2026-10-27T04:00:00Z')});await f.page.route('**/api/order-rules?view=summary',r=>r.fulfill({json:data}));await f.page.reload();return {...f,data};}
|
||||
test('business home presents actual next window and deduplicated work, keeps mobile layout and reduced motion',{timeout:60000},async t=>{const {page}=await setup(t);await page.locator('[data-business-home]').waitFor();assert.equal(await page.locator('[data-home-metric="pending"]').innerText(),'7');assert.equal(await page.locator('[data-home-next-send]').innerText(),'17:00');assert.match(await page.locator('[data-home-cutoff]').innerText(),/16:55/);assert.equal(await page.locator('[data-home-batch]').count(),2);assert.match(await page.locator('[data-home-batch]').first().innerText(),/6.*顺延/s);assert.equal(await page.getByRole('link',{name:'查看全部批次',exact:true}).getAttribute('href'),'#notification-batches');await require('node:fs/promises').mkdir('output/business-flow-test/home-visual',{recursive:true});await page.screenshot({path:'output/business-flow-test/home-visual/desktop.png',fullPage:true});await page.setViewportSize({width:674,height:1000});await page.screenshot({path:'output/business-flow-test/home-visual/compact.png',fullPage:true});await page.emulateMedia({reducedMotion:'reduce'});assert.equal(await page.locator('.home-live .status-dot').evaluate(e=>getComputedStyle(e,'::before').animationName),'none');await page.setViewportSize({width:390,height:844});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);await page.screenshot({path:'output/business-flow-test/home-visual/mobile.png',fullPage:true});});
|
||||
test('paused and blocked states remain honest and the clock never claims delivery at the deadline',{timeout:60000},async t=>{const {page,data}=await setup(t);await page.locator('[data-business-home]').waitFor();await page.clock.fastForward(5*3600000+1000);assert.match(await page.locator('[data-home-countdown]').innerText(),/刷新.*发送结果/);data.settings.enabled=false;data.capabilities.liveTodo=false;data.issues=[{id:'i',error:'<img src=x onerror=alert(1)>',status:'open'}];await page.reload();await page.getByText('自动邮件已暂停',{exact:true}).waitFor();assert.equal(await page.locator('.home-live .status-dot-animated').count(),0);assert.equal(await page.locator('.home-issues img').count(),0);assert.match(await page.locator('.home-issues').innerText(),/img src/);});
|
||||
test('failed summary loading never displays invented zero counts or healthy state',{timeout:60000},async t=>{const {page}=await setup(t);await page.unroute('**/api/order-rules?view=summary');await page.route('**/api/order-rules?view=summary',r=>r.fulfill({status:503,json:{error:'首页数据暂不可用'}}));await page.reload();await page.getByText('首页数据暂不可用',{exact:false}).first().waitFor();assert.equal(await page.locator('[data-business-home]').count(),0);});
|
||||
test('failed internal refresh retains the last home and offers a working retry',{timeout:60000},async t=>{const {page,data}=await setup(t);await page.locator('[data-business-home]').waitFor();await page.unroute('**/api/order-rules?view=summary');let fail=true;await page.route('**/api/order-rules?view=summary',r=>fail?r.fulfill({status:503,json:{error:'暂时不可用'}}):r.fulfill({json:data}));await page.clock.fastForward(15001);await page.locator('[data-business-updates]').waitFor();await page.getByRole('button',{name:'刷新业务首页',exact:true}).click();await page.getByText('刷新失败:暂时不可用',{exact:false}).waitFor();assert.equal(await page.locator('[data-home-metric="pending"]').innerText(),'7');fail=false;await page.getByRole('button',{name:'刷新业务首页',exact:true}).click();await page.locator('[data-business-updates]').waitFor({state:'hidden'});assert.equal(await page.locator('[data-home-metric="pending"]').innerText(),'7');});
|
||||
@@ -0,0 +1,67 @@
|
||||
'use strict';
|
||||
const test=require('node:test'),assert=require('node:assert/strict');
|
||||
const {summary}=require('../../src/modules/order-rules/query.cjs');
|
||||
const {windowForCutoff}=require('../../src/modules/order-rules/window.cjs');
|
||||
const alice={username:'alice',role:'operator'},admin={username:'admin',role:'admin'};
|
||||
function fixture(){
|
||||
const data={},schedule={times:['11:00','17:00'],weekends:false};
|
||||
const store={all:k=>data[k]||[],get:(k,id)=>(data[k]||[]).find(r=>r.id===id),snapshot:()=>({}),clock:()=>new Date('2026-10-26T01:00:00Z'),schedule:()=>schedule,calendar:()=>[],settings:()=>({}),intakeWindow:()=>null};
|
||||
const add=(id,categoryId='a',connectionId='alice-source',extra={})=>{
|
||||
const event={source:'todo',connectionId,taskId:id,instanceId:id,processName:'process',nodeName:'node',receivedAt:'2026-10-26T00:30:00Z',fields:{private:'RAW-SECRET'}};
|
||||
const rule={id:categoryId,categoryId,name:'Category '+categoryId,version:1,scopes:[{processName:'process',nodeName:'node'}],huizhouEnabled:true,to:['SECRET@example.com'],cc:['CC@example.com'],intro:'BODY-SECRET'};
|
||||
const order={id,categoryId,status:'pending',sample:event,event,ruleSnapshot:rule,notifications:{huizhou:{status:'pending',orderNos:['H-'+id],issues:[]}},...extra};
|
||||
(data.orders||=[]).push(order);return order;
|
||||
};
|
||||
return {data,store,add,context:{orderRules:store,workspace:{recordSources:()=>[{id:'alice-source',owner:'alice'},{id:'bob-source',owner:'bob'}]}}};
|
||||
}
|
||||
|
||||
test('home counts physical orders once across normal and Hui current collection and omits historical/removed orders',()=>{
|
||||
const f=fixture();f.add('one');f.add('two');f.add('removed','removed','alice-source',{removedAt:'2026-10-26T00:40:00Z'});
|
||||
const old=f.add('old','old');old.event.receivedAt='2026-10-20T00:00:00Z';
|
||||
f.data.batches=[{id:'prepared-old',categoryId:'old',status:'prepared',orderIds:['old']},{id:'unknown-old',status:'unknown',orderIds:['old']}];
|
||||
const result=summary(f.context,alice);
|
||||
assert.equal(result.home?.pendingOrders,2);assert.equal(result.home.collectingBatches,2);assert.equal(result.home.carriedOrders,0);
|
||||
assert.deepEqual(result.counts,{orders:3,blocked:0,unknown:1,activeBatches:4});
|
||||
assert.deepEqual(result.home.batches.map(b=>[b.categoryName,b.notificationMode,b.orderCount,b.carryCount,b.cutoff]),[
|
||||
['Category a','normal',2,0,'2026-10-26T03:00:00.000Z'],['Category a','huizhou',2,0,'2026-10-26T03:00:00.000Z']]);
|
||||
for(const row of result.home.batches){assert.deepEqual(Object.keys(row).sort(),['id','categoryId','categoryName','notificationMode','orderCount','carryCount','cutoff','error'].sort());assert.equal(typeof row.error,'string');}
|
||||
assert.doesNotMatch(JSON.stringify(result.home),/SECRET|orderIds|ruleSnapshot|subject|text|html/);
|
||||
});
|
||||
|
||||
test('home respects entire-batch ownership for operators and viewers, and rechecks ownership each request',()=>{
|
||||
const f=fixture();f.add('own','own');f.add('mixed-own','mixed');f.add('mixed-private','mixed','bob-source');f.add('private','private','bob-source');
|
||||
for(const role of ['operator','viewer']){const home=summary(f.context,{...alice,role}).home;assert.equal(home?.pendingOrders,1);assert.equal(home.collectingBatches,2);assert(home.batches.every(b=>b.categoryId==='own'));}
|
||||
assert.equal(summary(f.context,admin).home.pendingOrders,4);assert.equal(summary(f.context,admin).home.collectingBatches,6);
|
||||
f.context.workspace.recordSources=()=>[{id:'alice-source',owner:'bob'},{id:'bob-source',owner:'bob'}];
|
||||
assert.deepEqual(summary(f.context,alice).home,{pendingOrders:0,collectingBatches:0,carriedOrders:0,batches:[],lastScanAt:null});
|
||||
});
|
||||
|
||||
test('home previews at most four groups without truncating aggregate counts',()=>{
|
||||
const f=fixture();for(const id of ['a','b','c'])f.add(id,id);
|
||||
const home=summary(f.context,admin).home;
|
||||
assert.equal(home?.batches.length,4);assert.equal(home.collectingBatches,6);assert.equal(home.pendingOrders,3);
|
||||
});
|
||||
|
||||
test('home deduplicates carried physical orders across notification modes without mutating durable records',()=>{
|
||||
const f=fixture(),order=f.add('carried');
|
||||
order.archive={archivedAt:'2026-10-23T02:00:00Z',files:[{name:'x.pdf',path:'C:\\x.pdf',sha256:'a'.repeat(64),size:1,kind:'pdf'}]};
|
||||
order.event.receivedAt='2026-10-23T01:00:00Z';
|
||||
f.data['execution-tasks']=[{id:'task',orderId:order.id,connectionId:'alice-source',row:order.sample,sampleId:'capture',status:'pending',step:'complete'}];
|
||||
f.data['capture-samples']=[{id:'capture',taskId:'task',provenance:'server-provider',sample:order.sample,snapshot:{html:'<p>capture</p>'}}];
|
||||
f.store.intakeWindow=()=>windowForCutoff('2026-10-23T03:00:00.000Z',f.store.schedule());
|
||||
const basisHash=require('../../src/modules/order-rules/task-identity.cjs').digest([order.sourceHash,order.sample,order.ruleSnapshot,order.archiveGeneration,order.archive]);
|
||||
order.carryForward={normal:{basisHash,targetCutoff:'2026-10-26T03:00:00.000Z'},huizhou:{basisHash,targetCutoff:'2026-10-26T03:00:00.000Z'}};
|
||||
const before=structuredClone(f.data),home=summary(f.context,alice).home;
|
||||
assert.equal(home?.carriedOrders,1);assert.equal(home.pendingOrders,1);assert.deepEqual(home.batches.map(b=>b.carryCount),[1,1]);assert.deepEqual(f.data,before);
|
||||
});
|
||||
|
||||
test('home last scan selects latest valid successful authorized completion and supports empty state',()=>{
|
||||
const f=fixture();assert.deepEqual(summary(f.context,alice).home,{pendingOrders:0,collectingBatches:0,carriedOrders:0,batches:[],lastScanAt:null});
|
||||
f.data['execution-scans']=[
|
||||
{id:'older',connectionId:'alice-source',status:'complete',finishedAt:'2026-10-26T00:00:00Z'},
|
||||
{id:'latest',connectionId:'alice-source',status:'complete',finishedAt:'2026-10-26T00:30:00Z'},
|
||||
{id:'failed',connectionId:'alice-source',status:'failed',finishedAt:'2026-10-26T00:50:00Z'},
|
||||
{id:'invalid',connectionId:'alice-source',status:'complete',finishedAt:'bad-date'},
|
||||
{id:'private',connectionId:'bob-source',status:'complete',finishedAt:'2026-10-26T00:55:00Z'}];
|
||||
assert.equal(summary(f.context,alice).home.lastScanAt,'2026-10-26T00:30:00Z');assert.equal(summary(f.context,admin).home.lastScanAt,'2026-10-26T00:55:00Z');
|
||||
});
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>订单通知中心</title><link href="/vendor/tabler.css" rel="stylesheet"><link href="/vendor/tom-select.css" rel="stylesheet"><link href="/app.css" rel="stylesheet"><link href="/field-mappings.css" rel="stylesheet"></head>
|
||||
<body><div id="app"><div class="page page-center"><div class="container-tight py-4"><div class="card"><div class="card-body text-center">正在连接订单通知中心…</div></div></div></div></div><script src="/vendor/tabler.js" defer></script><script src="/vendor/tom-select.js" defer></script><script src="/bpm-sync-settings.js" defer></script><script src="/bpm.js" defer></script><script src="/workspace.js" defer></script><script src="/mail-history.js" defer></script><script src="/mail-template-editor.js" defer></script><script src="/mail.js" defer></script><script src="/record-state.js" defer></script><script src="/record-table.js" defer></script><script src="/record-ui.js" defer></script><script src="/orders.js" defer></script><script src="/pdf-records.js" defer></script><script src="/storage-preview-host.js" defer></script><script src="/storage.js" defer></script><script src="/notifications.js" defer></script><script src="/field-sample-picker.js" defer></script><script src="/field-recognition-panel.js" defer></script><script src="/order-rules-scopes.js" defer></script><script src="/order-rules-resources.js" defer></script><script src="/order-rules-import.js" defer></script><script src="/order-rules-editor.js" defer></script><script src="/order-rules-preview.js" defer></script><script src="/field-mappings.js" defer></script><script src="/order-execution.js" defer></script><script src="/order-notifications-shared.js" defer></script><script src="/modules/order-notifications/batch-editor.js" defer></script><script src="/modules/order-notifications/detail.js" defer></script><script src="/modules/order-notifications/records.js" defer></script><script src="/order-notifications.js" defer></script><script src="/order-rules.js" defer></script><script src="/health.js" defer></script><script src="/assistant-operations.js" defer></script><script src="/assistant.js" defer></script><script src="/account.js" defer></script><script src="/navigation.js" defer></script><script src="/page-lifecycle.js" defer></script><script src="/app.js" defer></script></body></html>
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>订单通知中心</title><link href="/vendor/tabler.css" rel="stylesheet"><link href="/vendor/tom-select.css" rel="stylesheet"><link href="/app.css" rel="stylesheet"><link href="/field-mappings.css" rel="stylesheet"><link href="/business-home.css" rel="stylesheet"></head>
|
||||
<body><div id="app"><div class="page page-center"><div class="container-tight py-4"><div class="card"><div class="card-body text-center">正在连接订单通知中心…</div></div></div></div></div><script src="/vendor/tabler.js" defer></script><script src="/vendor/tom-select.js" defer></script><script src="/bpm-sync-settings.js" defer></script><script src="/bpm.js" defer></script><script src="/workspace.js" defer></script><script src="/mail-history.js" defer></script><script src="/mail-template-editor.js" defer></script><script src="/mail.js" defer></script><script src="/record-state.js" defer></script><script src="/record-table.js" defer></script><script src="/record-ui.js" defer></script><script src="/orders.js" defer></script><script src="/pdf-records.js" defer></script><script src="/storage-preview-host.js" defer></script><script src="/storage.js" defer></script><script src="/notifications.js" defer></script><script src="/field-sample-picker.js" defer></script><script src="/field-recognition-panel.js" defer></script><script src="/order-rules-scopes.js" defer></script><script src="/order-rules-resources.js" defer></script><script src="/order-rules-import.js" defer></script><script src="/order-rules-editor.js" defer></script><script src="/order-rules-preview.js" defer></script><script src="/field-mappings.js" defer></script><script src="/order-execution.js" defer></script><script src="/order-notifications-shared.js" defer></script><script src="/modules/order-notifications/batch-editor.js" defer></script><script src="/modules/order-notifications/detail.js" defer></script><script src="/modules/order-notifications/records.js" defer></script><script src="/business-home.js" defer></script><script src="/order-notifications.js" defer></script><script src="/order-rules.js" defer></script><script src="/health.js" defer></script><script src="/assistant-operations.js" defer></script><script src="/assistant.js" defer></script><script src="/account.js" defer></script><script src="/navigation.js" defer></script><script src="/page-lifecycle.js" defer></script><script src="/app.js" defer></script></body></html>
|
||||
@@ -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