dsh-data-dashboard 0.1.8 → 0.1.9
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 +105 -34
- package/backend/incremental/jobs.mjs +11 -11
- package/backend/incremental/xlsx-rows.mjs +74 -3
- package/backend/modules/distributor/index.mjs +9 -6
- package/backend/modules/movement/index.mjs +17 -64
- package/backend/modules/scan/index.mjs +62 -0
- package/backend/modules/scan/legacy.mjs +21 -0
- package/backend/modules.mjs +2 -1
- package/backend/public/admin.css +9 -2
- package/backend/public/admin.js +74 -21
- package/backend/public/board.html +1 -1
- package/backend/public/board.js +2 -2
- package/backend/public/index.html +10 -10
- package/backend/real-data/decimal-sum.mjs +22 -0
- package/backend/real-data/generate-dashboard.mjs +18 -11
- package/backend/real-data/organization-mapping.mjs +31 -11
- package/backend/real-data/source-payload.mjs +163 -86
- package/backend/real-data/terminal-components.mjs +7 -7
- package/backend/real-data/terminal-structure.mjs +5 -5
- package/backend/real-data/v10-components.mjs +2 -2
- package/backend/real-data/v10-details.mjs +7 -62
- package/backend/real-data/v10-model.mjs +74 -71
- package/backend/real-data/v10-overview-data.mjs +14 -20
- package/backend/real-data/v10-overview.mjs +16 -6
- package/backend/real-data/v10-presentation.mjs +48 -27
- package/backend/real-data/v10-template.mjs +99 -71
- package/backend/review-engine.mjs +65 -35
- package/backend/review-service.mjs +28 -13
- package/backend/server.mjs +26 -17
- package/backend/store.mjs +3 -0
- package/backend/target-template.mjs +4 -2
- package/backend/validate-workbook.mjs +5 -2
- package/backend/web-sync/exporter.mjs +55 -21
- package/build-manifest.json +41 -38
- package/index.js +1 -1
- package/lib/tool-definitions.mjs +33 -15
- package/lib/tools.mjs +318 -85
- package/package.json +1 -1
|
@@ -1,68 +1,21 @@
|
|
|
1
1
|
import { defineModule } from '../../recognition/module-definition.mjs';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const isDealerMovement = type => type === '经销商销售出库' || type === '经销商销售退货';
|
|
4
|
+
|
|
4
5
|
export default defineModule({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"key": "scanDate",
|
|
21
|
-
"header": "扫码日期"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"key": "orderCode",
|
|
25
|
-
"header": "订单编码"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"key": "outletCode",
|
|
29
|
-
"header": "售点编码"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"key": "region",
|
|
33
|
-
"header": "大区名称"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"key": "office",
|
|
37
|
-
"header": "办事处名称"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"key": "directorUnit",
|
|
41
|
-
"header": "主任单元名称"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"key": "dealerCode",
|
|
45
|
-
"header": "经销商编码"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"key": "movementType",
|
|
49
|
-
"header": "出入库名称"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"key": "productCode",
|
|
53
|
-
"header": "产品编码"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"key": "scanBottles",
|
|
57
|
-
"header": "扫码数量(瓶)"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"key": "scanAmount",
|
|
61
|
-
"header": "扫码金额"
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"key": "scanCases",
|
|
65
|
-
"header": "扫码件数"
|
|
66
|
-
}
|
|
67
|
-
]
|
|
6
|
+
id: 'movement',
|
|
7
|
+
title: '经销商动销明细',
|
|
8
|
+
description: '经销商销售出库与销售退货明细',
|
|
9
|
+
sheetNames: ['经销商动销明细表'],
|
|
10
|
+
notes: ['按数据日期归属;只计经销商销售出库和经销商销售退货,金额与件数按原值累加。'],
|
|
11
|
+
fields: [
|
|
12
|
+
['date', '数据日期'], ['documentCode', '单据编号'],
|
|
13
|
+
['dealerCode', '经销商编码'], ['dealerName', '经销商名称'],
|
|
14
|
+
['productCode', '产品编码'], ['productName', '产品名称'],
|
|
15
|
+
['marketingCompany', '营销公司名称'], ['businessUnit', '事业部'], ['theater', '战区'],
|
|
16
|
+
['region', '大区'], ['office', '办事处'], ['directorUnit', '主任单元'],
|
|
17
|
+
['brand', '品牌'], ['category', '品类'], ['variety', '品种'],
|
|
18
|
+
['documentType', '单据类型'], ['movementType', '变动类型'],
|
|
19
|
+
['cases', '总动销数量'], ['amount', '总动销金额'],
|
|
20
|
+
].map(([key, header]) => ({ key, header })),
|
|
68
21
|
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { defineModule } from '../../recognition/module-definition.mjs';
|
|
2
|
+
|
|
3
|
+
// Header matching stays structural; confirmed business meanings are recorded in notes.
|
|
4
|
+
export default defineModule({
|
|
5
|
+
"id": "scan",
|
|
6
|
+
"title": "终端扫码(仅用于签约有效终端)",
|
|
7
|
+
"description": "掌柜宝售点扫码明细",
|
|
8
|
+
"sheetNames": [
|
|
9
|
+
"掌柜宝售点扫码明细表(历史数据+新系统)"
|
|
10
|
+
],
|
|
11
|
+
"notes": ["按扫码日期和源件数判断签约有效终端与有效协议;按原售点编码和完整组织路径关联。"],
|
|
12
|
+
"fields": [
|
|
13
|
+
{
|
|
14
|
+
"key": "scanDate",
|
|
15
|
+
"header": "扫码日期"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"key": "orderCode",
|
|
19
|
+
"header": "订单编码"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"key": "outletCode",
|
|
23
|
+
"header": "售点编码"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"key": "region",
|
|
27
|
+
"header": "大区名称"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"key": "office",
|
|
31
|
+
"header": "办事处名称"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"key": "directorUnit",
|
|
35
|
+
"header": "主任单元名称"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"key": "dealerCode",
|
|
39
|
+
"header": "经销商编码"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"key": "movementType",
|
|
43
|
+
"header": "出入库名称"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"key": "productCode",
|
|
47
|
+
"header": "产品编码"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"key": "scanBottles",
|
|
51
|
+
"header": "扫码数量(瓶)"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"key": "scanAmount",
|
|
55
|
+
"header": "扫码金额"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"key": "scanCases",
|
|
59
|
+
"header": "扫码件数"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import scan from './index.mjs';
|
|
2
|
+
import { normalizeHeader } from '../../recognition/headers.mjs';
|
|
3
|
+
|
|
4
|
+
export function isLegacyScanUpload(upload) {
|
|
5
|
+
return upload?.moduleId === 'movement' && upload.validation?.ok === true
|
|
6
|
+
&& scan.sheetNames.some(name => normalizeHeader(name) === normalizeHeader(upload.validation.sheet))
|
|
7
|
+
&& scan.fields.every(field => upload.validation.headers?.some(header => normalizeHeader(header) === normalizeHeader(field.header)));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function uploadForModule(state, id, uploadId) {
|
|
11
|
+
return state.uploads.find(upload => upload.id === uploadId && (upload.moduleId === id || id === 'scan' && isLegacyScanUpload(upload)));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function legacyScanId(state) {
|
|
15
|
+
const id = state.active?.movement;
|
|
16
|
+
return isLegacyScanUpload(uploadForModule(state, 'movement', id)) ? id : undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function activeUploadId(state, id) {
|
|
20
|
+
return state.active?.[id] ?? (id === 'scan' ? legacyScanId(state) : undefined);
|
|
21
|
+
}
|
package/backend/modules.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import invoice from './modules/invoice/index.mjs';
|
|
2
|
+
import scan from './modules/scan/index.mjs';
|
|
2
3
|
import movement from './modules/movement/index.mjs';
|
|
3
4
|
import opening from './modules/opening/index.mjs';
|
|
4
5
|
import terminal from './modules/terminal/index.mjs';
|
|
@@ -10,6 +11,6 @@ import tunzhihu from './modules/tunzhihu/index.mjs';
|
|
|
10
11
|
import distributor from './modules/distributor/index.mjs';
|
|
11
12
|
|
|
12
13
|
// Shared registration only. Module branches edit their own directory.
|
|
13
|
-
export const moduleDefinitions = [invoice, movement, opening, terminal, inventory, banquet, target, zang10, tunzhihu, distributor];
|
|
14
|
+
export const moduleDefinitions = [invoice, movement, opening, terminal, inventory, banquet, target, zang10, tunzhihu, distributor, scan];
|
|
14
15
|
export const moduleById = new Map(moduleDefinitions.map(module => [module.id, module]));
|
|
15
16
|
export { normalizeHeader } from './recognition/headers.mjs';
|
package/backend/public/admin.css
CHANGED
|
@@ -104,7 +104,7 @@ main{max-width:1500px;margin:0 auto;padding:45px 52px 24px 148px}.page-header{di
|
|
|
104
104
|
.batch-row.is-analyzing{background:#f7fafc}
|
|
105
105
|
@media(max-width:900px){.flow-receipt{grid-template-columns:1fr}}
|
|
106
106
|
/* Merged page: the update view is embedded without the rail and page header. */
|
|
107
|
-
html.embedded .rail,html.embedded .page-header,html.embedded .skip-link{display:none}
|
|
107
|
+
html.embedded .rail,html.embedded .page-header,html.embedded .skip-link,html.embedded .mode-notice,html.embedded .update-capacity{display:none}
|
|
108
108
|
html.embedded main{padding:20px 28px 24px;max-width:1240px}
|
|
109
109
|
|
|
110
110
|
/* 2026-11-24 unified update entry (design ⑨) and receipt / status table (design ⑩). */
|
|
@@ -124,7 +124,7 @@ html.embedded main{padding:20px 28px 24px;max-width:1240px}
|
|
|
124
124
|
.check-card.is-scope,.check-card.is-failed,.check-card.is-conflict{border-color:#f0c9cc;background:#fffafa}
|
|
125
125
|
.check-card.is-analyzing,.check-card.is-identifying{background:#f9fbfc}
|
|
126
126
|
.check-head{display:flex;align-items:center;gap:12px;font-size:13px;min-width:0}
|
|
127
|
-
.check-board{width:72px;flex:none;font-weight:600}
|
|
127
|
+
.check-board{min-width:72px;max-width:120px;flex:none;font-weight:600}
|
|
128
128
|
.check-board-select{height:30px;border:1px solid #e1a3a9;border-radius:8px;padding:0 6px;font:inherit;font-size:12px;background:#fff}
|
|
129
129
|
.check-file{color:#4d5e6c;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
130
130
|
.check-mode{font-size:12px;color:#6b7a88;white-space:nowrap}
|
|
@@ -218,3 +218,10 @@ button.org-chip{cursor:pointer}
|
|
|
218
218
|
.org-map-row .org-map-list{padding:0}
|
|
219
219
|
.org-map-detail-line{margin:4px 0 8px;font-size:11.5px;color:#92400e}
|
|
220
220
|
@media(max-width:760px){.org-map{margin-top:-10px}.org-map-time,.org-map-toggle{margin-left:0}}
|
|
221
|
+
|
|
222
|
+
.receipt-foot.is-live{color:var(--wine,#9b2f3d);font-weight:500}
|
|
223
|
+
.update-add.is-disabled{opacity:.45;pointer-events:none}
|
|
224
|
+
|
|
225
|
+
.module-title-note{display:block;font-size:10px;font-weight:400;color:#8a96a0;margin-top:2px}
|
|
226
|
+
|
|
227
|
+
.update-tip p{margin:2px 0}
|
package/backend/public/admin.js
CHANGED
|
@@ -4,7 +4,7 @@ if (new URLSearchParams(location.search).has('embed')) document.documentElement.
|
|
|
4
4
|
|
|
5
5
|
const $ = selector => document.querySelector(selector);
|
|
6
6
|
const rows = new Map();
|
|
7
|
-
const preferredOrder = ['invoice', 'zang10', 'tunzhihu', 'movement', 'distributor', 'opening', 'terminal', 'inventory', 'banquet', 'target'];
|
|
7
|
+
const preferredOrder = ['invoice', 'zang10', 'tunzhihu', 'movement', 'distributor', 'scan', 'opening', 'terminal', 'inventory', 'banquet', 'target'];
|
|
8
8
|
let state = null;
|
|
9
9
|
let working = null;
|
|
10
10
|
let connected = false;
|
|
@@ -24,6 +24,7 @@ const iconPaths = {
|
|
|
24
24
|
target: '<circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1"/>',
|
|
25
25
|
zang10: '<path d="M4 3h16v18l-3-2-3 2-3-2-3 2-4-2zM8 8h8m-8 4h5"/><circle cx="16" cy="14" r="2"/>',
|
|
26
26
|
tunzhihu: '<path d="M4 3h16v18l-3-2-3 2-3-2-3 2-4-2zM8 8h8m-8 4h5"/><path d="M15 12l2 2 3-3"/>',
|
|
27
|
+
scan: '<path d="M4 7V4h3M17 4h3v3M20 17v3h-3M7 20H4v-3M7 8v8M10 8v8M13 8v8M16 8v8"/>',
|
|
27
28
|
distributor: '<path d="M3 7h11v9H3zM14 10h4l3 3v3h-7M7 19a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm10 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/>',
|
|
28
29
|
};
|
|
29
30
|
|
|
@@ -110,7 +111,7 @@ function currentBusy() { return state?.busy || working; }
|
|
|
110
111
|
function busyLabel(busy) {
|
|
111
112
|
if (!busy) return '等待手动生成';
|
|
112
113
|
if (busy.stage) return busy.stage;
|
|
113
|
-
return busy.kind === 'upload' ? '正在更新资料' : '
|
|
114
|
+
return busy.kind === 'upload' ? '正在更新资料' : '正在生成看板';
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
function renderControls() {
|
|
@@ -118,7 +119,7 @@ function renderControls() {
|
|
|
118
119
|
const realMode = state?.app?.mode === 'real';
|
|
119
120
|
const hasSources = state?.modules?.some(module => module.activeUpload || module.candidateUpload);
|
|
120
121
|
$('#generate-button').disabled = !connected || Boolean(busy) || !realMode || !hasSources;
|
|
121
|
-
$('#generate-button').firstChild.textContent = busy?.kind === 'generate' ? '正在生成,请稍候' : '
|
|
122
|
+
$('#generate-button').firstChild.textContent = busy?.kind === 'generate' ? '正在生成,请稍候' : '生成看板';
|
|
122
123
|
$('#task-status').textContent = !connected ? '后台未连接' : busy ? busyLabel(busy) : '空闲';
|
|
123
124
|
$('#generation-progress').textContent = !connected ? '连接后台后可生成' : busy ? busyLabel(busy) : !realMode ? '当前后台尚未启用真实数据生成,请刷新状态' : !hasSources ? '请先在上方更新至少一类资料' : '使用本次选择的来源 · 每次保存为新文件';
|
|
124
125
|
for (const row of rows.values()) row.cycle.disabled = !connected;
|
|
@@ -144,7 +145,7 @@ function rangeText(module, upload) {
|
|
|
144
145
|
function versionText(upload) {
|
|
145
146
|
if (!upload) return '—';
|
|
146
147
|
const composition = upload.composition;
|
|
147
|
-
return composition?.step ?
|
|
148
|
+
return composition?.step ? `整份导入后更新 ${composition.step} 次` : '整份导入';
|
|
148
149
|
}
|
|
149
150
|
function operationText(upload) {
|
|
150
151
|
if (!upload) return '—';
|
|
@@ -168,11 +169,29 @@ function createStatusRow(module) {
|
|
|
168
169
|
root.dataset.module = module.id;
|
|
169
170
|
const name = element('span', 'status-name'); name.setAttribute('role', 'cell');
|
|
170
171
|
const symbol = element('span', 'module-icon'); symbol.append(icon(module.id));
|
|
171
|
-
|
|
172
|
+
// 名称带括号说明时分两行:主名称加粗,括号里的用途小字显示,避免在窄列里折行错位。
|
|
173
|
+
const [mainTitle, note] = module.title.split(/((.+))$/);
|
|
174
|
+
const title = element('b', '', mainTitle); title.title = module.description || '';
|
|
175
|
+
if (note) title.append(element('small', 'module-title-note', note));
|
|
172
176
|
name.append(symbol, title);
|
|
173
177
|
if (module.id === 'target') {
|
|
174
178
|
const template = element('a', 'text-link target-template', '下载模板 ↓');
|
|
175
179
|
template.href = '/api/target-template'; template.setAttribute('download', '经营目标模板.xlsx');
|
|
180
|
+
// 首次生成模板要读取组织(约 20 秒),点击后显示进度,下载开始后恢复。
|
|
181
|
+
template.addEventListener('click', async event => {
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
if (template.dataset.loading) return;
|
|
184
|
+
template.dataset.loading = '1'; template.textContent = '准备模板中,请稍候…'; template.title = '第一次需要整理组织名称,可能要十几到二十秒';
|
|
185
|
+
try {
|
|
186
|
+
const response = await fetch('/api/target-template');
|
|
187
|
+
if (!response.ok) throw new Error(String(response.status));
|
|
188
|
+
const url = URL.createObjectURL(await response.blob());
|
|
189
|
+
const link = Object.assign(document.createElement('a'), { href: url, download: '经营目标模板.xlsx' });
|
|
190
|
+
document.body.append(link); link.click(); link.remove(); setTimeout(() => URL.revokeObjectURL(url), 10000);
|
|
191
|
+
template.textContent = '已开始下载'; setTimeout(() => { template.textContent = '下载模板 ↓'; }, 2500);
|
|
192
|
+
} catch { template.textContent = '下载失败,点此重试'; }
|
|
193
|
+
finally { delete template.dataset.loading; }
|
|
194
|
+
});
|
|
176
195
|
template.title = '预填当前已上传来源中的组织名称;目标值需自行填写';
|
|
177
196
|
name.append(template);
|
|
178
197
|
}
|
|
@@ -230,7 +249,7 @@ function mappingList(view) {
|
|
|
230
249
|
tbody.append(row);
|
|
231
250
|
}
|
|
232
251
|
table.append(thead, tbody); box.append(table);
|
|
233
|
-
if (view.more) box.append(element('p', 'org-map-more', `另有 ${view.more}
|
|
252
|
+
if (view.more) box.append(element('p', 'org-map-more', `另有 ${view.more} 条未列出,完整清单保存在该版本的检查记录里。`));
|
|
234
253
|
if (view.kind === 'partial') box.append(element('p', 'org-map-note', window.OrgMapping.note));
|
|
235
254
|
return box;
|
|
236
255
|
}
|
|
@@ -274,7 +293,7 @@ function renderHistory() {
|
|
|
274
293
|
const host = $('#generation-history'); host.replaceChildren();
|
|
275
294
|
if (!generations.length) {
|
|
276
295
|
const empty = element('div', 'empty-state');
|
|
277
|
-
empty.append(element('strong', '', '还没有生成记录'), element('p', '', '
|
|
296
|
+
empty.append(element('strong', '', '还没有生成记录'), element('p', '', '更新资料并通过检查后,点击上方按钮生成看板。'));
|
|
278
297
|
host.append(empty);
|
|
279
298
|
return;
|
|
280
299
|
}
|
|
@@ -310,7 +329,7 @@ function renderHistory() {
|
|
|
310
329
|
if (view) links.append(view); if (download) links.append(download);
|
|
311
330
|
actions.append(links);
|
|
312
331
|
} else if (generation.status === 'failed') actions.append(element('span', 'history-sub history-error', generation.error || '生成未完成,请重试。'));
|
|
313
|
-
else actions.append(element('span', 'history-sub', generation.stage || '
|
|
332
|
+
else actions.append(element('span', 'history-sub', generation.stage || '正在准备生成…'));
|
|
314
333
|
const mappingCell = element('td');
|
|
315
334
|
const mapping = generation.status === 'completed' && generation.mode === 'real' && window.OrgMapping ? window.OrgMapping.view(generation) : null;
|
|
316
335
|
if (mapping) {
|
|
@@ -364,16 +383,19 @@ function applyState(next) {
|
|
|
364
383
|
window.ReviewUI?.setState(state);
|
|
365
384
|
if (trackedGeneration) {
|
|
366
385
|
const current = (state.generations || []).find(item => item.id === trackedGeneration);
|
|
386
|
+
const movementWarnings = (current?.moduleSummaries?.movement?.warnings || []).filter(message => /^\d+ 行非经销商销售出库或销售退货的单据含非零/.test(message));
|
|
367
387
|
if (lastReceipt?.generating && ['completed', 'failed'].includes(current?.status)) {
|
|
368
388
|
lastReceipt.generating = false;
|
|
369
|
-
lastReceipt.foot = current.status === 'failed' ? `看板生成失败:${current.error || '请稍后重试'}
|
|
389
|
+
lastReceipt.foot = current.status === 'failed' ? `看板生成失败:${String(current.error || '请稍后重试').replace(/[。.]+$/, '')}。已更新的资料已保留,不用重传文件,可在下方点「生成看板」重试。` : current.needsReview ? '已生成待确认版本,当前看板未替换。收到的原文件都保存在本机。'
|
|
370
390
|
: document.documentElement.classList.contains('embedded') ? '看板已生成并切到「看板」页。收到的原文件都保存在本机。' : '看板已生成,可在下方“生成记录”查看。收到的原文件都保存在本机。';
|
|
371
391
|
if (current.status === 'completed' && current.skippedModules?.length) lastReceipt.foot += ` ${current.skippedModules.map(item => item.title).join('、')}模板已更新,旧文件本次未计入,请按新模板重新上传。`;
|
|
392
|
+
if (current.status === 'completed' && movementWarnings.length) lastReceipt.foot += ` ${movementWarnings.join(' ')}`;
|
|
372
393
|
renderReceipt();
|
|
373
394
|
}
|
|
374
395
|
const skippedNote = current?.skippedModules?.length ? ` 注意:${current.skippedModules.map(item => item.title).join('、')}模板已更新,旧文件本次未计入,请按新模板重新上传。` : '';
|
|
375
396
|
if (current?.status === 'completed') {
|
|
376
|
-
|
|
397
|
+
const completion = skippedNote ? skippedNote.trim() : current.needsReview ? '待确认版本已生成。相关汇总及关联指标保持待确认,请在生成记录中查看;最近正常版本入口未被替换。' : current.mode === 'real' ? '真实数据看板已生成,使用本次开始生成时锁定的来源。可在“生成记录”中查看或下载 HTML;缺失来源和待确认指标已明确标注。' : '历史演示看板已生成。请查看生成记录中的模式说明。';
|
|
398
|
+
setNotice([completion, ...movementWarnings].join(' '));
|
|
377
399
|
trackedGeneration = null;
|
|
378
400
|
} else if (current?.status === 'failed') {
|
|
379
401
|
setNotice(`生成失败:${current.error || '请检查后台状态后重试。'}`, true);
|
|
@@ -400,11 +422,17 @@ async function refresh(silent = false) {
|
|
|
400
422
|
// workbook keeps its original whole upload.
|
|
401
423
|
const batchItems = [];
|
|
402
424
|
let batchRunning = false;
|
|
425
|
+
// 批量更新与生成的进度:第几个文件、当前步骤(后台实时报告)、已用时间。
|
|
426
|
+
let batchProgress = null;
|
|
427
|
+
const elapsed = since => { const sec = Math.max(0, Math.round((Date.now() - since) / 1000)); return sec < 60 ? `已用 ${sec} 秒` : `已用 ${Math.floor(sec / 60)} 分 ${String(sec % 60).padStart(2, '0')} 秒`; };
|
|
428
|
+
const stepText = busy => busyLabel(busy).replace(/^正在/, '');
|
|
429
|
+
const embedded = () => document.documentElement.classList.contains('embedded');
|
|
430
|
+
let checkingSince = null;
|
|
403
431
|
let generateAfterBatch = false;
|
|
404
432
|
let lastReceipt = null;
|
|
405
433
|
const moduleOf = id => state?.modules?.find(module => module.id === id) || null;
|
|
406
434
|
const moduleTitle = id => moduleOf(id)?.title || '';
|
|
407
|
-
const SHORT = { invoice: '发票', movement: '
|
|
435
|
+
const SHORT = { invoice: '发票', movement: '经销商动销', scan: '终端扫码', opening: '开瓶', inventory: '库存', terminal: '签约', banquet: '宴席', target: '目标', zang10: '藏10', tunzhihu: '吞之乎', distributor: '分销商动销' };
|
|
408
436
|
const shortTitle = id => SHORT[id] || moduleTitle(id);
|
|
409
437
|
const isUpdatable = id => Boolean(moduleOf(id)?.updatable);
|
|
410
438
|
const modesOf = id => moduleOf(id)?.modes || [];
|
|
@@ -628,14 +656,21 @@ function renderBatch() {
|
|
|
628
656
|
for (const id of [...new Set(skipped)]) hints.push(`${shortTitle(id)}不提交,看板沿用${shortTitle(id)}上一版(${effectiveText(id)})`);
|
|
629
657
|
if (confirmLater.length) hints.push(`${confirmLater.join('、')}勾选确认后一并提交`);
|
|
630
658
|
if (waiting) hints.push(states.some(({ st }) => st === 'unknown') ? '有文件需要选择板块' : '正在核对文件…');
|
|
631
|
-
|
|
659
|
+
if (waiting) checkingSince ??= Date.now(); else checkingSince = null;
|
|
660
|
+
$('#batch-hint').textContent = batchRunning && batchProgress
|
|
661
|
+
? `第 ${batchProgress.index}/${batchProgress.total} 个 · ${batchProgress.title}(${stepText(currentBusy())} · ${elapsed(batchProgress.started)})${generateAfterBatch ? ',更新完将自动生成看板' : ''},请勿关闭窗口`
|
|
662
|
+
: waiting && !states.some(({ st }) => st === 'unknown') ? `正在识别和核对文件(${elapsed(checkingSince)}),请稍候`
|
|
663
|
+
: hints.join(';') + (hints.length ? '。' : '');
|
|
664
|
+
$('#batch-add').classList.toggle('is-disabled', batchRunning);
|
|
665
|
+
$('#batch-more').disabled = batchRunning;
|
|
632
666
|
const touched = new Set(submittable.map(({ item }) => item.moduleId));
|
|
633
667
|
const ready = states.filter(({ st }) => st === 'ok').length, confirm = confirmLater.length;
|
|
634
|
-
$('#batch-summary').textContent = !has ? '
|
|
668
|
+
$('#batch-summary').textContent = !has ? '所有资料都从这里导入:拖入或选择一个或多个 Excel,系统按工作表名自动认出是哪类资料;这次没选的资料沿用当前版本。'
|
|
635
669
|
: `已选 ${batchItems.length} 个文件:${[ready ? `${ready} 个可以提交` : '', confirm ? `${confirm} 个需确认` : '', reexport.length ? `${reexport.length} 个需要重新导出或调整` : ''].filter(Boolean).join(',') || '正在核对'}。${touched.has('target') ? '没选的板块' : '没选的板块和经营目标'}沿用当前版本。`;
|
|
636
670
|
$('#batch-clear').hidden = !has || batchRunning;
|
|
637
671
|
}
|
|
638
672
|
async function addBatchFiles(files) {
|
|
673
|
+
if (batchRunning) return;
|
|
639
674
|
$('#receipt').hidden = true;
|
|
640
675
|
for (const file of files) {
|
|
641
676
|
if (!/\.xlsx$/i.test(file.name)) { batchItems.push({ file, moduleId:null, status:'failed', message:'不是 .xlsx 文件;旧版 .xls 请先另存为 .xlsx。' }); continue; }
|
|
@@ -659,7 +694,7 @@ async function uploadTarget(item) {
|
|
|
659
694
|
return { result, receipt: null };
|
|
660
695
|
}
|
|
661
696
|
async function applyItem(item) {
|
|
662
|
-
working = {kind:'upload', moduleId:item.moduleId, stage:item.mode === 'full' ? '正在核对并更新资料' : '
|
|
697
|
+
working = {kind:'upload', moduleId:item.moduleId, stage:item.mode === 'full' ? '正在核对并更新资料' : '正在合并到现有数据'}; renderControls();
|
|
663
698
|
try {
|
|
664
699
|
const { result } = isUpdatable(item.moduleId) ? { result: await request('/api/updates/apply', { method:'POST', headers:{'Content-Type':'application/json', 'X-Local-Token':state.token}, body:JSON.stringify({ stagedId:item.staged.stagedId, mode:item.mode, start:item.start, end:item.end, confirmMissing:!!item.confirmMissing }) }) } : await uploadTarget(item);
|
|
665
700
|
item.staged = null;
|
|
@@ -681,9 +716,9 @@ function changeText(item) {
|
|
|
681
716
|
const arrow = key => { const value = figure(key); return value ? `${countText(value.before)} → ${countText(value.after)}` : ''; };
|
|
682
717
|
const auto = isUpdatable(item.moduleId) && modesOf(item.moduleId).length > 1 ? `(${item.modeAuto ? '系统建议' : '手动'})` : '';
|
|
683
718
|
const what = item.mode === 'range' ? `范围更新 ${dayRange(r.start, r.end)}${auto}` : item.mode === 'incremental' ? `增量追加 ${dayRange(r.file.start, r.file.end)}${auto}` : `整份替换${auto}`;
|
|
684
|
-
const core = { invoice: `净额 ${delta('amount', ' 万元')}`, movement:
|
|
719
|
+
const core = { invoice: `净额 ${delta('amount', ' 万元')}`, movement: `动销净额 ${delta('amount', ' 万元')}`, scan: `扫码件数 ${delta('quantity', ' 件')}`, opening: `开瓶金额 ${delta('amount', ' 万元')}`, inventory: `${delta('rows', '')} 条盘点`,
|
|
685
720
|
terminal: `协议 ${arrow('agreements')}${r.disappearingAgreements ? `(已确认 ${countText(r.disappearingAgreements)} 份消失)` : ''}`, banquet: `场次 ${delta('quantity', ' 场')}`,
|
|
686
|
-
zang10: `订单金额 ${delta('amount', ' 万元')}`, tunzhihu: `发票金额 ${delta('amount', ' 万元')}`, distributor:
|
|
721
|
+
zang10: `订单金额 ${delta('amount', ' 万元')}`, tunzhihu: `发票金额 ${delta('amount', ' 万元')}`, distributor: `动销净额 ${delta('amount', ' 万元')}` }[item.moduleId] || '';
|
|
687
722
|
return [what, core].filter(Boolean).join(',');
|
|
688
723
|
}
|
|
689
724
|
function renderReceipt() {
|
|
@@ -694,7 +729,11 @@ function renderReceipt() {
|
|
|
694
729
|
const grid = $('#receipt-grid'); grid.replaceChildren();
|
|
695
730
|
for (const label of ['板块', '做了什么', '现在生效']) grid.append(element('span', 'receipt-col', label));
|
|
696
731
|
for (const line of lastReceipt.lines) grid.append(element('span', `receipt-board${line.ok ? '' : ' is-bad'}`, line.title), element('span', line.ok ? '' : 'is-bad', line.what), element('span', `receipt-now ${line.ok ? 'is-ok' : 'is-warn'}`, line.now));
|
|
697
|
-
$('#receipt-foot').textContent = lastReceipt.
|
|
732
|
+
$('#receipt-foot').textContent = lastReceipt.generating && lastReceipt.generatingSince
|
|
733
|
+
? `正在生成看板(${stepText(currentBusy())} · ${elapsed(lastReceipt.generatingSince)}),通常需几十秒,请勿关闭窗口;${embedded() ? '完成后会自动切到「看板」页。' : '完成后可在下方「生成记录」查看。'}`
|
|
734
|
+
: lastReceipt.foot;
|
|
735
|
+
$('#receipt-foot').classList.toggle('is-live', Boolean(lastReceipt.generating));
|
|
736
|
+
$('#receipt-close').hidden = Boolean(lastReceipt.generating);
|
|
698
737
|
}
|
|
699
738
|
function nowText(moduleId) {
|
|
700
739
|
const module = moduleOf(moduleId), upload = selectedUpload(module);
|
|
@@ -716,7 +755,9 @@ async function uploadBatch(andGenerate = false) {
|
|
|
716
755
|
const skipped = states.filter(({ st }) => ['scope', 'adjust', 'conflict', 'failed', 'duplicate'].includes(st)).map(({ item }) => item);
|
|
717
756
|
batchRunning = true; generateAfterBatch = andGenerate; setNotice(''); renderBatch();
|
|
718
757
|
const lines = [];
|
|
758
|
+
batchProgress = { index: 0, total: queue.length, title: '', started: Date.now() };
|
|
719
759
|
for (const item of queue) {
|
|
760
|
+
Object.assign(batchProgress, { index: batchProgress.index + 1, title: moduleTitle(item.moduleId) });
|
|
720
761
|
item.status = 'uploading'; renderBatch();
|
|
721
762
|
while (currentBusy()) { await new Promise(resolve => setTimeout(resolve, 500)); await refresh(true); }
|
|
722
763
|
const result = await applyItem(item);
|
|
@@ -741,10 +782,20 @@ async function uploadBatch(andGenerate = false) {
|
|
|
741
782
|
: pending ? '有重复候选或组织对应待处理,请在下方“本次数据检查”确认后再生成。收到的原文件都保存在本机。'
|
|
742
783
|
: failed && andGenerate ? '有板块未通过,本次没有生成看板。收到的原文件都保存在本机。' : '收到的原文件都保存在本机。可直接生成看板。' };
|
|
743
784
|
for (const item of batchItems.splice(0, batchItems.length)) await discardStaged(item);
|
|
744
|
-
batchRunning = false; generateAfterBatch = false;
|
|
785
|
+
batchRunning = false; generateAfterBatch = false; batchProgress = null;
|
|
786
|
+
if (willGenerate) lastReceipt.generatingSince = Date.now();
|
|
745
787
|
renderBatch(); renderReceipt(); renderControls();
|
|
746
788
|
$('#receipt').scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
747
|
-
if (willGenerate)
|
|
789
|
+
if (willGenerate) {
|
|
790
|
+
trackedGeneration = null;
|
|
791
|
+
await generate(false);
|
|
792
|
+
// 生成没能启动(例如还有待处理检查项):回执不能一直停在“正在生成”。
|
|
793
|
+
if (!trackedGeneration && lastReceipt?.generating) {
|
|
794
|
+
lastReceipt.generating = false;
|
|
795
|
+
lastReceipt.foot = `看板没有开始生成:${($('#notice').textContent || '请稍后重试').replace(/^无法开始生成:/, '').replace(/[。.]+$/, '')}。已更新的资料已保留,处理后可在下方点「生成看板」。`;
|
|
796
|
+
renderReceipt();
|
|
797
|
+
}
|
|
798
|
+
}
|
|
748
799
|
}
|
|
749
800
|
$('#batch-input').addEventListener('change', event => { const files = [...event.target.files]; event.target.value = ''; addBatchFiles(files); });
|
|
750
801
|
$('#batch-more').addEventListener('change', event => { const files = [...event.target.files]; event.target.value = ''; addBatchFiles(files); });
|
|
@@ -755,11 +806,11 @@ $('#receipt-close').addEventListener('click', () => { lastReceipt = null; render
|
|
|
755
806
|
const panel = $('#update-panel'), drop = $('#batch-drop');
|
|
756
807
|
for (const name of ['dragenter', 'dragover']) panel.addEventListener(name, event => { event.preventDefault(); drop.classList.add('is-dragging'); panel.classList.add('is-dragging'); });
|
|
757
808
|
for (const name of ['dragleave', 'drop']) panel.addEventListener(name, event => { event.preventDefault(); drop.classList.remove('is-dragging'); panel.classList.remove('is-dragging'); });
|
|
758
|
-
panel.addEventListener('drop', event => addBatchFiles([...event.dataTransfer.files]));
|
|
809
|
+
panel.addEventListener('drop', event => { if (batchRunning) { setNotice('正在更新中,请等这一批完成后再添加文件。', true); return; } addBatchFiles([...event.dataTransfer.files]); });
|
|
759
810
|
|
|
760
811
|
async function generate(allowPending = false) {
|
|
761
812
|
if (currentBusy() || !state?.token || state.app?.mode !== 'real' || !state.modules?.some(module => module.activeUpload || module.candidateUpload)) return;
|
|
762
|
-
working = {kind:'generate', stage:'
|
|
813
|
+
working = {kind:'generate', stage:'正在准备生成看板'}; setNotice(''); renderControls();
|
|
763
814
|
try {
|
|
764
815
|
const result = await request('/api/generations', {method:'POST', headers:{'Content-Type':'application/json', 'X-Local-Token':state.token}, body:JSON.stringify({allowPending})});
|
|
765
816
|
trackedGeneration = result.generation.id;
|
|
@@ -775,4 +826,6 @@ document.querySelectorAll('.rail-item').forEach(link => link.addEventListener('c
|
|
|
775
826
|
window.ReviewUI?.init({request, getState: () => state, applyState, isBusy: () => Boolean(currentBusy()) || !connected, setWorking: value => { working = value; renderControls(); }, generate});
|
|
776
827
|
refresh();
|
|
777
828
|
setInterval(() => { if (document.visibilityState === 'visible' || currentBusy()) refresh(true); }, 2000);
|
|
829
|
+
// 每秒刷新进度文字里的已用时间。
|
|
830
|
+
setInterval(() => { if (batchRunning) renderBatch(); if (lastReceipt?.generating) renderReceipt(); }, 1000);
|
|
778
831
|
document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') refresh(true); });
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<iframe id="board-frame" title="战区经营看板" hidden></iframe>
|
|
27
27
|
<div class="empty" id="board-empty">
|
|
28
28
|
<strong>还没有生成过看板</strong>
|
|
29
|
-
<p>先在“更新数据”里导入 Excel
|
|
29
|
+
<p>先在“更新数据”里导入 Excel,核对无误后点“确认更新并生成看板”。</p>
|
|
30
30
|
<button type="button" class="btn btn-wine" data-go="update">去更新数据</button>
|
|
31
31
|
</div>
|
|
32
32
|
</section>
|
package/backend/public/board.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Merged page: latest dashboard, the update page and generation history in
|
|
4
4
|
// one place. Dashboards stay independent offline HTML files.
|
|
5
5
|
const $ = selector => document.querySelector(selector);
|
|
6
|
-
const titles = { invoice: '发票', movement: '
|
|
6
|
+
const titles = { invoice: '发票', movement: '经销商动销', scan: '终端扫码', opening: '开瓶', terminal: '签约', inventory: '库存', banquet: '宴席', target: '目标', zang10: '藏10', tunzhihu: '吞之乎', distributor: '分销商动销' };
|
|
7
7
|
let state = null, viewingId = null, known = null, followLatest = true, toastTimer = null;
|
|
8
8
|
const openMapping = new Set();
|
|
9
9
|
const updateFrame = $('#update-frame');
|
|
@@ -101,7 +101,7 @@ function mappingDetail(row, mapping) {
|
|
|
101
101
|
for (const [text, cls] of [[item.module, 'mod'], [item.path, ''], [item.rows, ''], [item.reason, item.rejected ? 'rej' : 'pend']]) { const c = r.insertCell(); c.textContent = text; if (cls) c.className = cls; }
|
|
102
102
|
}
|
|
103
103
|
cell.append(line, table);
|
|
104
|
-
if (mapping.more) { const more = document.createElement('p'); more.className = 'map-note'; more.textContent = `另有 ${mapping.more}
|
|
104
|
+
if (mapping.more) { const more = document.createElement('p'); more.className = 'map-note'; more.textContent = `另有 ${mapping.more} 条未列出,完整清单保存在该版本的检查记录里。`; cell.append(more); }
|
|
105
105
|
if (mapping.kind === 'partial') { const note = document.createElement('p'); note.className = 'map-note'; note.textContent = window.OrgMapping.note; cell.append(note); }
|
|
106
106
|
}
|
|
107
107
|
async function refresh() {
|
|
@@ -38,20 +38,20 @@
|
|
|
38
38
|
<div id="notice" class="notice" role="status" aria-live="polite" hidden></div>
|
|
39
39
|
<a id="review-resume" class="review-resume" href="#review" hidden>继续处理待确认项</a>
|
|
40
40
|
<div class="workspace-summary" aria-label="后台状态">
|
|
41
|
-
<div><span>今日已更新</span><strong><b id="today-count">—</b><small id="today-total"> /
|
|
42
|
-
<div><span>资料准备</span><strong><b id="ready-count">—</b><small id="ready-total"> /
|
|
41
|
+
<div><span>今日已更新</span><strong><b id="today-count">—</b><small id="today-total"> / — 类</small></strong></div>
|
|
42
|
+
<div><span>资料准备</span><strong><b id="ready-count">—</b><small id="ready-total"> / — 类</small></strong></div>
|
|
43
43
|
<div><span>已生成成品</span><strong><b id="generation-count">—</b><small> 份</small></strong></div>
|
|
44
44
|
<div><span>当前任务</span><strong class="summary-status" id="task-status">正在读取</strong></div>
|
|
45
|
-
<p
|
|
45
|
+
<p>选文件后先核对,点确认才生效<br/>历史版本单独保留,不会覆盖</p>
|
|
46
46
|
</div>
|
|
47
47
|
|
|
48
48
|
<section id="sources" class="section" aria-labelledby="sources-title">
|
|
49
49
|
<div class="update-panel" id="update-panel">
|
|
50
50
|
<div class="update-head">
|
|
51
|
-
<div><h2 id="sources-title">选好文件,系统自动读取日期并给出更新方式</h2><p id="batch-summary"
|
|
51
|
+
<div><h2 id="sources-title">选好文件,系统自动读取日期并给出更新方式</h2><p id="batch-summary">所有资料都从这里导入:拖入或选择一个或多个 Excel,系统按工作表名自动认出是哪类资料;这次没选的资料沿用当前版本。</p></div>
|
|
52
52
|
<label class="update-add" id="batch-add" hidden>+ 继续添加文件<input id="batch-more" type="file" accept=".xlsx" multiple hidden /></label>
|
|
53
53
|
</div>
|
|
54
|
-
<
|
|
54
|
+
<div class="update-tip"><p><b>建议导出方式</b>(日常更新导“最近 7 天”;首次上传或换模板时,先导完整历史):</p><p>· <b>按日期更新,导最近 7 天</b>:发票、经销商动销明细、分销商动销明细(两表相加计入动销)、开瓶、库存、吞之乎。</p><p>· <b>按需或按月</b>:终端扫码仅用于判断签约有效终端、不计入动销,要看最新有效率时导最近 7 天即可;藏10、宴席按月导出(同月重传会替换该月);签约有变动时整份导出;经营目标在下方列表点“下载模板”。</p><p>· <b>导出范围</b>:与当前数据一致(同一战区、全部产品),不一致的文件会被拦下。</p></div>
|
|
55
55
|
<label class="batch-drop" id="batch-drop">
|
|
56
56
|
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 15V3m-4 4 4-4 4 4M4 14v6h16v-6"/></svg>
|
|
57
57
|
<strong>拖入 Excel,或</strong>
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
</section>
|
|
85
85
|
|
|
86
86
|
<section id="review" class="review-panel" aria-labelledby="review-title">
|
|
87
|
-
<div class="section-heading"><
|
|
87
|
+
<div class="section-heading"><div><h2 id="review-title">本次数据检查</h2><p>集中处理重复记录和组织对应。已确认的结果保存在本机,原始 Excel 不改写。</p></div></div>
|
|
88
88
|
<p id="review-summary" class="review-summary">正在读取检查结果…</p>
|
|
89
89
|
<div class="review-toolbar"><button id="review-check-button" class="button button-secondary" type="button" data-review-action>检查全部当前来源</button><button id="review-export" class="button button-quiet" type="button" data-review-action>导出待核对清单</button><button id="review-later" class="button button-quiet" type="button">稍后继续处理</button></div>
|
|
90
90
|
<p class="review-saving-note">每组点击确认后即保存。暂未确认的勾选不会执行;退出后可从“继续处理”返回。</p>
|
|
@@ -95,18 +95,18 @@
|
|
|
95
95
|
</section>
|
|
96
96
|
|
|
97
97
|
<section id="generate" class="generate-panel" aria-labelledby="generate-title">
|
|
98
|
-
<div class="generation-copy"><
|
|
99
|
-
<div class="generation-action"><button id="generate-button" class="button button-primary" type="button" disabled
|
|
98
|
+
<div class="generation-copy"><h2 id="generate-title">用当前资料生成看板</h2><p id="generate-sources" class="generate-sources"></p><p>处理完上方待确认项,或不想重传表格、只想重新出一版看板时点这里。每次生成单独保存,不覆盖以前的版本。</p><div class="generation-footnote"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 11v6m0-10v.1"/></svg><span>未处理项会阻止普通生成;也可明确生成待确认版本,相关汇总及关联指标不显示为完整结果。</span></div></div>
|
|
99
|
+
<div class="generation-action"><button id="generate-button" class="button button-primary" type="button" disabled>生成看板<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 12h15m-6-6 6 6-6 6"/></svg></button><button id="generate-pending-button" class="button button-pending" type="button" disabled>跳过待确认,先生成待确认版本</button><span id="generation-progress" role="status" aria-live="polite">等待后台就绪</span><a id="latest-output" class="text-link" target="_blank" rel="noopener" hidden>打开最新生成的看板 ↗</a></div>
|
|
100
100
|
</section>
|
|
101
101
|
|
|
102
102
|
<div id="org-mapping-status" class="org-map" role="status" aria-live="polite" hidden></div>
|
|
103
103
|
|
|
104
104
|
<section id="history" class="section" aria-labelledby="history-title">
|
|
105
|
-
<div class="section-header"><div class="section-heading"><
|
|
105
|
+
<div class="section-header"><div class="section-heading"><div><h2 id="history-title">生成记录</h2><p>每次生成单独保存,可随时查看或下载已有成品。</p></div></div><span id="history-count" class="section-hint"></span></div>
|
|
106
106
|
<div id="generation-history" class="history-panel"><div class="empty-state"><strong>还没有生成记录</strong><p>上传资料并通过校验后,点击上方按钮生成真实数据看板。</p></div></div>
|
|
107
107
|
</section>
|
|
108
108
|
|
|
109
|
-
<section id="about" class="about-panel" aria-labelledby="about-title"><div><h2 id="about-title">资料与口径说明</h2><p
|
|
109
|
+
<section id="about" class="about-panel" aria-labelledby="about-title"><div><h2 id="about-title">资料与口径说明</h2><p>“联盟体”在看板统一称为“终端”。看板分发票、动销、开瓶、签约、库存、宴席六个板块:藏10、吞之乎平台销售并入发票;动销 = 经销商动销明细(仅计销售出库与退货)+ 分销商动销明细,统一按件和金额统计,不再统计瓶数;终端扫码仅用于判断签约有效终端,不计入动销;“经营目标”用于计算达成率。</p><p>所有资料都从“更新数据”顶部选择文件:发票、经销商动销明细、分销商动销明细、终端扫码、开瓶、库存、吞之乎按日期更新,藏10、宴席按月份更新(系统建议追加、按范围替换或整份替换);签约和经营目标整份替换;提交前核对变化和导出范围。文件无法使用时保留旧有效版本;处理决定可记住、撤销。</p></div><div><span class="storage-label">本机保存位置</span><code id="data-directory">正在读取…</code><p>上传资料与生成记录保存在本机。下载的看板文件包含本次资料和筛选所需内容,可以离线打开。</p></div></section>
|
|
110
110
|
<footer><span>战区数字看板 <i></i> LOCAL WORKSPACE</span><span id="version-label">正在读取生成模式</span></footer>
|
|
111
111
|
</main>
|
|
112
112
|
</body>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Sum decimal source values exactly before returning JSON numbers. This avoids
|
|
2
|
+
// accumulated binary floating-point noise in currency and keeps source signs.
|
|
3
|
+
export function createDecimalSum() {
|
|
4
|
+
let total = 0n, scale = 0;
|
|
5
|
+
function add(value) {
|
|
6
|
+
const match = String(value).match(/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/i);
|
|
7
|
+
if (!match) return;
|
|
8
|
+
let digits = BigInt(`${match[1]}${match[2]}${match[3] ?? ''}`);
|
|
9
|
+
let nextScale = (match[3]?.length ?? 0) - Number(match[4] ?? 0);
|
|
10
|
+
if (nextScale < 0) { digits *= 10n ** BigInt(-nextScale); nextScale = 0; }
|
|
11
|
+
if (nextScale > scale) { total *= 10n ** BigInt(nextScale - scale); scale = nextScale; }
|
|
12
|
+
total += digits * 10n ** BigInt(scale - nextScale);
|
|
13
|
+
}
|
|
14
|
+
const exact = () => `${total}e-${scale}`;
|
|
15
|
+
return { add, exact, value: () => Number(exact()) };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function sumDecimal(values) {
|
|
19
|
+
const sum = createDecimalSum();
|
|
20
|
+
for (const value of values) if (value != null) sum.add(value);
|
|
21
|
+
return sum.value();
|
|
22
|
+
}
|