fix: retain execution failure causes beside notification results

This commit is contained in:
abaishu0730 committed 2026-10-21 15:56:50 +08:00
1 parent 80f9bde3cb
commit d669a7b28e
2 files changed
+14 -1

No files matched your search

+13
View File
@@ -80,3 +80,16 @@ test('record lists and details show independent results and batch modes without
await page.getByRole('button',{name:'关闭详情',exact:true}).click();await page.goto(f.base+'/#notification-batches?scope=all');const batch=page.locator('tr').filter({has:page.getByText('hui-batch',{exact:true})});await batch.waitFor();assert.match(await batch.innerText(),/惠州通知/);await batch.getByRole('button',{name:'查看详情',exact:true}).click();await dialog.getByRole('heading',{name:'保存核验结论',exact:true}).waitFor();assert.match(await dialog.textContent(),/通知模式惠州通知/);assert.equal(await dialog.getByRole('button',{name:'人工补发原冻结批次',exact:true}).count(),0);
await page.setViewportSize({width:390,height:844});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);
});
test('order list retains execution failure and conflict causes beside independent notification results',{timeout:90000},async t=>{
const f=await fixture(t),{runtime,page}=f;
const cases=[{id:'execution-failed',status:'failed',error:'归档读取校验失败,通知尚待处理'},{id:'execution-conflict',status:'blocked',error:'新来源修订与已归档版本冲突,请核对',conflict:true}];
for(const item of cases){
runtime.orderRules.put('orders',{id:item.id,status:'sent',error:'普通路已有结果说明',event:{connectionId:'c',orderNo:item.id,receivedAt:'2026-10-21T01:00:00Z'},notifications:{huizhou:{status:'pending',batchId:null,error:'惠州路独立等待原因',orderNos:['H-200'],issues:[]}}});
runtime.orderRules.put('execution-tasks',{id:'task-'+item.id,orderId:item.id,connectionId:'c',version:1,status:item.status,error:item.error,conflict:item.conflict||false,row:{orderNo:item.id}});
}
runtime.orderRules.put('execution-tasks',{id:'bare-execution',connectionId:'c',version:1,status:'failed',error:'尚未生成订单的采集失败',row:{orderNo:'bare-execution'}});
await f.open('#notification-orders');
for(const item of cases){const row=page.locator('tr').filter({has:page.getByText(item.id,{exact:true})});await row.waitFor();const text=await row.innerText();assert.ok(text.includes(item.error),text);assert.match(text,/普通通知.*已提交邮件服务器/s);assert.match(text,/惠州通知.*等待汇总/s);assert.match(text,/普通路已有结果说明/);assert.match(text,/惠州路独立等待原因/);}
const bare=page.locator('tr').filter({has:page.getByText('bare-execution',{exact:true})});assert.match(await bare.innerText(),/尚未生成订单的采集失败/);assert.doesNotMatch(await bare.innerText(),/普通通知|惠州通知/);
});
+1 -1
View File
@@ -9,7 +9,7 @@ window.BusinessRecordViews=(()=>{
const input=(name,label,type='text')=>`<label class="small">${label}<input class="form-control" type="${type}" name="${name}" maxlength="200" value="${esc(filters[name]||'')}"></label>`;
container.innerHTML=`<div class="alert alert-warning" data-record-error hidden role="alert"></div><section class="card"><div class="card-header flex-wrap gap-2"><h2 class="card-title">${kind==='orders'?'订单中心':'邮件批次'}</h2><div class="btn-list ms-auto"></div></div><div class="card-body record-filters"><div class="row g-2"><div class="col-12 col-md-4">${input('q','搜索订单 / 标识 / 主题')}</div><div class="col-6 col-md-2">${select('categoryId','类别')}</div><div class="col-6 col-md-2">${select('connectionId','来源连接')}</div><div class="col-6 col-md-2"><label class="small">状态<select class="form-select" name="status"><option value="">全部状态</option>${states.map(s=>`<option value="${s}" ${filters.status===s?'selected':''}>${labels[s]}</option>`).join('')}</select></label></div>${kind==='batches'?`<div class="col-6 col-md-2"><label class="small">范围<select class="form-select" name="scope"><option value="active" ${filters.scope==='active'?'selected':''}>未终结批次</option><option value="all" ${filters.scope==='all'?'selected':''}>全部批次</option></select></label></div>`:''}<div class="col-6 col-md-3">${input('from',kind==='batches'?'窗口截止日期从(北京时间)':'接收日期从(北京时间)','date')}</div><div class="col-6 col-md-3">${input('to',kind==='batches'?'窗口截止日期至':'接收日期至','date')}</div><div class="col-12 col-md-2 align-self-end"><button class="btn" data-record-query type="button">查询</button></div></div></div><div data-arrival-list></div>${window.RecordUi.footer}</section>${kind==='orders'&&user.role!=='viewer'?'<section class="card mt-3"><div class="card-body"><h3 class="h4">扫描并处理订单</h3><p class="text-secondary">读取授权待办、采集真实字段、生成 PDF 并归档;BPM 节点由人工办理。邮件按独立开关和批次调度发送。</p><form data-business-scan><label class="form-label" for="business-scan-connection">扫描连接</label><select id="business-scan-connection" class="form-select" name="scanConnectionId" required><option value="">正在读取授权连接</option></select><button class="btn" type="submit">扫描并处理订单</button><div role="alert"></div></form></div></section>':''}`;
let table;const detail=window.BusinessRecordDetail.mount(container,{...options,onChanged:()=>{const error=container.querySelector('[data-record-error]');error.hidden=false;error.textContent='业务状态已变化,请刷新记录核对。';}});
function draw(data){const host=container.querySelector('[data-arrival-list]');host.innerHTML=`<div class="table-responsive"><table class="table table-vcenter card-table"><thead><tr><th>${kind==='orders'?'订单 / 类别':'主题 / 类别'}</th><th>状态与原因</th><th>接收 / 创建时间</th><th>详情</th></tr></thead><tbody>${data.items.map((row,index)=>`<tr><td class="text-break"><strong>${esc(row.orderNo||row.subject||row.id)}</strong><div class="small text-secondary">${esc(catalogs.categories.get(row.categoryId)||row.categoryId||'未分类')}</div>${kind==='batches'?'<span class="badge bg-blue-lt mt-1">'+(row.notificationMode==='huizhou'?'惠州通知':'普通通知')+'</span>':''}</td><td>${esc(labels[row.status]||row.status)}${kind==='orders'&&row.notifications?['normal','huizhou'].map(mode=>{const notice=row.notifications[mode];return notice?'<div class="small mt-1"><strong>'+(mode==='huizhou'?'惠州通知':'普通通知')+'</strong>:'+esc(labels[notice.status]||notice.status)+'<div class="text-danger text-break">'+esc(notice.error||'')+'</div>'+(notice.issues?.length?'<div class="text-warning text-break">'+notice.issues.map(esc).join(';')+'</div>':'')+'</div>':'';}).join(''):''}<div class="small text-danger text-break">${esc(row.reason||(!row.notifications?row.error:'')||'')}</div></td><td class="small">${esc(formatDate(row.receivedAt||row.createdAt))}</td><td><button class="btn btn-sm" type="button" data-business-detail="${index}">查看详情</button></td></tr>`).join('')||'<tr><td colspan="4" class="text-secondary">暂无匹配记录</td></tr>'}</tbody></table></div>`;host.querySelectorAll('[data-business-detail]').forEach(button=>button.onclick=()=>detail.open(kind,data.items[Number(button.dataset.businessDetail)].id,button));}
function draw(data){const host=container.querySelector('[data-arrival-list]');host.innerHTML=`<div class="table-responsive"><table class="table table-vcenter card-table"><thead><tr><th>${kind==='orders'?'订单 / 类别':'主题 / 类别'}</th><th>状态与原因</th><th>接收 / 创建时间</th><th>详情</th></tr></thead><tbody>${data.items.map((row,index)=>`<tr><td class="text-break"><strong>${esc(row.orderNo||row.subject||row.id)}</strong><div class="small text-secondary">${esc(catalogs.categories.get(row.categoryId)||row.categoryId||'未分类')}</div>${kind==='batches'?'<span class="badge bg-blue-lt mt-1">'+(row.notificationMode==='huizhou'?'惠州通知':'普通通知')+'</span>':''}</td><td>${esc(labels[row.status]||row.status)}${kind==='orders'&&row.notifications?['normal','huizhou'].map(mode=>{const notice=row.notifications[mode];return notice?'<div class="small mt-1"><strong>'+(mode==='huizhou'?'惠州通知':'普通通知')+'</strong>:'+esc(labels[notice.status]||notice.status)+'<div class="text-danger text-break">'+esc(notice.error||'')+'</div>'+(notice.issues?.length?'<div class="text-warning text-break">'+notice.issues.map(esc).join(';')+'</div>':'')+'</div>':'';}).join(''):''}<div class="small text-danger text-break">${esc(row.error||row.reason||'')}</div></td><td class="small">${esc(formatDate(row.receivedAt||row.createdAt))}</td><td><button class="btn btn-sm" type="button" data-business-detail="${index}">查看详情</button></td></tr>`).join('')||'<tr><td colspan="4" class="text-secondary">暂无匹配记录</td></tr>'}</tbody></table></div>`;host.querySelectorAll('[data-business-detail]').forEach(button=>button.onclick=()=>detail.open(kind,data.items[Number(button.dataset.businessDetail)].id,button));}
const names=Object.keys(filters).filter(k=>!['page','pageSize'].includes(k));
table=window.RecordTable.mount({view,container,isActive,api,endpoint:'/order-rules/'+kind,render:draw,readDraft:()=>Object.fromEntries(names.map(k=>[k,container.querySelector('[name="'+k+'"]').value.trim()])),writeDraft(next){for(const k of names)container.querySelector('[name="'+k+'"]').value=next[k];}});
const workspaceRead=api('/workspace');