dsh-data-dashboard 0.0.0-stage → 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/README.md +35 -2
- package/assets/theater-board.svg +1 -0
- package/backend/incremental/flow.mjs +492 -0
- package/backend/incremental/jobs.mjs +58 -0
- package/backend/incremental/xlsx-rows.mjs +145 -0
- package/backend/job-worker.mjs +22 -0
- package/backend/modules/banquet/index.mjs +46 -0
- package/backend/modules/inventory/index.mjs +45 -0
- package/backend/modules/inventory/legacy-fields.mjs +83 -0
- package/backend/modules/invoice/index.mjs +72 -0
- package/backend/modules/movement/index.mjs +68 -0
- package/backend/modules/opening/index.mjs +48 -0
- package/backend/modules/target/index.mjs +45 -0
- package/backend/modules/terminal/index.mjs +114 -0
- package/backend/modules.mjs +12 -0
- package/backend/public/admin.css +220 -0
- package/backend/public/admin.js +772 -0
- package/backend/public/board.css +70 -0
- package/backend/public/board.html +50 -0
- package/backend/public/board.js +153 -0
- package/backend/public/index.html +113 -0
- package/backend/public/org-mapping.js +49 -0
- package/backend/public/review.css +5 -0
- package/backend/public/review.js +452 -0
- package/backend/real-data/generate-dashboard.mjs +137 -0
- package/backend/real-data/inventory-history.mjs +316 -0
- package/backend/real-data/organization-mapping.mjs +166 -0
- package/backend/real-data/source-payload.mjs +459 -0
- package/backend/real-data/terminal-components.mjs +280 -0
- package/backend/real-data/terminal-structure.css +105 -0
- package/backend/real-data/terminal-structure.mjs +276 -0
- package/backend/real-data/v10-components.mjs +112 -0
- package/backend/real-data/v10-details.css +18 -0
- package/backend/real-data/v10-details.mjs +251 -0
- package/backend/real-data/v10-layout.css +27 -0
- package/backend/real-data/v10-model.mjs +568 -0
- package/backend/real-data/v10-overview-data.mjs +253 -0
- package/backend/real-data/v10-overview.css +370 -0
- package/backend/real-data/v10-overview.mjs +340 -0
- package/backend/real-data/v10-presentation.mjs +354 -0
- package/backend/real-data/v10-shell.html +1097 -0
- package/backend/real-data/v10-template.mjs +353 -0
- package/backend/recognition/fingerprint.mjs +32 -0
- package/backend/recognition/headers.mjs +2 -0
- package/backend/recognition/module-definition.mjs +4 -0
- package/backend/recognition/result.mjs +29 -0
- package/backend/recognition/upload-limits.mjs +14 -0
- package/backend/review-engine.mjs +364 -0
- package/backend/review-service.mjs +182 -0
- package/backend/server.mjs +569 -0
- package/backend/store.mjs +68 -0
- package/backend/target-template.mjs +47 -0
- package/backend/validate-workbook.mjs +251 -0
- package/backend/web-sync/README.md +37 -0
- package/backend/web-sync/client.mjs +63 -0
- package/backend/web-sync/exporter.mjs +260 -0
- package/backend/web-sync/local.html +34 -0
- package/backend/web-sync/server.mjs +147 -0
- package/build-manifest.json +80 -0
- package/client.js +54 -0
- package/cordis.patch.yml +3 -0
- package/index.js +117 -0
- package/lib/dist-manifest.mjs +19 -0
- package/lib/market-index.mjs +56 -0
- package/lib/package-audit.mjs +34 -0
- package/lib/settings.mjs +71 -0
- package/lib/tool-definitions.mjs +56 -0
- package/lib/tools.mjs +255 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +71 -4
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// Serialized into the offline document. Keep this factory self-contained.
|
|
2
|
+
export function createV10Details({ T, g, model, presentation, charts }) {
|
|
3
|
+
const el = (tag, props, ...children) => {
|
|
4
|
+
const { key, ...attributes } = props || {};
|
|
5
|
+
return (children.length > 1 && T.jsxs ? T.jsxs : T.jsx)(tag, { ...attributes, children: children.length === 1 ? children[0] : children }, key);
|
|
6
|
+
};
|
|
7
|
+
const finite = value => typeof value === 'number' && Number.isFinite(value);
|
|
8
|
+
const list = value => Array.isArray(value) ? value : Array.isArray(value?.items) ? value.items : [];
|
|
9
|
+
const available = metric => metric && metric.state === 'available' && finite(metric.value);
|
|
10
|
+
const metric = (value, unit = '', label = '') => typeof value === 'object' && value !== null ? value : { value, unit, label, state: finite(value) ? 'available' : 'pending' };
|
|
11
|
+
const unit = item => item?.unit === '元' ? '万元' : item?.unit || '';
|
|
12
|
+
const numeric = item => item?.unit === '元' ? item.value / 10000 : item.value;
|
|
13
|
+
const valueText = item => available(item) ? model.format(numeric(item), item.displayPrecision ?? (item.unit === '元' || item.unit?.includes('/') || item.unit === '%' || item.unit === '月' ? 2 : 0), item.displayPrecision ?? (item.unit === '元' || item.unit?.includes('/') || item.unit === '%' || item.unit === '月' ? 2 : 6)) : item?.state === 'missing' ? '无记录' : item?.state === 'unavailable' ? '不可用' : '待确认';
|
|
14
|
+
const reason = item => item?.reason || (available(item) ? '' : '当前来源未提供完整的计算依据');
|
|
15
|
+
const name = item => item?.name || item?.label || '未提供名称';
|
|
16
|
+
const english = { invoice: 'INVOICE SALES', movement: 'TERMINAL SALES', opening: 'CONSUMER OPENINGS', inventory: 'INVENTORY CHECK', banquet: 'BANQUET ACTIVITY' };
|
|
17
|
+
const descriptions = {
|
|
18
|
+
invoice: '当月净额与年累计、开票节奏、组织和产品贡献、经销商集中度。',
|
|
19
|
+
movement: '扫码金额与开票对比、组织和产品贡献、终端渠道与集中度。',
|
|
20
|
+
opening: '开瓶节奏、现金红包、开瓶与动销的来源数量比及城市分布。',
|
|
21
|
+
inventory: '当前导出记录的盘点规模、提交节奏、差异与产品结构。',
|
|
22
|
+
banquet: '来源固定期间的宴席场次、开瓶、场均开瓶及组织表现。',
|
|
23
|
+
};
|
|
24
|
+
const tones = { invoice: 'inv', movement: 'mv', opening: 'op', inventory: 'stk', banquet: 'bq' };
|
|
25
|
+
const moveTab = (event, ids, current, select) => {
|
|
26
|
+
const at = ids.indexOf(current);
|
|
27
|
+
const next = event.key === 'ArrowRight' ? (at + 1) % ids.length : event.key === 'ArrowLeft' ? (at + ids.length - 1) % ids.length : event.key === 'Home' ? 0 : event.key === 'End' ? ids.length - 1 : null;
|
|
28
|
+
if (next === null) return;
|
|
29
|
+
event.preventDefault(); select(ids[next]); event.currentTarget.parentElement?.querySelectorAll('[role="tab"]')[next]?.focus();
|
|
30
|
+
};
|
|
31
|
+
function Empty({ text = '当前范围无可展示记录。' }) { return el('p', { className: 'inv-empty v10-empty' }, text); }
|
|
32
|
+
function Heading({ title, note }) { return el('div', { className: 'section-title' }, el('h3', {}, title), note && el('span', {}, note)); }
|
|
33
|
+
function MetricValue({ item, suffix = true }) {
|
|
34
|
+
return el(g.Fragment, {}, valueText(item), suffix && available(item) && unit(item) && el('small', {}, unit(item)));
|
|
35
|
+
}
|
|
36
|
+
function Kpis({ items }) {
|
|
37
|
+
return el('div', { className: 'detail-kpis inv-kpis' }, ...list(items).map((item, index) => el('div', { key: item.key || item.label || index, className: !available(item) ? 'pending' : index === 0 ? 'main' : item.value < 0 ? 'neg' : '', 'data-state': item.state },
|
|
38
|
+
el('span', {}, item.label || item.name), el('strong', {}, el(MetricValue, { item })), el('em', { title: [item.reason, item.note, ...(item.notes || [])].filter(Boolean).join(';') }, available(item) ? item.note || '' : reason(item)),
|
|
39
|
+
)));
|
|
40
|
+
}
|
|
41
|
+
function MonthlyChart({ points, kind, filters, drill }) {
|
|
42
|
+
const entries = list(points), values = entries.flatMap(item => [available(item) ? item.value : null, finite(item.negative) ? item.negative : null, finite(item.comparison) ? item.comparison : null]).filter(finite);
|
|
43
|
+
const positive = Math.max(0, ...values), negative = Math.min(0, ...values), range = positive - negative || 1;
|
|
44
|
+
const zero = -negative / range * 100;
|
|
45
|
+
const isMoney = entries.some(item => item.unit === '元');
|
|
46
|
+
return el(g.Fragment, {},
|
|
47
|
+
el('div', { className: `inv-months full v10-months ${kind === 'movement' ? 'mv' : ''}`, style: { '--month-count': Math.max(entries.length, 1) }, 'aria-label': kind === 'inventory' ? '盘点提交记录月度分布' : '月度来源趋势' },
|
|
48
|
+
...entries.map((item, index) => {
|
|
49
|
+
const key = item.month || item.key, month = Number(String(key).slice(-2));
|
|
50
|
+
const selected = key === filters.month, canPick = /^\d{4}-\d{2}$/.test(key || '');
|
|
51
|
+
const multipleYears = new Set(entries.map(point => point.month?.slice(0, 4)).filter(Boolean)).size > 1;
|
|
52
|
+
const label = canPick ? multipleYears ? `${key.slice(0,4)}/${month}` : `${month}月` : item.label || String(key || index + 1);
|
|
53
|
+
const bar = (value, cls) => finite(value) && el('i', { className: cls, style: { bottom: `${value >= 0 ? zero : zero + value / range * 100}%`, height: `${Math.abs(value) / range * 100}%` } });
|
|
54
|
+
return el('button', { key: key || index, type: 'button', className: `inv-m ${month % 3 === 0 ? 'q' : ''} ${selected ? 'sel' : ''} ${canPick ? 'pick' : ''} ${available(item) && item.value < 0 ? 'is-negative' : ''}`, disabled: !canPick, onClick: () => canPick && drill('month', key), 'aria-label': `${label}:${valueText(item)} ${available(item) ? unit(item) : reason(item)}${canPick ? ',点击切换月份' : ''}`, title: [label, `${valueText(item)} ${available(item) ? unit(item) : ''}`, item.note, reason(item)].filter(Boolean).join(' · ') },
|
|
55
|
+
el('em', { 'data-state': item.state }, available(item) ? kind === 'opening' ? model.format(item.value / 10000, 1) : model.format(numeric(item), 0, isMoney ? 0 : 2) : '—'),
|
|
56
|
+
el('div', { className: 'bar' }, el('span', { className: 'v10-zero', style: { bottom: `${zero}%` } }), available(item) && bar(item.value, 'net'), finite(item.negative) && item.negative !== 0 && bar(item.negative, 'ded'), finite(item.comparison) && el('s', { style: { bottom: `${zero + item.comparison / range * 100}%` }, title: `同月发票:${model.format(item.comparison / 10000, 2)} 万元` }), !available(item) && el('span', { className: 'v10-missing-mark' }, '—')),
|
|
57
|
+
el('span', {}, label),
|
|
58
|
+
kind === 'opening' && el('small', { title: `现金红包:${valueText(item.cashAmount)} ${available(item.cashAmount) ? unit(item.cashAmount) : reason(item.cashAmount)}`, 'data-state': item.cashAmount?.state }, valueText(item.cashAmount), available(item.cashAmount) ? ' 万元' : ''),
|
|
59
|
+
);
|
|
60
|
+
}),
|
|
61
|
+
),
|
|
62
|
+
entries.length === 0 && el(Empty, {}),
|
|
63
|
+
el('div', { className: `inv-legend ${kind === 'movement' ? 'mv' : ''}` },
|
|
64
|
+
el('span', {}, el('i', { className: 'l-net' }), kind === 'inventory' ? '提交记录' : kind === 'opening' ? '开瓶瓶数' : '净额'),
|
|
65
|
+
entries.some(item => finite(item.negative) && item.negative !== 0) && el('span', {}, el('i', { className: 'l-ded' }), kind === 'invoice' ? '负金额' : '负金额'),
|
|
66
|
+
entries.some(item => finite(item.comparison)) && el('span', {}, el('i', { className: 'l-cmp' }), '同月发票净额'),
|
|
67
|
+
el('b', {}, `单位:${kind === 'opening' ? '万瓶(柱顶);万元(现金红包)' : unit(entries[0]) || '来源单位'} · 点击柱子切换月份;缺失不补零`),
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
function DailyChart({ points, color, title }) {
|
|
72
|
+
const entries = list(points), valid = entries.filter(available);
|
|
73
|
+
if (!valid.length) return el(Empty, { text: entries.find(item => item.reason)?.reason || '当前范围没有可绘制的日期来源。' });
|
|
74
|
+
const values = valid.map(numeric), max = Math.max(0, ...values), min = Math.min(0, ...values), span = max - min || 1;
|
|
75
|
+
const width = 720, left = 54, right = 12, top = 15, bottom = 174, baseline = top + max / span * (bottom - top);
|
|
76
|
+
const x = index => left + index / Math.max(entries.length - 1, 1) * (width - left - right);
|
|
77
|
+
const y = item => top + (max - numeric(item)) / span * (bottom - top);
|
|
78
|
+
const segments = []; let segment = [];
|
|
79
|
+
entries.forEach((item, index) => { if (available(item)) segment.push({ item, index }); else if (segment.length) { segments.push(segment); segment = []; } });
|
|
80
|
+
if (segment.length) segments.push(segment);
|
|
81
|
+
const ticks = [...new Set([0, Math.floor((entries.length - 1) / 4), Math.floor((entries.length - 1) / 2), Math.floor((entries.length - 1) * .75), entries.length - 1])];
|
|
82
|
+
return el('div', { className: 'v10-daily-chart' },
|
|
83
|
+
el('svg', { viewBox: `0 0 ${width} 206`, role: 'img', 'aria-label': `${title};单位${unit(valid[0])};缺少来源的日期不连接` },
|
|
84
|
+
el('title', {}, title),
|
|
85
|
+
...[0, .5, 1].map(fraction => {
|
|
86
|
+
const yy = top + fraction * (bottom - top), value = max - fraction * span;
|
|
87
|
+
return el('g', { key: fraction }, el('line', { x1: left, x2: width - right, y1: yy, y2: yy, stroke: '#e6ebf0', strokeDasharray: '3 5' }), el('text', { x: left - 7, y: yy + 4, textAnchor: 'end', className: 'v10-axis-label' }, model.format(value, 0)));
|
|
88
|
+
}),
|
|
89
|
+
el('line', { x1: left, x2: width - right, y1: baseline, y2: baseline, stroke: '#d8e0e6' }),
|
|
90
|
+
...segments.map((part, index) => {
|
|
91
|
+
const line = part.map(({ item, index: i }, at) => `${at ? 'L' : 'M'} ${x(i)} ${y(item)}`).join(' ');
|
|
92
|
+
return el('g', { key: index }, el('path', { d: `${line} L ${x(part.at(-1).index)} ${baseline} L ${x(part[0].index)} ${baseline} Z`, fill: color, fillOpacity: '.09' }), el('path', { d: line, fill: 'none', stroke: color, strokeWidth: '2' }));
|
|
93
|
+
}),
|
|
94
|
+
...entries.filter(available).map(item => { const index = entries.indexOf(item); return el('circle', { key: item.key || item.date || index, cx: x(index), cy: y(item), r: '3', fill: color, tabIndex: 0 }, el('title', {}, `${item.date || item.label || item.key}:${valueText(item)} ${unit(item)}`)); }),
|
|
95
|
+
...ticks.map(index => el('text', { key: index, x: x(index), y: 197, textAnchor: 'middle', className: 'v10-axis-label' }, entries[index]?.label || entries[index]?.date?.slice(-2) || entries[index]?.key || '')),
|
|
96
|
+
),
|
|
97
|
+
el('p', { className: 'v10-chart-caption' }, `单位:${unit(valid[0])}。缺失日期保留断点;累计值只按适用期间的来源计算。`),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function Trend({ description, kind, filters, drill, color }) {
|
|
101
|
+
const [mode, setMode] = g.useState('month');
|
|
102
|
+
const inventory = kind === 'inventory';
|
|
103
|
+
const labels = inventory ? description?.inventoryMode === 'visit-history' ? '最近盘点日期分布 · 按提交月份' : '盘点提交节奏 · 每月来源记录' : kind === 'invoice' ? '开票节奏' : kind === 'movement' ? '动销节奏 · 对比发票' : '开瓶节奏';
|
|
104
|
+
return el('section', { className: 'chart-section', 'aria-label': labels },
|
|
105
|
+
el('div', { className: 'section-title' }, el('h3', {}, inventory ? labels : `${mode === 'month' ? '月度' : mode === 'daily' ? '每日' : '当月累计'}${labels}`),
|
|
106
|
+
!inventory && el('div', { className: 'segmented', role: 'group', 'aria-label': '趋势粒度' }, ...[['month', '月度'], ['daily', '每日'], ['cumulative', '累计']].map(([key, text]) => el('button', { key, type: 'button', className: mode === key ? 'active' : '', 'aria-pressed': mode === key, onClick: () => setMode(key) }, text))),
|
|
107
|
+
),
|
|
108
|
+
mode === 'month' || inventory ? el(MonthlyChart, { points: description?.monthly, kind, filters, drill }) : el(DailyChart, { points: description?.[mode], color, title: `${filters.month} ${mode === 'daily' ? '每日' : '累计'}${labels}` }),
|
|
109
|
+
description?.note && el('details', { className: 'v10-trend-note' }, el('summary', {}, '趋势口径'), el('p', { className: 'v10-chart-caption' }, description.note)),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function Ranked({ items, color, drill, groupField, leaf = false, limit, secondary = false }) {
|
|
113
|
+
const entries = limit ? list(items).slice(0, limit) : list(items), max = Math.max(...entries.filter(available).map(item => Math.abs(item.value)), 1);
|
|
114
|
+
return entries.length ? el('div', { className: secondary ? 'inv-dealer-rows' : 'group-rows' }, ...entries.map((item, index) => {
|
|
115
|
+
const canDrill = !secondary && !leaf && item.drillable !== false && model.organizations.some(organization => organization[groupField] === item.key);
|
|
116
|
+
return el(canDrill ? 'button' : 'div', { key: item.key || item.name || index, className: secondary ? 'inv-dealer' : 'group-row', ...(canDrill ? { type: 'button', onClick: () => drill(groupField, item.key), 'aria-label': `筛选${name(item)}` } : {}), 'data-state': item.state },
|
|
117
|
+
el('span', { className: 'rank' }, String(index + 1).padStart(2, '0')),
|
|
118
|
+
el('div', { className: secondary ? '' : 'group-name' }, el('strong', { title: [name(item), item.note].filter(Boolean).join(';') }, name(item), secondary && item.records > 0 && el('small', {}, `${model.format(item.records)} 条来源记录`)), el('div', { className: 'track' }, available(item) && el('i', { style: { width: `${Math.abs(item.value) / max * 100}%`, background: item.value < 0 ? '#c99464' : color } }))),
|
|
119
|
+
el('b', {}, el(MetricValue, { item }), !available(item) ? el('small', {}, reason(item)) : item.shareText ? el('small', {}, item.shareText) : finite(item.share) && el('small', {}, `${model.format(item.share * 100, 1)}%`)),
|
|
120
|
+
canDrill && el('span', { className: 'v10-drill-arrow', 'aria-hidden': true }, '›'),
|
|
121
|
+
);
|
|
122
|
+
})) : el(Empty, {});
|
|
123
|
+
}
|
|
124
|
+
function Concentration({ items, tone }) {
|
|
125
|
+
const entries = list(items);
|
|
126
|
+
return entries.length ? el(g.Fragment, {}, el('div', { className: `inv-conc ${tone || ''}` }, ...entries.map((item, index) => el('div', { key: item.key || item.n || index, 'data-state': item.state, title: item.note || reason(item) },
|
|
127
|
+
el('span', {}, item.name || item.label || `Top ${item.n}`), el('strong', {}, el(MetricValue, { item })),
|
|
128
|
+
el('div', {}, available(item) && (finite(item.share) || item.unit === '%') && el('i', { style: { width: `${Math.max(0, Math.min(100, finite(item.share) ? item.share * 100 : item.value))}%` } })),
|
|
129
|
+
!available(item) && el('small', {}, reason(item)),
|
|
130
|
+
))), entries[0].note && el('p', { className: 'v10-chart-caption' }, entries[0].note)) : null;
|
|
131
|
+
}
|
|
132
|
+
function Products({ description, filters, drill }) {
|
|
133
|
+
const brands = list(description.brands), products = list(description.products);
|
|
134
|
+
if (description.inventoryMode === 'visit-history') return el('section', { className: 'product-section' },
|
|
135
|
+
el(Heading, { title: '产品构成 · 完整产品名称', note: '按最近盘点瓶数;不随品牌/品类筛选' }),
|
|
136
|
+
el(Ranked, { items: products, color: '#687e88', secondary: true, limit: 12 }));
|
|
137
|
+
const positiveTotal = brands.filter(available).reduce((total, item) => total + Math.max(0, item.value), 0);
|
|
138
|
+
const negative = brands.some(item => available(item) && item.value < 0);
|
|
139
|
+
const colors = ['#ab343c', '#8a6c79', '#547fa3', '#9c7865', '#879c87', '#b99e73'];
|
|
140
|
+
return el('section', { className: 'product-section' },
|
|
141
|
+
el(Heading, { title: '产品结构 · 品牌 → 品类', note: '点击品类联动筛选,再次点击取消' }),
|
|
142
|
+
positiveTotal > 0 && !negative && brands.every(available) && el('div', { className: 'inv-brandbar', 'aria-label': '品牌金额构成' }, ...brands.map((item, index) => el('i', { key: item.key || index, style: { width: `${item.value / positiveTotal * 100}%`, background: item.color || colors[index % colors.length] }, title: `${name(item)}:${valueText(item)} ${unit(item)}` }))),
|
|
143
|
+
el('div', { className: 'inv-brandlegend' }, ...brands.map((item, index) => el('span', { key: item.key || index }, el('i', { style: { background: item.color || colors[index % colors.length] } }), name(item), el('b', { title: `${valueText(item)} ${available(item) ? unit(item) : reason(item)}` }, available(item) && finite(item.share) && !negative ? `${model.format(item.share * 100, item.share < .01 ? 1 : 0)}%` : valueText(item))))),
|
|
144
|
+
negative && el('p', { className: 'v10-chart-caption' }, '当前品牌含负净额,分别保留数值,不以正向占比条混合展示。'),
|
|
145
|
+
el('div', { className: 'product-buttons inv-products' }, ...products.slice(0, 10).map((item, index) => {
|
|
146
|
+
const key = item.product, canPick = item.drillable !== false && model.categories.some(category => category.id === key), selected = filters.product === key;
|
|
147
|
+
return el('button', { key: key || index, type: 'button', className: selected ? 'selected' : '', disabled: !canPick, 'aria-pressed': selected, onClick: () => canPick && drill('product', selected ? 'all' : key) },
|
|
148
|
+
el('i', { style: { background: item.color || colors[index % colors.length] } }), el('span', { title: name(item) }, name(item), item.brand && el('small', {}, item.brand)), el('b', { 'data-state': item.state }, el(MetricValue, { item })),
|
|
149
|
+
);
|
|
150
|
+
})),
|
|
151
|
+
!products.length && el(Empty, {}),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
function SourceTable({ rows, kind, inventoryMode, cutoffDate }) {
|
|
155
|
+
const [page, setPage] = g.useState(0), size = 24;
|
|
156
|
+
const entries = list(rows), pages = Math.max(1, Math.ceil(entries.length / size)), current = Math.min(page, pages - 1);
|
|
157
|
+
g.useEffect(() => setPage(0), [rows, kind]);
|
|
158
|
+
const columns = {
|
|
159
|
+
invoice: [['organization', '完整组织路径'], ['date', '业务日期'], ['dealerName', '经销商'], ['dealerCode', '经销商编码'], ['brand', '品牌'], ['category', '品类'], ['amount', '发票净额 / 万元', '元']],
|
|
160
|
+
movement: [['organization', '完整组织路径'], ['date', '扫码日期'], ['terminalName', '终端'], ['terminalCode', '售点编码'], ['brand', '品牌'], ['category', '品类'], ['amount', '扫码净额 / 万元', '元'], ['bottles', '瓶单位数量', '瓶'], ['boxes', '盒单位数量', '盒'], ['cases', '来源扫码件数', '源件数']],
|
|
161
|
+
opening: [['organization', '产品所属完整组织'], ['date', '抽奖日期'], ['city', '开瓶城市'], ['bottles', '开瓶 / 瓶', '瓶'], ['amount', '现金红包 / 万元', '元']],
|
|
162
|
+
inventory: inventoryMode === 'visit-history'
|
|
163
|
+
? [['organization', '源完整营销组织'], ['dealerName', '经销商'], ['dealerCode', '经销商编码'], ['productName', '完整产品名称'], ['submittedAt', '盘点提交时间'], ['system', '提交时系统 / 瓶', '瓶'], ['counted', '盘点 / 瓶', '瓶'], ['signedVariance', '盘点与系统差异 / 瓶', '瓶'], ['previousSubmittedAt', '上次盘点时间'], ['previousCounted', '上次盘点瓶数 / 瓶', '瓶'], ['changeFromPrevious', '较上次变化瓶数 / 瓶', '瓶'], ['daysSinceStocktake', '距所选截止日天数 / 天', '天'], ['comparisonStatusLabel', '比较状态'], ['absoluteVariance', '绝对差 / 瓶', '瓶'], ['sourceVariance', '源偏差 / 瓶', '瓶'], ['systemAmount', '提交时系统金额 / 万元', '元'], ['recordStatus', '核查提示'], ['supplementRequested', '是否补录'], ['supplementStatus', '补录状态']]
|
|
164
|
+
: [['organization', '完整组织路径'], ['dealerName', '经销商'], ['dealerCode', '经销商编码'], ['productCode', '产品编码'], ['productName', '产品'], ['date', '盘点提交日期'], ['system', '系统 / 瓶', '瓶'], ['counted', '盘点 / 瓶', '瓶'], ['sourceVariance', '源偏差 / 瓶', '瓶'], ['signedVariance', '盘点−系统 / 瓶', '瓶'], ['absoluteVariance', '绝对差 / 瓶', '瓶']],
|
|
165
|
+
banquet: [['organization', '完整组织路径'], ['events', '执行 / 场', '场'], ['bottles', '开瓶 / 瓶', '瓶'], ['average', '场均 / 瓶', '瓶/场'], ['reward', '推荐奖励 / 元', '元']],
|
|
166
|
+
}[kind] || [];
|
|
167
|
+
const cell = (row, field, measureUnit) => {
|
|
168
|
+
if (kind === 'banquet' && field === 'reward') return '待确认';
|
|
169
|
+
const value = row[field];
|
|
170
|
+
if (value && typeof value === 'object' && 'state' in value) return valueText(value);
|
|
171
|
+
if (measureUnit) return finite(value) ? valueText(metric(value, measureUnit)) : '待确认';
|
|
172
|
+
return typeof value === 'string' && value ? value : '未提供';
|
|
173
|
+
};
|
|
174
|
+
return el('div', { className: 'table-wrap v10-source-table' },
|
|
175
|
+
el('p', { className: 'v10-chart-caption' }, `按当前筛选展示允许导出的来源记录;源空值保持未知,不补零。${kind === 'inventory' && inventoryMode === 'visit-history' ? `距所选截止日天数以 ${cutoffDate || '未提供'} 为基准;基准日取所选月末与来源最大已知提交日期的较早者,不使用电脑今天日期。较上次变化不代表销量。` : ''}`),
|
|
176
|
+
el('div', { className: 'v10-table-scroll' }, el('table', {}, el('thead', {}, el('tr', {}, ...columns.map(([field, label]) => el('th', { key: field, scope: 'col' }, label)))), el('tbody', {}, ...entries.slice(current * size, (current + 1) * size).map((row, index) => el('tr', { key: row.key || index }, ...columns.map(([field, , measureUnit]) => el('td', { key: field, title: cell(row, field, measureUnit) }, cell(row, field, measureUnit)))))))),
|
|
177
|
+
!entries.length && el(Empty, {}),
|
|
178
|
+
el('div', { className: 'v10-pagination' }, el('span', {}, `共 ${model.format(entries.length)} 条来源记录 · 第 ${current + 1} / ${pages} 页`), el('button', { type: 'button', disabled: current === 0, onClick: () => setPage(current - 1) }, '上一页'), el('button', { type: 'button', disabled: current >= pages - 1, onClick: () => setPage(current + 1) }, '下一页')),
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
function ObservationTable({ items, kind, inventoryMode }) {
|
|
182
|
+
const entries = list(items);
|
|
183
|
+
if (!entries.length) return el(Empty, {});
|
|
184
|
+
if (entries.every(item => item.records === 0)) return el(Empty, { text: entries[0].note || reason(entries[0]) });
|
|
185
|
+
if (entries.every(item => !available(item) && !finite(item.system))) return el(Empty, { text: reason(entries[0]) });
|
|
186
|
+
return el('div', { className: `sg-series ${kind === 'inventory' ? 'stk-dev' : 'bq-eff'} v10-observation-table` },
|
|
187
|
+
el('div', { className: 'sg-row head' }, el('span', {}, kind === 'inventory' ? '来源记录' : '单元'), el('span', {}, kind === 'inventory' ? '系统 / 瓶' : '执行 / 场'), el('span', {}, kind === 'inventory' ? '盘点 / 瓶' : '开瓶 / 瓶'), el('span', {}, kind === 'inventory' ? inventoryMode === 'visit-history' ? '盘点与系统差异 / 瓶' : '盘点−系统 / 瓶' : '场均 / 瓶')),
|
|
188
|
+
...entries.slice(0, 8).map((item, index) => el('div', { className: 'sg-row', key: item.key || index }, el('strong', { title: [name(item), item.note].filter(Boolean).join(';') }, name(item)),
|
|
189
|
+
el('span', {}, valueText(metric(kind === 'inventory' ? item.system : item.events ?? item.sessions, kind === 'inventory' ? '瓶' : '场'))),
|
|
190
|
+
el('span', {}, valueText(metric(kind === 'inventory' ? item.counted : item.bottles, '瓶'))),
|
|
191
|
+
el('b', { className: available(item) && item.value < 0 ? 'minus' : '' }, el(MetricValue, { item, suffix: false })),
|
|
192
|
+
)),
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
function DayChangeTable({ items }) {
|
|
196
|
+
const entries = list(items);
|
|
197
|
+
if (!entries.length) return el(Empty, {});
|
|
198
|
+
const first = entries.find(item => item.date) || {}, day = date => date ? date.slice(5) : '—';
|
|
199
|
+
const bottles = value => finite(value) ? model.format(value) : '—';
|
|
200
|
+
return el('div', { className: 'sg-series op-day v10-observation-table', 'aria-label': `${first.date || '末日'} 与 ${first.previousDate || '昨日'} 开瓶比较` },
|
|
201
|
+
el('div', { className: 'sg-row head' }, el('span', {}, '组织'), el('span', {}, `${day(first.previousDate)} / 瓶`), el('span', {}, `${day(first.date)} / 瓶`), el('span', {}, '变化 / 瓶'), el('span', {}, '较昨日')),
|
|
202
|
+
...entries.map((item, index) => el('div', { className: 'sg-row', key: item.key || index }, el('strong', { title: name(item) }, name(item)),
|
|
203
|
+
el('span', {}, bottles(item.previous)), el('span', {}, bottles(item.current)),
|
|
204
|
+
el('span', { className: finite(item.difference) && item.difference < 0 ? 'minus' : finite(item.difference) && item.difference > 0 ? 'plus' : '' }, finite(item.difference) ? `${item.difference > 0 ? '+' : ''}${model.format(item.difference)}` : '—'),
|
|
205
|
+
el('b', { className: available(item) && item.value < 0 ? 'minus' : available(item) && item.value > 0 ? 'plus' : '', title: reason(item) }, available(item) ? `${item.value > 0 ? '+' : ''}${model.format(item.value, 1, 1)}%` : '—'))),
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
function Definitions({ module, description }) {
|
|
209
|
+
const notes = [...new Set([...(description.notes || []), ...(module.pending || [])].filter(value => typeof value === 'string' && value))];
|
|
210
|
+
return el('div', { className: 'definitions' },
|
|
211
|
+
el('div', { className: 'source-label' }, module.source?.originalName || '当前板块没有有效上传来源'),
|
|
212
|
+
...notes.map((text, index) => el('div', { key: text, className: 'definition-row' }, el('strong', {}, `口径 ${index + 1}`), el('p', {}, text))),
|
|
213
|
+
...(module.crossMetrics || []).map(item => el('div', { key: item.key, className: 'definition-row' }, el('strong', {}, item.label), el('div', {}, item.reason && el('p', {}, item.reason), ...(item.notes || []).map((text, index) => el('p', { key: index }, text))))),
|
|
214
|
+
el('div', { className: 'v10-source-proof' }, el('h3', {}, '本次来源版本'), module.source ? el('dl', {}, el('dt', {}, '上传版本'), el('dd', {}, module.source.uploadId), el('dt', {}, 'SHA-256'), el('dd', {}, module.source.sha256), el('dt', {}, '来源期间'), el('dd', {}, module.period)) : el('p', {}, '请先上传并校验对应来源。'), el('p', {}, `生成时间:${model.payload.generatedAt}`)),
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function UpLevel({ filters, drill }) {
|
|
218
|
+
const step = filters.unit !== 'all' ? ['unit', model.label(filters.office)] : filters.office !== 'all' ? ['office', model.label(filters.region)] : filters.region !== 'all' ? ['region', '全战区'] : null;
|
|
219
|
+
return step && el('button', { type: 'button', className: 'up-level v10-up-level', 'aria-label': `返回上一级:${step[1]}`, onClick: () => drill(step[0], 'all') }, '‹ 返回上一级', el('small', {}, step[1]));
|
|
220
|
+
}
|
|
221
|
+
function Details({ kind, data, filters, drill }) {
|
|
222
|
+
const module = data.modules[kind];
|
|
223
|
+
const inventoryVisit = kind === 'inventory' && module.inventoryMode === 'visit-history';
|
|
224
|
+
const description = g.useMemo(() => presentation.describe(kind, data, filters), [kind, data, filters]);
|
|
225
|
+
const tone = tones[kind];
|
|
226
|
+
const section = (title, body, note) => el('section', { className: `product-section inv-dealers ${tone}` }, el(Heading, { title, note }), body);
|
|
227
|
+
const ranking = description.ranking || {};
|
|
228
|
+
return el('section', { className: `details-panel v10-details v10-${kind}`, 'aria-label': `${module.title}详细信息`, style: { '--detail-accent': module.color } },
|
|
229
|
+
el('div', { className: 'detail-title' }, el('div', {}, el('span', { className: 'eyebrow' }, english[kind]), el('h2', {}, `${module.title}分析`), el('p', {}, inventoryVisit ? '经销商与完整产品名称的最近一次已知盘点、盘点与系统差异和记录时效。' : descriptions[kind])), el('span', { className: 'scope-tag' }, '筛选联动')),
|
|
230
|
+
el('div', { className: 'detail-context' }, el('span', {}, model.scope(filters)), el('span', {}, module.period), el('span', {}, inventoryVisit ? '库存不随品牌/品类筛选' : ['invoice', 'movement', 'inventory'].includes(kind) ? filters.product === 'all' ? '全部产品' : model.categories.find(item => item.id === filters.product)?.name || '所选产品' : '不随产品筛选')),
|
|
231
|
+
el('div', { className: `analysis-content inv-analysis ${tone}-analysis` },
|
|
232
|
+
el(Kpis, { items: description.kpis }),
|
|
233
|
+
inventoryVisit && el('p', { className: 'v10-method-note' }, `最近盘点日期:${module.inventoryStats?.latestMinDate || '未提供'} 至 ${module.inventoryStats?.latestMaxDate || '未提供'}。各条记录并非同一天盘点,不代表当天实时库存。距所选截止日天数的基准日:${module.inventoryStats?.cutoffDate || '未提供'}。${description.inventoryReviewSummary || ''}${module.inventoryStats?.conflictRows ? `有 ${model.format(module.inventoryStats.conflictRows)} 条最近候选待核实,相关数量不合并。` : ''}`),
|
|
234
|
+
kind === 'banquet' ? el('p', { className: 'sg-note bq' }, `${module.period}。组织筛选有效;不随月份或产品筛选。奖励合计与场均奖励待确认。`) : el(Trend, { key: kind, description: description.trend, kind, filters, drill, color: module.color }),
|
|
235
|
+
kind === 'inventory' && section(inventoryVisit ? '失效指标 · 缺少来源' : '库存健康 · 来源状态', el(Concentration, { items: description.health, tone: inventoryVisit ? 'stk' : 'stk four' }), inventoryVisit ? '缺少来源字段的指标不计算,不用其他字段替代' : '分类规则待确认时保持未知,不推断安全阈值'),
|
|
236
|
+
el(UpLevel, { filters, drill }),
|
|
237
|
+
el(Heading, { title: `${filters.unit === 'all' ? '下级组织' : '当前单元'} · ${kind === 'inventory' ? inventoryVisit ? '最近盘点瓶数' : '盘点库存金额' : kind === 'opening' ? '开瓶瓶数' : kind === 'banquet' ? '执行场次' : '当月净额'}`, note: filters.unit === 'all' ? '点击一行联动组织筛选' : '按当前完整组织路径统计' }),
|
|
238
|
+
el(Ranked, { items: description.organizations, color: module.color, drill, groupField: module.groupField, leaf: filters.unit !== 'all' }),
|
|
239
|
+
['invoice', 'movement', 'inventory'].includes(kind) && el(Products, { description, filters, drill }),
|
|
240
|
+
kind === 'movement' && section('终端渠道结构', el(Ranked, { items: description.channels, color: module.color, secondary: true, limit: 8 }), '按来源渠道展示扫码金额'),
|
|
241
|
+
kind === 'opening' && section('下级组织 · 较昨日开瓶', el(DayChangeTable, { items: description.dayChanges }), '所选期间末日对比前一天;无记录显示 —,不补零'),
|
|
242
|
+
kind === 'opening' && section('开瓶城市 · 消费地', el(g.Fragment, {}, el(Concentration, { items: description.cities?.concentration || ranking.concentration, tone: 'op' }), el(Ranked, { items: description.cities, color: module.color, secondary: true, limit: 10 })), '与产品所属组织独立观察'),
|
|
243
|
+
['invoice', 'movement', 'inventory', 'banquet'].includes(kind) && section(ranking.title || ({ invoice: '客户集中度 · 经销商', movement: '终端集中度 · 售点', inventory: '库存 Top 经销商', banquet: '执行 Top 单元' })[kind], el(g.Fragment, {}, el(Concentration, { items: ranking.concentration, tone }), el(Ranked, { items: ranking.items, color: module.color, secondary: true, limit: kind === 'banquet' ? 10 : 8 })), ranking.note),
|
|
244
|
+
kind === 'inventory' && section(inventoryVisit ? '盘点与系统差异 · 逐条比较' : '盘点差异 · 逐条比较', el(ObservationTable, { items: description.deviations, kind, inventoryMode: module.inventoryMode }), '盘点减系统,按来源记录逐条比较'),
|
|
245
|
+
kind === 'banquet' && section('场均开瓶排行', el(ObservationTable, { items: description.efficiency, kind }), '同一完整组织路径 · 来源固定期间'),
|
|
246
|
+
el('div', { className: 'v10-method-note' }, '缺失、待确认和真实零值分别展示;“—”表示缺少来源或口径待确认,不补零。'),
|
|
247
|
+
),
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
return { Details, Kpis, Ranked, Heading };
|
|
251
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Preserve the reviewed V10 shell geometry; only adapt dynamic source states. */
|
|
2
|
+
/* Keep navigation immediate; the shell's reduced-motion !important rule wins. */
|
|
3
|
+
.app-shell.detail-mode .focus-summary,
|
|
4
|
+
.app-shell.detail-mode .focus-summary>.compact-card{animation-duration:.12s;animation-delay:0s}
|
|
5
|
+
.v10-terminal .preview-table-wrap{max-width:100%;overflow-x:auto;scrollbar-width:thin}
|
|
6
|
+
.v10-source-notice{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
|
|
7
|
+
.preview-fixed-dock{display:grid!important;grid-template-columns:repeat(6,minmax(0,1fr));gap:4px!important;padding:11px 7px!important;overflow:visible!important;scroll-snap-type:none!important}
|
|
8
|
+
.preview-fixed-dock button{width:100%;min-width:0;scroll-snap-align:none}
|
|
9
|
+
.filter-bar select{min-width:0;max-width:100%;text-overflow:ellipsis}
|
|
10
|
+
.filter-bar label{min-width:0}
|
|
11
|
+
.metric-value[data-state="pending"] strong,.metric-value[data-state="missing"] strong,.metric-value[data-state="unavailable"] strong{font-size:28px;letter-spacing:0;color:#9b7b70}
|
|
12
|
+
.v10-card-state{font-size:11px;line-height:1.6;color:#8c6d62;margin:8px 0 0}
|
|
13
|
+
.v10-card-months{width:100%;min-width:0}
|
|
14
|
+
.v10-card-months .bar i.is-negative{background:#b7791f;border-radius:0 0 3px 3px}
|
|
15
|
+
.v10-zero{position:absolute;left:0;right:0;border-top:1px solid #b4bec8;height:0}
|
|
16
|
+
.v10-no-bar{position:absolute;inset:0;display:grid;place-items:center;color:#a8b2bb;font-size:12px;background:repeating-linear-gradient(135deg,transparent 0 4px,#edf1f54d 4px 7px);border-radius:4px}
|
|
17
|
+
.v10-spark-empty{display:flex;align-items:center;font-size:10px;color:#95a0ab}
|
|
18
|
+
.app-shell .card-bottom.inv-bottom{flex-wrap:wrap;gap:4px 10px;line-height:1.6}
|
|
19
|
+
.app-shell .card-bottom.inv-bottom span{white-space:normal}
|
|
20
|
+
.app-shell .inv-ytd{overflow-wrap:anywhere}
|
|
21
|
+
.app-shell .support-foot{line-height:1.6;overflow-wrap:anywhere}
|
|
22
|
+
.rules-pending p,.preview-provenance dd{overflow-wrap:anywhere}
|
|
23
|
+
.preview-pending-line{font-size:11px;line-height:1.7;color:#8b6b5e;margin-top:10px}
|
|
24
|
+
/* Share the overview's left column equally after removing signing star bars. */
|
|
25
|
+
.app-shell:not(.detail-mode) .bento-grid>.terminal{grid-column:1;grid-row:1 / 4;align-self:start;height:calc((100% - 10px) / 2)}
|
|
26
|
+
.app-shell:not(.detail-mode) .bento-grid>.opening{grid-column:1;grid-row:1 / 4;align-self:end;height:calc((100% - 10px) / 2)}
|
|
27
|
+
.metric-card.inventory .stock-compare b[data-state]:not([data-state="available"]){color:#9aa7af}
|