清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
171 lines
56 KiB
HTML
171 lines
56 KiB
HTML
<!--
|
||
用途:在途仓自动调拨 Agent 的来源实例路由化 MVP 原型。
|
||
依赖:独立 HTML、原生 CSS、原生 JavaScript;视觉语言参考 HXOPS 现有 Vue + Tailwind Chat 页面。
|
||
逻辑:仅模拟前端路由、页面状态和交互边界;不调用 RPA、ERP、企业微信或真实接口。
|
||
-->
|
||
<!doctype html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
<title>HXOPS · 在途仓自动调拨 Agent · 来源实例 MVP</title>
|
||
<style>
|
||
:root { --canvas:#f8fafc; --surface:#fff; --surface-soft:#f5f8fc; --line:#e5eaf1; --ink:#182230; --text:#4d5d73; --muted:#8491a5; --brand:#1677d2; --brand-50:#edf6ff; --good:#18854d; --good-50:#ecf9f0; --warn:#b7730d; --warn-50:#fff7e7; --bad:#c63d53; --bad-50:#fff0f2; --shadow:0 10px 28px rgba(21,39,66,.07); }
|
||
*{box-sizing:border-box} html,body,#app{width:100%;height:100%;margin:0} #app{display:flex;min-width:0;overflow:hidden} body{font:14px/1.5 "Microsoft YaHei","PingFang SC",Arial,sans-serif;color:var(--text);background:var(--canvas)} button,input,select{font:inherit} button{cursor:pointer} button:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid rgba(22,119,210,.22);outline-offset:2px}
|
||
.shell{display:flex;width:100%;height:100%;min-width:0;overflow:hidden}.side{display:flex;flex:0 0 244px;width:244px;min-width:244px;max-width:244px;flex-direction:column;overflow:hidden;background:var(--surface);border-right:1px solid var(--line)}.brand{display:flex;align-items:center;gap:10px;height:64px;padding:0 18px;border-bottom:1px solid var(--line)}.brand-mark{display:grid;place-items:center;width:32px;height:32px;border-radius:9px;background:linear-gradient(135deg,#208add,#2368c9);color:#fff;font-size:12px;font-weight:800}.brand b{display:block;color:var(--ink);font-size:15px}.brand span{display:block;color:var(--muted);font-size:11px}.new-chat{margin:14px;border:1px solid #bfdbf6;border-radius:9px;padding:9px 12px;text-align:left;color:#1265af;background:var(--brand-50);font-weight:700}.nav-label{padding:9px 17px 5px;color:#96a2b3;font-size:10px;font-weight:800;letter-spacing:.08em}.history{min-height:0;padding:0 9px;overflow:auto}.history button{position:relative;width:100%;border:0;border-radius:8px;padding:9px 10px;background:transparent;color:var(--text);text-align:left}.history button:hover{background:var(--surface-soft)}.history button.active{color:#1469b4;background:var(--brand-50)}.history b,.history span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.history b{font-size:12px}.history span{margin-top:2px;color:var(--muted);font-size:10px}.dot{position:absolute;top:11px;right:10px;width:7px;height:7px;border-radius:50%;background:#ed9a2c}.dot.bad{background:#d64d61}.user{display:flex;gap:8px;align-items:center;margin-top:auto;padding:14px 17px;border-top:1px solid var(--line)}.avatar{display:grid;place-items:center;width:30px;height:30px;border-radius:50%;color:#1269b3;background:#dff1ff;font-size:11px;font-weight:800}.user b,.user span{display:block}.user b{color:var(--ink);font-size:11px}.user span{color:var(--muted);font-size:10px}
|
||
.main{display:flex;min-width:0;min-height:0;flex:1 1 auto;flex-direction:column;overflow:hidden}.topbar{height:64px;display:flex;align-items:center;gap:10px;padding:0 28px;background:var(--surface);border-bottom:1px solid var(--line)}.agent-icon{display:grid;place-items:center;width:32px;height:32px;border-radius:9px;color:var(--brand);background:var(--brand-50);font-weight:800}.title b{display:block;color:var(--ink);font-size:14px}.title span{display:block;margin-top:1px;color:var(--muted);font-size:11px}.crumb{margin-left:auto;color:var(--muted);font-size:12px}.layout{min-height:0;flex:1;overflow:auto}.page{width:min(1160px,100%);margin:0 auto;padding:28px}.page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:18px}.page-head h1{margin:0;color:var(--ink);font-size:22px}.page-head p{max-width:720px;margin:5px 0 0;color:var(--muted);font-size:13px}.back{border:0;background:transparent;color:#176fba;font-weight:700}.card{border:1px solid var(--line);border-radius:12px;background:var(--surface);box-shadow:var(--shadow)}.card-h{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:15px 18px;border-bottom:1px solid var(--line)}.card-h h2{margin:0;color:var(--ink);font-size:15px}.card-h p{margin:3px 0 0;color:var(--muted);font-size:11px}.card-b{padding:18px}.grid{display:grid;gap:16px}.grid.two{grid-template-columns:1.55fr 1fr}.summary{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}.metric{padding:13px;border:1px solid var(--line);border-radius:10px;background:#fff}.metric b{display:block;color:var(--ink);font-size:20px}.metric span{display:block;margin-top:3px;color:var(--muted);font-size:11px}.metric button{border:0;padding:0;background:transparent;color:inherit;text-align:left}.metric.action{border-color:#cfe5f9;background:var(--brand-50)}.metric.action b{color:#1268b2}.notice{display:flex;gap:9px;margin-top:14px;border-radius:8px;padding:10px 12px;color:#596b82;background:var(--surface-soft);font-size:12px}.notice i{font-style:normal;font-weight:800}.notice.good{color:#167642;background:var(--good-50)}.notice.warn{color:#97620c;background:var(--warn-50)}.notice.bad{color:#ae3146;background:var(--bad-50)}.btn{border:1px solid #d1dbe7;border-radius:8px;padding:8px 12px;color:#43536a;background:#fff;font-size:12px;font-weight:700}.btn:hover{background:var(--surface-soft)}.btn.primary{border-color:var(--brand);color:#fff;background:var(--brand)}.btn.danger{border-color:#efb9c2;color:#b43449;background:var(--bad-50)}.btn[disabled]{cursor:not-allowed;opacity:.48}.actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.chip{display:inline-flex;align-items:center;border-radius:999px;padding:3px 8px;font-size:11px;font-weight:700}.chip.good{color:#147340;background:var(--good-50)}.chip.warn{color:#9a640c;background:var(--warn-50)}.chip.bad{color:#ad3145;background:var(--bad-50)}.chip.gray{color:#68788e;background:#eff3f7}.chat-panel{min-height:370px;display:flex;flex-direction:column}.chat-messages{flex:1;padding:18px}.bubble{max-width:88%;margin-bottom:13px;border:1px solid var(--line);border-radius:4px 12px 12px;padding:10px 12px;color:var(--text);background:#fff;font-size:13px}.bubble.user-msg{margin-left:auto;border-color:var(--brand);border-radius:12px 4px 12px 12px;color:#fff;background:var(--brand)}.composer{display:flex;gap:8px;padding:12px;border-top:1px solid var(--line)}.composer input{min-width:0;flex:1;border:1px solid #d4dee9;border-radius:8px;padding:9px 11px}.quick{display:grid;gap:8px}.quick button{border:1px solid var(--line);border-radius:8px;padding:10px;color:#53637a;background:#fff;text-align:left;font-size:12px}.quick button:hover{border-color:#bfdcf7;color:#1267b1;background:var(--brand-50)}
|
||
.scope{display:flex;justify-content:space-between;gap:16px;align-items:center;padding:14px;border:1px solid #d7e9fa;border-radius:10px;background:#f5faff}.scope b{display:block;color:#145f9f}.scope span{display:block;margin-top:2px;color:#60748c;font-size:12px}.source-toolbar{display:flex;gap:10px;align-items:center;margin-bottom:13px}.source-toolbar input{width:280px;border:1px solid #d4dee9;border-radius:8px;padding:8px 10px}.source-toolbar .count{margin-left:auto;color:var(--muted);font-size:12px}.source-group{border:1px solid var(--line);border-radius:10px;overflow:hidden;margin-top:10px}.source-group-head{display:flex;align-items:center;gap:10px;padding:12px 13px;background:#fbfcfe}.source-group-head b{color:var(--ink)}.source-group-head span{color:var(--muted);font-size:11px}.source-group-head button{margin-left:auto;border:0;color:#176fba;background:transparent;font-size:12px}.source-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border-top:1px solid var(--line)}.source-item{display:flex;align-items:center;gap:9px;min-height:54px;padding:10px 13px;border-right:1px solid var(--line);border-bottom:1px solid var(--line)}.source-item:nth-child(even){border-right:0}.source-item:last-child{border-bottom:0}.source-item b{display:block;color:var(--ink);font-size:12px}.source-item span{display:block;color:var(--muted);font-size:11px}.sticky-actions{position:sticky;bottom:0;display:flex;justify-content:flex-end;gap:8px;margin:18px -18px -18px;padding:13px 18px;border-top:1px solid var(--line);background:rgba(255,255,255,.96)}
|
||
.stage-list{display:grid;gap:10px}.stage{display:grid;grid-template-columns:14px 1fr auto;gap:10px;align-items:start;padding:12px;border:1px solid var(--line);border-radius:9px}.stage .mark{width:10px;height:10px;margin-top:4px;border-radius:50%;background:#a8b3c1}.stage.good .mark{background:var(--good)}.stage.warn .mark{background:#e1a238}.stage.bad .mark{background:var(--bad)}.stage b{display:block;color:var(--ink);font-size:12px}.stage span{display:block;margin-top:2px;color:var(--muted);font-size:11px}.facts{display:grid;grid-template-columns:repeat(3,1fr);gap:0;border:1px solid var(--line);border-radius:9px;overflow:hidden}.fact{padding:10px 12px;border-right:1px solid var(--line);border-bottom:1px solid var(--line)}.fact:nth-child(3n){border-right:0}.fact:nth-last-child(-n+3){border-bottom:0}.fact span{display:block;color:var(--muted);font-size:10px}.fact b{display:block;margin-top:3px;color:var(--ink);font-size:12px}.table-wrap{overflow:auto}.table{width:100%;border-collapse:collapse;font-size:12px}.table th,.table td{padding:11px 10px;border-bottom:1px solid var(--line);text-align:left;vertical-align:middle}.table th{color:#7d8ba0;background:#fafbfd;font-size:11px;font-weight:700}.table td b{color:var(--ink)}.table tr.disabled{color:#8693a4;background:#fbfcfe}.link{border:0;padding:0;color:#146fba;background:transparent;font-weight:700}.confirm-band{display:flex;justify-content:space-between;align-items:center;gap:14px;margin-top:13px;border:1px solid #d3e8f9;border-radius:9px;padding:12px;background:#f5faff}.confirm-band b{color:#155f9f}.route-org{margin-top:12px;border:1px solid var(--line);border-radius:10px;background:#fff;overflow:hidden}.route-org>summary,.route-item>summary{display:flex;align-items:center;gap:12px;list-style:none;cursor:pointer}.route-org>summary::-webkit-details-marker,.route-item>summary::-webkit-details-marker{display:none}.route-org>summary{padding:14px 16px;background:#fbfcfe}.route-org>summary::before,.route-item>summary::before{content:'›';width:16px;color:#6d7d91;font-size:20px;line-height:1;transition:transform .15s}.route-org[open]>summary::before,.route-item[open]>summary::before{transform:rotate(90deg)}.route-org-title{min-width:0;flex:1}.route-org-title b{display:block;color:var(--ink);font-size:14px}.route-org-title span{display:block;margin-top:2px;color:var(--muted);font-size:11px}.route-org-metrics{display:flex;gap:14px;color:#52637a;font-size:12px}.route-org-metrics b{color:var(--ink)}.route-table{border-top:1px solid var(--line)}.route-item{border-bottom:1px solid var(--line)}.route-item:last-child{border-bottom:0}.route-item>summary{padding:11px 16px}.route-item>summary:hover{background:var(--surface-soft)}.route-item-main{min-width:0;flex:1}.route-item-main b{color:var(--ink)}.route-item-main span{margin-left:8px;color:var(--muted);font-size:11px}.route-item-metrics{display:flex;gap:18px;color:#52637a;font-size:12px}.route-item-metrics strong{color:var(--ink)}.route-invoices{padding:0 16px 14px 44px;background:#fcfdff}.tabs{display:flex;gap:5px;border-bottom:1px solid var(--line);margin-bottom:14px}.tab{border:0;border-bottom:2px solid transparent;padding:9px 11px;color:#718097;background:transparent;font-size:12px;font-weight:700}.tab.active{border-color:var(--brand);color:#146bb4}.filters{display:flex;gap:8px;margin-bottom:12px}.filters select{border:1px solid #d5dfe9;border-radius:7px;padding:7px 9px;color:var(--text);background:#fff}.progress{height:7px;border-radius:999px;background:#eaf0f6;overflow:hidden}.progress i{display:block;height:100%;border-radius:inherit;background:var(--brand)}
|
||
.toast{position:fixed;right:24px;bottom:24px;z-index:20;max-width:380px;border-radius:9px;padding:11px 14px;color:#fff;background:#253c57;box-shadow:0 12px 30px rgba(20,37,60,.23);font-size:12px;opacity:0;transform:translateY(12px);pointer-events:none;transition:.18s}.toast.show{opacity:1;transform:translateY(0)}.overlay{position:fixed;inset:0;z-index:10;display:none;align-items:center;justify-content:center;padding:20px;background:rgba(19,32,49,.38)}.overlay.show{display:flex}.modal{width:min(480px,100%);border-radius:12px;background:#fff;box-shadow:0 24px 60px rgba(20,37,60,.28)}.modal h2{margin:0;padding:17px 18px 10px;color:var(--ink);font-size:16px}.modal p{margin:0;padding:0 18px;color:var(--muted);font-size:12px}.modal .body{padding:16px 18px}.modal input{width:100%;border:1px solid #d4dee9;border-radius:8px;padding:9px 10px}.modal .footer{display:flex;justify-content:flex-end;gap:8px;padding:12px 18px;border-top:1px solid var(--line)}
|
||
/* Chat 首页复用 HXOPS 真实 Chat 壳层:无业务顶栏、消息列居中、输入容器贴近底部。 */
|
||
.chat-mode .topbar{display:none}.chat-mode .main{background:var(--surface)}.chat-mode .layout{overflow:hidden}.chat-mode .side{flex-basis:320px;width:320px;max-width:320px}.chat-mode .page{width:100%;height:100%;max-width:none;margin:0;padding:0 24px}.chat-home{display:flex;height:100%;min-height:0;flex-direction:column;align-items:center}.chat-home-head{width:100%;max-width:780px;padding:38px 0 12px;text-align:center}.chat-home-head .welcome-mark{display:grid;place-items:center;width:46px;height:46px;margin:0 auto 14px;border-radius:50%;color:#fff;background:linear-gradient(135deg,#2f80d1,#1f65b0);font-weight:800;box-shadow:0 8px 22px rgba(47,128,209,.22)}.chat-home-head h1{margin:0;color:#0f172a;font-size:28px;line-height:1.25}.chat-home-head h1 span{color:#2f80d1}.chat-home-head p{margin:9px auto 0;max-width:650px;color:#64748b;font-size:13px}.chat-scenarios{display:flex;width:100%;max-width:860px;gap:8px;overflow-x:auto;padding:6px 0 14px;scrollbar-width:none}.chat-scenarios::-webkit-scrollbar{display:none}.chat-scenarios .tab{flex:0 0 auto;border:1px solid #e2e8f0;border-bottom:1px solid #e2e8f0;border-radius:999px;padding:8px 13px;color:#475569;background:#fff;font-size:12px;font-weight:600;white-space:nowrap}.chat-scenarios .tab.active{border-color:#9cc7f2;color:#1f5f99;background:#eef6ff}.chat-thread{width:100%;max-width:780px;min-height:0;flex:1;overflow:auto;padding:12px 0 150px}.chat-thread .bubble{max-width:82%;border-radius:14px;background:#fff;box-shadow:0 2px 8px rgba(15,23,42,.04)}.chat-thread .bubble.user-msg{border:0;border-radius:14px 5px 14px 14px;background:#2f80d1;box-shadow:none}.chat-thread .scope{border-color:#cfe5f9;border-radius:14px;background:#f8fbff}.chat-thread .notice{border-radius:12px}.chat-action{display:flex;justify-content:flex-end;margin-top:10px}.chat-input-wrap{position:fixed;right:0;bottom:0;left:320px;z-index:4;padding:12px 24px 18px;background:linear-gradient(transparent,rgba(255,255,255,.96) 22%)}.chat-input{display:flex;align-items:flex-end;gap:8px;width:min(780px,100%);margin:0 auto;border:1px solid #d8e0ec;border-radius:16px;padding:9px 10px;background:#fff;box-shadow:0 8px 28px rgba(15,23,42,.10)}.chat-input input{min-width:0;flex:1;border:0;outline:0;padding:9px 8px;color:#0f172a;background:transparent;font-size:15px}.chat-input button{display:grid;place-items:center;width:38px;height:38px;border:0;border-radius:50%;color:#fff;background:#2f80d1;font-weight:700}.chat-input-hint{width:min(780px,100%);margin:7px auto 0;text-align:center;color:#94a3b8;font-size:10px}
|
||
@media(max-width:800px){body{font-size:13px}#app{display:block;height:auto;min-height:100%;overflow:auto}.shell{display:block;overflow:auto}.side{display:none}.main{min-height:100%;overflow:visible}.topbar{padding:0 16px}.crumb{display:none}.page{padding:17px}.grid.two{grid-template-columns:1fr}.summary{grid-template-columns:repeat(2,1fr)}.page-head{display:block}.page-head .back{margin-bottom:8px}.source-toolbar{flex-wrap:wrap}.source-toolbar input{width:100%}.source-toolbar .count{margin-left:0}.source-list{grid-template-columns:1fr}.source-item{border-right:0}.facts{grid-template-columns:1fr}.fact{border-right:0}.fact:nth-last-child(-n+3){border-bottom:1px solid var(--line)}.fact:last-child{border-bottom:0}.confirm-band{display:block}.confirm-band .actions{margin-top:10px}.table{min-width:650px}.chat-mode .page{padding:0 14px}.chat-home-head{padding-top:25px}.chat-home-head h1{font-size:23px}.chat-input-wrap{left:0;padding:10px 12px 14px}.chat-thread{padding-bottom:140px}.chat-thread .bubble{max-width:92%}}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div id="app">
|
||
<aside class="side">
|
||
<div class="brand"><div class="brand-mark">HX</div><div><b>HXOPS</b><span>Enterprise AI Gateway</span></div></div>
|
||
<button class="new-chat" data-action="go-chat">+ 新建对话</button>
|
||
<div class="nav-label">最近对话</div>
|
||
<div class="history">
|
||
<button class="active" data-action="go-chat"><b>在途仓自动调拨</b><span>新建会话</span></button>
|
||
<button data-action="go-precheck"><b>DBS 昨日收料预检</b><span>PRE-20260818-001</span></button>
|
||
<button data-action="go-run"><b>自动调拨结果</b><span>AUTO-20260818-0900</span><i class="dot"></i></button>
|
||
<button data-action="go-backlog"><b>待处理调拨</b><span>6 笔可恢复异常</span><i class="dot bad"></i></button>
|
||
</div>
|
||
<div class="user"><div class="avatar">仓</div><div><b>仓库管理人员</b><span>在途仓调拨 Agent</span></div></div>
|
||
</aside>
|
||
<main class="main">
|
||
<header class="topbar"><div class="agent-icon">AI</div><div class="title"><b>在途仓自动调拨</b><span id="sub-title">Chat 首页 · 仅展示摘要与入口</span></div><div class="crumb" id="crumb">/chat/:agentId</div></header>
|
||
<div class="layout" id="page"></div>
|
||
</main>
|
||
</div>
|
||
<div class="toast" id="toast"></div>
|
||
<div class="overlay" id="modal-mask"><div class="modal"><h2 id="modal-title"></h2><p id="modal-desc"></p><div class="body"><input id="reason" placeholder="请输入原因(必填)" /></div><div class="footer"><button class="btn" data-action="modal-cancel">取消</button><button class="btn primary" data-action="modal-confirm">确认</button></div></div></div>
|
||
<script>
|
||
const $ = id => document.getElementById(id);
|
||
const S = { selected:new Set(['DBS-AWSBI']), collapsed:new Set(), businessDate:'2026-08-18', backlogTab:'recoverable', modal:null, toastTimer:null, precheckRequery:'initial', routeOrgs:new Set() };
|
||
const sources = [
|
||
{ platform:'DBS', code:'DBS-AWSBI', name:'AWSBI 在途仓', warehouse:'AWSBI-TRANSIT', enabled:true },
|
||
{ platform:'DBS', code:'DBS-AWSSG', name:'AWSSG 在途仓', warehouse:'AWSSG-TRANSIT', enabled:true },
|
||
{ platform:'DBS', code:'DBS-AWSMY', name:'AWSMY 在途仓', warehouse:'AWSMY-TRANSIT', enabled:true },
|
||
{ platform:'Crane', code:'CRANE-SZ', name:'深圳在途仓', warehouse:'CRANE-SZ-TRANSIT', enabled:true },
|
||
{ platform:'Crane', code:'CRANE-SG', name:'新加坡在途仓', warehouse:'CRANE-SG-TRANSIT', enabled:true },
|
||
{ platform:'Crane', code:'CRANE-HK', name:'香港在途仓', warehouse:'CRANE-HK-TRANSIT', enabled:false }
|
||
];
|
||
const text = (s='') => String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||
const button = (label, action, kind='') => `<button class="btn ${kind}" data-action="${action}">${label}</button>`;
|
||
const tag = (label, kind) => `<span class="chip ${kind}">${label}</span>`;
|
||
const goto = (page, extras={}) => { const u=new URL(location.href); u.search=''; u.searchParams.set('page',page); Object.entries(extras).forEach(([k,v])=>u.searchParams.set(k,v)); history.pushState({},'',u); render(); };
|
||
const pageName = () => new URL(location.href).searchParams.get('page') || 'chat';
|
||
const toast = msg => { const el=$('toast'); el.textContent=msg; el.classList.add('show'); clearTimeout(S.toastTimer); S.toastTimer=setTimeout(()=>el.classList.remove('show'),2800); };
|
||
const setHeader = (sub,crumb) => { $('sub-title').textContent=sub; $('crumb').textContent=crumb; };
|
||
const facts = rows => `<div class="facts">${rows.map(([k,v])=>`<div class="fact"><span>${k}</span><b>${v}</b></div>`).join('')}</div>`;
|
||
const chatScenarios = {
|
||
welcome:{ label:'开始使用', user:'我想处理昨天的在途仓收料。', reply:'可以。我会先帮你进入来源实例选择,再由业务页面创建预检。DBS、Crane 是平台分组;实际选择单位是来源实例,例如 DBS-AWSBI。', evidence:'尚未创建调拨任务;不会读取 RPA 或查询 ERP。', action:'go-source', actionLabel:'选择处理范围' },
|
||
rule:{ label:'业务规则', user:'为什么今天不能调拨?', reply:'当天收料尚未成熟,不能进入 ERP 库存查询或调拨写入。系统默认处理昨天及更早的收料日期;当天 Invoice 会保留为 not_matured,待后续业务日期再处理。', evidence:'规则边界:not_matured 不查询 ERP、不创建 ERP 单据。', action:'go-source', actionLabel:'查看可选业务日期与来源' },
|
||
status:{ label:'待处理状态', user:'现在还有多少待处理调拨?', reply:'演示数据中有 6 笔可恢复异常、2 笔已人工关闭,以及 1 笔结果未知。三类状态的允许操作不同,不能混合处理。', evidence:'可恢复异常可仅重查 ERP;已关闭可恢复;结果未知只读。', action:'go-backlog', actionLabel:'查看待处理调拨' },
|
||
intent:{ label:'发起调拨', user:'查询昨天 DBS-AWSBI 的可调拨数据。', reply:'我已理解为发起调拨意图,但不会直接写入 ERP。请先在页面选择 DBS-AWSBI 和业务日期,创建预检后再勾选严格匹配的 Invoice。', evidence:'需要经过:选择范围 → 预检 → 最终确认 → ERP 写入。', action:'go-source', actionLabel:'选择 DBS-AWSBI 并预检' },
|
||
progress:{ label:'文件与预检进度', user:'系统现在在做什么?', reply:'当创建预检时,系统会按来源实例显示真实阶段:优先使用任务创建前的最新有效收料文件;如果该文件不存在,才实时抓取并等待 RPA 回调。文件确定后,再汇总 Invoice 并查询 ERP。', evidence:'实时抓取期间会持续展示来源实例、阶段和等待原因;任务创建后文件版本冻结。', action:'go-source', actionLabel:'进入来源实例与预检流程' },
|
||
mismatch:{ label:'不可调拨原因', user:'INV-031 为什么不可调拨?', reply:'该 Invoice 当前收料数量为 300 PCS、ERP 账面库存为 280 PCS,未满足严格等量条件,因此不会进入确认或 ERP 写入范围。', evidence:'可在 ERP 人工处理后,仅重新查询该异常的 ERP 库存;不会重新抓 RPA 或替换冻结文件。', action:'go-precheck', actionLabel:'查看 INV-031 预检与复查入口' },
|
||
recovery:{ label:'ERP 处理后复查', user:'我已经在 ERP 处理好了库存,下一步怎么做?', reply:'请进入原预检页,点击“我已处理 ERP,重新查询异常库存”。系统会为异常 Invoice 新增一条 ERP 查询 Attempt;若严格匹配,才会自动加入可确认范围。', evidence:'复查不更新 RPA 文件、不改变收料快照、不写入 ERP。', action:'go-precheck', actionLabel:'进入异常预检页' },
|
||
safety:{ label:'结果未知说明', user:'为什么不能重试结果未知?', reply:'ERP 调用未返回可确认的成功或失败时,系统无法证明没有产生单据。再次提交存在重复写入风险,所以该状态只读,必须由 ERP 管理员线下核实。', evidence:'禁止:重试、关闭、恢复、重新执行;允许:查看已知事实与审计。', action:'go-unknown', actionLabel:'查看结果未知事项' },
|
||
schedule:{ label:'自动调拨结果', user:'最近一次自动调拨执行得怎么样?', reply:'自动排程按来源实例独立处理:每个实例使用其任务开始前的最新有效文件,分别预检、写入和汇总通知。一个实例失败不会阻断其他实例。', evidence:'演示 Run:DBS-AWSBI 成功 18 项;CRANE-SZ 文件获取超时并保留异常证据。', action:'go-run', actionLabel:'查看最近自动 Run' }
|
||
};
|
||
const chatScenario = () => new URL(location.href).searchParams.get('scene') || 'welcome';
|
||
function chatPage(){
|
||
setHeader('Chat 首页 · 对话解释与业务入口','/chat/:agentId');
|
||
const key=chatScenario(), scene=chatScenarios[key] || chatScenarios.welcome;
|
||
const scenarioTabs=Object.entries(chatScenarios).map(([id,item])=>`<button class="tab ${id===key?'active':''}" data-action="chat-scene-${id}">${item.label}</button>`).join('');
|
||
return `<section class="page"><div class="chat-home"><div class="chat-home-head"><div class="welcome-mark">AI</div><h1>你好,欢迎使用<span>在途仓自动调拨 Agent</span></h1><p>我会解释规则、展示收料文件与 ERP 查询进度;需要改变业务数据时,请在对应页面点击按钮确认。</p></div><div class="chat-scenarios" aria-label="对话场景">${scenarioTabs}</div><div class="chat-thread"><div class="bubble user-msg">${scene.user}</div><div class="bubble">${scene.reply}</div><div class="scope"><div><b>系统状态 / 可核验依据</b><span>${scene.evidence}</span></div></div><div class="chat-action">${button(scene.actionLabel,scene.action,'primary')}</div><div class="notice warn"><i>!</i><span>对话不会绕过业务按钮直接发起 ERP 写入;当天收料不会进入 ERP 查询或调拨。</span></div></div><div class="chat-input-wrap"><div class="chat-input"><input id="chat-input" aria-label="对话输入" placeholder="例如:为什么今天不能调拨?" /><button aria-label="发送" data-action="chat-send">↑</button></div><div class="chat-input-hint">AI 可能会犯错,请核实重要信息。 · 原型数据仅用于业务走查</div></div></div></section>`;
|
||
}
|
||
function sourcePage(){
|
||
setHeader('来源实例选择 · 本次调拨范围','/chat/:agentId?mode=transfer-source-selection');
|
||
const groups=[...new Set(sources.map(x=>x.platform))];
|
||
return `<section class="page"><div class="page-head">${button('← 返回对话','go-chat')}<div style="flex:1"><h1>选择收料来源实例</h1><p>DBS、Crane 仅为平台分组。请勾选实际需要处理的在途仓实例;未来新增实例会自动显示在对应平台。</p></div></div><div class="card"><div class="card-h"><div><h2>本次处理范围</h2><p>已选择的实例会独立准备文件、解析、预检与审计。</p></div></div><div class="card-b"><div class="source-toolbar"><input id="source-search" placeholder="搜索实例名称或编码,例如 AWSBI" /><button class="btn" data-action="select-enabled">全选已启用</button><button class="btn" data-action="clear-sources">清空</button><span class="count" id="source-count"></span></div><div id="source-groups">${groups.map(platform=>sourceGroup(platform)).join('')}</div><div class="sticky-actions">${button('取消','go-chat')}${button('确认范围并预检','start-precheck','primary')}</div></div></div></section>`;
|
||
}
|
||
function sourceGroup(platform){ const items=sources.filter(x=>x.platform===platform); const collapsed=S.collapsed.has(platform); return `<section class="source-group" data-platform="${platform}"><div class="source-group-head"><b>${platform}</b><span>${items.filter(x=>x.enabled).length} 个已启用实例</span><button data-action="toggle-${platform}">${collapsed?'展开':'收起'}</button></div><div class="source-list" ${collapsed?'style="display:none"':''}>${items.map(s=>`<label class="source-item" data-source-row="${s.code}"><input type="checkbox" data-source="${s.code}" ${S.selected.has(s.code)?'checked':''} ${s.enabled?'':'disabled'} /><span><b>${s.code}</b><span>${s.name} · 来源仓 ${s.warehouse}${s.enabled?'':' · 未启用'}</span></span></label>`).join('')}</div></section>`; }
|
||
function precheckPage(){
|
||
setHeader('调拨预检 · 冻结的文件与 ERP 匹配结果','/chat/:agentId?mode=transfer-precheck&precheck_id=PRE-20260819-001');
|
||
const requerying=S.precheckRequery==='loading';
|
||
const matched=S.precheckRequery==='matched';
|
||
const mismatchRow=requerying
|
||
? `<tr class="disabled"><td><input type="checkbox" disabled /></td><td>DBS-AWSBI</td><td><b>INV-031</b></td><td>300 PCS</td><td><span class="chip gray">查询中…</span></td><td><small>正在重新查询 ERP 库存;收料文件保持冻结。</small></td></tr>`
|
||
: matched
|
||
? `<tr><td><input type="checkbox" data-invoice="INV-031" checked /></td><td>DBS-AWSBI</td><td><b>INV-031</b></td><td>300 PCS</td><td>300 PCS<br /><small>最新查询 10:06</small></td><td>${tag('可执行','good')}<br /><button class="link" data-action="show-requery-history">查看历史比对</button></td></tr>`
|
||
: `<tr class="disabled"><td><input type="checkbox" disabled /></td><td>DBS-AWSBI</td><td><b>INV-031</b></td><td>300 PCS</td><td>280 PCS<br /><small>上次查询 09:12 · Attempt 1</small></td><td>${tag('数量不一致','warn')}<br /><button class="link" data-action="show-requery-history">查看历史比对</button></td></tr>`;
|
||
const requeryNotice=requerying
|
||
? `<div class="notice"><i>i</i><span>正在仅查询 1 个数量不一致 Invoice 的 ERP 库存;不会重新抓 RPA、替换文件或写入 ERP。</span></div>`
|
||
: matched
|
||
? `<div class="notice good"><i>✓</i><span>INV-031 已在 Attempt 2 匹配:收料 300 / ERP 300。该项目已自动勾选;请在进入确认后再执行 ERP 调拨。</span></div>`
|
||
: `<div class="notice warn"><i>!</i><span>若已在 ERP 完成人工库存处理,可重新查询数量不一致项。该操作只生成新的 ERP 查询 Attempt,不改变冻结收料文件。</span></div>`;
|
||
const total=matched?'已选 4 张 · 预计调拨总数量 2,600 PCS · 预计 ERP 写入 4 张':'已选 3 张 · 预计调拨总数量 2,300 PCS · 预计 ERP 写入 3 张';
|
||
return `<section class="page"><div class="page-head">${button('← 返回修改范围','go-source')}<div style="flex:1"><h1>调拨预检</h1><p>本次任务已固定收料文件、解析映射和策略;不可在中途抓取或替换 RPA 文件。</p></div>${tag('预检完成','good')}</div><div class="grid two"><div class="card"><div class="card-h"><div><h2>来源实例处理进度</h2><p>不显示伪造总百分比;按实例反映真实状态。</p></div></div><div class="card-b"><div class="stage-list"><div class="stage good"><i class="mark"></i><div><b>DBS-AWSBI · 收料文件已就绪</b><span>累计全量文件 DBS-AWSBI-receipt-20260818-v3.xlsx · checksum 7A4E…91B2</span></div>${tag('预检完成','good')}</div><div class="stage warn"><i class="mark"></i><div><b>DBS-AWSSG · 当天收料已排除</b><span>INV-041 收料日期为当天,标记 not_matured,未查询 ERP。</span></div>${tag('1 项未成熟','warn')}</div><div class="stage good"><i class="mark"></i><div><b>CRANE-SZ · ERP 库存已查询</b><span>按 Invoice 汇总收料数量后完成严格等量校验。</span></div>${tag('预检完成','good')}</div></div><div class="notice"><i>i</i><span>若实例文件失败,只阻断该实例;不影响本次选择中的其他来源实例。</span></div></div></div><div class="card"><div class="card-h"><div><h2>冻结上下文</h2><p>历史 Run 永久指向以下快照。</p></div></div><div class="card-b">${facts([['业务日期','2026-08-18'],['ERP 组织','CN01'],['目标 HUB 仓','HUB-SZ'],['文件版本','v3 · 7A4E…91B2'],['策略版本','transfer-policy-v1'],['预检有效期','10:32']])}<div class="actions">${button('查看冻结文件','show-file')}${button('查看审计快照','show-audit')}</div></div></div></div><div class="card" style="margin-top:16px"><div class="card-h"><div><h2>Invoice 预检明细</h2><p>同一 Invoice 的多行先汇总收料数量;仅可勾选严格匹配项。</p></div>${button(requerying?'正在查询异常 ERP 库存…':'我已处理 ERP,重新查询异常库存(1)','requery-precheck',requerying?'':'primary').replace('<button ','<button '+(requerying?'disabled ':''))}</div><div class="card-b"><div class="table-wrap"><table class="table"><thead><tr><th></th><th>来源实例</th><th>Invoice</th><th>收料数量</th><th>ERP 库存</th><th>预检结果</th></tr></thead><tbody><tr><td><input type="checkbox" data-invoice="INV-001" checked /></td><td>DBS-AWSBI</td><td><b>INV-001</b></td><td>500 PCS</td><td>500 PCS</td><td>${tag('可执行','good')}</td></tr><tr><td><input type="checkbox" data-invoice="INV-002" checked /></td><td>DBS-AWSBI</td><td><b>INV-002</b></td><td>1,200 PCS</td><td>1,200 PCS</td><td>${tag('可执行','good')}</td></tr><tr><td><input type="checkbox" data-invoice="INV-008" checked /></td><td>CRANE-SZ</td><td><b>INV-008</b></td><td>600 PCS</td><td>600 PCS</td><td>${tag('可执行','good')}</td></tr>${mismatchRow}<tr class="disabled"><td><input type="checkbox" disabled /></td><td>DBS-AWSSG</td><td><b>INV-041</b></td><td>400 PCS</td><td>—</td><td>${tag('当天收料','gray')}</td></tr></tbody></table></div>${requeryNotice}<div class="confirm-band"><div><b id="selected-summary">${total}</b><br /><small>此时尚未调用 ERP 写入接口。</small></div>${button('进入确认','go-confirm','primary')}</div></div></div></section>`;
|
||
}
|
||
function confirmPage(){
|
||
setHeader('确认 ERP 写入 · 最终范围确认','/chat/:agentId?mode=transfer-precheck&precheck_id=PRE-20260819-001&step=confirm');
|
||
return `<section class="page"><div class="page-head">${button('← 返回预检','go-precheck')}<div style="flex:1"><h1>确认执行调拨</h1><p>请确认本次 ERP 写入范围。点击“执行调拨”后,Worker 将逐项调用 ERP 的创建、审核、过账接口。</p></div>${tag('等待确认','warn')}</div><div class="card"><div class="card-h"><div><h2>最终写入摘要</h2><p>系统将在实际写入前再次校验预检有效性;快照过期时必须重新预检。</p></div></div><div class="card-b">${facts([['业务日期','2026-08-18'],['来源实例','DBS-AWSBI、CRANE-SZ'],['ERP 组织','CN01'],['来源仓','按实例固定映射'],['HUB 仓','HUB-SZ'],['预检有效期','10:32']])}<div class="table-wrap" style="margin-top:15px"><table class="table"><thead><tr><th>Invoice</th><th>来源实例</th><th>收料 / ERP</th><th>预计结果</th></tr></thead><tbody><tr><td><b>INV-001</b></td><td>DBS-AWSBI</td><td>500 / 500 PCS</td><td>${tag('写入 ERP','good')}</td></tr><tr><td><b>INV-002</b></td><td>DBS-AWSBI</td><td>1,200 / 1,200 PCS</td><td>${tag('写入 ERP','good')}</td></tr><tr><td><b>INV-008</b></td><td>CRANE-SZ</td><td>600 / 600 PCS</td><td>${tag('写入 ERP','good')}</td></tr></tbody></table></div><div class="notice warn"><i>!</i><span>将写入 3 张 Invoice,预计调拨总数量 2,300 PCS,预计 ERP 单据 3 张。此确认会追加操作者、时间、范围与冻结快照审计。</span></div><div class="actions">${button('返回预检','go-precheck')}${button('执行调拨','execute','primary')}</div></div></div></section>`;
|
||
}
|
||
/* 调拨路由为确认与审计的业务边界:来源实例 + ERP 组织 + 来源仓 + 目标仓。 */
|
||
const transferRoutes = {
|
||
awsbi:{ source:'DBS-AWSBI', organization:'CN01', from:'AWSBI-TRANSIT', to:'HUB-SZ', invoices:[['INV-001',500],['INV-002',1200],['INV-031',300]] },
|
||
craneSz:{ source:'CRANE-SZ', organization:'CN02', from:'CRANE-SZ-TRANSIT', to:'HUB-SH', invoices:[['INV-008',600]] }
|
||
};
|
||
function routeText(route){ return `${route.organization} · ${route.from} → ${route.to}`; }
|
||
function routeCell(route){ return `<b>${route.organization}</b><br /><small>${route.from} → ${route.to}</small>`; }
|
||
function precheckPage(){
|
||
setHeader('调拨预检 · 冻结的文件与 ERP 匹配结果','/chat/:agentId?mode=transfer-precheck&precheck_id=PRE-20260819-001');
|
||
const loading=S.precheckRequery==='loading', matched=S.precheckRequery==='matched';
|
||
const inv031=loading
|
||
? `<tr class="disabled"><td><input type="checkbox" disabled /></td><td>DBS-AWSBI</td><td>${routeCell(transferRoutes.awsbi)}</td><td><b>INV-031</b></td><td>300 PCS</td><td><span class="chip gray">查询中…</span></td><td><small>仅重新查询 ERP;收料文件保持冻结。</small></td></tr>`
|
||
: matched
|
||
? `<tr><td><input type="checkbox" data-invoice="INV-031" checked /></td><td>DBS-AWSBI</td><td>${routeCell(transferRoutes.awsbi)}</td><td><b>INV-031</b></td><td>300 PCS</td><td>300 PCS<br /><small>最新查询 10:06</small></td><td>${tag('可执行','good')}<br /><button class="link" data-action="show-requery-history">查看历史比对</button></td></tr>`
|
||
: `<tr class="disabled"><td><input type="checkbox" disabled /></td><td>DBS-AWSBI</td><td>${routeCell(transferRoutes.awsbi)}</td><td><b>INV-031</b></td><td>300 PCS</td><td>280 PCS<br /><small>上次查询 09:12 · Attempt 1</small></td><td>${tag('数量不一致','warn')}<br /><button class="link" data-action="show-requery-history">查看历史比对</button></td></tr>`;
|
||
const summary=matched?'已选 4 张 · 2 条调拨路由 · 预计调拨总数量 2,600 PCS · 预计 ERP 单据 4 张':'已选 3 张 · 2 条调拨路由 · 预计调拨总数量 2,300 PCS · 预计 ERP 单据 3 张';
|
||
const hint=loading?'正在仅查询 INV-031 的 ERP 库存;不会重新抓 RPA、替换文件或写入 ERP。':matched?'INV-031 已在 Attempt 2 匹配并加入 DBS-AWSBI → HUB-SZ 路由;仍须进入确认。':'如果已在 ERP 完成人工库存处理,可只重查数量不一致项。每次结果新增 Attempt,冻结文件不变。';
|
||
return `<section class="page"><div class="page-head">${button('← 返回修改范围','go-source')}<div style="flex:1"><h1>调拨预检</h1><p>本次任务已固定收料文件、解析映射和策略;不可在中途抓取或替换 RPA 文件。</p></div>${tag('预检完成','good')}</div><div class="grid two"><div class="card"><div class="card-h"><div><h2>来源实例处理进度</h2><p>来源实例分别准备文件和查询库存。</p></div></div><div class="card-b"><div class="stage-list"><div class="stage good"><i class="mark"></i><div><b>DBS-AWSBI · 收料文件已就绪</b><span>累计全量文件 DBS-AWSBI-receipt-20260818-v3.xlsx · checksum 7A4E…91B2</span></div>${tag('预检完成','good')}</div><div class="stage warn"><i class="mark"></i><div><b>DBS-AWSSG · 当天收料已排除</b><span>INV-041 标记 not_matured,未查询 ERP。</span></div>${tag('1 项未成熟','warn')}</div><div class="stage good"><i class="mark"></i><div><b>CRANE-SZ · ERP 库存已查询</b><span>ERP 组织 CN02 · CRANE-SZ-TRANSIT → HUB-SH</span></div>${tag('预检完成','good')}</div></div></div></div><div class="card"><div class="card-h"><div><h2>冻结上下文</h2><p>每条调拨路由均随本次 Run 冻结。</p></div></div><div class="card-b">${facts([['业务日期','2026-08-18'],['调拨路由','2 条'],['文件版本','v3 · 7A4E…91B2'],['策略版本','transfer-policy-v1'],['路由 1','CN01 · AWSBI → HUB-SZ'],['路由 2','CN02 · CRANE-SZ → HUB-SH']])}<div class="actions">${button('查看冻结文件','show-file')}${button('查看审计快照','show-audit')}</div></div></div></div><div class="card" style="margin-top:16px"><div class="card-h"><div><h2>Invoice 预检明细</h2><p>每一笔均显示实际 ERP 组织及来源仓 → 目标 HUB 仓路由。</p></div>${button(loading?'正在查询异常 ERP 库存…':'我已处理 ERP,重新查询异常库存(1)','requery-precheck',loading?'':'primary').replace('<button ','<button '+(loading?'disabled ':''))}</div><div class="card-b"><div class="table-wrap"><table class="table"><thead><tr><th></th><th>来源实例</th><th>调拨路由</th><th>Invoice</th><th>收料数量</th><th>ERP 库存</th><th>预检结果</th></tr></thead><tbody><tr><td><input type="checkbox" data-invoice="INV-001" checked /></td><td>DBS-AWSBI</td><td>${routeCell(transferRoutes.awsbi)}</td><td><b>INV-001</b></td><td>500 PCS</td><td>500 PCS</td><td>${tag('可执行','good')}</td></tr><tr><td><input type="checkbox" data-invoice="INV-002" checked /></td><td>DBS-AWSBI</td><td>${routeCell(transferRoutes.awsbi)}</td><td><b>INV-002</b></td><td>1,200 PCS</td><td>1,200 PCS</td><td>${tag('可执行','good')}</td></tr><tr><td><input type="checkbox" data-invoice="INV-008" checked /></td><td>CRANE-SZ</td><td>${routeCell(transferRoutes.craneSz)}</td><td><b>INV-008</b></td><td>600 PCS</td><td>600 PCS</td><td>${tag('可执行','good')}</td></tr>${inv031}<tr class="disabled"><td><input type="checkbox" disabled /></td><td>DBS-AWSSG</td><td><b>未进入路由</b><br /><small>当天收料</small></td><td><b>INV-041</b></td><td>400 PCS</td><td>—</td><td>${tag('当天收料','gray')}</td></tr></tbody></table></div><div class="notice ${matched?'good':loading?'':'warn'}"><i>${matched?'✓':loading?'i':'!'}</i><span>${hint}</span></div><div class="confirm-band"><div><b id="selected-summary">${summary}</b><br /><small>此时尚未调用 ERP 写入接口。</small></div>${button('进入确认','go-confirm','primary')}</div></div></div></section>`;
|
||
}
|
||
function confirmPage(){
|
||
setHeader('确认 ERP 写入 · 按 ERP 组织聚合','/chat/:agentId?mode=transfer-precheck&precheck_id=PRE-20260819-001&step=confirm');
|
||
const matched=S.precheckRequery==='matched';
|
||
const routeRows=[
|
||
{ ...transferRoutes.awsbi, invoices:matched?transferRoutes.awsbi.invoices:transferRoutes.awsbi.invoices.slice(0,2) },
|
||
{ ...transferRoutes.craneSz }
|
||
].map(route=>({ ...route, qty:route.invoices.reduce((sum,[,qty])=>sum+qty,0) }));
|
||
const groups=Object.values(routeRows.reduce((acc,route)=>{ (acc[route.organization]??={ organization:route.organization, routes:[] }).routes.push(route); return acc; },{}));
|
||
const count=routeRows.reduce((sum,route)=>sum+route.invoices.length,0), total=routeRows.reduce((sum,route)=>sum+route.qty,0);
|
||
const routeDetail=route=>`<details class="route-item"><summary><div class="route-item-main"><b>${route.from} → ${route.to}</b><span>${route.source}</span></div><div class="route-item-metrics"><span><strong>${route.invoices.length}</strong> 张 Invoice</span><span><strong>${route.qty.toLocaleString()}</strong> PCS</span><span>${tag('可写入','good')}</span></div></summary><div class="route-invoices"><div class="table-wrap"><table class="table"><thead><tr><th>Invoice</th><th>来源实例</th><th>来源仓</th><th>目标 HUB 仓</th><th>收料 / ERP</th></tr></thead><tbody>${route.invoices.map(([id,qty])=>`<tr><td><b>${id}</b></td><td>${route.source}</td><td>${route.from}</td><td>${route.to}</td><td>${qty.toLocaleString()} / ${qty.toLocaleString()} PCS</td></tr>`).join('')}</tbody></table></div></div></details>`;
|
||
const orgBlock=group=>{const qty=group.routes.reduce((sum,route)=>sum+route.qty,0), invoices=group.routes.reduce((sum,route)=>sum+route.invoices.length,0), open=S.routeOrgs.has(group.organization); return `<details class="route-org" ${open?'open':''}><summary data-action="toggle-org-${group.organization}"><div class="route-org-title"><b>${group.organization} · ERP 调拨组织</b><span>${group.routes.length} 条调拨路由 · 点击展开路由汇总</span></div><div class="route-org-metrics"><span><b>${invoices}</b> 张 Invoice</span><span><b>${qty.toLocaleString()}</b> PCS</span><span><b>${invoices}</b> 张 ERP 单据</span></div></summary><div class="route-table">${group.routes.map(routeDetail).join('')}</div></details>`;};
|
||
return `<section class="page"><div class="page-head">${button('← 返回预检','go-precheck')}<div style="flex:1"><h1>确认执行调拨</h1><p>先按 ERP 组织聚合确认;展开组织查看路由,展开路由查看 Invoice。默认不平铺路由或 Invoice 明细。</p></div>${tag('等待确认','warn')}</div><div class="card"><div class="card-h"><div><h2>最终写入摘要</h2><p>实际写入前会复核预检快照有效性;快照过期必须重新预检。</p></div></div><div class="card-b">${facts([['业务日期','2026-08-18'],['ERP 组织',`${groups.length} 个`],['调拨路由',`${routeRows.length} 条`],['预计调拨总数量',`${total.toLocaleString()} PCS`],['预计 ERP 单据',`${count} 张`],['预检有效期','10:32']])}<div class="notice"><i>i</i><span>组织是确认页的一级聚合;路由按“来源实例 + ERP 组织 + 来源仓 + 目标仓”计算。仅异常组织或用户主动点击时展开详细内容。</span></div>${groups.map(orgBlock).join('')}<div class="notice warn"><i>!</i><span>将按 ${groups.length} 个 ERP 组织、${routeRows.length} 条调拨路由写入 ${count} 张 Invoice,预计调拨总数量 ${total.toLocaleString()} PCS。确认会记录操作者、时间、每条路由和冻结快照。</span></div><div class="actions">${button('返回预检','go-precheck')}${button(`执行 ${count} 张调拨`,'execute','primary')}</div></div></div></section>`;
|
||
}
|
||
function runPage(){
|
||
setHeader('Run 结果 · 固定执行证据','/chat/:agentId?mode=transfer-run&run_id=AUTO-20260818-0900');
|
||
return `<section class="page"><div class="page-head">${button('← 返回对话','go-chat')}<div style="flex:1"><h1>自动调拨 Run 详情</h1><p>AUTO-20260818-0900 · 企业微信深链可直接进入该 Run,不创建新对话。</p></div>${tag('已完成','good')}</div><div class="card"><div class="card-h"><div><h2>执行概览</h2><p>自动排程按来源实例分别处理并发送一条汇总通知。</p></div></div><div class="card-b">${facts([['业务日期','2026-08-18'],['触发方式','自动排程'],['成功','18'],['业务阻断','2'],['来源异常','1'],['通知','已发送']])}<div class="progress" style="margin-top:15px"><i style="width:84%"></i></div><div class="stage-list" style="margin-top:15px"><div class="stage good"><i class="mark"></i><div><b>DBS-AWSBI · 已完成</b><span>20 项预检,18 项 ERP 成功;重复 Invoice 已由 ERP 返回原调拨单号。</span></div>${tag('成功 18','good')}</div><div class="stage bad"><i class="mark"></i><div><b>CRANE-SZ · 文件获取超时</b><span>HTTP Callback 超时,已留存来源异常和任务证据;不影响 DBS 结果。</span></div>${tag('来源异常','bad')}</div></div><div class="actions">${button('下载固定异常 Excel','download')}${button('查看执行审计','show-audit')}${button('进入待处理','go-backlog','primary')}</div></div></div><div class="card" style="margin-top:16px"><div class="card-h"><div><h2>逐项结果</h2><p>结果固定,不从此页重新抓取 RPA 或发起新 ERP 写入。</p></div></div><div class="card-b"><div class="table-wrap"><table class="table"><thead><tr><th>Invoice</th><th>结果</th><th>ERP 单据 / 事实</th><th>审计</th></tr></thead><tbody><tr><td>INV-001</td><td>${tag('成功','good')}</td><td>TRF-10001</td><td><button class="link" data-action="show-audit">查看</button></td></tr><tr><td>INV-002</td><td>${tag('重复成功','good')}</td><td>TRF-98220</td><td><button class="link" data-action="show-audit">查看</button></td></tr><tr><td>INV-031</td><td>${tag('数量不一致','warn')}</td><td>收料 300 / ERP 280</td><td><button class="link" data-action="go-backlog">待处理</button></td></tr></tbody></table></div></div></div></section>`;
|
||
}
|
||
function backlogPage(){
|
||
setHeader('待处理调拨 · 可恢复、已关闭与结果未知分离','/chat/:agentId?mode=transfer-backlog');
|
||
const tab=S.backlogTab; const body=tab==='recoverable'?recoverable():tab==='closed'?closed():unknown(); return `<section class="page"><div class="page-head">${button('← 返回对话','go-chat')}<div style="flex:1"><h1>待处理调拨</h1><p>将可恢复异常、已人工关闭和结果未知隔离展示,避免把安全边界不同的事项混在同一张表中。</p></div></div><div class="card"><div class="card-h"><div><h2>跨 Run 待处理事项</h2><p>可恢复项只允许重新查询 ERP 库存,不更新文件、不抓 RPA、不直接写 ERP。</p></div></div><div class="card-b"><div class="tabs"><button class="tab ${tab==='recoverable'?'active':''}" data-action="tab-recoverable">可恢复异常 6</button><button class="tab ${tab==='closed'?'active':''}" data-action="tab-closed">已人工关闭 2</button><button class="tab ${tab==='unknown'?'active':''}" data-action="tab-unknown">结果未知 1</button></div>${body}</div></div></section>`;
|
||
}
|
||
function recoverable(){return `<div class="filters"><select><option>来源:全部</option><option>DBS</option><option>Crane</option></select><select><option>日期:全部</option><option>最近 3 天</option></select></div><div class="table-wrap"><table class="table"><thead><tr><th></th><th>来源实例 / 日期</th><th>Invoice</th><th>当前事实</th><th>最近查询</th><th></th></tr></thead><tbody><tr><td><input type="checkbox" checked /></td><td>DBS-AWSBI<br><small>2026-08-16</small></td><td><b>INV-031</b></td><td>收料 300 / ERP 280</td><td>09:12</td><td><button class="link" data-action="show-audit">证据</button></td></tr><tr><td><input type="checkbox" checked /></td><td>CRANE-SZ<br><small>2026-08-15</small></td><td><b>INV-042</b></td><td>收料 800 / ERP 0</td><td>09:12</td><td><button class="link" data-action="show-audit">证据</button></td></tr><tr><td><input type="checkbox" /></td><td>DBS-AWSSG<br><small>2026-08-14</small></td><td><b>INV-073</b></td><td>明确技术失败</td><td>08:50</td><td><button class="link" data-action="show-audit">证据</button></td></tr></tbody></table></div><div class="notice"><i>i</i><span>多选后每个 Invoice 都会重新查询 ERP 库存;满足严格等量的项目才进入新的确认页。</span></div><div class="actions">${button('重新查询 ERP 库存(2)','requery','primary')}${button('标记无需继续处理','close-item','danger')}</div>`}
|
||
function closed(){return `<div class="table-wrap"><table class="table"><thead><tr><th>Invoice</th><th>关闭原因</th><th>关闭人 / 时间</th><th></th></tr></thead><tbody><tr><td>INV-061</td><td>货代确认无需调拨</td><td>仓库管理人员 · 08-17 15:00</td><td><button class="link" data-action="restore-item">恢复处理</button></td></tr><tr><td>INV-068</td><td>业务已线下完成</td><td>仓库管理人员 · 08-17 16:20</td><td><button class="link" data-action="restore-item">恢复处理</button></td></tr></tbody></table></div><div class="notice"><i>i</i><span>恢复后回到“可恢复异常”池;原关闭原因、操作者和快照永久保留。</span></div>`}
|
||
function unknown(){return `<div class="notice bad"><i>!</i><span>ERP 未返回确定成功或失败。系统只展示已知事实,不提供重查、关闭、恢复或执行按钮。</span></div><div class="table-wrap"><table class="table"><thead><tr><th>Invoice</th><th>所属 Run</th><th>调用时间</th><th>Operation ID</th><th></th></tr></thead><tbody><tr><td><b>INV-052</b></td><td>AUTO-20260818-0900</td><td>09:17:21</td><td>OP-20260818-8891</td><td><button class="link" data-action="show-unknown">查看事实与 SOP</button></td></tr></tbody></table></div>`}
|
||
function render(){ const page=pageName(); document.body.classList.toggle('chat-mode',page==='chat'); const renderer={chat:chatPage,source:sourcePage,precheck:precheckPage,confirm:confirmPage,run:runPage,backlog:backlogPage,unknown:backlogPage}[page]||chatPage; $('page').innerHTML=renderer(); bind(); if(page==='source') filterSources(); }
|
||
function filterSources(){ const input=$('source-search'); if(!input)return; const apply=()=>{const q=input.value.trim().toLowerCase(); document.querySelectorAll('[data-source-row]').forEach(row=>row.hidden=!row.textContent.toLowerCase().includes(q));}; input.addEventListener('input',apply); $('source-count').textContent=`已选 ${S.selected.size} 个来源实例`; }
|
||
function openModal(type){S.modal=type; const data={close:['标记“无需继续处理”','该 Invoice 将变为 manually_closed,自动排程不再处理;历史与审计永久保留。'],restore:['恢复处理','恢复后回到可恢复异常池,可重新查询 ERP 库存。']}[type]; $('modal-title').textContent=data[0];$('modal-desc').textContent=data[1];$('reason').value='';$('modal-mask').classList.add('show');}
|
||
function action(a){
|
||
if(a.startsWith('chat-scene-'))return goto('chat',{scene:a.slice(11)});
|
||
if(a==='go-chat')return goto('chat'); if(a==='go-source')return goto('source'); if(a==='go-precheck')return goto('precheck'); if(a==='go-confirm')return goto('confirm'); if(a==='go-run')return goto('run'); if(a==='go-backlog')return goto('backlog'); if(a==='go-unknown'){S.backlogTab='unknown';return goto('backlog')}
|
||
if(a==='select-enabled'){sources.filter(x=>x.enabled).forEach(x=>S.selected.add(x.code));render();return} if(a==='clear-sources'){S.selected.clear();render();return} if(a.startsWith('toggle-org-')){const org=a.slice(11);S.routeOrgs.has(org)?S.routeOrgs.delete(org):S.routeOrgs.add(org);return} if(a.startsWith('toggle-')){const p=a.slice(7);S.collapsed.has(p)?S.collapsed.delete(p):S.collapsed.add(p);render();return}
|
||
if(a==='start-precheck'){if(!S.selected.size){toast('请至少选择一个已启用来源实例。');return} toast('原型:正在使用任务创建前可用的最新有效文件。');setTimeout(()=>goto('precheck'),450);return}
|
||
if(a==='execute'){toast('原型:已提交 Worker 执行。关闭页面不会取消后台任务。');setTimeout(()=>goto('run'),650);return} if(a==='requery'){toast('原型:仅重新查询所选异常的 ERP 库存;文件版本不变,未写入 ERP。');setTimeout(()=>goto('confirm'),500);return} if(a==='requery-precheck'){S.precheckRequery='loading';render();toast('原型:正在重新查询 INV-031 的 ERP 库存;未抓取 RPA 文件。');setTimeout(()=>{S.precheckRequery='matched';render();toast('原型:INV-031 已匹配并加入本次确认范围。');},900);return}
|
||
if(a==='tab-recoverable'){S.backlogTab='recoverable';render();return}if(a==='tab-closed'){S.backlogTab='closed';render();return}if(a==='tab-unknown'){S.backlogTab='unknown';render();return}if(a==='close-item'){openModal('close');return}if(a==='restore-item'){openModal('restore');return}
|
||
if(a==='modal-cancel'){$('modal-mask').classList.remove('show');return}if(a==='modal-confirm'){if(!$('reason').value.trim()){toast('请填写原因。');return}$('modal-mask').classList.remove('show');toast('原型:已追加审计并更新事项状态。');S.backlogTab=S.modal==='restore'?'recoverable':'closed';render();return}
|
||
if(a==='show-file'){toast('原型:展示冻结文件版本、checksum、原始行和下载访问审计。');return}if(a==='show-audit'){toast('原型:展示操作人、时间、动作、变更前后快照与关联 Run。');return}if(a==='show-requery-history'){toast('原型:Attempt 1 为收料 300 / ERP 280;最新 Attempt 会追加保存,原快照不被覆盖。');return}if(a==='show-unknown'){toast('原型:结果未知只能由 ERP 管理员线下核实;系统不生成第二次 ERP 写入。');return}if(a==='download'){toast('原型:下载 Run 创建时的固定异常 Excel,并记录下载审计。');return}if(a==='chat-send'){const q=($('chat-input')?.value||'').trim();const scene=q.includes('今天')?'rule':q.includes('待处理')?'status':q.includes('INV-031')||q.includes('不一致')?'mismatch':q.includes('ERP')&&q.includes('处理好')?'recovery':q.includes('未知')?'safety':q.includes('自动')||q.includes('排程')?'schedule':q.includes('现在')||q.includes('进度')?'progress':q.includes('调拨')||q.includes('昨天')?'intent':'welcome';return goto('chat',{scene});}
|
||
}
|
||
function bind(){document.querySelectorAll('[data-action]').forEach(el=>el.onclick=()=>action(el.dataset.action));document.querySelectorAll('[data-source]').forEach(el=>el.onchange=()=>{el.checked?S.selected.add(el.dataset.source):S.selected.delete(el.dataset.source);const count=$('source-count');if(count)count.textContent=`已选 ${S.selected.size} 个来源实例`;});document.querySelectorAll('[data-invoice]').forEach(el=>el.onchange=()=>{const checked=[...document.querySelectorAll('[data-invoice]:checked')];const n=checked.length, total=checked.reduce((sum,x)=>sum+({"INV-001":500,"INV-002":1200,"INV-008":600,"INV-031":300}[x.dataset.invoice]||0),0);const t=$('selected-summary');if(t)t.textContent=`已选 ${n} 张 · 预计调拨总数量 ${total.toLocaleString()} PCS · 预计 ERP 写入 ${n} 张`;});}
|
||
window.addEventListener('popstate',render); render();
|
||
</script>
|
||
</body>
|
||
</html>
|