dsh-data-dashboard 0.1.5 → 0.1.6
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/incremental/flow.mjs +32 -13
- package/backend/modules/banquet/index.mjs +11 -33
- package/backend/modules/distributor/index.mjs +28 -0
- package/backend/modules/opening/index.mjs +1 -1
- package/backend/modules/tunzhihu/index.mjs +27 -0
- package/backend/modules/zang10/index.mjs +30 -0
- package/backend/modules.mjs +4 -1
- package/backend/public/admin.js +12 -8
- package/backend/public/board.js +1 -1
- package/backend/real-data/source-payload.mjs +116 -19
- package/backend/real-data/v10-components.mjs +5 -4
- package/backend/real-data/v10-details.mjs +27 -13
- package/backend/real-data/v10-model.mjs +59 -12
- package/backend/real-data/v10-overview-data.mjs +49 -14
- package/backend/real-data/v10-overview.css +37 -18
- package/backend/real-data/v10-overview.mjs +88 -75
- package/backend/real-data/v10-presentation.mjs +44 -30
- package/backend/real-data/v10-template.mjs +41 -5
- package/backend/review-engine.mjs +13 -2
- package/backend/server.mjs +1 -1
- package/build-manifest.json +27 -24
- package/lib/tool-definitions.mjs +2 -2
- package/lib/tools.mjs +5 -1
- package/package.json +1 -1
|
@@ -34,8 +34,8 @@ export function createV10OverviewData(model, presentation) {
|
|
|
34
34
|
for (const item of values) { const next = item - correction, updated = value + next; correction = (updated - value) - next; value = updated; }
|
|
35
35
|
return value;
|
|
36
36
|
};
|
|
37
|
-
function windowMetric(id, module, start, end, requireMonths = false) {
|
|
38
|
-
const field = id === 'opening' ? 'bottles' : 'amount', unit =
|
|
37
|
+
function windowMetric(id, module, start, end, requireMonths = false, fieldOverride = null) {
|
|
38
|
+
const field = fieldOverride || (id === 'opening' ? 'bottles' : 'amount'), unit = field === 'bottles' ? '瓶' : '元';
|
|
39
39
|
const fail = (reason, state = 'missing') => ({ ...pending('同期来源合计', unit, reason, state), range: { start, end } });
|
|
40
40
|
const source = model.payload.modules[id], cover = model.payload.coverage[id];
|
|
41
41
|
if (source.state === 'unavailable') return fail('未接入有效来源');
|
|
@@ -58,21 +58,43 @@ export function createV10OverviewData(model, presentation) {
|
|
|
58
58
|
return { label: '同期来源合计', unit, value, state: 'available', reason: null, range: { start, end },
|
|
59
59
|
negative: id === 'opening' ? null : sum(rows.filter(row => row.amount < 0).map(row => row.amount)) };
|
|
60
60
|
}
|
|
61
|
-
function yearComparison(id, module, filters, cumulative = false, fixedRange = null) {
|
|
61
|
+
function yearComparison(id, module, filters, cumulative = false, fixedRange = null, field = null) {
|
|
62
62
|
const p = periodOf(filters), range = p.mode === 'range';
|
|
63
63
|
const label = cumulative ? '累计同比' : range ? '区间同比' : '当月同比', cover = model.payload.coverage[id];
|
|
64
64
|
const month = range ? p.month : filters.month, validMonth = /^\d{4}-(0[1-9]|1[0-2])$/.test(month || '');
|
|
65
65
|
const start = fixedRange?.start || (validMonth ? cumulative ? `${month.slice(0, 4)}-01-01` : range ? p.start : `${month}-01` : null);
|
|
66
66
|
const end = fixedRange?.end || (validMonth && validDate(cover?.end) ? [range ? p.end : monthEnd(month), cover.end].sort()[0] : null);
|
|
67
|
-
const current = windowMetric(id, module, start, end, cumulative);
|
|
67
|
+
const current = windowMetric(id, module, start, end, cumulative, field);
|
|
68
68
|
const previous = windowMetric(id, module, validDate(start) ? priorDate(start) : null,
|
|
69
|
-
validDate(end) ? priorDate(end, end === monthEnd(end.slice(0, 7))) : null, cumulative);
|
|
69
|
+
validDate(end) ? priorDate(end, end === monthEnd(end.slice(0, 7))) : null, cumulative, field);
|
|
70
70
|
let reason = !ready(current) ? `本期:${current.reason}` : !ready(previous) ? `去年同期:${previous.reason}` : previous.value <= 0 ? '去年同期为零或负数,不计算增长率' : null;
|
|
71
71
|
const value = reason ? null : (current.value - previous.value) / previous.value * 100;
|
|
72
72
|
if (!reason && !finite(value)) reason = '同比超出可表示范围';
|
|
73
73
|
return { label, unit: '%', value: reason ? null : value, state: reason ? 'pending' : 'available', reason,
|
|
74
74
|
current, previous, range: { start, end }, notes: validDate(start) && validDate(end) ? [`${start} 至 ${end};对比 ${previous.range.start} 至 ${previous.range.end}`] : [] };
|
|
75
75
|
}
|
|
76
|
+
// 环比:本期对上月同一段日期(日数超出上月天数时取上月月末),来源须覆盖两段。
|
|
77
|
+
function monthComparison(id, module, filters, field = null) {
|
|
78
|
+
const p = periodOf(filters), cover = model.payload.coverage[id];
|
|
79
|
+
const month = p.mode === 'range' ? p.month : filters.month;
|
|
80
|
+
if (!/^\d{4}-(0[1-9]|1[0-2])$/.test(month || '') || !validDate(cover?.end)) return pending('环比', '%', '所选期间无法定位上月同期');
|
|
81
|
+
const start = p.mode === 'range' ? p.start : `${month}-01`, end = [p.mode === 'range' ? p.end : monthEnd(month), cover.end].sort()[0];
|
|
82
|
+
if (end < start) return pending('环比', '%', '本期尚无来源记录', 'missing');
|
|
83
|
+
const back = date => { const y = Number(date.slice(0, 4)), m = Number(date.slice(5, 7)) - 1, prior = m === 0 ? `${y - 1}-12` : `${y}-${String(m).padStart(2, '0')}`; return `${prior}-${String(Math.min(Number(date.slice(8)), Number(monthEnd(prior).slice(8)))).padStart(2, '0')}`; };
|
|
84
|
+
const current = windowMetric(id, module, start, end, false, field), previous = windowMetric(id, module, back(start), back(end), false, field);
|
|
85
|
+
let reason = !ready(current) ? `本期:${current.reason}` : !ready(previous) ? `上月同期:${previous.reason}` : previous.value <= 0 ? '上月同期为零或负数,不计算环比' : null;
|
|
86
|
+
const value = reason ? null : (current.value - previous.value) / previous.value * 100;
|
|
87
|
+
return { label: '环比', unit: '%', value, state: reason ? 'pending' : 'available', reason, current, previous, range: { start, end }, notes: [`${start} 至 ${end};对比 ${previous.range.start} 至 ${previous.range.end}`] };
|
|
88
|
+
}
|
|
89
|
+
// 季度累计同比:季度首日至所选期间末日(不晚于来源截止日),对比去年同一段日期。
|
|
90
|
+
function quarterComparison(id, module, filters) {
|
|
91
|
+
const t = module.targets?.quarter, cover = model.payload.coverage[id];
|
|
92
|
+
if (!t || !validDate(t.start) || !validDate(t.end)) return pending('季度同比', '%', '所选期间无法定位季度');
|
|
93
|
+
if (!validDate(cover?.end)) return pending('季度同比', '%', '来源截止日期缺失');
|
|
94
|
+
const end = [t.end, cover.end].sort()[0];
|
|
95
|
+
if (end < t.start) return pending('季度同比', '%', '本季度尚无来源记录', 'missing');
|
|
96
|
+
return { ...yearComparison(id, module, filters, false, { start: t.start, end }), label: '季度同比' };
|
|
97
|
+
}
|
|
76
98
|
function yearMonths(id, module, filters) {
|
|
77
99
|
const year = Number(filters.month.slice(0, 4)), selected = Number(filters.month.slice(5));
|
|
78
100
|
if (!Number.isInteger(year) || !selected) return [];
|
|
@@ -92,9 +114,9 @@ export function createV10OverviewData(model, presentation) {
|
|
|
92
114
|
if (!validDate(previous.range.start) || !validDate(previous.range.end) || !validDate(cover?.start) || !validDate(cover?.end)
|
|
93
115
|
|| cover.start > previous.range.start || cover.end < previous.range.end) return [];
|
|
94
116
|
const scoped = module.scopedRows || [], byDay = new Map();
|
|
95
|
-
const blocked = scoped.some(row => !validDate(row.date)) || model.payload.modules.opening.metrics?.
|
|
117
|
+
const blocked = scoped.some(row => !validDate(row.date)) || model.payload.modules.opening.metrics?.amount?.status === 'pending';
|
|
96
118
|
for (const row of scoped) if (row.date >= previous.range.start && row.date <= previous.range.end) {
|
|
97
|
-
if (!byDay.has(row.date)) byDay.set(row.date, []); byDay.get(row.date).push(row.
|
|
119
|
+
if (!byDay.has(row.date)) byDay.set(row.date, []); byDay.get(row.date).push(row.amount);
|
|
98
120
|
}
|
|
99
121
|
return currentPoints.map(point => {
|
|
100
122
|
const date = priorDate(point.date), values = byDay.get(date) || [];
|
|
@@ -150,6 +172,13 @@ export function createV10OverviewData(model, presentation) {
|
|
|
150
172
|
openingRate, openingTotal: openingTotal(filters, modules.opening, openingRate),
|
|
151
173
|
ratio: copy(modules.movement.crossMetrics?.find(item => item.key === 'invoiceMovementMonthRatio')
|
|
152
174
|
|| pending('当月动销 / 开票', '%', '当前来源未确认该跨表指标')),
|
|
175
|
+
// 季度累计、季度同比与季度目标达成率(区域一览“动销/发票”视图按季度展示)。
|
|
176
|
+
quarterInvoice: copy(modules.invoice.targets?.quarter?.actual || pending('季度累计', '元', '所选期间无法定位季度')),
|
|
177
|
+
quarterMovement: copy(modules.movement.targets?.quarter?.actual || pending('季度累计', '元', '所选期间无法定位季度')),
|
|
178
|
+
quarterInvoiceYoY: quarterComparison('invoice', modules.invoice, filters),
|
|
179
|
+
quarterMovementYoY: quarterComparison('movement', modules.movement, filters),
|
|
180
|
+
invoiceQuarterAttainment: copy(modules.invoice.targets?.quarter?.attainment || pending('季度目标达成率', '%', '未上传经营目标', 'missing')),
|
|
181
|
+
movementQuarterAttainment: copy(modules.movement.targets?.quarter?.attainment || pending('季度目标达成率', '%', '未上传经营目标', 'missing')),
|
|
153
182
|
// 当月(区间)目标达成率,与总览卡同一取数规则。
|
|
154
183
|
invoiceAttainment: copy(modules.invoice.targets?.attainment || pending('发票目标达成率', '%', '未上传经营目标', 'missing')),
|
|
155
184
|
movementAttainment: copy(modules.movement.targets?.attainment || pending('动销目标达成率', '%', '未上传经营目标', 'missing')) };
|
|
@@ -186,18 +215,18 @@ export function createV10OverviewData(model, presentation) {
|
|
|
186
215
|
}
|
|
187
216
|
result.openingPeriod = `${start} 至 ${end}`;
|
|
188
217
|
const unknownDate = scoped.some(row => !validDate(row.date));
|
|
189
|
-
const blocked = unknownDate ? '存在缺失或无效日期,无法完整分期' : source.metrics?.
|
|
218
|
+
const blocked = unknownDate ? '存在缺失或无效日期,无法完整分期' : source.metrics?.amount?.status === 'pending' ? '开瓶金额来源规则或口径待确认' : null;
|
|
190
219
|
const byDay = new Map();
|
|
191
220
|
for (const row of scoped) {
|
|
192
221
|
if (!validDate(row.date) || row.date < start || row.date > end) continue;
|
|
193
222
|
if (!byDay.has(row.date)) byDay.set(row.date, []);
|
|
194
|
-
byDay.get(row.date).push(row.
|
|
223
|
+
byDay.get(row.date).push(row.amount);
|
|
195
224
|
}
|
|
196
225
|
for (let day = start; day <= end; day = new Date(Date.parse(`${day}T00:00:00Z`) + 86400000).toISOString().slice(0, 10)) {
|
|
197
226
|
const values = byDay.get(day) || [];
|
|
198
227
|
let value = null, state = 'pending', reason = blocked;
|
|
199
228
|
if (!blocked && !values.length) { state = 'missing'; reason = '当日无来源记录,不推定为零'; }
|
|
200
|
-
else if (!blocked && values.some(item => !finite(item))) reason = '
|
|
229
|
+
else if (!blocked && values.some(item => !finite(item))) reason = '当日存在缺失或不可用开瓶金额';
|
|
201
230
|
else if (!blocked) {
|
|
202
231
|
let sum = 0, correction = 0;
|
|
203
232
|
for (const item of values) { const next = item - correction, updated = sum + next; correction = (updated - sum) - next; sum = updated; }
|
|
@@ -219,7 +248,7 @@ export function createV10OverviewData(model, presentation) {
|
|
|
219
248
|
const groupField = ['region', 'office', 'unit'].includes(supplied.groupField) ? supplied.groupField : f.region === 'all' ? 'region' : f.office === 'all' ? 'office' : 'unit';
|
|
220
249
|
const keys = [...new Set((supplied.grouped || []).map(item => item.name))];
|
|
221
250
|
const expectedParts = groupField === 'region' ? 4 : groupField === 'office' ? 5 : 6;
|
|
222
|
-
const parentInvoice = supplied.modules.invoice.main;
|
|
251
|
+
const parentInvoice = supplied.modules.invoice.main, parentQuarter = supplied.modules.invoice.targets?.quarter?.actual;
|
|
223
252
|
const regional = keys.map(key => {
|
|
224
253
|
const selection = childFilters(f, groupField, key), parts = partsFor(key);
|
|
225
254
|
const metrics = regionalMetrics(selection, keyFor(selection) === cacheKey ? supplied : null);
|
|
@@ -229,7 +258,10 @@ export function createV10OverviewData(model, presentation) {
|
|
|
229
258
|
: pending('发票占比', '%', '当前组织或父范围发票净额不完整,或父范围合计不大于零');
|
|
230
259
|
// 该组织(含下级)在哪些来源出现过;总览各视图只列出与本视图来源相关的组织。
|
|
231
260
|
const sources = [...new Set(model.organizations.filter(item => item[groupField] === key).flatMap(item => [...(item.sources || [])]))];
|
|
232
|
-
|
|
261
|
+
const quarterShare = ready(metrics.quarterInvoice) && ready(parentQuarter) && parentQuarter.value > 0 && finite(metrics.quarterInvoice.value / parentQuarter.value * 100)
|
|
262
|
+
? { label: '季度发票占比', unit: '%', value: metrics.quarterInvoice.value / parentQuarter.value * 100, state: 'available', reason: null }
|
|
263
|
+
: pending('季度发票占比', '%', '当前组织或父范围季度发票不完整,或父范围合计不大于零');
|
|
264
|
+
return { key, name: model.label(key), fullName: fullName(key), sources, quarterShare,
|
|
233
265
|
drillable: f.unit === 'all' && parts.length === expectedParts && parts.every(text) && model.organizations.some(item => item[groupField] === key),
|
|
234
266
|
...Object.fromEntries(Object.entries(metrics).map(([name, item]) => [name, copy(item)])), invoiceShare };
|
|
235
267
|
});
|
|
@@ -240,11 +272,14 @@ export function createV10OverviewData(model, presentation) {
|
|
|
240
272
|
openingGrowth: (({ groups, ...total }) => total)(supplied.modules.opening.dayChange || { ...pending('较昨日开瓶', '%', '当前数据未提供日度比较'), precision: 1 }),
|
|
241
273
|
sourceEndLabel: ends.length === 1 && ends[0] ? `截至 ${ends[0]}` : !ends.length || ends.every(value => value === null) ? '来源截止日期未提供' : '各来源截止不同', sourceEnds };
|
|
242
274
|
result.heroes = Object.fromEntries(['invoice', 'movement'].map(id => [id, {
|
|
243
|
-
monthly: yearMonths(id, supplied.modules[id], f), yoy: yearComparison(id, supplied.modules[id], f),
|
|
275
|
+
monthly: yearMonths(id, supplied.modules[id], f), yoy: yearComparison(id, supplied.modules[id], f), quarterYoY: quarterComparison(id, supplied.modules[id], f),
|
|
244
276
|
ytdYoY: yearComparison(id, supplied.modules[id], f, true),
|
|
245
277
|
}]));
|
|
246
278
|
result.openingYoY = yearComparison('opening', supplied.modules.opening, f);
|
|
247
|
-
|
|
279
|
+
// 开瓶卡以开瓶金额为主(2026-11-27):金额同比、环比;走势也画金额。
|
|
280
|
+
result.openingAmountYoY = { ...yearComparison('opening', supplied.modules.opening, f, false, null, 'amount'), label: '开瓶金额同比' };
|
|
281
|
+
result.openingAmountMoM = { ...monthComparison('opening', supplied.modules.opening, f, 'amount'), label: '开瓶金额环比' };
|
|
282
|
+
result.openingPreviousDaily = previousOpeningDays(supplied.modules.opening, result.openingAmountYoY, result.openingDaily);
|
|
248
283
|
if (!byFilters) { byFilters = new Map(); cache.set(supplied, byFilters); }
|
|
249
284
|
byFilters.set(cacheKey, result);
|
|
250
285
|
return result;
|
|
@@ -291,13 +291,9 @@ body:has(.app-shell.overview-mode){background:#edf0f4}
|
|
|
291
291
|
.app-shell.overview-mode .ov-period-value small{margin-left:4px;font-family:var(--ov-cn);font-size:11px;font-weight:400;letter-spacing:0;color:#66717e}
|
|
292
292
|
.app-shell.overview-mode .ov-progress{position:relative;display:block;height:5px;border-radius:3px;background:#e3e7ec}
|
|
293
293
|
.app-shell.overview-mode .ov-progress i{position:absolute;inset:0 auto 0 0;display:block;border-radius:3px;background:var(--ov-accent);transition:width .45s var(--ov-ease)}
|
|
294
|
-
.app-shell.overview-mode .ov-progress b{position:absolute;top:-3px;bottom:-3px;width:2px;margin-left:-1px;border-radius:1px;background:#18212b;opacity:.45;transition:left .45s var(--ov-ease)}
|
|
295
294
|
.app-shell.overview-mode .ov-period-foot{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:4px 8px;min-width:0;font-size:11px;color:#4d5864;white-space:nowrap}
|
|
296
295
|
.app-shell.overview-mode .ov-period-foot b{font-family:var(--ov-num);font-size:13px;font-weight:600;font-variant-numeric:tabular-nums;color:#18212b}
|
|
297
296
|
.app-shell.overview-mode .ov-period-reason{min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;color:#66717e}
|
|
298
|
-
.app-shell.overview-mode .ov-delta{padding:1px 7px;border-radius:999px;font-family:var(--ov-num),var(--ov-cn);font-size:10.5px;font-style:normal;font-weight:500;font-variant-numeric:tabular-nums}
|
|
299
|
-
.app-shell.overview-mode .ov-delta.is-up{background:#e6f2ee}
|
|
300
|
-
.app-shell.overview-mode .ov-delta.is-down{background:#f8e8e9}
|
|
301
297
|
/* 辅助指标与月度图 */
|
|
302
298
|
.app-shell.overview-mode .ov-stats{margin-top:18px}
|
|
303
299
|
.app-shell.overview-mode .ov-stats>div>span:first-child{font-size:11px;color:#66717e}
|
|
@@ -309,36 +305,22 @@ body:has(.app-shell.overview-mode){background:#edf0f4}
|
|
|
309
305
|
.app-shell.overview-mode .ov-region-tabs button{padding:4px 12px;border-radius:7px;font-size:11.5px;color:#4d5864;transition:background .2s var(--ov-ease),color .2s var(--ov-ease)}
|
|
310
306
|
.app-shell.overview-mode .ov-region-tabs button:hover{color:#18212b}
|
|
311
307
|
.app-shell.overview-mode .ov-region-tabs button[aria-selected="true"]{background:#fff;color:#18212b;box-shadow:0 1px 2px rgba(0,0,0,.08)}
|
|
312
|
-
.app-shell.overview-mode .ov-region-movement :is(.ov-region-columns,.ov-region-row){grid-template-columns:24px minmax(104px,132px) minmax(72px,1fr) 84px 58px 84px 58px 64px;gap:14px}
|
|
313
|
-
.app-shell.overview-mode .ov-region-movement .ov-region-columns>span:nth-last-child(-n+5){text-align:right}
|
|
314
308
|
.app-shell.overview-mode .ov-region-columns{color:#66717e}
|
|
315
309
|
.app-shell.overview-mode .ov-region-name{color:#18212b}
|
|
316
310
|
.app-shell.overview-mode .ov-region-row{transition:background .15s var(--ov-ease)}
|
|
317
311
|
.app-shell.overview-mode .ov-region-row:not(:disabled):hover{background:#f7f9fb}
|
|
318
|
-
.app-shell.overview-mode .ov-att{display:flex;flex-direction:column;align-items:flex-end;gap:6px;min-width:0;font-family:var(--ov-num);font-variant-numeric:tabular-nums}
|
|
319
|
-
.app-shell.overview-mode .ov-att b{font-size:12.5px;font-weight:600;line-height:1.3;color:#18212b;white-space:nowrap}
|
|
320
|
-
.app-shell.overview-mode .ov-att i{position:relative;display:block;width:100%;max-width:52px;height:3px;border-radius:2px;background:#eceff3;overflow:hidden}
|
|
321
|
-
.app-shell.overview-mode .ov-att s{position:absolute;inset:0 auto 0 0;display:block;border-radius:2px;background:#c45a62}
|
|
322
|
-
.app-shell.overview-mode .ov-att[data-region-metric="movementAttainment"] s{background:#2f8a74}
|
|
323
|
-
.app-shell.overview-mode .ov-att:not([data-state="available"]) b{font-weight:400;color:#b3bac3}
|
|
324
312
|
/* 数字换新:短淡入,读数不滚动 */
|
|
325
313
|
@keyframes ov-refresh{from{opacity:.3;transform:translateY(2px)}to{opacity:1;transform:none}}
|
|
326
314
|
.app-shell.overview-mode :is(.ov-refresh,.ov-region-list){animation:ov-refresh .26s var(--ov-ease) both}
|
|
327
315
|
@media(max-width:900px){.app-shell.overview-mode .ov-value{font-size:40px}}
|
|
328
316
|
@media(max-width:760px){
|
|
329
|
-
.app-shell.overview-mode .ov-region-movement :is(.ov-region-columns,.ov-region-row){grid-template-columns:minmax(64px,1fr) 60px 44px 60px 44px;gap:6px}
|
|
330
|
-
.app-shell.overview-mode .ov-region-movement :is(.ov-region-columns,.ov-region-row)>:is(:nth-child(1),:nth-child(3)){display:none}
|
|
331
|
-
.app-shell.overview-mode .ov-region-movement .ov-number{font-size:12.5px}
|
|
332
317
|
}
|
|
333
318
|
@media(max-width:480px){.app-shell.overview-mode .ov-periods{grid-template-columns:minmax(0,1fr)}}
|
|
334
319
|
@media(prefers-reduced-motion:reduce){.app-shell.overview-mode *{animation:none!important}}
|
|
335
|
-
.app-shell.overview-mode .ov-period-time{margin-left:8px;color:#66717e}
|
|
336
320
|
.app-shell.overview-mode .ov-opening .ov-heading .ov-scope-chip{margin-left:2px;font-weight:400}
|
|
337
321
|
.app-shell.overview-mode .ov-spark-empty{justify-content:center;padding:0 8px;font-size:11.5px;line-height:1.6;text-align:center;color:#7a8491}
|
|
338
322
|
.app-shell.overview-mode .ov-period{padding:12px 12px 11px}
|
|
339
323
|
.app-shell.overview-mode .ov-period-foot b{font-size:12.5px}
|
|
340
|
-
.app-shell.overview-mode .ov-period-time{margin-left:6px}
|
|
341
|
-
.app-shell.overview-mode .ov-delta{padding:1px 6px}
|
|
342
324
|
/* 手机窄屏:区域页签与时间区换行,不出现横向滚动 */
|
|
343
325
|
@media(max-width:760px){
|
|
344
326
|
.app-shell.overview-mode .ov-region-header{flex-wrap:wrap;row-gap:8px}
|
|
@@ -368,3 +350,40 @@ body:has(.app-shell.overview-mode){background:#edf0f4}
|
|
|
368
350
|
.app-shell.overview-mode .ov-comparison{padding-left:20px}
|
|
369
351
|
@media(max-width:480px){.app-shell.overview-mode .ov-month-target{flex-wrap:wrap;row-gap:8px}.app-shell.overview-mode .ov-month-target .ov-progress{flex-basis:100%;order:3}}
|
|
370
352
|
@media(max-width:900px){.app-shell.overview-mode .ov-value{font-size:38px}}
|
|
353
|
+
|
|
354
|
+
/* 2026-11-27 季度为主:去掉时间进度对比;区域一览长条 = 季度达成 */
|
|
355
|
+
.app-shell.overview-mode .ov-progress.is-done i{background:var(--ov-accent);box-shadow:0 0 0 2px color-mix(in srgb,var(--ov-accent) 18%,transparent)}
|
|
356
|
+
.app-shell.overview-mode .ov-period-line{display:flex;align-items:baseline;gap:10px;min-width:0;white-space:nowrap}
|
|
357
|
+
.app-shell.overview-mode .ov-period-line .ov-growth{font-size:11px}
|
|
358
|
+
.app-shell.overview-mode .ov-period-line .ov-growth em{font-size:11.5px}
|
|
359
|
+
.app-shell.overview-mode .ov-period-foot{min-height:16px}
|
|
360
|
+
.app-shell.overview-mode .ov-region-movement :is(.ov-region-columns,.ov-region-row){grid-template-columns:24px minmax(110px,150px) minmax(110px,1fr) minmax(110px,1fr) 104px 104px;gap:18px}
|
|
361
|
+
.app-shell.overview-mode .ov-region-movement .ov-region-columns>span:nth-last-child(-n+2){text-align:right}
|
|
362
|
+
.app-shell.overview-mode .ov-goal-head{display:flex;align-items:center;gap:6px;white-space:nowrap}
|
|
363
|
+
.app-shell.overview-mode .ov-goal-head i{display:inline-block;width:8px;height:8px;border-radius:2px}
|
|
364
|
+
.app-shell.overview-mode .ov-goal{display:flex;align-items:center;gap:10px;min-width:0}
|
|
365
|
+
.app-shell.overview-mode .ov-goal-track{position:relative;flex:1 1 auto;min-width:40px;height:8px;border-radius:4px;background:#eef1f4;overflow:hidden}
|
|
366
|
+
.app-shell.overview-mode .ov-goal-track i{position:absolute;inset:0 auto 0 0;display:block;border-radius:4px;transition:width .45s var(--ov-ease)}
|
|
367
|
+
.app-shell.overview-mode .ov-goal-invoice .ov-goal-track i{background:#d27a80}
|
|
368
|
+
.app-shell.overview-mode .ov-goal-movement .ov-goal-track i{background:#5aa592}
|
|
369
|
+
.app-shell.overview-mode .ov-goal-invoice.is-done .ov-goal-track i{background:#b8343c}
|
|
370
|
+
.app-shell.overview-mode .ov-goal-movement.is-done .ov-goal-track i{background:#1f7a66}
|
|
371
|
+
.app-shell.overview-mode .ov-goal>b{flex:none;width:46px;text-align:right;font-family:var(--ov-num);font-size:12.5px;font-weight:600;font-variant-numeric:tabular-nums;color:#18212b;white-space:nowrap}
|
|
372
|
+
.app-shell.overview-mode .ov-goal.is-amount>b{width:0}
|
|
373
|
+
.app-shell.overview-mode .ov-goal:not(.is-amount):not([data-state="available"])>b{font-weight:400;color:#b3bac3}
|
|
374
|
+
@media(max-width:760px){
|
|
375
|
+
.app-shell.overview-mode .ov-region-movement :is(.ov-region-columns,.ov-region-row){grid-template-columns:minmax(70px,1fr) minmax(0,1.2fr) minmax(0,1.2fr);gap:10px}
|
|
376
|
+
.app-shell.overview-mode .ov-region-movement :is(.ov-region-columns,.ov-region-row)>:is(:nth-child(1),:nth-child(5),:nth-child(6)){display:none}
|
|
377
|
+
.app-shell.overview-mode .ov-goal{gap:6px}
|
|
378
|
+
.app-shell.overview-mode .ov-goal>b{width:40px;font-size:11.5px}
|
|
379
|
+
}
|
|
380
|
+
.v10-details .analysis-content>.v10-method-note:not(:last-child){margin-bottom:20px}
|
|
381
|
+
/* 2026-11-27 开瓶以金额为主:同比、环比两行,瓶数次要 */
|
|
382
|
+
.app-shell.overview-mode .ov-opening-value{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
|
|
383
|
+
.app-shell.overview-mode .ov-opening-bottles{font-family:var(--ov-num),var(--ov-cn);font-size:11.5px;color:#66717e;white-space:nowrap}
|
|
384
|
+
.app-shell.overview-mode .ov-opening-bottles b,.app-shell.overview-mode .ov-opening-bottles>span{color:#18212b;font-weight:500}
|
|
385
|
+
.app-shell.overview-mode .ov-opening-compare{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:10px}
|
|
386
|
+
.app-shell.overview-mode .ov-opening-compare>span{display:flex;flex-direction:column;gap:4px;padding:8px 10px;border-radius:10px;background:#f5f7f9;min-width:0}
|
|
387
|
+
.app-shell.overview-mode .ov-opening-compare small{font-family:var(--ov-num),var(--ov-cn);font-size:10.5px;color:#66717e;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
388
|
+
.app-shell.overview-mode .ov-opening-compare .ov-growth em{font-size:12.5px}
|
|
389
|
+
.app-shell.overview-mode .ov-scope-chip.is-soft{background:transparent;border:1px solid #e3e7ec;color:#66717e}
|
|
@@ -76,59 +76,62 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
76
76
|
if (typeof end === 'string' && end < p.start) return `${month} · 来源截至 ${day(end)}`;
|
|
77
77
|
return typeof end === 'string' && end < p.end ? `${month} · 截至 ${day(end)}` : month;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
// 达成进度条:只表示达成率(公司按季度销售,销量集中在季末,不与时间进度对比)。
|
|
80
|
+
function Progress({ item }) {
|
|
80
81
|
const ok = available(item), v = ok ? Math.max(0, Math.min(item.value, 100)) : 0;
|
|
81
|
-
return el('span', { className:
|
|
82
|
-
ok && el('i', { style: { width: `${v}%` } }), progress && el('b', { style: { left: `${Math.min(Math.max(progress.value, 0), 100)}%` } }));
|
|
82
|
+
return el('span', { className: `ov-progress${ok && item.value >= 100 ? ' is-done' : ''}`, 'aria-hidden': true }, ok && v > 0 && el('i', { style: { width: `${v}%` } }));
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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(';');
|
|
84
|
+
const targetText = target => available(target) ? `目标 ${number(target.value / 10000, 2)} 万` : '';
|
|
85
|
+
// 季度达成:主数字下的整行进度条。
|
|
86
|
+
function QuarterTarget({ t }) {
|
|
87
|
+
const item = t.attainment, ok = available(item);
|
|
88
|
+
const title = [ok ? `季度达成 ${pct(item.value)} = 季度累计 ÷ 全季目标` : `季度达成:${reason(item) || '待确认'}`, available(t.target) && t.target.note].filter(Boolean).join(';');
|
|
97
89
|
return el('div', { className: 'ov-month-target', title },
|
|
98
|
-
el('span', { className: 'ov-mt-label' },
|
|
99
|
-
el(Progress, { item
|
|
100
|
-
ok ? el('span', { className: 'ov-mt-meta' },
|
|
101
|
-
: el('span', { className: 'ov-mt-meta ov-period-reason' }, reason(item) || '待确认'));
|
|
90
|
+
el('span', { className: 'ov-mt-label' }, '季度达成', el('b', {}, ok ? pct(item.value) : '—')),
|
|
91
|
+
el(Progress, { item }),
|
|
92
|
+
ok ? el('span', { className: 'ov-mt-meta' }, targetText(t.target)) : el('span', { className: 'ov-mt-meta ov-period-reason' }, reason(item) || '待确认'));
|
|
102
93
|
}
|
|
103
|
-
//
|
|
104
|
-
function PeriodTile({
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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 }),
|
|
94
|
+
// 次要期间块:当月(区间)与财年。
|
|
95
|
+
function PeriodTile({ kind, head, sub, actual, growth, attainment, target, hasTargets, title, scopeKey }) {
|
|
96
|
+
const ok = hasTargets && available(attainment);
|
|
97
|
+
return el('div', { className: `ov-period ov-period-${kind}`, title },
|
|
98
|
+
el('span', { className: 'ov-period-head' }, el('span', {}, head), el('small', {}, sub),
|
|
99
|
+
hasTargets && available(target) && el('span', { className: 'ov-period-target' }, targetText(target))),
|
|
100
|
+
el('span', { className: 'ov-period-line' },
|
|
101
|
+
el('span', { key: `a${scopeKey}`, className: 'ov-period-value ov-refresh' }, el(Value, { item: actual, digits: 2, unit: '万' })),
|
|
102
|
+
growth && el(Growth, { item: growth, label: '同比' })),
|
|
103
|
+
hasTargets && el(Progress, { item: attainment }),
|
|
115
104
|
el('span', { className: 'ov-period-foot' },
|
|
116
|
-
ok ? el(
|
|
117
|
-
: el('span', { className: 'ov-period-reason' }, hasTargets ? reason(
|
|
105
|
+
ok ? el('span', {}, '达成 ', el('b', {}, pct(attainment.value)))
|
|
106
|
+
: el('span', { className: 'ov-period-reason' }, hasTargets ? reason(attainment) || '目标待确认' : '未上传经营目标')));
|
|
118
107
|
}
|
|
119
108
|
function Hero({ kind, data, comparison, filters, open, drill }) {
|
|
120
109
|
const module = data.modules[kind], movement = kind === 'movement', view = movement ? presentation.describe(kind, data, filters) : null;
|
|
121
110
|
const ytdRatio = cross(module, 'invoiceMovementYtdRatio'), targets = module.targets || {}, hasTargets = Boolean(targets.available);
|
|
122
111
|
const ytd = extra(module, '当年截至所选月来源金额'), negativeAmount = extra(module, '负金额合计');
|
|
123
|
-
const scopeKey = scopeKeyOf(filters),
|
|
112
|
+
const scopeKey = scopeKeyOf(filters), p = model.periodOf(filters), range = p.mode === 'range', quarter = targets.quarter, fiscal = targets.fiscal;
|
|
113
|
+
const cover = model.payload.coverage?.[kind]?.end, day = date => `${Number(date.slice(5, 7))}/${Number(date.slice(8))}`;
|
|
114
|
+
// 主角:季度累计;没有可定位的季度时退回当月(区间)。
|
|
115
|
+
const primary = quarter ? quarter.actual : module.main, primaryYoY = quarter ? comparison.quarterYoY : comparison.yoy;
|
|
116
|
+
const primaryLabel = quarter ? module.main.label.replace(/^(当月|区间)/, '季度') : module.main.label;
|
|
117
|
+
const through = quarter && typeof cover === 'string' ? [quarter.end, cover].sort()[0] : quarter?.end;
|
|
118
|
+
const primaryScope = !quarter ? scopeLabel(kind, filters) : typeof cover === 'string' && cover < quarter.start ? `${quarter.label} · 来源截至 ${day(cover)}`
|
|
119
|
+
: through < quarter.periodEnd ? `${quarter.label} · 截至 ${day(through)}` : quarter.label;
|
|
120
|
+
const monthName = range ? '区间' : '当月', monthSub = scopeLabel(kind, filters);
|
|
121
|
+
const monthTitle = [`${monthName}:${monthSub}`, hasTargets && (available(targets.attainment) ? `${monthName}达成 ${pct(targets.attainment.value)};${targets.attainment.note || ''}` : `达成:${reason(targets.attainment)}`), range && '区间目标按天数折算'].filter(Boolean).join(';');
|
|
122
|
+
const fiscalTitle = fiscal ? [`财年:${fiscal.detail}`, fiscal.actual.range && `累计 ${fiscal.actual.range.start} 至 ${fiscal.actual.range.end}`, !available(fiscal.actual) && reason(fiscal.actual),
|
|
123
|
+
hasTargets && (available(fiscal.target) ? `全年目标 ${number(fiscal.target.value / 10000, 2)} 万元;${fiscal.target.note || ''}` : `目标:${reason(fiscal.target)}`)].filter(Boolean).join(';') : '';
|
|
124
124
|
return el('article', { className: `overview-card ov-${kind} ov-hero`, style: { '--hero-accent': module.color }, role: 'button', tabIndex: 0, 'aria-label': `查看${module.title}详情`,
|
|
125
125
|
onClick: () => open(kind), onKeyDown: event => { if (event.target === event.currentTarget && ['Enter', ' '].includes(event.key)) { event.preventDefault(); open(kind); } } },
|
|
126
126
|
el('div', { className: 'ov-heading' }, el('i', { className: 'ov-dot', 'aria-hidden': true }), el('h2', {}, module.title), el('span', { className: 'ov-action' }, '详情 →')),
|
|
127
|
-
el('p', { className: 'ov-label' }, el('span', {},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
(
|
|
131
|
-
|
|
127
|
+
el('p', { className: 'ov-label', title: quarter ? `${quarter.detail};累计到所选期间末日` : undefined }, el('span', {}, primaryLabel), el('span', { className: 'ov-scope-chip' }, primaryScope),
|
|
128
|
+
kind === 'invoice' && model.payload.platforms && Object.keys(model.payload.platforms).length > 0 && el('span', { className: 'ov-scope-chip is-soft', title: '发票合计含公司发票与已上传的平台订单,构成见发票详情' },
|
|
129
|
+
`含${Object.keys(model.payload.platforms).map(id => ({ zang10: '藏10', tunzhihu: '吞之乎' })[id]).join('、')}平台`)),
|
|
130
|
+
el('div', { className: 'ov-hero-values' }, el('div', { key: `v${scopeKey}`, className: 'ov-value ov-refresh', 'data-metric': kind }, el(Value, { item: primary, digits: 2 })), el(Comparison, { key: `c${scopeKey}`, item: primaryYoY })),
|
|
131
|
+
hasTargets && quarter && el(QuarterTarget, { t: quarter }),
|
|
132
|
+
el('div', { className: 'ov-periods' },
|
|
133
|
+
el(PeriodTile, { kind: 'month', head: monthName, sub: monthSub, actual: module.main, growth: comparison.yoy, attainment: targets.attainment, target: targets.month, hasTargets, title: monthTitle, scopeKey }),
|
|
134
|
+
fiscal && el(PeriodTile, { kind: 'fiscal', head: '财年', sub: `${fiscal.label.replace(' 财年', '')} · 7月起`, actual: fiscal.actual, attainment: fiscal.attainment, target: fiscal.target, hasTargets, title: fiscalTitle, scopeKey })),
|
|
132
135
|
el('div', { className: 'ov-stats' },
|
|
133
136
|
el(Stat, { label: '年累计 · 1月起', name: 'ytd', item: ytd, digits: 2, unit: '万', growth: comparison.ytdYoY }),
|
|
134
137
|
el(Stat, { label: range ? '区间负金额' : '当月负金额', name: 'negative', item: negativeAmount, digits: 2, unit: '万' }),
|
|
@@ -148,10 +151,7 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
148
151
|
const inventoryDifference = { label: '盘点减系统金额差额', unit: '元', value: null,
|
|
149
152
|
state: inventory.state === 'unavailable' ? 'missing' : 'pending',
|
|
150
153
|
reason: inventory.state === 'unavailable' ? '未接入有效库存来源' : '两类库存金额的计价与估值基础尚未确认,暂不计算金额差额' };
|
|
151
|
-
const
|
|
152
|
-
const fixedPeriod = cover?.start && cover?.end ? cover.start.slice(0, 4) === cover.end.slice(0, 4)
|
|
153
|
-
? `${Number(cover.start.slice(5, 7))}–${Number(cover.end.slice(5, 7))} 月固定`
|
|
154
|
-
: `${cover.start.slice(0, 7)} 至 ${cover.end.slice(0, 7)} 固定` : '固定期间待确认';
|
|
154
|
+
const banquetMonth = banquet.period.split(';')[0];
|
|
155
155
|
const entries = [
|
|
156
156
|
{ module: terminal, auxiliary: el(g.Fragment, {}, el(Auxiliary, { label: '有效终端', item: terminalEffective }),
|
|
157
157
|
el('span', { className: 'ov-tag', title: reason(terminalRate) }, '有效率 ', el(Value, { item: terminalRate, digits: 1, unit: '%' }))), note: `${number(totals.agreements)} 份协议;不随产品筛选` },
|
|
@@ -162,23 +162,14 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
162
162
|
: { module: inventory, main: extra(inventory, '所选记录盘点金额合计'), digits: 2,
|
|
163
163
|
auxiliary: el(g.Fragment, {}, el(Auxiliary, { label: '系统', item: extra(inventory, '所选记录系统金额合计'), digits: 2, unit: '万' }),
|
|
164
164
|
el(Auxiliary, { label: '差额', item: inventoryDifference }), el(Auxiliary, { label: '可销', item: cross(inventory, 'inventorySellableMonths'), digits: 1, unit: '月' })), note: `${inventory.period};盘点金额与系统金额按来源分别展示,单位万元` },
|
|
165
|
-
{ module: banquet, auxiliary: el(g.Fragment, {}, el(Auxiliary, { label: '开瓶', item: extra(banquet, '
|
|
166
|
-
el(Auxiliary, { label: '场均', item: extra(banquet, '场均开瓶'), digits: 1, unit: '瓶' }), el('span', { title: banquet.period },
|
|
165
|
+
{ module: banquet, auxiliary: el(g.Fragment, {}, el(Auxiliary, { label: '开瓶', item: extra(banquet, '宴席开瓶'), unit: '瓶' }),
|
|
166
|
+
el(Auxiliary, { label: '场均', item: extra(banquet, '场均开瓶'), digits: 1, unit: '瓶' }), el('span', { title: banquet.period }, banquetMonth)), note: banquet.period },
|
|
167
167
|
];
|
|
168
168
|
return el('section', { className: 'overview-card ov-operations', 'aria-label': '签约、库存与宴席' },
|
|
169
169
|
...entries.map(({ module, main = module.main, digits = 0, auxiliary, note }) => el('button', { key: module.id, type: 'button', className: `ov-operation ov-${module.id}`, onClick: () => open(module.id), 'aria-label': `查看${module.title}详情`, title: note },
|
|
170
170
|
el('span', { className: 'ov-operation-heading' }, el('i', { className: 'ov-dot', style: { background: module.color } }), module.title, el('span', { className: 'ov-action' }, '→')),
|
|
171
171
|
el('span', { className: 'ov-secondary-value', 'data-metric': module.id }, el(Value, { item: main, digits })), el('span', { className: 'ov-kv' }, auxiliary))));
|
|
172
172
|
}
|
|
173
|
-
function DayChange({ item }) {
|
|
174
|
-
const day = date => date ? `${Number(date.slice(5, 7))}/${Number(date.slice(8))}` : '—';
|
|
175
|
-
const bottles = value => finite(value) ? `${number(value)} 瓶` : '—';
|
|
176
|
-
const diff = finite(item?.difference) ? `${item.difference > 0 ? '+' : ''}${number(item.difference)} 瓶` : '';
|
|
177
|
-
const label = `${day(item?.date)} 较 ${day(item?.previousDate)}`;
|
|
178
|
-
const detail = [`${item?.date || '末日'}:${bottles(item?.current)}`, `${item?.previousDate || '昨日'}:${bottles(item?.previous)}`, diff && `变化 ${diff}`, reason(item)].filter(Boolean).join(';');
|
|
179
|
-
return el('span', { className: 'ov-day-change', 'data-state': item?.state, title: detail, 'aria-label': `较昨日开瓶 ${detail}` },
|
|
180
|
-
el(Growth, { item, label }), el('span', { className: 'ov-day-values' }, bottles(item?.current), el('small', {}, ` / 昨日 ${bottles(item?.previous)}`)));
|
|
181
|
-
}
|
|
182
173
|
function Opening({ data, description, filters, open }) {
|
|
183
174
|
const module = data.modules.opening, points = description.openingDaily, previous = description.openingPreviousDaily;
|
|
184
175
|
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;
|
|
@@ -199,17 +190,22 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
199
190
|
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);
|
|
200
191
|
return el('button', { type: 'button', className: 'overview-card ov-opening', 'aria-label': '查看消费者开瓶详情', onClick: () => open('opening') },
|
|
201
192
|
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' }, '→')),
|
|
202
|
-
|
|
203
|
-
el(
|
|
204
|
-
|
|
205
|
-
|
|
193
|
+
// 2026-11-27:开瓶以开瓶金额(万元)为主,配同比、环比;开瓶瓶数为次要数字;去掉“较昨日”。
|
|
194
|
+
el('span', { className: 'ov-opening-value' }, el('span', { key: `o${scopeKeyOf(filters)}`, className: 'ov-secondary-value ov-refresh', 'data-metric': 'opening' }, el(Value, { item: extra(module, '开瓶金额'), digits: 2 })),
|
|
195
|
+
el('span', { className: 'ov-opening-bottles', title: reason(module.main) }, '开瓶 ', el(Value, { item: module.main, unit: '瓶' }))),
|
|
196
|
+
el('span', { className: 'ov-opening-compare' },
|
|
197
|
+
el('span', { title: (description.openingAmountYoY?.notes || []).join(';') || reason(description.openingAmountYoY) }, el(Growth, { item: description.openingAmountYoY, label: '同比' }),
|
|
198
|
+
el('small', {}, '去年同期 ', el(Value, { item: description.openingAmountYoY?.previous, digits: 2, unit: '万' }))),
|
|
199
|
+
el('span', { title: (description.openingAmountMoM?.notes || []).join(';') || reason(description.openingAmountMoM) }, el(Growth, { item: description.openingAmountMoM, label: '环比' }),
|
|
200
|
+
el('small', {}, '上月同期 ', el(Value, { item: description.openingAmountMoM?.previous, digits: 2, unit: '万' })))),
|
|
201
|
+
valid.length ? el('svg', { className: 'ov-sparkline', viewBox: '0 0 400 80', preserveAspectRatio: 'none', role: 'img', 'aria-label': `${description.openingPeriod}每日开瓶金额;两年按相同日期比较,缺日断开` },
|
|
206
202
|
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 }))),
|
|
207
203
|
...paths(previous, true), ...paths(points, false)) : el('span', { className: 'ov-spark-empty' }, reason(module.main) || description.openingState?.reason || '所选期间暂无开瓶来源记录'),
|
|
208
204
|
el('span', { className: 'ov-day-axis', title: description.openingPeriod }, ...ticks.map(day => el('span', { key: day }, `${day}日`))),
|
|
209
|
-
el('span', { className: 'ov-opening-legend', title: `${description.openingPeriod}
|
|
205
|
+
el('span', { className: 'ov-opening-legend', title: `${description.openingPeriod};每日开瓶金额;组织口径,不随产品筛选` },
|
|
210
206
|
el('span', {}, el('i', {}), year || '本年'), el('span', { className: previous.some(available) ? '' : 'is-pending' }, el('i', { className: 'is-prior' }), year ? Number(year) - 1 : '上年'), el('span', {}, '不随产品筛选')));
|
|
211
207
|
}
|
|
212
|
-
function Regions({ items, filters, groupField, drill }) {
|
|
208
|
+
function Regions({ items, filters, groupField, drill, quarter }) {
|
|
213
209
|
const modes = [['movement', '动销/发票'], ['terminal', '签约有效率'], ['opening', '开瓶']];
|
|
214
210
|
const [mode, setMode] = g.useState('movement'), listRef = g.useRef(null);
|
|
215
211
|
const scopeKey = JSON.stringify([filters.month, filters.period, filters.start, filters.end, filters.region, filters.office, filters.unit, filters.product]);
|
|
@@ -218,13 +214,18 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
218
214
|
const viewSources = { movement: ['invoice', 'movement'], terminal: ['terminal'], opening: ['opening'] }[mode];
|
|
219
215
|
const relevant = items.filter(row => !Array.isArray(row.sources) || row.sources.some(id => viewSources.includes(id)));
|
|
220
216
|
const hidden = items.length - relevant.length;
|
|
221
|
-
const
|
|
217
|
+
const sortKey = mode === 'movement' ? 'quarterInvoice' : 'invoice';
|
|
218
|
+
const rows = [...relevant].sort((a, b) => (available(b[sortKey]) ? b[sortKey].value : -Infinity) - (available(a[sortKey]) ? a[sortKey].value : -Infinity) || a.name.localeCompare(b.name, 'zh-CN'));
|
|
219
|
+
const hasTargets = Boolean(model.targetSource);
|
|
222
220
|
const title = filters.unit !== 'all' ? '当前单元经营' : filters.region !== 'all' ? '下级经营一览' : '区域经营一览';
|
|
223
221
|
const level = groupField === 'region' ? '大区' : groupField === 'office' ? '办事处' : '主任单元';
|
|
224
222
|
const range = rows.find(row => row.openingTotal.range?.end >= row.openingTotal.range?.start)?.openingTotal.range;
|
|
225
223
|
const openingPeriod = range ? `${range.start} 至 ${range.end}` : '共同期间待确认';
|
|
226
224
|
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
|
|
225
|
+
const coverEnds = ['invoice', 'movement'].map(id => model.payload.coverage?.[id]?.end).filter(Boolean).sort();
|
|
226
|
+
const quarterThrough = quarter ? [quarter.end, coverEnds[0] || quarter.end].sort()[0] : null;
|
|
227
|
+
const quarterSubtitle = quarter ? `季度 ${quarter.label}${quarterThrough && quarterThrough < quarter.periodEnd ? ` · 截至 ${Number(quarterThrough.slice(5, 7))}/${Number(quarterThrough.slice(8))}` : ''} · 点击${level}下钻` : subtitle;
|
|
228
|
+
const subtitleFull = mode !== 'movement' ? subtitle : hasTargets ? quarterSubtitle : `${quarterSubtitle} · 未上传经营目标,长条暂按季度金额对比`;
|
|
228
229
|
const pairs = mode === 'terminal' ? [['signed', '签约'], ['effectiveCount', '有效']] : [['invoice', '发票'], ['movement', '动销']];
|
|
229
230
|
const values = rows.flatMap(row => pairs.map(([key]) => row[key]).filter(available).map(item => item.value));
|
|
230
231
|
const max = Math.max(0, ...values), min = Math.min(0, ...values), span = max - min || 1, zero = -min / span * 100;
|
|
@@ -234,11 +235,22 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
234
235
|
min < 0 && el('s', { style: { left: `${zero}%` } }), available(row[key])
|
|
235
236
|
? 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 } })
|
|
236
237
|
: el('em', { 'data-state': row[key].state }, '—'))));
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
// 季度达成进度条;未上传目标时按季度金额相对大小画条,并在副标题注明。
|
|
239
|
+
const amountMax = Math.max(0, ...rows.flatMap(row => [row.quarterInvoice, row.quarterMovement]).filter(available).map(item => item.value));
|
|
240
|
+
const goalCell = (row, attKey, amountKey, tone, label) => {
|
|
241
|
+
const att = row[attKey], amount = row[amountKey];
|
|
242
|
+
if (!hasTargets) {
|
|
243
|
+
const width = available(amount) && amount.value > 0 && amountMax > 0 ? amount.value / amountMax * 100 : 0;
|
|
244
|
+
return el('span', { className: `ov-goal ov-goal-${tone} is-amount`, 'data-region-metric': attKey, title: `${label}季度金额 ${valueText(amount, 2)} 万元(未上传经营目标,按金额相对大小显示)` },
|
|
245
|
+
el('span', { className: 'ov-goal-track' }, width > 0 && el('i', { style: { width: `${width}%` } })), el('b', {}));
|
|
246
|
+
}
|
|
247
|
+
const ok = available(att);
|
|
248
|
+
return el('span', { className: `ov-goal ov-goal-${tone}${ok && att.value >= 100 ? ' is-done' : ''}`, 'data-region-metric': attKey, 'data-state': att?.state,
|
|
249
|
+
title: ok ? `${label}季度达成 ${pct(att.value)};${att.note || ''}` : `${label}季度达成:${reason(att) || '待确认'}` },
|
|
250
|
+
el('span', { className: 'ov-goal-track' }, ok && att.value > 0 && el('i', { style: { width: `${Math.min(att.value, 100)}%` } })),
|
|
251
|
+
el('b', {}, ok ? pct(att.value, att.value >= 100 ? 0 : 1) : '—'));
|
|
241
252
|
};
|
|
253
|
+
const quarterField = (row, key, yoyKey) => el('span', { className: 'ov-number', 'data-region-metric': key }, el(Value, { item: row[key], digits: 2, unit: '' }), el(Growth, { item: row[yoyKey] }));
|
|
242
254
|
function onTabKey(event, index) {
|
|
243
255
|
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;
|
|
244
256
|
if (next === null) return;
|
|
@@ -253,21 +265,22 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
253
265
|
}, label)))),
|
|
254
266
|
el('div', { className: 'ov-region-columns' }, el('span', {}), el('span', {}, level),
|
|
255
267
|
...(mode === 'opening' ? [el('span', { key: 'total' }, '总开瓶数 / 瓶'), el('span', { key: 'rate' }, '总开瓶率')]
|
|
256
|
-
: [el('span', { key: 'legend', className: 'ov-pair-legend' }, ...pairs.map(([key, label]) => el('span', { key }, el('i', { className: `ov-${key}-bar` }), label))),
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
268
|
+
: mode === 'terminal' ? [el('span', { key: 'legend', className: 'ov-pair-legend' }, ...pairs.map(([key, label]) => el('span', { key }, el('i', { className: `ov-${key}-bar` }), label))),
|
|
269
|
+
el('span', { key: 'first' }, '签约数 / 家'), el('span', { key: 'second' }, '有效数 / 家'), el('span', { key: 'rate' }, '签约有效率')]
|
|
270
|
+
: [el('span', { key: 'goal-invoice', className: 'ov-goal-head' }, el('i', { className: 'ov-invoice-bar' }), hasTargets ? '发票季度达成' : '季度发票'),
|
|
271
|
+
el('span', { key: 'goal-movement', className: 'ov-goal-head' }, el('i', { className: 'ov-movement-bar' }), hasTargets ? '动销季度达成' : '季度动销'),
|
|
272
|
+
el('span', { key: 'first' }, '季度发票 / 万元'), el('span', { key: 'second' }, '季度动销 / 万元')])),
|
|
260
273
|
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}列表,可纵向滚动查看全部组织` },
|
|
261
274
|
...rows.map((row, index) => el('button', { key: row.key, type: 'button', className: 'ov-region-row', disabled: !row.drillable, 'data-region-key': row.key,
|
|
262
275
|
'aria-label': `${row.drillable ? '筛选' : '查看'}${row.name}`, title: row.fullName, onClick: () => row.drillable && drill(groupField, row.key) },
|
|
263
276
|
el('span', { className: 'ov-rank' }, String(index + 1).padStart(2, '0')),
|
|
264
277
|
el('span', { className: 'ov-region-name', title: row.fullName }, el('strong', {}, row.name),
|
|
265
|
-
mode === 'movement' ? el('small', { title: reason(row.
|
|
278
|
+
mode === 'movement' ? el('small', { title: reason(row.quarterShare) }, '季度发票占比 ', el(Value, { item: row.quarterShare, digits: 1, unit: '%' }))
|
|
266
279
|
: el('small', {}, mode === 'terminal' ? '签约终端 · 家' : '年累计 · 共同期间')),
|
|
267
280
|
...(mode === 'opening' ? [field(row, 'openingTotal'), field(row, 'openingRate', 1, '%')]
|
|
268
281
|
: mode === 'terminal' ? [bar(row), field(row, 'signed'), field(row, 'effectiveCount'), field(row, 'effectiveRate', 1, '%')]
|
|
269
|
-
: [
|
|
270
|
-
|
|
282
|
+
: [goalCell(row, 'invoiceQuarterAttainment', 'quarterInvoice', 'invoice', '发票'), goalCell(row, 'movementQuarterAttainment', 'quarterMovement', 'movement', '动销'),
|
|
283
|
+
quarterField(row, 'quarterInvoice', 'quarterInvoiceYoY'), quarterField(row, 'quarterMovement', 'quarterMovementYoY')]))),
|
|
271
284
|
!rows.length && el('p', { className: 'ov-empty' }, '当前范围暂无组织来源记录')),
|
|
272
285
|
el('div', { className: 'ov-region-foot' }, el('span', {}, mode === 'opening' ? '累计同比 · 不随产品筛选 · — 表示待确认或缺失' : '金额下方为同比 · — 表示待确认或缺失',
|
|
273
286
|
hidden > 0 && el('span', { title: '这些组织只出现在其他板块(多为库存盘点的独立路径),可在对应详情或筛选中查看' }, ` · 另有 ${hidden} 个组织本视图无来源记录,未列出`)),
|
|
@@ -334,7 +347,7 @@ export function createV10Overview({ T, g, model, Pn }) {
|
|
|
334
347
|
return el('div', { className: 'overview-shell', 'aria-label': '战区经营总览六板块' },
|
|
335
348
|
el(Hero, { kind: 'invoice', data, comparison: description.heroes.invoice, filters, open, drill }), el(Hero, { kind: 'movement', data, comparison: description.heroes.movement, filters, open, drill }),
|
|
336
349
|
el(Operations, { data, open }), el(Opening, { data, description, filters, open }),
|
|
337
|
-
el(Regions, { items: description.regional, filters, groupField: data.groupField, drill }));
|
|
350
|
+
el(Regions, { items: description.regional, filters, groupField: data.groupField, drill, quarter: data.modules.invoice.targets?.quarter }));
|
|
338
351
|
}
|
|
339
352
|
return { Overview, PeriodFilter, UpLevel };
|
|
340
353
|
}
|