dsh-data-dashboard 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/public/admin.css +28 -0
- package/backend/public/admin.js +61 -2
- package/backend/public/board.css +30 -3
- package/backend/public/board.html +12 -9
- package/backend/public/board.js +70 -13
- package/backend/public/index.html +3 -0
- package/backend/public/org-mapping.js +49 -0
- package/backend/real-data/generate-dashboard.mjs +2 -0
- package/backend/real-data/organization-mapping.mjs +119 -55
- package/backend/real-data/v10-components.mjs +1 -1
- package/backend/real-data/v10-model.mjs +48 -1
- package/backend/real-data/v10-overview-data.mjs +7 -2
- package/backend/real-data/v10-overview.css +139 -33
- package/backend/real-data/v10-overview.mjs +100 -23
- package/backend/real-data/v10-presentation.mjs +12 -0
- package/backend/real-data/v10-template.mjs +4 -2
- package/backend/server.mjs +27 -3
- package/build-manifest.json +24 -23
- package/client.js +33 -3
- package/package.json +1 -1
package/backend/public/admin.css
CHANGED
|
@@ -190,3 +190,31 @@ html.embedded main{padding:20px 28px 24px;max-width:1240px}
|
|
|
190
190
|
.status-state.is-muted{color:#9aa7b2}
|
|
191
191
|
@media(max-width:1100px){.status-row{grid-template-columns:130px minmax(0,1fr) 120px 150px 90px 70px}.check-head{flex-wrap:wrap}.check-file{flex-basis:100%;order:5}}
|
|
192
192
|
@media(max-width:760px){.status-head{display:none}.status-row{grid-template-columns:1fr 1fr}.status-name,.status-row>span:nth-child(2){grid-column:1/-1}.check-table{grid-template-columns:110px repeat(3,minmax(0,1fr))}.receipt-grid{grid-template-columns:80px minmax(0,1fr)}.receipt-grid .receipt-now{grid-column:2}.update-head{flex-direction:column}}
|
|
193
|
+
|
|
194
|
+
/* Organization mapping status (设计预览画布 ⑪). */
|
|
195
|
+
.org-map{margin:-18px 0 34px;border-radius:12px;font-size:12px;line-height:1.6}
|
|
196
|
+
.org-map-line{display:flex;align-items:center;gap:10px;padding:11px 16px;flex-wrap:wrap}
|
|
197
|
+
.org-map-dot{width:8px;height:8px;border-radius:50%;flex:none}
|
|
198
|
+
.org-map b{font-weight:600;white-space:nowrap}
|
|
199
|
+
.org-map-text{min-width:0;flex:1 1 320px}
|
|
200
|
+
.org-map-time{margin-left:auto;font-size:11px;opacity:.8;white-space:nowrap}
|
|
201
|
+
.org-map-toggle{margin-left:auto;border:0;background:none;color:var(--wine);font:inherit;font-weight:600;cursor:pointer;padding:2px 0;white-space:nowrap}
|
|
202
|
+
.org-map-applied{background:#ecfdf5;color:#065f46}.org-map-applied .org-map-dot{background:#047857}
|
|
203
|
+
.org-map-partial{background:#fffbeb;color:#92400e;border:1px solid #fcd34d}.org-map-partial .org-map-dot{background:#d97706}
|
|
204
|
+
.org-map-invalid{background:#fff1f2;color:#9f1239;border:1px solid #fecdd3}.org-map-invalid .org-map-dot{background:#e11d48}
|
|
205
|
+
.org-map-list{padding:0 16px 12px;overflow-x:auto}
|
|
206
|
+
.org-map-list table{width:100%;border-collapse:collapse;background:#fff;border-radius:8px;overflow:hidden;font-size:12px;min-width:560px}
|
|
207
|
+
.org-map-list th{font-weight:500;font-size:11px;color:#8a7a5a;background:#fff8e1;text-align:left;padding:8px 10px}
|
|
208
|
+
.org-map-list td{padding:8px 10px;border-top:1px solid #fef3c7;color:#4d5e6c}
|
|
209
|
+
.org-map-module{font-weight:600;color:#283640}
|
|
210
|
+
.org-map-pending{color:#a16207}.org-map-rejected{color:#b42318}
|
|
211
|
+
.org-map-note,.org-map-more{margin:8px 0 0;color:#7c6a46;font-size:11.5px}
|
|
212
|
+
.org-chip{font:inherit;font-size:11px;border-radius:999px;padding:3px 9px;white-space:nowrap;border:1px solid transparent;background:#f1f5f9;color:#64748b}
|
|
213
|
+
button.org-chip{cursor:pointer}
|
|
214
|
+
.org-chip-applied{background:#ecfdf5;color:#047857}
|
|
215
|
+
.org-chip-partial{background:#fffbeb;color:#a16207;border-color:#fcd34d;font-weight:600}
|
|
216
|
+
.org-chip-invalid{background:#fff1f2;color:#b42318;font-weight:600}
|
|
217
|
+
.org-map-row td{background:#fffdf5;padding:6px 21px 14px}
|
|
218
|
+
.org-map-row .org-map-list{padding:0}
|
|
219
|
+
.org-map-detail-line{margin:4px 0 8px;font-size:11.5px;color:#92400e}
|
|
220
|
+
@media(max-width:760px){.org-map{margin-top:-10px}.org-map-time,.org-map-toggle{margin-left:0}}
|
package/backend/public/admin.js
CHANGED
|
@@ -212,6 +212,48 @@ function localLink(href, label, download = false) {
|
|
|
212
212
|
return link;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
// Organization mapping status (设计预览画布 ⑪): the latest generation under the
|
|
216
|
+
// generate panel, and one chip per record that opens the same list.
|
|
217
|
+
const openMappingRows = new Set();
|
|
218
|
+
let mappingBannerOpen = false, mappingBannerSignature = '';
|
|
219
|
+
function mappingList(view) {
|
|
220
|
+
const box = element('div', 'org-map-list');
|
|
221
|
+
const table = element('table'); const head = element('tr');
|
|
222
|
+
for (const label of ['板块', '原路径(大区 / 办事处 / 主任单元)', '行数', '原因']) { const th = element('th', '', label); th.scope = 'col'; head.append(th); }
|
|
223
|
+
const thead = element('thead'); thead.append(head); const tbody = element('tbody');
|
|
224
|
+
for (const item of view.items) {
|
|
225
|
+
const row = element('tr');
|
|
226
|
+
row.append(element('td', 'org-map-module', item.module), element('td', '', item.path), element('td', '', item.rows), element('td', item.rejected ? 'org-map-rejected' : 'org-map-pending', item.reason));
|
|
227
|
+
tbody.append(row);
|
|
228
|
+
}
|
|
229
|
+
table.append(thead, tbody); box.append(table);
|
|
230
|
+
if (view.more) box.append(element('p', 'org-map-more', `另有 ${view.more} 条未列出,完整清单见该版本的 diagnostics.json。`));
|
|
231
|
+
if (view.kind === 'partial') box.append(element('p', 'org-map-note', window.OrgMapping.note));
|
|
232
|
+
return box;
|
|
233
|
+
}
|
|
234
|
+
function renderMappingBanner(generations) {
|
|
235
|
+
const host = $('#org-mapping-status');
|
|
236
|
+
const latest = generations.find(item => item.status === 'completed' && item.mode === 'real');
|
|
237
|
+
const view = latest && window.OrgMapping ? window.OrgMapping.view(latest) : null;
|
|
238
|
+
// Rebuild only on change: the state poll runs every few seconds and the box is aria-live.
|
|
239
|
+
const signature = JSON.stringify([latest?.id, view, mappingBannerOpen]);
|
|
240
|
+
if (signature === mappingBannerSignature) return;
|
|
241
|
+
mappingBannerSignature = signature;
|
|
242
|
+
host.replaceChildren();
|
|
243
|
+
if (!view || view.kind === 'none') { host.hidden = true; return; }
|
|
244
|
+
host.hidden = false; host.className = `org-map org-map-${view.kind}`;
|
|
245
|
+
const line = element('div', 'org-map-line');
|
|
246
|
+
line.append(element('i', 'org-map-dot'), element('b', '', `组织映射:${view.chip.split(' · ')[0]}`), element('span', 'org-map-text', view.line));
|
|
247
|
+
if (view.items.length) {
|
|
248
|
+
const toggle = element('button', 'org-map-toggle', mappingBannerOpen ? '收起清单 ▴' : '查看清单 ▾'); toggle.type = 'button';
|
|
249
|
+
toggle.setAttribute('aria-expanded', String(mappingBannerOpen));
|
|
250
|
+
toggle.addEventListener('click', () => { mappingBannerOpen = !mappingBannerOpen; renderMappingBanner(generations); });
|
|
251
|
+
line.append(toggle);
|
|
252
|
+
} else line.append(element('span', 'org-map-time', `最近生成 ${readableTime(latest.finishedAt || latest.createdAt)}`));
|
|
253
|
+
host.append(line);
|
|
254
|
+
if (mappingBannerOpen && view.items.length) host.append(mappingList(view));
|
|
255
|
+
}
|
|
256
|
+
|
|
215
257
|
function renderHistory() {
|
|
216
258
|
const generations = [...(state?.generations || [])].sort((a,b) => String(b.createdAt).localeCompare(String(a.createdAt)));
|
|
217
259
|
$('#history-count').textContent = `${generations.length} 条记录`;
|
|
@@ -222,6 +264,7 @@ function renderHistory() {
|
|
|
222
264
|
latestLink.href = localLink(latest.viewUrl, '').href;
|
|
223
265
|
latestLink.textContent = latest.mode === 'real' ? '打开最新生成的真实数据看板 ↗' : latest.mode === 'demo' ? '打开最近的历史演示看板 ↗' : '打开最近生成的看板 ↗';
|
|
224
266
|
}
|
|
267
|
+
renderMappingBanner(generations);
|
|
225
268
|
const signature = JSON.stringify(generations);
|
|
226
269
|
if (signature === historySignature) return;
|
|
227
270
|
historySignature = signature;
|
|
@@ -235,7 +278,7 @@ function renderHistory() {
|
|
|
235
278
|
const wrapper = element('div', 'history-table-wrap');
|
|
236
279
|
const table = element('table', 'history-table');
|
|
237
280
|
const thead = element('thead'); const tr = element('tr');
|
|
238
|
-
for (const label of ['成品 / 任务', '生成时间', '状态', '操作']) { const th = element('th','',label); th.scope = 'col'; tr.append(th); }
|
|
281
|
+
for (const label of ['成品 / 任务', '生成时间', '状态', '组织映射', '操作']) { const th = element('th','',label); th.scope = 'col'; tr.append(th); }
|
|
239
282
|
thead.append(tr); const tbody = element('tbody');
|
|
240
283
|
for (const generation of generations) {
|
|
241
284
|
const row = element('tr');
|
|
@@ -265,7 +308,23 @@ function renderHistory() {
|
|
|
265
308
|
actions.append(links);
|
|
266
309
|
} else if (generation.status === 'failed') actions.append(element('span', 'history-sub history-error', generation.error || '生成未完成,请重试。'));
|
|
267
310
|
else actions.append(element('span', 'history-sub', generation.stage || '正在准备成品…'));
|
|
268
|
-
|
|
311
|
+
const mappingCell = element('td');
|
|
312
|
+
const mapping = generation.status === 'completed' && generation.mode === 'real' && window.OrgMapping ? window.OrgMapping.view(generation) : null;
|
|
313
|
+
if (mapping) {
|
|
314
|
+
const open = openMappingRows.has(generation.id) && mapping.items.length;
|
|
315
|
+
const chip = element(mapping.items.length ? 'button' : 'span', `org-chip org-chip-${mapping.kind}`, `${mapping.chip}${mapping.items.length ? (open ? ' ▴' : ' ▾') : ''}`);
|
|
316
|
+
if (mapping.line) chip.title = mapping.line;
|
|
317
|
+
if (mapping.items.length) {
|
|
318
|
+
chip.type = 'button'; chip.setAttribute('aria-expanded', String(Boolean(open)));
|
|
319
|
+
chip.addEventListener('click', () => { if (openMappingRows.has(generation.id)) openMappingRows.delete(generation.id); else openMappingRows.add(generation.id); historySignature = null; renderHistory(); });
|
|
320
|
+
}
|
|
321
|
+
mappingCell.append(chip);
|
|
322
|
+
} else mappingCell.append(element('span', 'history-sub', '—'));
|
|
323
|
+
row.append(name, created, statusCell, mappingCell, actions); tbody.append(row);
|
|
324
|
+
if (mapping && mapping.items.length && openMappingRows.has(generation.id)) {
|
|
325
|
+
const detail = element('tr', 'org-map-row'); const cell = element('td'); cell.colSpan = 5;
|
|
326
|
+
cell.append(element('p', 'org-map-detail-line', mapping.line), mappingList(mapping)); detail.append(cell); tbody.append(detail);
|
|
327
|
+
}
|
|
269
328
|
}
|
|
270
329
|
table.append(thead, tbody); wrapper.append(table); host.append(wrapper);
|
|
271
330
|
}
|
package/backend/public/board.css
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
:root{font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;color:#1f2328;--line:#e5e7eb;--muted:#6b7280;--wine:#aa343e;--wine-dark:#8f2933;--green:#258475}
|
|
2
2
|
*{box-sizing:border-box}[hidden]{display:none!important}html,body{height:100%}body{margin:0;display:flex;flex-direction:column;background:#fff}
|
|
3
3
|
button{font:inherit;cursor:pointer}
|
|
4
|
-
|
|
4
|
+
/* Title + tabs sit centred; the right column only holds a temporary status hint,
|
|
5
|
+
so it appearing or disappearing never moves the centred group. */
|
|
6
|
+
.bar{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);grid-template-areas:". title meta";align-items:center;column-gap:16px;padding:10px 18px;border-bottom:1px solid var(--line);background:#fff;flex:none}
|
|
7
|
+
.title-group{grid-area:title;display:flex;align-items:center;gap:16px;white-space:nowrap}
|
|
5
8
|
.bar h1{font-size:15px;font-weight:600;margin:0;white-space:nowrap}
|
|
6
9
|
.seg{display:flex;background:#f1f2f4;border-radius:9px;padding:3px}
|
|
7
10
|
.seg button{border:0;background:transparent;padding:5px 14px;border-radius:7px;font-size:13px;color:#4b5563}
|
|
@@ -11,8 +14,19 @@ button{font:inherit;cursor:pointer}
|
|
|
11
14
|
.seg button[data-view="update"]::before{content:"";display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--wine);margin-right:6px;vertical-align:2px}
|
|
12
15
|
.seg button[data-view="update"].on{background:var(--wine);color:#fff}
|
|
13
16
|
.seg button[data-view="update"].on::before{background:#fff}
|
|
14
|
-
.meta{margin:0
|
|
15
|
-
.meta
|
|
17
|
+
.meta{grid-area:meta;justify-self:end;max-width:100%;margin:0;font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
18
|
+
.meta.warn{color:#b42318}
|
|
19
|
+
@media (max-width:760px){
|
|
20
|
+
/* Too narrow for a side column: the hint drops to its own centred line under the tabs. */
|
|
21
|
+
.bar{grid-template-columns:minmax(0,1fr);grid-template-areas:none;row-gap:4px}
|
|
22
|
+
.title-group,.meta{grid-area:auto;justify-self:center}
|
|
23
|
+
}
|
|
24
|
+
@media (max-width:480px){
|
|
25
|
+
.bar{padding:8px 10px}
|
|
26
|
+
.title-group{gap:10px}
|
|
27
|
+
.bar h1{font-size:14px}
|
|
28
|
+
.seg button{padding:5px 10px}
|
|
29
|
+
}
|
|
16
30
|
.btn{border:1px solid #d1d5db;background:#fff;border-radius:8px;padding:6px 12px;font-size:12.5px;color:#1f2328;white-space:nowrap}
|
|
17
31
|
.btn:hover{background:#f9fafb}
|
|
18
32
|
.btn-wine{background:var(--wine);border-color:var(--wine);color:#fff}.btn-wine:hover{background:var(--wine-dark)}
|
|
@@ -41,3 +55,16 @@ tr.viewing td{background:#fdf6f6}
|
|
|
41
55
|
.link{border:0;background:none;color:var(--wine);padding:0 2px;font-size:12.5px}
|
|
42
56
|
a.link{text-decoration:none}.link:hover{text-decoration:underline}
|
|
43
57
|
.toast{position:fixed;right:22px;bottom:22px;background:#111827;color:#fff;font-size:13px;padding:10px 14px;border-radius:10px;z-index:9}
|
|
58
|
+
/* Organization mapping column (设计预览画布 ⑪). */
|
|
59
|
+
.chip{font:inherit;font-size:11px;border-radius:999px;padding:2px 8px;white-space:nowrap;border:1px solid transparent;background:#f1f5f9;color:#64748b}
|
|
60
|
+
button.chip{cursor:pointer}
|
|
61
|
+
.chip.applied{background:#ecfdf5;color:#047857}
|
|
62
|
+
.chip.partial{background:#fffbeb;color:#a16207;border-color:#fcd34d;font-weight:600}
|
|
63
|
+
.chip.invalid{background:#fff1f2;color:#b42318;font-weight:600}
|
|
64
|
+
tr.map-row td{background:#fffdf5;padding:6px 10px 14px}
|
|
65
|
+
.map-line{margin:2px 0 8px;font-size:12px;color:#92400e}
|
|
66
|
+
.map-list{font-size:12px;background:#fff;border:1px solid #fde68a;border-radius:8px;border-collapse:separate;border-spacing:0;overflow:hidden}
|
|
67
|
+
.map-list th{background:#fff8e1;color:#8a7a5a}
|
|
68
|
+
.map-list td{border-bottom:1px solid #fef3c7;padding:7px 10px}
|
|
69
|
+
.map-list .mod{font-weight:600}.map-list .pend{color:#a16207}.map-list .rej{color:#b42318}
|
|
70
|
+
.map-note{margin:8px 0 0;font-size:11.5px;color:#7c6a46}
|
|
@@ -6,17 +6,20 @@
|
|
|
6
6
|
<meta name="color-scheme" content="light" />
|
|
7
7
|
<title>战区经营看板</title>
|
|
8
8
|
<link rel="stylesheet" href="/board.css" />
|
|
9
|
+
<script src="/org-mapping.js" defer></script>
|
|
9
10
|
<script src="/board.js" defer></script>
|
|
10
11
|
</head>
|
|
11
12
|
<body>
|
|
12
13
|
<header class="bar">
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
<div class="title-group">
|
|
15
|
+
<h1>战区经营看板</h1>
|
|
16
|
+
<nav class="seg" aria-label="切换视图">
|
|
17
|
+
<button type="button" class="on" data-view="board">看板</button>
|
|
18
|
+
<button type="button" data-view="update">更新数据</button>
|
|
19
|
+
<button type="button" data-view="history">历史版本</button>
|
|
20
|
+
</nav>
|
|
21
|
+
</div>
|
|
22
|
+
<p class="meta" id="meta" role="status" aria-live="polite" hidden></p>
|
|
20
23
|
</header>
|
|
21
24
|
<main class="views">
|
|
22
25
|
<section class="view on" id="view-board" aria-label="最新看板">
|
|
@@ -35,8 +38,8 @@
|
|
|
35
38
|
<div class="card">
|
|
36
39
|
<div class="card-head"><h2>历史版本</h2><p>每次生成单独保存;新上传不会改动已生成的版本。点“查看”在看板页打开。</p></div>
|
|
37
40
|
<table>
|
|
38
|
-
<thead><tr><th>生成时间</th><th>数据截至</th><th>使用的资料</th><th>状态</th><th></th></tr></thead>
|
|
39
|
-
<tbody id="history"><tr><td colspan="
|
|
41
|
+
<thead><tr><th>生成时间</th><th>数据截至</th><th>使用的资料</th><th>状态</th><th>组织映射</th><th></th></tr></thead>
|
|
42
|
+
<tbody id="history"><tr><td colspan="6" class="muted">正在读取…</td></tr></tbody>
|
|
40
43
|
</table>
|
|
41
44
|
</div>
|
|
42
45
|
</div>
|
package/backend/public/board.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
const $ = selector => document.querySelector(selector);
|
|
6
6
|
const titles = { invoice: '发票', movement: '动销', opening: '开瓶', terminal: '签约', inventory: '库存', banquet: '宴席', target: '目标' };
|
|
7
7
|
let state = null, viewingId = null, known = null, followLatest = true, toastTimer = null;
|
|
8
|
+
const openMapping = new Set();
|
|
8
9
|
const updateFrame = $('#update-frame');
|
|
9
10
|
|
|
10
11
|
function show(view) {
|
|
@@ -35,25 +36,25 @@ function openVersion(job) {
|
|
|
35
36
|
if (viewingId !== job.id) { frame.src = job.viewUrl; viewingId = job.id; }
|
|
36
37
|
frame.hidden = false; $('#board-empty').hidden = true;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
// The top bar stays quiet for the normal current version; a hint only appears
|
|
40
|
+
// while generating, while viewing a non-current version, or when offline.
|
|
41
|
+
function setMeta(text, warn = false) {
|
|
42
|
+
const meta = $('#meta');
|
|
43
|
+
meta.textContent = text; meta.title = text; meta.hidden = !text; meta.classList.toggle('warn', warn);
|
|
44
|
+
}
|
|
45
|
+
function metaText() {
|
|
39
46
|
const current = completed().find(job => job.id === viewingId);
|
|
40
47
|
const latest = latestNormal();
|
|
41
|
-
const running = (state.generations || []).find(job => job.status === 'running');
|
|
42
|
-
$('#meta').innerHTML = '';
|
|
43
48
|
const parts = [];
|
|
44
|
-
if (running) parts.push(
|
|
45
|
-
if (current
|
|
46
|
-
|
|
47
|
-
parts.forEach(([label, value], index) => {
|
|
48
|
-
if (index) $('#meta').append(' · ');
|
|
49
|
-
$('#meta').append(label);
|
|
50
|
-
if (value) { const b = document.createElement('b'); b.textContent = ` ${value}`; $('#meta').append(b); }
|
|
51
|
-
});
|
|
49
|
+
if ((state.generations || []).some(job => job.status === 'running')) parts.push('正在生成新版本…');
|
|
50
|
+
if (current && current.id !== latest?.id) parts.push(`正在查看${current.needsReview ? '待确认' : '历史'}版本 · ${time(current.finishedAt || current.createdAt)} 生成`);
|
|
51
|
+
return parts.join(' · ');
|
|
52
52
|
}
|
|
53
|
+
function renderMeta() { setMeta(metaText()); }
|
|
53
54
|
function renderHistory() {
|
|
54
55
|
const body = $('#history'); body.replaceChildren();
|
|
55
56
|
const jobs = (state.generations || []).filter(job => ['completed', 'failed', 'running'].includes(job.status));
|
|
56
|
-
if (!jobs.length) { const row = body.insertRow(); const cell = row.insertCell(); cell.colSpan =
|
|
57
|
+
if (!jobs.length) { const row = body.insertRow(); const cell = row.insertCell(); cell.colSpan = 6; cell.className = 'muted'; cell.textContent = '还没有生成记录'; return; }
|
|
57
58
|
const latest = latestNormal();
|
|
58
59
|
for (const job of jobs.slice(0, 50)) {
|
|
59
60
|
const row = body.insertRow(); if (job.id === viewingId) row.className = 'viewing';
|
|
@@ -64,6 +65,19 @@ function renderHistory() {
|
|
|
64
65
|
const kind = job.status === 'failed' ? ['failed', '生成失败'] : job.status === 'running' ? ['running', '生成中'] : job.needsReview ? ['pending', '待确认版本'] : job.id === latest?.id ? ['cur', '当前'] : ['old', '历史'];
|
|
65
66
|
pill.className = `pill ${kind[0]}`; pill.textContent = kind[1]; status.append(pill);
|
|
66
67
|
if (job.status === 'failed' && job.error) status.title = job.error;
|
|
68
|
+
const mappingCell = row.insertCell();
|
|
69
|
+
const mapping = job.status === 'completed' && window.OrgMapping ? window.OrgMapping.view(job) : null;
|
|
70
|
+
if (mapping) {
|
|
71
|
+
const open = mapping.items.length && openMapping.has(job.id);
|
|
72
|
+
const chip = document.createElement(mapping.items.length ? 'button' : 'span');
|
|
73
|
+
chip.className = `chip ${mapping.kind}`; chip.textContent = `${mapping.chip}${mapping.items.length ? (open ? ' ▴' : ' ▾') : ''}`;
|
|
74
|
+
if (mapping.line) chip.title = mapping.line;
|
|
75
|
+
if (mapping.items.length) {
|
|
76
|
+
chip.type = 'button'; chip.setAttribute('aria-expanded', String(Boolean(open)));
|
|
77
|
+
chip.addEventListener('click', () => { if (openMapping.has(job.id)) openMapping.delete(job.id); else openMapping.add(job.id); renderHistory(); });
|
|
78
|
+
}
|
|
79
|
+
mappingCell.append(chip);
|
|
80
|
+
} else mappingCell.textContent = '—';
|
|
67
81
|
const actions = row.insertCell();
|
|
68
82
|
if (job.status === 'completed') {
|
|
69
83
|
const view = document.createElement('button'); view.type = 'button'; view.className = 'link'; view.textContent = '查看';
|
|
@@ -71,13 +85,30 @@ function renderHistory() {
|
|
|
71
85
|
const download = document.createElement('a'); download.className = 'link'; download.href = job.downloadUrl; download.textContent = '下载'; download.setAttribute('download', '');
|
|
72
86
|
actions.append(view, ' · ', download);
|
|
73
87
|
}
|
|
88
|
+
if (mapping && mapping.items.length && openMapping.has(job.id)) mappingDetail(body.insertRow(), mapping);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function mappingDetail(row, mapping) {
|
|
92
|
+
row.className = 'map-row';
|
|
93
|
+
const cell = row.insertCell(); cell.colSpan = 6;
|
|
94
|
+
const line = document.createElement('p'); line.className = 'map-line'; line.textContent = mapping.line;
|
|
95
|
+
const table = document.createElement('table'); table.className = 'map-list';
|
|
96
|
+
const head = table.createTHead().insertRow();
|
|
97
|
+
for (const label of ['板块', '原路径(大区 / 办事处 / 主任单元)', '行数', '原因']) { const th = document.createElement('th'); th.textContent = label; head.append(th); }
|
|
98
|
+
const tbody = table.createTBody();
|
|
99
|
+
for (const item of mapping.items) {
|
|
100
|
+
const r = tbody.insertRow();
|
|
101
|
+
for (const [text, cls] of [[item.module, 'mod'], [item.path, ''], [item.rows, ''], [item.reason, item.rejected ? 'rej' : 'pend']]) { const c = r.insertCell(); c.textContent = text; if (cls) c.className = cls; }
|
|
74
102
|
}
|
|
103
|
+
cell.append(line, table);
|
|
104
|
+
if (mapping.more) { const more = document.createElement('p'); more.className = 'map-note'; more.textContent = `另有 ${mapping.more} 条未列出,完整清单见该版本的 diagnostics.json。`; cell.append(more); }
|
|
105
|
+
if (mapping.kind === 'partial') { const note = document.createElement('p'); note.className = 'map-note'; note.textContent = window.OrgMapping.note; cell.append(note); }
|
|
75
106
|
}
|
|
76
107
|
async function refresh() {
|
|
77
108
|
try {
|
|
78
109
|
const response = await fetch('/api/state', { cache: 'no-store' });
|
|
79
110
|
state = await response.json();
|
|
80
|
-
} catch {
|
|
111
|
+
} catch { setMeta('无法连接本机后台,请确认后台已启动', true); return; }
|
|
81
112
|
const done = completed();
|
|
82
113
|
if (known === null) { known = new Set(done.map(job => job.id)); openVersion(latestNormal()); }
|
|
83
114
|
else {
|
|
@@ -94,3 +125,29 @@ async function refresh() {
|
|
|
94
125
|
}
|
|
95
126
|
refresh();
|
|
96
127
|
setInterval(() => { if (document.visibilityState === 'visible') refresh(); }, 3000);
|
|
128
|
+
|
|
129
|
+
// DSH desktop (DSH插件 4.1): app-region inside a cross-origin iframe is ignored,
|
|
130
|
+
// so the host (client.js) lays a transparent drag layer over this top bar. This
|
|
131
|
+
// page only reports where the bar and its clickable controls are — geometry,
|
|
132
|
+
// never business data — and only when the plugin marked the frame and the
|
|
133
|
+
// parent is the DSH desktop window. Without the marker nothing here runs.
|
|
134
|
+
(function reportDragRegion() {
|
|
135
|
+
if (new URLSearchParams(location.search).get('host') !== 'dsh-desktop' || window.parent === window) return;
|
|
136
|
+
const HOST = 'dsh-app://app';
|
|
137
|
+
const bar = $('header.bar');
|
|
138
|
+
const rect = node => { const r = node.getBoundingClientRect(); return [r.left, r.top, r.width, r.height].map(v => Math.round(v * 10) / 10); };
|
|
139
|
+
let pending = 0;
|
|
140
|
+
const send = () => {
|
|
141
|
+
pending = 0;
|
|
142
|
+
const holes = [...bar.querySelectorAll('button, a[href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])')]
|
|
143
|
+
.filter(node => node.getClientRects().length).slice(0, 32).map(rect);
|
|
144
|
+
window.parent.postMessage({ type: 'theater-board:drag-region', version: 1, bar: rect(bar), holes }, HOST);
|
|
145
|
+
};
|
|
146
|
+
const schedule = () => { if (!pending) pending = requestAnimationFrame(send); };
|
|
147
|
+
new ResizeObserver(schedule).observe(bar);
|
|
148
|
+
window.addEventListener('resize', schedule);
|
|
149
|
+
bar.addEventListener('click', schedule);
|
|
150
|
+
window.addEventListener('pageshow', schedule);
|
|
151
|
+
window.addEventListener('load', schedule);
|
|
152
|
+
schedule();
|
|
153
|
+
})();
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
<link rel="stylesheet" href="/admin.css" />
|
|
9
9
|
<link rel="stylesheet" href="/review.css" />
|
|
10
10
|
<script src="/review.js" defer></script>
|
|
11
|
+
<script src="/org-mapping.js" defer></script>
|
|
11
12
|
<script src="/admin.js" defer></script>
|
|
12
13
|
</head>
|
|
13
14
|
<body>
|
|
@@ -98,6 +99,8 @@
|
|
|
98
99
|
<div class="generation-action"><button id="generate-button" class="button button-primary" type="button" disabled>生成真实数据看板<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 12h15m-6-6 6 6-6 6"/></svg></button><button id="generate-pending-button" class="button button-pending" type="button" disabled>仍有问题,生成待确认版本</button><span id="generation-progress" role="status" aria-live="polite">等待后台就绪</span><a id="latest-output" class="text-link" target="_blank" rel="noopener" hidden>打开最新生成的看板 ↗</a></div>
|
|
99
100
|
</section>
|
|
100
101
|
|
|
102
|
+
<div id="org-mapping-status" class="org-map" role="status" aria-live="polite" hidden></div>
|
|
103
|
+
|
|
101
104
|
<section id="history" class="section" aria-labelledby="history-title">
|
|
102
105
|
<div class="section-header"><div class="section-heading"><span class="step-number">05</span><div><h2 id="history-title">生成记录</h2><p>每次生成单独保存,可随时查看或下载已有成品。</p></div></div><span id="history-count" class="section-hint"></span></div>
|
|
103
106
|
<div id="generation-history" class="history-panel"><div class="empty-state"><strong>还没有生成记录</strong><p>上传资料并通过校验后,点击上方按钮生成真实数据看板。</p></div></div>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Organization-mapping status of one generation record, shared by the update
|
|
4
|
+
// page (admin.js) and the merged page history (board.js). Wording follows
|
|
5
|
+
// 设计预览画布 ⑪ (confirmed 2026-11-26); each page draws it with its own CSS.
|
|
6
|
+
(function () {
|
|
7
|
+
const TITLES = { invoice: '发票', movement: '动销', opening: '开瓶', terminal: '签约', inventory: '库存', banquet: '宴席' };
|
|
8
|
+
const ORDER = ['opening', 'banquet', 'movement', 'invoice', 'terminal', 'inventory'];
|
|
9
|
+
const REASONS = { pending: '待确认:现有映射未覆盖', 'target-missing': '已拒:目标路径在当前数据中不存在', ambiguous: '已拒:有歧义', malformed: '已拒:格式不符' };
|
|
10
|
+
const n = value => Number(value || 0).toLocaleString('zh-CN');
|
|
11
|
+
const pathText = path => !Array.isArray(path) ? '(格式不符,无法显示)' : (path.slice(0, 3).some(Boolean) ? path : path.slice(3)).map(part => part || '(空)').join(' / ');
|
|
12
|
+
|
|
13
|
+
function appliedParts(modules) {
|
|
14
|
+
const parts = [];
|
|
15
|
+
for (const id of ORDER) {
|
|
16
|
+
const m = modules[id];
|
|
17
|
+
if (!m || !m.appliedPaths) continue;
|
|
18
|
+
const aliasOnly = m.aliasPaths === m.appliedPaths;
|
|
19
|
+
parts.push(`${TITLES[id] || id}${aliasOnly ? '别名' : ''} ${n(m.appliedPaths)} 条${parts.length || aliasOnly ? '' : '路径'} / ${n(m.appliedRows)} 行`);
|
|
20
|
+
}
|
|
21
|
+
return parts;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** → { kind, chip, line, items } or kind 'none' when nothing is recorded. */
|
|
25
|
+
function view(job) {
|
|
26
|
+
const summary = job && job.organizationMapping;
|
|
27
|
+
if (!summary || typeof summary !== 'object') {
|
|
28
|
+
const legacy = job && job.legacyOrganizationMappingStatus;
|
|
29
|
+
const chip = legacy === 'stale' ? '未记录 · 旧规则停用' : legacy === 'confirmed' ? '未记录 · 旧规则已应用' : '未记录';
|
|
30
|
+
return { kind: 'none', chip, line: '', items: [] };
|
|
31
|
+
}
|
|
32
|
+
const modules = summary.modules || {};
|
|
33
|
+
const total = key => Object.values(modules).reduce((sum, m) => sum + (Number(m[key]) || 0), 0);
|
|
34
|
+
const rejected = total('rejectedCount'), pendingPaths = total('pendingPathCount'), pendingRows = total('pendingRows');
|
|
35
|
+
const items = (summary.items || []).map(item => ({ module: TITLES[item.moduleId] || item.moduleId, path: pathText(item.path), rows: n(item.rows), reason: REASONS[item.reason] || item.reason, rejected: item.reason !== 'pending' }));
|
|
36
|
+
const more = Math.max(0, (summary.itemCount || items.length) - items.length);
|
|
37
|
+
const applied = appliedParts(modules);
|
|
38
|
+
if (summary.status === 'invalid') return { kind: 'invalid', chip: '无效', line: '映射合同格式不受支持,本次一条映射都没有应用;开瓶、宴席按原路径显示。', items, more };
|
|
39
|
+
if (summary.status === 'partial') {
|
|
40
|
+
const issue = `${n(rejected)} 条被拒 · ${n(pendingPaths)} 个待确认路径(${n(pendingRows)} 行)`;
|
|
41
|
+
const chip = `部分应用 · ${pendingPaths ? `${n(pendingPaths)} 待确认` : `${n(rejected)} 被拒`}`;
|
|
42
|
+
return { kind: 'partial', chip, line: [...applied.map(part => `${part}已应用`), issue].join(' · '), issue, items, more };
|
|
43
|
+
}
|
|
44
|
+
if (summary.status === 'applied') return { kind: 'applied', chip: '已应用', line: applied.join(' · ') || '没有需要映射的路径', items: [], more: 0 };
|
|
45
|
+
return { kind: 'none', chip: '未配置', line: '没有组织映射合同。', items: [], more: 0 };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
window.OrgMapping = { view, note: '这些行保留原路径单独显示(看板下拉中带“(上级未提供)”),记录数和总值不变。要补上级,需要先列候选映射、由你确认后写入;系统不会自动推定。' };
|
|
49
|
+
})();
|
|
@@ -2,6 +2,7 @@ import { readFile, writeFile, readdir, realpath } from 'node:fs/promises';
|
|
|
2
2
|
import { resolve, relative, sep } from 'node:path';
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import { buildSourcePayload } from './source-payload.mjs';
|
|
5
|
+
import { summarizeOrganizationMapping } from './organization-mapping.mjs';
|
|
5
6
|
import { moduleDefinitions } from '../modules.mjs';
|
|
6
7
|
|
|
7
8
|
const sha = value => createHash('sha256').update(value).digest('hex');
|
|
@@ -131,5 +132,6 @@ export async function generateDashboard({ project, dataDir, sourceVersions, outp
|
|
|
131
132
|
processors: Object.fromEntries(ids.map(id => [id, { version: payload.processingVersion, state: payload.modules[id].state }])),
|
|
132
133
|
moduleSummaries: Object.fromEntries(ids.map(id => [id, { state: payload.modules[id].state, records: payload.modules[id].records.length, metrics: payload.modules[id].metrics, warnings: payload.modules[id].warnings || [], unavailable: payload.modules[id].unavailable || [] }])),
|
|
133
134
|
pendingDecisions: payload.pendingDecisions,
|
|
135
|
+
organizationMapping: summarizeOrganizationMapping(report.organizationMapping),
|
|
134
136
|
};
|
|
135
137
|
}
|