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
|
@@ -30,7 +30,7 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
30
30
|
el('em', { className: available(item) ? item.value > 0 ? 'is-up' : item.value < 0 ? 'is-down' : 'is-flat' : 'is-pending' }, text), label && el('span', {}, label));
|
|
31
31
|
}
|
|
32
32
|
function Comparison({ item, opening = false }) {
|
|
33
|
-
return el('span', { className: `ov-comparison${opening ? ' ov-comparison-inline' : ''}` },
|
|
33
|
+
return el('span', { className: `ov-comparison ov-refresh${opening ? ' ov-comparison-inline' : ''}` },
|
|
34
34
|
el(Growth, { item, label: '同比' }), el('span', { className: 'ov-previous', title: reason(item) }, opening ? '去年同期 ' : '去年同期 ',
|
|
35
35
|
el(Value, { item: item?.previous, digits: opening ? 0 : 2, unit: opening ? '瓶' : '万' })));
|
|
36
36
|
}
|
|
@@ -62,23 +62,78 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
62
62
|
current && deduction && el('b', { className: 'ov-negative-label' }, number(item.negative / 10000))),
|
|
63
63
|
!available(item) && !available(previous) && el('span', { className: 'ov-missing', 'data-state': item.state }, '—')),
|
|
64
64
|
el('span', { className: 'ov-month-label' }, `${month}月`));
|
|
65
|
-
}))
|
|
65
|
+
})));
|
|
66
|
+
}
|
|
67
|
+
const pct = (value, digits = 1) => `${number(value, digits)}%`;
|
|
68
|
+
const scopeKeyOf = filters => JSON.stringify([filters.month, filters.period, filters.start, filters.end, filters.region, filters.office, filters.unit, filters.product]);
|
|
69
|
+
// 卡片标题旁的期间小标:让人一眼看出当前月份或区间,以及来源截止到哪天。
|
|
70
|
+
function scopeLabel(kind, filters) {
|
|
71
|
+
const p = model.periodOf(filters), end = model.payload.coverage?.[kind]?.end;
|
|
72
|
+
const day = date => `${Number(date.slice(5, 7))}/${Number(date.slice(8))}`;
|
|
73
|
+
if (p.mode === 'range') return `${day(p.start)}–${day(p.end)} · ${p.days} 天`;
|
|
74
|
+
if (p.mode !== 'month') return p.label;
|
|
75
|
+
const month = `${Number(filters.month.slice(5))} 月`;
|
|
76
|
+
if (typeof end === 'string' && end < p.start) return `${month} · 来源截至 ${day(end)}`;
|
|
77
|
+
return typeof end === 'string' && end < p.end ? `${month} · 截至 ${day(end)}` : month;
|
|
78
|
+
}
|
|
79
|
+
function Progress({ item, progress }) {
|
|
80
|
+
const ok = available(item), v = ok ? Math.max(0, Math.min(item.value, 100)) : 0;
|
|
81
|
+
return el('span', { className: 'ov-progress', 'aria-hidden': true },
|
|
82
|
+
ok && el('i', { style: { width: `${v}%` } }), progress && el('b', { style: { left: `${Math.min(Math.max(progress.value, 0), 100)}%` } }));
|
|
83
|
+
}
|
|
84
|
+
function Delta({ item, progress }) {
|
|
85
|
+
if (!available(item) || !progress) return null;
|
|
86
|
+
const diff = item.value - progress.value, ahead = diff >= 0;
|
|
87
|
+
return el('em', { className: `ov-delta ${ahead ? 'is-up' : 'is-down'}`, title: `${ahead ? '领先' : '落后'}时间进度 ${number(Math.abs(diff), 1)} 个百分点(达成 ${pct(item.value)},时间 ${pct(progress.value)})` },
|
|
88
|
+
`${ahead ? '领先' : '落后'} ${number(Math.abs(diff), 1)}`);
|
|
89
|
+
}
|
|
90
|
+
// 当月(区间)目标达成:与季度、财年同一种进度条,竖线为时间进度。
|
|
91
|
+
function MonthTarget({ targets, range }) {
|
|
92
|
+
const item = targets.attainment, progress = targets.monthProgress, ok = available(item), target = targets.month;
|
|
93
|
+
const label = range ? '区间达成' : '当月达成';
|
|
94
|
+
const title = [ok ? `${label} ${pct(item.value)};${item.note || ''}` : `${label}:${reason(item) || '待确认'}`,
|
|
95
|
+
available(target) && target.note, progress && `时间进度 ${pct(progress.value)}(${progress.days}/${progress.totalDays} 天,截至 ${progress.through})`,
|
|
96
|
+
range && '区间目标已按天数折算,不再对比时间进度'].filter(Boolean).join(';');
|
|
97
|
+
return el('div', { className: 'ov-month-target', title },
|
|
98
|
+
el('span', { className: 'ov-mt-label' }, label, el('b', {}, ok ? pct(item.value) : '—')),
|
|
99
|
+
el(Progress, { item, progress }),
|
|
100
|
+
ok ? el('span', { className: 'ov-mt-meta' }, available(target) && `目标 ${number(target.value / 10000, 2)} 万`, el(Delta, { item, progress }))
|
|
101
|
+
: el('span', { className: 'ov-mt-meta ov-period-reason' }, reason(item) || '待确认'));
|
|
102
|
+
}
|
|
103
|
+
// 季度 / 财年:累计实际 + 对全期目标的达成与时间进度。
|
|
104
|
+
function PeriodTile({ t, hasTargets, scopeKey }) {
|
|
105
|
+
const quarter = t.kind === 'quarter', att = t.attainment, ok = hasTargets && available(att);
|
|
106
|
+
const range = t.actual.range ? `${t.actual.range.start} 至 ${t.actual.range.end}` : `${t.start} 至 ${t.end}`;
|
|
107
|
+
const title = [`${quarter ? '本季度' : '本财年'}:${t.detail}`, `累计 ${range}`, !available(t.actual) && reason(t.actual),
|
|
108
|
+
hasTargets && (available(t.target) ? `全期目标 ${number(t.target.value / 10000, 2)} 万元;${t.target.note || ''}` : `目标:${reason(t.target)}`),
|
|
109
|
+
ok && `达成率 = 累计实际 ÷ 全期目标 = ${pct(att.value)}`, t.progress && `时间进度 ${pct(t.progress.value)}(${t.progress.days}/${t.progress.totalDays} 天,截至 ${t.progress.through})`].filter(Boolean).join(';');
|
|
110
|
+
return el('div', { className: `ov-period ov-period-${t.kind}`, title },
|
|
111
|
+
el('span', { className: 'ov-period-head' }, el('span', {}, quarter ? '季度' : '财年'), el('small', {}, quarter ? t.label : t.label.replace(' 财年', '')),
|
|
112
|
+
hasTargets && available(t.target) && el('span', { className: 'ov-period-target' }, `目标 ${number(t.target.value / 10000, 2)} 万`)),
|
|
113
|
+
el('span', { key: `a${scopeKey}`, className: 'ov-period-value ov-refresh' }, el(Value, { item: t.actual, digits: 2, unit: '万' })),
|
|
114
|
+
el(Progress, { item: hasTargets ? att : null, progress: t.progress }),
|
|
115
|
+
el('span', { className: 'ov-period-foot' },
|
|
116
|
+
ok ? el(g.Fragment, {}, el('span', {}, '达成 ', el('b', {}, pct(att.value)), t.progress && el('span', { className: 'ov-period-time' }, `时间 ${pct(t.progress.value)}`)), el(Delta, { item: att, progress: t.progress }))
|
|
117
|
+
: el('span', { className: 'ov-period-reason' }, hasTargets ? reason(att) || '目标待确认' : `${t.progress ? `时间进度 ${pct(t.progress.value)} · ` : ''}未上传经营目标`)));
|
|
66
118
|
}
|
|
67
119
|
function Hero({ kind, data, comparison, filters, open, drill }) {
|
|
68
|
-
const module = data.modules[kind], view = presentation.describe(kind, data, filters)
|
|
69
|
-
const ytdRatio = cross(module, 'invoiceMovementYtdRatio');
|
|
120
|
+
const module = data.modules[kind], movement = kind === 'movement', view = movement ? presentation.describe(kind, data, filters) : null;
|
|
121
|
+
const ytdRatio = cross(module, 'invoiceMovementYtdRatio'), targets = module.targets || {}, hasTargets = Boolean(targets.available);
|
|
70
122
|
const ytd = extra(module, '当年截至所选月来源金额'), negativeAmount = extra(module, '负金额合计');
|
|
123
|
+
const scopeKey = scopeKeyOf(filters), range = model.periodOf(filters).mode === 'range';
|
|
71
124
|
return el('article', { className: `overview-card ov-${kind} ov-hero`, style: { '--hero-accent': module.color }, role: 'button', tabIndex: 0, 'aria-label': `查看${module.title}详情`,
|
|
72
125
|
onClick: () => open(kind), onKeyDown: event => { if (event.target === event.currentTarget && ['Enter', ' '].includes(event.key)) { event.preventDefault(); open(kind); } } },
|
|
73
126
|
el('div', { className: 'ov-heading' }, el('i', { className: 'ov-dot', 'aria-hidden': true }), el('h2', {}, module.title), el('span', { className: 'ov-action' }, '详情 →')),
|
|
74
|
-
el('p', { className: 'ov-label' }, module.main.label),
|
|
75
|
-
el('div', { className: 'ov-hero-values' }, el('div', { className: 'ov-value', 'data-metric': kind }, el(Value, { item: module.main, digits: 2 })), el(Comparison, { item: comparison.yoy })),
|
|
127
|
+
el('p', { className: 'ov-label' }, el('span', {}, module.main.label), el('span', { className: 'ov-scope-chip' }, scopeLabel(kind, filters))),
|
|
128
|
+
el('div', { className: 'ov-hero-values' }, el('div', { key: `v${scopeKey}`, className: 'ov-value ov-refresh', 'data-metric': kind }, el(Value, { item: module.main, digits: 2 })), el(Comparison, { key: `c${scopeKey}`, item: comparison.yoy })),
|
|
129
|
+
hasTargets && el(MonthTarget, { targets, range }),
|
|
130
|
+
(targets.quarter || targets.fiscal) && el('div', { className: 'ov-periods' },
|
|
131
|
+
targets.quarter && el(PeriodTile, { t: targets.quarter, hasTargets, scopeKey }), targets.fiscal && el(PeriodTile, { t: targets.fiscal, hasTargets, scopeKey })),
|
|
76
132
|
el('div', { className: 'ov-stats' },
|
|
77
|
-
el(Stat, { label: '年累计', name: 'ytd', item: ytd, digits: 2, unit: '万', growth: comparison.ytdYoY }),
|
|
78
|
-
el(Stat, { label:
|
|
79
|
-
el(Stat, { label:
|
|
80
|
-
movement
|
|
81
|
-
: el(Stat, { label: '达成率', name: 'attainment', item: view.kpis[5], digits: 1 })),
|
|
133
|
+
el(Stat, { label: '年累计 · 1月起', name: 'ytd', item: ytd, digits: 2, unit: '万', growth: comparison.ytdYoY }),
|
|
134
|
+
el(Stat, { label: range ? '区间负金额' : '当月负金额', name: 'negative', item: negativeAmount, digits: 2, unit: '万' }),
|
|
135
|
+
movement && el(Stat, { label: '扫码终端', name: 'count', item: view.kpis[4], unit: '家' }),
|
|
136
|
+
movement && el(Stat, { label: '累计动销比', name: 'ratio', item: ytdRatio, digits: 1, unit: '%' })),
|
|
82
137
|
el(MonthlyChart, { points: comparison.monthly, kind, filters, drill }));
|
|
83
138
|
}
|
|
84
139
|
function Auxiliary({ label, item, digits = 0, unit = '' }) {
|
|
@@ -124,7 +179,7 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
124
179
|
return el('span', { className: 'ov-day-change', 'data-state': item?.state, title: detail, 'aria-label': `较昨日开瓶 ${detail}` },
|
|
125
180
|
el(Growth, { item, label }), el('span', { className: 'ov-day-values' }, bottles(item?.current), el('small', {}, ` / 昨日 ${bottles(item?.previous)}`)));
|
|
126
181
|
}
|
|
127
|
-
function Opening({ data, description, open }) {
|
|
182
|
+
function Opening({ data, description, filters, open }) {
|
|
128
183
|
const module = data.modules.opening, points = description.openingDaily, previous = description.openingPreviousDaily;
|
|
129
184
|
const valid = [...points, ...previous].filter(available), max = Math.max(0, ...valid.map(item => item.value)), min = Math.min(0, ...valid.map(item => item.value)), range = max - min || 1;
|
|
130
185
|
const x = index => 3 + index * 394 / Math.max(points.length - 1, 1), y = value => 74 - (value - min) / range * 68, baseline = y(0);
|
|
@@ -143,13 +198,13 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
143
198
|
const first = points[0]?.date, last = points.at(-1)?.date, year = first?.slice(0, 4);
|
|
144
199
|
const ticks = [...new Set([first && Number(first.slice(8)), 10, 20, last && Number(last.slice(8))])].filter(day => first && day >= Number(first.slice(8)) && day <= Number(last.slice(8))).sort((a, b) => a - b);
|
|
145
200
|
return el('button', { type: 'button', className: 'overview-card ov-opening', 'aria-label': '查看消费者开瓶详情', onClick: () => open('opening') },
|
|
146
|
-
el('span', { className: 'ov-heading' }, el('i', { className: 'ov-dot' }), el('span', {}, module.title), el('span', { className: 'ov-action' }, '→')),
|
|
201
|
+
el('span', { className: 'ov-heading' }, el('i', { className: 'ov-dot' }), el('span', {}, module.title), el('span', { className: 'ov-scope-chip' }, scopeLabel('opening', filters)), el('span', { className: 'ov-action' }, '→')),
|
|
147
202
|
el('span', { className: 'ov-opening-value' }, el('span', { className: 'ov-secondary-value', 'data-metric': 'opening' }, el(Value, { item: module.main }))),
|
|
148
203
|
el(Comparison, { item: description.openingYoY, opening: true }),
|
|
149
204
|
el(DayChange, { item: description.openingGrowth }),
|
|
150
205
|
valid.length ? el('svg', { className: 'ov-sparkline', viewBox: '0 0 400 80', preserveAspectRatio: 'none', role: 'img', 'aria-label': `${description.openingPeriod}每日开瓶;两年按相同日期比较,缺日断开` },
|
|
151
206
|
el('defs', {}, el('linearGradient', { id: 'ov-opening-fill', x1: '0', y1: '0', x2: '0', y2: '1' }, el('stop', { offset: '0', stopColor: '#4a6f94', stopOpacity: .16 }), el('stop', { offset: '1', stopColor: '#4a6f94', stopOpacity: 0 }))),
|
|
152
|
-
...paths(previous, true), ...paths(points, false)) : el('span', { className: 'ov-spark-empty' }, '
|
|
207
|
+
...paths(previous, true), ...paths(points, false)) : el('span', { className: 'ov-spark-empty' }, reason(module.main) || description.openingState?.reason || '所选期间暂无开瓶来源记录'),
|
|
153
208
|
el('span', { className: 'ov-day-axis', title: description.openingPeriod }, ...ticks.map(day => el('span', { key: day }, `${day}日`))),
|
|
154
209
|
el('span', { className: 'ov-opening-legend', title: `${description.openingPeriod};${reason(description.openingYoY)};组织口径,不随产品筛选` },
|
|
155
210
|
el('span', {}, el('i', {}), year || '本年'), el('span', { className: previous.some(available) ? '' : 'is-pending' }, el('i', { className: 'is-prior' }), year ? Number(year) - 1 : '上年'), el('span', {}, '不随产品筛选')));
|
|
@@ -159,12 +214,17 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
159
214
|
const [mode, setMode] = g.useState('movement'), listRef = g.useRef(null);
|
|
160
215
|
const scopeKey = JSON.stringify([filters.month, filters.period, filters.start, filters.end, filters.region, filters.office, filters.unit, filters.product]);
|
|
161
216
|
g.useLayoutEffect(() => { listRef.current?.scrollTo({ top: 0, behavior: 'instant' }); }, [scopeKey]);
|
|
162
|
-
|
|
217
|
+
// 只列本视图来源里出现过的组织:库存独有路径(“库存来源 · …”)不在这三个视图展示数据,不再占行。
|
|
218
|
+
const viewSources = { movement: ['invoice', 'movement'], terminal: ['terminal'], opening: ['opening'] }[mode];
|
|
219
|
+
const relevant = items.filter(row => !Array.isArray(row.sources) || row.sources.some(id => viewSources.includes(id)));
|
|
220
|
+
const hidden = items.length - relevant.length;
|
|
221
|
+
const rows = [...relevant].sort((a, b) => (available(b.invoice) ? b.invoice.value : -Infinity) - (available(a.invoice) ? a.invoice.value : -Infinity) || a.name.localeCompare(b.name, 'zh-CN'));
|
|
163
222
|
const title = filters.unit !== 'all' ? '当前单元经营' : filters.region !== 'all' ? '下级经营一览' : '区域经营一览';
|
|
164
223
|
const level = groupField === 'region' ? '大区' : groupField === 'office' ? '办事处' : '主任单元';
|
|
165
224
|
const range = rows.find(row => row.openingTotal.range?.end >= row.openingTotal.range?.start)?.openingTotal.range;
|
|
166
225
|
const openingPeriod = range ? `${range.start} 至 ${range.end}` : '共同期间待确认';
|
|
167
226
|
const subtitle = mode === 'opening' ? `年累计 · ${openingPeriod}` : mode === 'terminal' ? `${model.periodOf(filters).mode === 'range' ? `截至 ${model.periodOf(filters).end}` : '截至所选月末'} · 按终端去重` : `${model.periodOf(filters).mode === 'range' ? model.periodOf(filters).label : `${Number(filters.month.slice(5)) || '当前'} 月`} · 点击${level}下钻`;
|
|
227
|
+
const subtitleFull = mode === 'movement' && !model.targetSource ? `${subtitle} · 未上传经营目标,达成率暂缺` : subtitle;
|
|
168
228
|
const pairs = mode === 'terminal' ? [['signed', '签约'], ['effectiveCount', '有效']] : [['invoice', '发票'], ['movement', '动销']];
|
|
169
229
|
const values = rows.flatMap(row => pairs.map(([key]) => row[key]).filter(available).map(item => item.value));
|
|
170
230
|
const max = Math.max(0, ...values), min = Math.min(0, ...values), span = max - min || 1, zero = -min / span * 100;
|
|
@@ -174,6 +234,11 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
174
234
|
min < 0 && el('s', { style: { left: `${zero}%` } }), available(row[key])
|
|
175
235
|
? el('i', { className: `ov-${key}-bar${negative(row[key]) ? ' is-negative' : ''}`, style: { left: `${row[key].value >= 0 ? zero : zero + row[key].value / span * 100}%`, width: `${Math.abs(row[key].value) / span * 100}%`, minWidth: row[key].value === 0 ? '1px' : undefined } })
|
|
176
236
|
: el('em', { 'data-state': row[key].state }, '—'))));
|
|
237
|
+
const attainmentCell = (row, key) => {
|
|
238
|
+
const item = row[key], ok = available(item);
|
|
239
|
+
return el('span', { className: 'ov-att', 'data-region-metric': key, 'data-state': item?.state, title: ok ? [item.label, item.note].filter(Boolean).join(';') : reason(item) || '待确认' },
|
|
240
|
+
el('b', {}, ok ? pct(item.value, item.value >= 100 ? 0 : 1) : '—'), el('i', { 'aria-hidden': true }, ok && el('s', { style: { width: `${Math.min(Math.max(item.value, 0), 100)}%` } })));
|
|
241
|
+
};
|
|
177
242
|
function onTabKey(event, index) {
|
|
178
243
|
const next = event.key === 'ArrowRight' ? (index + 1) % modes.length : event.key === 'ArrowLeft' ? (index + modes.length - 1) % modes.length : event.key === 'Home' ? 0 : event.key === 'End' ? modes.length - 1 : null;
|
|
179
244
|
if (next === null) return;
|
|
@@ -181,7 +246,7 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
181
246
|
}
|
|
182
247
|
return el('section', { className: `overview-card ov-regional ov-region-${mode}`, 'aria-label': title, 'data-region-view': mode },
|
|
183
248
|
el('div', { className: 'ov-region-header' }, el('div', { className: 'ov-heading' }, el('i', { className: 'ov-dot' }), el('h2', {}, title), el(UpLevel, { filters, drill, compact: true })),
|
|
184
|
-
el('span', { className: 'ov-region-note', title:
|
|
249
|
+
el('span', { className: 'ov-region-note', title: subtitleFull }, subtitleFull),
|
|
185
250
|
el('div', { className: 'ov-region-tabs', role: 'tablist', 'aria-label': '区域经营视图' }, ...modes.map(([key, label], index) => el('button', {
|
|
186
251
|
key, id: `ov-region-tab-${key}`, type: 'button', role: 'tab', tabIndex: mode === key ? 0 : -1,
|
|
187
252
|
'aria-selected': mode === key, 'aria-controls': 'ov-region-panel', onClick: () => setMode(key), onKeyDown: event => onTabKey(event, index),
|
|
@@ -189,8 +254,10 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
189
254
|
el('div', { className: 'ov-region-columns' }, el('span', {}), el('span', {}, level),
|
|
190
255
|
...(mode === 'opening' ? [el('span', { key: 'total' }, '总开瓶数 / 瓶'), el('span', { key: 'rate' }, '总开瓶率')]
|
|
191
256
|
: [el('span', { key: 'legend', className: 'ov-pair-legend' }, ...pairs.map(([key, label]) => el('span', { key }, el('i', { className: `ov-${key}-bar` }), label))),
|
|
192
|
-
el('span', { key: 'first' },
|
|
193
|
-
|
|
257
|
+
...(mode === 'terminal' ? [el('span', { key: 'first' }, '签约数 / 家'), el('span', { key: 'second' }, '有效数 / 家'), el('span', { key: 'rate' }, '签约有效率')]
|
|
258
|
+
: [el('span', { key: 'first' }, '发票 / 万元'), el('span', { key: 'first-att', title: '当月(区间)发票目标达成率' }, '发票达成'),
|
|
259
|
+
el('span', { key: 'second' }, '动销 / 万元'), el('span', { key: 'second-att', title: '当月(区间)动销目标达成率' }, '动销达成'), el('span', { key: 'rate' }, '动销/发票')])])),
|
|
260
|
+
el('div', { key: `${mode}${scopeKey}`, className: 'ov-region-list', ref: listRef, id: 'ov-region-panel', role: 'tabpanel', tabIndex: 0, 'aria-labelledby': `ov-region-tab-${mode}`, 'aria-label': `${level}列表,可纵向滚动查看全部组织` },
|
|
194
261
|
...rows.map((row, index) => el('button', { key: row.key, type: 'button', className: 'ov-region-row', disabled: !row.drillable, 'data-region-key': row.key,
|
|
195
262
|
'aria-label': `${row.drillable ? '筛选' : '查看'}${row.name}`, title: row.fullName, onClick: () => row.drillable && drill(groupField, row.key) },
|
|
196
263
|
el('span', { className: 'ov-rank' }, String(index + 1).padStart(2, '0')),
|
|
@@ -198,10 +265,12 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
198
265
|
mode === 'movement' ? el('small', { title: reason(row.invoiceShare) }, '发票占比 ', el(Value, { item: row.invoiceShare, digits: 1, unit: '%' }))
|
|
199
266
|
: el('small', {}, mode === 'terminal' ? '签约终端 · 家' : '年累计 · 共同期间')),
|
|
200
267
|
...(mode === 'opening' ? [field(row, 'openingTotal'), field(row, 'openingRate', 1, '%')]
|
|
201
|
-
: [bar(row), field(row,
|
|
202
|
-
|
|
268
|
+
: mode === 'terminal' ? [bar(row), field(row, 'signed'), field(row, 'effectiveCount'), field(row, 'effectiveRate', 1, '%')]
|
|
269
|
+
: [bar(row), field(row, 'invoice', 2), attainmentCell(row, 'invoiceAttainment'), field(row, 'movement', 2), attainmentCell(row, 'movementAttainment'),
|
|
270
|
+
field(row, 'ratio', 0, '%', available(row.ratio) && row.ratio.value > 300)]))),
|
|
203
271
|
!rows.length && el('p', { className: 'ov-empty' }, '当前范围暂无组织来源记录')),
|
|
204
|
-
el('div', { className: 'ov-region-foot' }, el('span', {}, mode === 'opening' ? '累计同比 · 不随产品筛选 · — 表示待确认或缺失' : '金额下方为同比 · — 表示待确认或缺失'
|
|
272
|
+
el('div', { className: 'ov-region-foot' }, el('span', {}, mode === 'opening' ? '累计同比 · 不随产品筛选 · — 表示待确认或缺失' : '金额下方为同比 · — 表示待确认或缺失',
|
|
273
|
+
hidden > 0 && el('span', { title: '这些组织只出现在其他板块(多为库存盘点的独立路径),可在对应详情或筛选中查看' }, ` · 另有 ${hidden} 个组织本视图无来源记录,未列出`)),
|
|
205
274
|
rows.length > 3 && el('span', {}, '向下滚动查看更多')));
|
|
206
275
|
}
|
|
207
276
|
const shiftDay = (date, days) => new Date(Date.parse(`${date}T00:00:00Z`) + days * 86400000).toISOString().slice(0, 10);
|
|
@@ -252,11 +321,19 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
252
321
|
el('button', { type: 'button', className: 'period-clear', title: '全部重置:时间回到最新月份,组织和产品回到全部', 'aria-label': '全部重置', onClick: () => { drill('region', 'all'); drill('product', 'all'); drill('month', model.defaults.month); } }, '↺'),
|
|
253
322
|
el('span', { className: `period-note${issue && changed ? ' is-error' : ''}`, 'aria-live': 'polite' }, issue && changed ? issue : range ? `${period.days} 天 · 签约、库存取末日状态` : `${period.label}${bounds ? ` · 数据至 ${bounds.max.slice(5)}` : ''}`));
|
|
254
323
|
}
|
|
255
|
-
|
|
324
|
+
// 从详情返回总览时回到原来的滚动位置(筛选由外壳保留)。
|
|
325
|
+
let overviewScroll = null;
|
|
326
|
+
function Overview({ data, filters, open: openDetail, drill }) {
|
|
256
327
|
const description = g.useMemo(() => adapter.describe(data, filters), [data, filters]);
|
|
328
|
+
g.useLayoutEffect(() => {
|
|
329
|
+
if (overviewScroll === null) return;
|
|
330
|
+
const y = overviewScroll; overviewScroll = null;
|
|
331
|
+
window.scrollTo(0, y); requestAnimationFrame(() => window.scrollTo(0, y));
|
|
332
|
+
}, []);
|
|
333
|
+
const open = kind => { overviewScroll = window.scrollY; openDetail(kind); };
|
|
257
334
|
return el('div', { className: 'overview-shell', 'aria-label': '战区经营总览六板块' },
|
|
258
335
|
el(Hero, { kind: 'invoice', data, comparison: description.heroes.invoice, filters, open, drill }), el(Hero, { kind: 'movement', data, comparison: description.heroes.movement, filters, open, drill }),
|
|
259
|
-
el(Operations, { data, open }), el(Opening, { data, description, open }),
|
|
336
|
+
el(Operations, { data, open }), el(Opening, { data, description, filters, open }),
|
|
260
337
|
el(Regions, { items: description.regional, filters, groupField: data.groupField, drill }));
|
|
261
338
|
}
|
|
262
339
|
return { Overview, PeriodFilter, UpLevel };
|
|
@@ -107,6 +107,16 @@ export function createV10Presentation(model) {
|
|
|
107
107
|
let kpis = [copy(m.main), ...(m.extra || []).map(item => copy(item))];
|
|
108
108
|
const targetKpi = (item, label) => item ? copy(item, { label, displayPrecision: item.unit === '%' ? 1 : item.unit === '瓶' ? 0 : undefined, note: item.note || (item.target?.note ?? '') })
|
|
109
109
|
: pending(label, '%', '未上传经营目标', 'missing');
|
|
110
|
+
// 季度、财年(7 月起)累计实际始终展示;上传目标后追加对应达成率与时间进度。
|
|
111
|
+
const cumulativeKpis = () => ['quarter', 'fiscal'].flatMap(kind => {
|
|
112
|
+
const t = m.targets?.[kind];
|
|
113
|
+
if (!t) return [];
|
|
114
|
+
const name = kind === 'quarter' ? `季度累计(${t.label})` : `${t.label}累计`;
|
|
115
|
+
const actual = copy(t.actual, { label: name, note: `${t.detail};${t.actual.range ? `${t.actual.range.start} 至 ${t.actual.range.end}` : ''}` });
|
|
116
|
+
if (!m.targets?.available) return [actual];
|
|
117
|
+
const progress = t.progress ? `;时间进度 ${model.format(t.progress.value, 1, 1)}%(${t.progress.days}/${t.progress.totalDays} 天)` : '';
|
|
118
|
+
return [actual, targetKpi({ ...t.attainment, note: `${t.attainment.note || t.attainment.reason || ''}${progress}` }, `${kind === 'quarter' ? '季度' : '财年'}目标达成率`)];
|
|
119
|
+
});
|
|
110
120
|
const dayKpi = change => {
|
|
111
121
|
if (!change) return pending('较昨日开瓶', '%', '当前数据未提供日度比较');
|
|
112
122
|
const day = date => date ? date.slice(5) : '—', bottles = value => finite(value) ? `${model.format(value)} 瓶` : '无记录';
|
|
@@ -157,6 +167,7 @@ export function createV10Presentation(model) {
|
|
|
157
167
|
ranking.concentration = concentration(ranking.items, '当前范围发票净额合计');
|
|
158
168
|
kpis = [copy(m.main), existing('正金额合计', '元'), existing('负金额合计', '元'), existing('当年截至所选月来源金额', '元'),
|
|
159
169
|
distinct(rows, 'dealerCode', '来源经销商数'), targetKpi(m.targets?.attainment, '目标达成率')];
|
|
170
|
+
kpis.push(...cumulativeKpis());
|
|
160
171
|
if (m.targets?.available) kpis.push(targetKpi(m.targets.ytdAttainment, '年累计目标达成率'), targetKpi(m.targets.month, p.mode === 'range' ? '区间目标' : '当月目标'), targetKpi(m.targets.ytd, '年累计目标'));
|
|
161
172
|
}
|
|
162
173
|
if (kind === 'movement') {
|
|
@@ -166,6 +177,7 @@ export function createV10Presentation(model) {
|
|
|
166
177
|
channels = group(rows, row => row.channel, row => row.channel, 'amount', '元', '来源渠道净额', row => text(row.channel));
|
|
167
178
|
kpis = [copy(m.main), existing('扫码数量(瓶单位记录)', '瓶'), existing('负金额合计', '元'), existing('当年截至所选月来源金额', '元'),
|
|
168
179
|
distinct(rows, 'terminalCode', '来源扫码终端数'), cross('invoiceMovementYtdRatio', '年累计动销 / 开票', '%')];
|
|
180
|
+
kpis.push(...cumulativeKpis());
|
|
169
181
|
if (m.targets?.available) kpis.push(targetKpi(m.targets.attainment, '目标达成率'), targetKpi(m.targets.ytdAttainment, '年累计目标达成率'), targetKpi(m.targets.month, p.mode === 'range' ? '区间目标' : '当月目标'));
|
|
170
182
|
notes.push(...['扫码数量(盒单位记录)', '来源扫码件数'].map(label => { const metric = existing(label); return `${label}:${model.formatMetric(metric)}${metric.state === 'available' ? ` ${metric.unit}` : ''}。`; }));
|
|
171
183
|
notes.push('负金额合计只按源金额符号汇总,不将所有负金额推定为退货出库。');
|
|
@@ -12,7 +12,7 @@ import { createV10Overview } from './v10-overview.mjs';
|
|
|
12
12
|
export { createV10Model } from './v10-model.mjs';
|
|
13
13
|
export const V10_TEMPLATE_SHA256 = 'b58e609411d0b9ab2d77d7079ea580e8210d11946999a8c11cea1fc34bf9b886';
|
|
14
14
|
export const V10_SCRIPT_SHA256 = 'd11a689940d80a4010c5f45786ac2da7d3106cb8309216b4df2d55c8dac4599c';
|
|
15
|
-
export const V10_RENDERER_VERSION =
|
|
15
|
+
export const V10_RENDERER_VERSION = 20;
|
|
16
16
|
export const V10_SHELL_SHA256 = 'd5118e6e2ec447cc22992c348e18ae719bfbda959a2b694352843c120522a5f1';
|
|
17
17
|
const APPLICATION_MARKER = '/*__V10_APPLICATION__*/';
|
|
18
18
|
const IDS = ['invoice', 'movement', 'opening', 'terminal', 'inventory', 'banquet'];
|
|
@@ -50,7 +50,9 @@ export function sanitizeV10Payload(input) {
|
|
|
50
50
|
for (const key of ['organizationMapping', 'terminalIdentity', 'crossTableMetrics', 'banquetOpeningSubset', 'banquetReward', 'inventoryValuationBasis']) {
|
|
51
51
|
const rule = contract[key];
|
|
52
52
|
if (!rule) continue;
|
|
53
|
-
|
|
53
|
+
// Organization mapping v2 reports its own path-verified status (v10 业务确认 2026-11-26).
|
|
54
|
+
const statuses = key === 'organizationMapping' ? ['applied', 'partial', 'invalid', 'not-configured', 'confirmed', 'pending'] : ['confirmed', 'pending', 'not-guaranteed'];
|
|
55
|
+
if (!isObject(rule) || !statuses.includes(rule.status)) fail(`规则 ${key} 状态无效`);
|
|
54
56
|
const clean = { status: rule.status };
|
|
55
57
|
for (const field of ['sources', 'appliedSources']) if (rule[field]) {
|
|
56
58
|
if (!isObject(rule[field])) fail(`规则 ${key} 来源绑定无效`);
|
package/backend/server.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const knownModules = new Set(moduleDefinitions.map(m => m.id));
|
|
|
27
27
|
const CYCLES = ['daily', 'weekly', 'monthly', 'irregular'];
|
|
28
28
|
export const DEFAULT_CYCLES = { invoice: 'daily', movement: 'daily', opening: 'daily', terminal: 'weekly', inventory: 'monthly', banquet: 'irregular', target: 'monthly' };
|
|
29
29
|
const publicFiles = new Map([['/', ['board.html', 'text/html; charset=utf-8']], ['/board', ['board.html', 'text/html; charset=utf-8']], ['/admin', ['index.html', 'text/html; charset=utf-8']], ['/board.js', ['board.js', 'text/javascript; charset=utf-8']], ['/board.css', ['board.css', 'text/css; charset=utf-8']], ['/admin.js', ['admin.js', 'text/javascript; charset=utf-8']], ['/admin.css', ['admin.css', 'text/css; charset=utf-8']]]);
|
|
30
|
-
for (const [file, type] of [['review.js', 'text/javascript'], ['review.css', 'text/css']]) publicFiles.set(`/${file}`, [file, `${type}; charset=utf-8`]);
|
|
30
|
+
for (const [file, type] of [['review.js', 'text/javascript'], ['review.css', 'text/css'], ['org-mapping.js', 'text/javascript']]) publicFiles.set(`/${file}`, [file, `${type}; charset=utf-8`]);
|
|
31
31
|
|
|
32
32
|
class RequestError extends Error {
|
|
33
33
|
constructor(status, message, extra = {}) { super(message); this.status = status; this.extra = extra; }
|
|
@@ -144,11 +144,34 @@ export async function createAdminServer({ port = 4180, dataDir = DEFAULT_DATA_DI
|
|
|
144
144
|
} catch {}
|
|
145
145
|
try {
|
|
146
146
|
const result = await workerJob({ kind: 'coverage', file: resolve(directory, 'source.xlsx'), validation: upload.validation, moduleId: upload.moduleId }, () => {}, log);
|
|
147
|
-
|
|
147
|
+
// Write the cache file before publishing the range, so a reader that sees it can also find the file.
|
|
148
148
|
await atomicJson(resolve(directory, 'coverage.json'), { sha256: upload.sha256, start: result.start, end: result.end }).catch(log);
|
|
149
|
+
coverageCache.set(upload.id, { start: result.start, end: result.end });
|
|
149
150
|
} catch (error) { log(error.stack); coverageCache.set(upload.id, { start: null, end: null }); }
|
|
150
151
|
}
|
|
151
152
|
}
|
|
153
|
+
// Generations made before the mapping summary was recorded (2026-11-26) show
|
|
154
|
+
// the old rule's status from their own diagnostics.json, read once, kept in
|
|
155
|
+
// memory only; state.json and the files are not rewritten.
|
|
156
|
+
const legacyMapping = new Map();
|
|
157
|
+
const LEGACY_PATTERN = /"organizationMapping":\{"version":1,"status":"([a-z-]{1,20})"/;
|
|
158
|
+
async function legacyMappingStatus(id) {
|
|
159
|
+
let tail = '';
|
|
160
|
+
for await (const chunk of createReadStream(resolve(dataDir, 'generations', id, 'diagnostics.json'), { encoding: 'utf8', highWaterMark: 1 << 20 })) {
|
|
161
|
+
const match = LEGACY_PATTERN.exec(tail + chunk);
|
|
162
|
+
if (match) return match[1];
|
|
163
|
+
tail = chunk.slice(-200);
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
async function fillLegacyMapping() {
|
|
168
|
+
for (const job of [...store.state.generations].reverse()) {
|
|
169
|
+
if (closing) return;
|
|
170
|
+
if (job.status !== 'completed' || job.organizationMapping || legacyMapping.has(job.id) || !/^[a-f0-9-]{36}$/.test(job.id)) continue;
|
|
171
|
+
legacyMapping.set(job.id, await legacyMappingStatus(job.id).catch(() => null));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const withLegacyMapping = job => job.status !== 'completed' || job.organizationMapping || !legacyMapping.get(job.id) ? job : { ...job, legacyOrganizationMappingStatus: legacyMapping.get(job.id) };
|
|
152
175
|
const refreshCoverage = () => { if (coverageRun || closing) return; coverageRun = track(fillCoverage().catch(log).finally(() => { coverageRun = null; })); };
|
|
153
176
|
function view() {
|
|
154
177
|
return {
|
|
@@ -160,7 +183,7 @@ export async function createAdminServer({ port = 4180, dataDir = DEFAULT_DATA_DI
|
|
|
160
183
|
reviewStatus: store.state.uploads.find(u => u.id === (store.state.candidates?.[m.id] || store.state.active[m.id]))?.reviewStatus ?? 'unchecked' })),
|
|
161
184
|
reviewRevision: store.state.review?.revision ?? 0,
|
|
162
185
|
uploads: [...store.state.uploads].reverse().map(withCoverage),
|
|
163
|
-
generations: [...store.state.generations].reverse().map(job => ({ ...job, ...(job.status === 'completed' ? { viewUrl: `/api/generations/${job.id}/view`, downloadUrl: `/api/generations/${job.id}/download` } : {}) })),
|
|
186
|
+
generations: [...store.state.generations].reverse().map(withLegacyMapping).map(job => ({ ...job, ...(job.status === 'completed' ? { viewUrl: `/api/generations/${job.id}/view`, downloadUrl: `/api/generations/${job.id}/download` } : {}) })),
|
|
164
187
|
busy,
|
|
165
188
|
settings: { cycles: { ...DEFAULT_CYCLES, ...(store.state.settings?.cycles || {}) } },
|
|
166
189
|
};
|
|
@@ -531,6 +554,7 @@ export async function createAdminServer({ port = 4180, dataDir = DEFAULT_DATA_DI
|
|
|
531
554
|
actualPort = server.address().port;
|
|
532
555
|
} catch (error) { await store.release(); throw error; }
|
|
533
556
|
refreshCoverage();
|
|
557
|
+
track(fillLegacyMapping().catch(log));
|
|
534
558
|
return {
|
|
535
559
|
server, port: actualPort, url: `http://127.0.0.1:${actualPort}/`, dataDir,
|
|
536
560
|
async close() {
|
package/build-manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-data-dashboard",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"builtAt": "2026-11-
|
|
5
|
-
"sourceCommit": "
|
|
6
|
-
"sourceDirty":
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"builtAt": "2026-11-27T01:17:00.339Z",
|
|
5
|
+
"sourceCommit": "e405e18a01cf4ba970551ba47ad0367fdfc025da",
|
|
6
|
+
"sourceDirty": false,
|
|
7
7
|
"files": {
|
|
8
8
|
"README.md": "ae7f24665cd16f9d729d719ef2335c328d14e0c8b791e40c5c39c8a61d8783d6",
|
|
9
9
|
"assets/theater-board.svg": "896b0573d86494e4c31b11bde56cecd517b509bd3bf940a24742ac565f164afc",
|
|
@@ -20,32 +20,33 @@
|
|
|
20
20
|
"backend/modules/opening/index.mjs": "e6f11fc58689848251511ac332cdc3ffc419d7907adcabd3b7440985bcf410fc",
|
|
21
21
|
"backend/modules/target/index.mjs": "d644e882b3b7476c6b8b8985f23aa714b15b0ac902a880137bbf951ac407ee6d",
|
|
22
22
|
"backend/modules/terminal/index.mjs": "cd65735c7dd277e7bc137e9d49c5e15f5b5d99da7c91e93480711351a6f016ea",
|
|
23
|
-
"backend/public/admin.css": "
|
|
24
|
-
"backend/public/admin.js": "
|
|
25
|
-
"backend/public/board.css": "
|
|
26
|
-
"backend/public/board.html": "
|
|
27
|
-
"backend/public/board.js": "
|
|
28
|
-
"backend/public/index.html": "
|
|
23
|
+
"backend/public/admin.css": "085ef21c7dee63aedb4b7b4eefe99b7d913581d23085933edfc270abf9720897",
|
|
24
|
+
"backend/public/admin.js": "47cf02725ba2f8570ff79f3e83131667217ac3196ca9bbccc95c9152ef1cbe07",
|
|
25
|
+
"backend/public/board.css": "c7a03188cfbb9f174f0375d48f511a454b60eb58dc4bf0a7e469633e43f12a91",
|
|
26
|
+
"backend/public/board.html": "e731c85e60aa1acd8ae3fca73094754b3d6b8254313e359b3d93a85a2b82d264",
|
|
27
|
+
"backend/public/board.js": "76b71d3dc156b84f0e6042c6958a6ecb7702dea42cb978b0df84129d1fa04f6d",
|
|
28
|
+
"backend/public/index.html": "ee6513a26671f374696cd3b4d6dc6ffcbb9f4935ee6fca36adb1ec56279768ec",
|
|
29
|
+
"backend/public/org-mapping.js": "66ac67a2efa3405d1cb705e4d61ec20307e54142818bac6993e7585a8d5ead5b",
|
|
29
30
|
"backend/public/review.css": "6fd7366dccd877335f0897577f8cb56a30a2232fe0e779bef84d75757b78b56f",
|
|
30
31
|
"backend/public/review.js": "cd6bd9ad50e458bc13d7a6b41c6c2ad800cf297a05279a7908b02518bc4ae53c",
|
|
31
|
-
"backend/real-data/generate-dashboard.mjs": "
|
|
32
|
+
"backend/real-data/generate-dashboard.mjs": "e9d88b345ef35651f22b713c9ec88687df24e794f5ee85870cb76c7ece642766",
|
|
32
33
|
"backend/real-data/inventory-history.mjs": "863345fc46ef2c66e1f5279823f408a7ee2b78a421574176c7221b79d44d5a50",
|
|
33
|
-
"backend/real-data/organization-mapping.mjs": "
|
|
34
|
+
"backend/real-data/organization-mapping.mjs": "4e64d9a1930f774f24a3d8d544a9aad4877bc1f1c5010a69fbde1b022348f1c4",
|
|
34
35
|
"backend/real-data/source-payload.mjs": "f2f04697dac7ee7d62f5bb1f3304b552118ff8854c8dae7fb4e0575d4fdb3679",
|
|
35
36
|
"backend/real-data/terminal-components.mjs": "e7c7399e9459964d25cee0c0f7d72834e6480603d6c64b9f41c581319db9c12a",
|
|
36
37
|
"backend/real-data/terminal-structure.css": "17ca1107abff93b48e5d129a3943b01b2f6ff7113eeede589f51634861069e26",
|
|
37
38
|
"backend/real-data/terminal-structure.mjs": "a06b4f0eb91e0c2aea6c8f75ff898017787a4269d4e1630866fb31796ead462e",
|
|
38
|
-
"backend/real-data/v10-components.mjs": "
|
|
39
|
+
"backend/real-data/v10-components.mjs": "f83ff9ac02c2ac814069740e6d08a237c5c2f358c6e5b0be1a749684e9183343",
|
|
39
40
|
"backend/real-data/v10-details.css": "a0c12a87ea7fd2974051f0e7b6c00a6057fe8e60515abd6c53aa52b93e8cf924",
|
|
40
41
|
"backend/real-data/v10-details.mjs": "740c3246fbf5fbbd8ae806dc3e042f4a8d5ce9cea31553fe45a1ea77a6514195",
|
|
41
42
|
"backend/real-data/v10-layout.css": "2efc29f10d984a8629ef87aae1c72cbdc09658a3553407732c2359931a66cdbd",
|
|
42
|
-
"backend/real-data/v10-model.mjs": "
|
|
43
|
-
"backend/real-data/v10-overview-data.mjs": "
|
|
44
|
-
"backend/real-data/v10-overview.css": "
|
|
45
|
-
"backend/real-data/v10-overview.mjs": "
|
|
46
|
-
"backend/real-data/v10-presentation.mjs": "
|
|
43
|
+
"backend/real-data/v10-model.mjs": "0f3fddedf6284d897a88ba29014ec4879c5433ba59c6b6344218f884507824d4",
|
|
44
|
+
"backend/real-data/v10-overview-data.mjs": "54835189ee28f8fb5c27f399d9d74dc1bf7ebf5f4a9f66f2c0a2e13455ca4eeb",
|
|
45
|
+
"backend/real-data/v10-overview.css": "296050d284913ffc52ac89672ff212bf96592785a5491e574a8bf4c990363a99",
|
|
46
|
+
"backend/real-data/v10-overview.mjs": "9cf6aff3304039dde3bcaa205607e9f64553b0645242436a5be9ba8469f55ecc",
|
|
47
|
+
"backend/real-data/v10-presentation.mjs": "2b23265c8cc2e8caf3982b6ceea494b25ebd4c4f078097aa635ddd5970cfeb86",
|
|
47
48
|
"backend/real-data/v10-shell.html": "d5118e6e2ec447cc22992c348e18ae719bfbda959a2b694352843c120522a5f1",
|
|
48
|
-
"backend/real-data/v10-template.mjs": "
|
|
49
|
+
"backend/real-data/v10-template.mjs": "375258305a3d15454b3cf0088fdda5ad0164b023228539257ed81947bf220253",
|
|
49
50
|
"backend/recognition/fingerprint.mjs": "652340bf7b1f1617c03d53e5c5724154ffabc262c0a522e498ba015671420528",
|
|
50
51
|
"backend/recognition/headers.mjs": "1cadc4fb39b8a1d7decddae666c827b00903b7f14cfd9e7f4974f2042f07fc02",
|
|
51
52
|
"backend/recognition/module-definition.mjs": "2aaea663fcc2a52c193637135ad762c7c2af35da96aa12d89742ab6606ed7801",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
"backend/recognition/upload-limits.mjs": "8fde2d6c62ab7f0bfa1a945d34efc462087b895fd25e92cf5d5c34c97d738ace",
|
|
54
55
|
"backend/review-engine.mjs": "9c13e5684b4697f09b5bda808266095ae3acd40474124d4dd021ff067b547e1d",
|
|
55
56
|
"backend/review-service.mjs": "c9d4526b952e07c7c9a5d9c5ef9ccaf6bd108527057dd605e24107312d1bb02f",
|
|
56
|
-
"backend/server.mjs": "
|
|
57
|
+
"backend/server.mjs": "1f1bf71cfbf05331b1602b6d6c1f2f7adf7d6e94cbedd992b3b9cb66688ca896",
|
|
57
58
|
"backend/store.mjs": "1e74edc99a577fa9a72a43722a35b6cee7c0c5582b49a5786bbc676412602f0b",
|
|
58
59
|
"backend/target-template.mjs": "fa33f13b8ee56da7a2bc44c1c474d879817e270bddad03350799143f7fe78b43",
|
|
59
60
|
"backend/validate-workbook.mjs": "2f86c034e4af578b7971486e81e86912f69a086c877c516223350b52931cc377",
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"backend/web-sync/exporter.mjs": "b74a1bef8f072242b12d8a683f6cf42744da925c478558c2c7306fd2ab282130",
|
|
63
64
|
"backend/web-sync/local.html": "baa1606eac3438fcbab366fd0336a210126ff0a924e5c369b529784a6ade2609",
|
|
64
65
|
"backend/web-sync/server.mjs": "2b0dd216db6cccf1f641e372394109654fea018780825a6a7bd52d126636043e",
|
|
65
|
-
"client.js": "
|
|
66
|
+
"client.js": "a849fe79c38810c963b42a21232889a53e033bdf72ce2b0568dfaac9caa4755b",
|
|
66
67
|
"cordis.patch.yml": "9c21f648e3a89752d07d2db65b1236330b8489b584ddfc63f98be9d9e3116133",
|
|
67
68
|
"index.js": "b851c33fb87bc02aa3c95d9c236a21865501fcda0576ffa568ae2eabdb73954e",
|
|
68
69
|
"lib/dist-manifest.mjs": "92ea95c04d108b62e9c513eb7330914a24fbc46b5a4a0869ee0fca1cfb7418fe",
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
"lib/tools.mjs": "78cf680319cc2e5868b01c76c55a369ee034e9a5be2dc6a3865462dd1ed2c172",
|
|
74
75
|
"locale/en.json": "e7a5b39324d6162e7d29957fbc7a0f4bde9c588de2000c874f058df5520f472c",
|
|
75
76
|
"locale/zh.json": "dd29dcecb35aa6e95a295af228fd39f833c1f492cc5ca41567bb6945ab134510",
|
|
76
|
-
"package-lock.json": "
|
|
77
|
-
"package.json": "
|
|
77
|
+
"package-lock.json": "4f21205e3a251a6fe55654efcef180a92a9229f65f574738d5d86edecf5da709",
|
|
78
|
+
"package.json": "12c40f4aa60dac9e9e137cc000094f8f8db0859aa3c04137cafcbb8a9f600fd7"
|
|
78
79
|
}
|
|
79
80
|
}
|
package/client.js
CHANGED
|
@@ -10,15 +10,45 @@ const LOOPBACK=['127.0.0.1','localhost'];
|
|
|
10
10
|
function BoardIcon({size}){const s=size||20;return h('svg',{width:s,height:s,viewBox:'0 0 24 24',fill:'none',stroke:'currentColor',strokeWidth:1.8,strokeLinejoin:'round','aria-hidden':true},h('rect',{x:3.5,y:3.5,width:7,height:9,rx:1.5}),h('rect',{x:13.5,y:3.5,width:7,height:5,rx:1.5}),h('rect',{x:13.5,y:11.5,width:7,height:9,rx:1.5}),h('rect',{x:3.5,y:15.5,width:7,height:5,rx:1.5}))}
|
|
11
11
|
// DSH Web on loopback keeps its own hostname (same-site with the backend);
|
|
12
12
|
// the DSH desktop window (dsh-app://app) uses 127.0.0.1.
|
|
13
|
-
|
|
13
|
+
const isDesktop=loc=>loc.protocol==='dsh-app:'&&loc.hostname==='app';
|
|
14
|
+
// The ?host=dsh-desktop marker only asks the board page to report its top-bar
|
|
15
|
+
// geometry; the backend's iframe admission checks the pathname, not the query.
|
|
16
|
+
function boardUrl(port,where){const loc=where||location;if(LOOPBACK.includes(loc.hostname)&&(loc.protocol==='http:'||loc.protocol==='https:'))return`http://${loc.hostname}:${port}/`;if(isDesktop(loc))return`http://127.0.0.1:${port}/?host=dsh-desktop`;return null}
|
|
17
|
+
// DSH desktop (DSH插件 4.1): Electron ignores -webkit-app-region inside the
|
|
18
|
+
// cross-origin board iframe, so the host lays a transparent drag layer over the
|
|
19
|
+
// board's top bar. The layer has pointer-events:none and holes (no-drag) over
|
|
20
|
+
// the bar's controls: the window drag is decided by geometry, every other
|
|
21
|
+
// click falls through to the iframe. Geometry comes only from the board frame
|
|
22
|
+
// itself (origin http://127.0.0.1:<port> and source === that frame's window);
|
|
23
|
+
// without a valid message there is no layer, so nothing can block clicks.
|
|
24
|
+
const MAX_HOLES=32;
|
|
25
|
+
function box(v,limit){if(!Array.isArray(v)||v.length!==4||!v.every(n=>typeof n==='number'&&Number.isFinite(n)))return null;const[x,y,w,hh]=v;if(w<=0||hh<=0||w>limit||hh>limit||Math.abs(x)>limit||Math.abs(y)>limit)return null;return{left:x,top:y,width:w,height:hh}}
|
|
26
|
+
function readDragRegion(event,expectedOrigin,frameWindow){
|
|
27
|
+
if(event.origin!==expectedOrigin||!frameWindow||event.source!==frameWindow)return null;
|
|
28
|
+
const d=event.data;if(!d||typeof d!=='object'||d.type!=='theater-board:drag-region'||d.version!==1)return null;
|
|
29
|
+
const bar=box(d.bar,20000);if(!bar||bar.height>200)return null;
|
|
30
|
+
if(!Array.isArray(d.holes)||d.holes.length>MAX_HOLES)return null;
|
|
31
|
+
const holes=d.holes.map(v=>box(v,20000));if(holes.some(v=>!v))return null;
|
|
32
|
+
return{bar,holes}}
|
|
33
|
+
const abs=r=>({position:'absolute',left:r.left,top:r.top,width:r.width,height:r.height,pointerEvents:'none'});
|
|
34
|
+
function DragLayer({region}){
|
|
35
|
+
return h(React.Fragment,null,h('div',{'data-theater-drag':'bar',style:{...abs(region.bar),WebkitAppRegion:'drag'}}),
|
|
36
|
+
...region.holes.map((r,i)=>h('div',{key:i,'data-theater-drag':'hole',style:{...abs(r),WebkitAppRegion:'no-drag'}})))}
|
|
14
37
|
function makePage(readPort){return function TheaterBoardPage(){
|
|
15
38
|
const port=readPort();const src=boardUrl(port);
|
|
39
|
+
const desktop=!!src&&isDesktop(location);
|
|
40
|
+
const frame=React.useRef(null);const[region,setRegion]=React.useState(null);
|
|
41
|
+
React.useEffect(()=>{if(!desktop)return;const origin=`http://127.0.0.1:${port}`;
|
|
42
|
+
const onMessage=event=>{const next=readDragRegion(event,origin,frame.current&&frame.current.contentWindow);if(next)setRegion(next)};
|
|
43
|
+
window.addEventListener('message',onMessage);return()=>window.removeEventListener('message',onMessage)},[desktop,port]);
|
|
16
44
|
if(!src)return h('div',{style:{padding:32,lineHeight:1.7}},'战区看板只能在本机的 DeepSeek Harness 中使用(桌面版,或地址为 127.0.0.1 / localhost 的网页版)。');
|
|
17
|
-
|
|
45
|
+
const iframe=h('iframe',{ref:frame,src,title:'战区经营看板',style:{display:'block',width:'100%',height:'100%',border:0,background:'#fff'}});
|
|
46
|
+
if(!desktop)return iframe;
|
|
47
|
+
return h('div',{style:{position:'relative',width:'100%',height:'100%'}},iframe,region?h(DragLayer,{region}):null)}}
|
|
18
48
|
const inject=['slots'];
|
|
19
49
|
function apply(ctx,config){
|
|
20
50
|
const readPort=()=>{try{const v=config&&config.port&&config.port.get();return Number.isInteger(v)?v:DEFAULT_PORT}catch{return DEFAULT_PORT}};
|
|
21
51
|
ctx.slots.inject('main',()=>ctx.slots.register({name:'main',key:PANEL_ID},makePage(readPort)));
|
|
22
52
|
ctx.slots.inject('sidebar.panellist',()=>ctx.slots.register({name:'sidebar.panellist',id:PANEL_ID,order:50,label:'战区看板'},BoardIcon));
|
|
23
53
|
}
|
|
24
|
-
exports.apply=apply;exports.inject=inject;exports.boardUrl=boardUrl;return module.exports}});
|
|
54
|
+
exports.apply=apply;exports.inject=inject;exports.boardUrl=boardUrl;exports.readDragRegion=readDragRegion;return module.exports}});
|