weaver-work-cli 0.1.76 → 0.1.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/chunks/{attachment-content-24RL44SE.js → attachment-content-TFOC3Y3X.js} +3 -3
- package/dist/chunks/{chunk-FEZK536Z.js → chunk-4PBN7NJY.js} +353 -43
- package/dist/chunks/{chunk-SQFKBWTR.js → chunk-5VQ7JHV4.js} +132 -47
- package/dist/chunks/{chunk-KJA7CRES.js → chunk-7SQN5IZR.js} +1 -1
- package/dist/chunks/{chunk-MS7MKBGJ.js → chunk-BP7BONZO.js} +664 -75
- package/dist/chunks/{chunk-L5SCNJKX.js → chunk-DACQKJ6O.js} +1 -1
- package/dist/chunks/{chunk-T7HVQ2WP.js → chunk-E2EY3DMS.js} +2 -2
- package/dist/chunks/{chunk-WJQJ7YEX.js → chunk-FAC4IFGQ.js} +2 -2
- package/dist/chunks/{minute-doc-4BA2R5EA.js → chunk-IBTGXLOT.js} +99 -16
- package/dist/chunks/{chunk-OJ4JPD25.js → chunk-LQLIXBJF.js} +6 -8
- package/dist/chunks/{chunk-H6N6U2D6.js → chunk-SWFTWNWL.js} +7 -7
- package/dist/chunks/{chunk-SU6IJD6D.js → chunk-TD5IOEGN.js} +1 -1
- package/dist/chunks/{chunk-Q7RXCK2Y.js → chunk-USYFVIUR.js} +22 -7
- package/dist/chunks/{chunk-WHI6YAUE.js → chunk-UZ2E3VNI.js} +1 -1
- package/dist/chunks/{chunk-AZC53XSQ.js → chunk-VNEU7OUN.js} +1 -1
- package/dist/chunks/{chunk-5QUTQHXF.js → chunk-WNFDR5PC.js} +198 -80
- package/dist/chunks/{chunk-NZQRW4KL.js → chunk-Z44YFIN6.js} +2 -2
- package/dist/chunks/{chunk-R4PN3OFK.js → chunk-ZOTXXGUM.js} +7 -7
- package/dist/chunks/{cli-DFLV57LO.js → cli-WA7FOQKC.js} +10 -10
- package/dist/chunks/{conflict-72Q6DM4I.js → conflict-D4GVAURN.js} +2 -2
- package/dist/chunks/{contract-IRNRQ5FY.js → contract-GW7US3UF.js} +4399 -3547
- package/dist/chunks/{create-flow-UGTDI7SP.js → create-flow-ERDGW3FZ.js} +10 -6
- package/dist/chunks/{ehr-PHIBBUIG.js → ehr-P6T7OAAV.js} +1 -1
- package/dist/chunks/{entry-mode-5WOXFE67.js → entry-mode-SQU5WTX6.js} +3 -3
- package/dist/chunks/{env-H4ALHESA.js → env-DASBNSEM.js} +2 -2
- package/dist/chunks/{factory-COX6AVK7.js → factory-A3NAKZAA.js} +1 -1
- package/dist/chunks/{group-chat-ZIWQQO4G.js → group-chat-7SEAVAJR.js} +3 -3
- package/dist/chunks/{lazy-dispatch-MZ3EZYDL.js → lazy-dispatch-ZDKLS5MR.js} +3 -3
- package/dist/chunks/{meeting-XE6CTXYA.js → meeting-7AEQGBAT.js} +18 -12
- package/dist/chunks/minute-doc-REI6RUE4.js +20 -0
- package/dist/chunks/{project-XREEXFU2.js → project-6PRGBLO2.js} +38 -14
- package/dist/chunks/{recruit-stage-TSQWOGQD.js → recruit-stage-TLZJUFHD.js} +543 -463
- package/dist/chunks/{registry-F4YFZLOD.js → registry-KQ4TNUWO.js} +1 -1
- package/dist/chunks/{registry-7UDUWYB5.js → registry-UVTI323K.js} +12 -11
- package/dist/chunks/{room-recommend-FO3HLPNB.js → room-recommend-ELEJUYBN.js} +4 -4
- package/dist/chunks/{schedule-DHNNOHVS.js → schedule-XBKY7VEA.js} +4 -4
- package/dist/chunks/{update-AV5VOXGY.js → update-77ZUIYSG.js} +2 -2
- package/dist/chunks/{workflow-MAGCHWYZ.js → workflow-SYCBS5XD.js} +1 -1
- package/dist/index.js +3 -3
- package/dist/internal/update/service.js +9 -8
- package/dist/shortcuts/contract/data/collection-ledger-html.js +109 -33
- package/dist/shortcuts/contract/data/collection-node-catalog.js +26 -2
- package/dist/shortcuts/contract/data/report-renderers.js +75 -31
- package/dist/shortcuts/contract/data/report-spec.js +17 -3
- package/dist/shortcuts/contract/manifest.js +20 -3
- package/dist/shortcuts/contract/operations/bizreview-report.js +23 -2
- package/dist/shortcuts/contract/operations/collection-node.js +116 -1
- package/dist/shortcuts/contract/operations/compare-report.js +27 -5
- package/dist/shortcuts/contract/operations/credit-page.js +11 -2
- package/dist/shortcuts/contract/operations/docx-slots.js +27 -2
- package/dist/shortcuts/contract/operations/draft-submit.js +9 -6
- package/dist/shortcuts/contract/operations/elements-build.js +162 -30
- package/dist/shortcuts/contract/operations/elements-spec.js +50 -0
- package/dist/shortcuts/contract/operations/generated-submit.js +35 -0
- package/dist/shortcuts/contract/operations/ledger-card.js +32 -2
- package/dist/shortcuts/contract/operations/ledger-stat.js +17 -5
- package/dist/shortcuts/contract/operations/ledger.js +88 -16
- package/dist/shortcuts/contract/operations/metrics.js +16 -3
- package/dist/shortcuts/contract/operations/ops-draft.js +359 -27
- package/dist/shortcuts/contract/operations/page.js +23 -0
- package/dist/shortcuts/contract/operations/quote-recognize.js +91 -13
- package/dist/shortcuts/contract/operations/quote-submit.js +16 -0
- package/dist/shortcuts/contract/operations/review-report.js +11 -3
- package/dist/shortcuts/contract/operations/save-recognize.js +62 -1
- package/dist/shortcuts/contract/operations/triage.js +18 -3
- package/dist/shortcuts/contract/operations/viewlink.js +17 -1
- package/dist/shortcuts/ehr/operations/recruit.js +255 -90
- package/dist/shortcuts/meeting/confirm-gate.js +42 -0
- package/dist/shortcuts/meeting/continuation.js +6 -2
- package/dist/shortcuts/meeting/minute-doc.js +119 -12
- package/dist/shortcuts/meeting/operations/attachment.js +19 -0
- package/dist/shortcuts/meeting/operations/compose-outcome.js +24 -2
- package/dist/shortcuts/meeting/operations/eb/conflict.js +2 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +162 -19
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +22 -3
- package/dist/shortcuts/meeting/operations/group-share.js +268 -0
- package/dist/shortcuts/meeting/operations/minute-content.js +58 -1
- package/dist/shortcuts/meeting/operations/minute-export.js +295 -0
- package/dist/shortcuts/meeting/operations/registry.js +4 -0
- package/dist/shortcuts/project/operations/read.js +40 -15
- package/dist/shortcuts/recruit-stage/context.js +16 -81
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +89 -53
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +15 -5
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +46 -108
- package/dist/shortcuts/recruit-stage/operations/list.js +203 -74
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +21 -85
- package/dist/shortcuts/recruit-stage/operations/search.js +113 -53
- package/dist/shortcuts/recruit-stage/shared.js +153 -4
- package/dist/shortcuts/workflow/endpoints.js +2 -0
- package/dist/shortcuts/workflow/operations/form.js +11 -0
- package/dist/shortcuts/workflow/operations/read.js +24 -5
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +2 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +2 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +28 -4
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.node.js +198 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +4 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.subordinate.js +70 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/workflowClarification.js +15 -5
- package/docs/project.md +1 -1
- package/package.json +1 -1
- package/scripts/pysite/__pycache__/sitecustomize.cpython-312.pyc +0 -0
- package/scripts/pysite/__pycache__/sitecustomize.cpython-313.pyc +0 -0
- package/scripts/pysite/__pycache__/sitecustomize.cpython-314.pyc +0 -0
- package/skills/weaver-e10-jinchengda/SKILL.md +64 -28
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-bizreview-report-template.html +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-bizreview.md +5 -4
- package/skills/weaver-e10-jinchengda/references/contract-collection-node.md +26 -2
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +9 -8
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +47 -52
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +5 -5
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +7 -1
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -12
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +44 -1
- package/skills/weaver-e10-jinchengda/references/contract-firstscreen-guide.md +5 -4
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +8 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +33 -3
- package/skills/weaver-e10-jinchengda/references/contract-ledger-report.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-material-gap.md +17 -3
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +12 -12
- package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +18 -10
- package/skills/weaver-e10-jinchengda/references/contract-ops-draft.md +77 -37
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +7 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +55 -12
- package/skills/weaver-e10-jinchengda/references/contract-review-todo.md +102 -0
- package/skills/weaver-e10-jinchengda/references/contract-sign-launch.md +1 -17
- package/skills/weaver-e10-jinchengda/references/contract-smart-draft.md +11 -8
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +2 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +6 -6
- package/skills/weaver-e10-meeting/SKILL.md +203 -80
- package/skills/weaver-e10-meeting/references/create-quickstart.md +98 -0
- package/skills/weaver-e10-meeting/references/delivery-checklist.md +34 -0
- package/skills/weaver-e10-meeting/references/error-codes.md +44 -0
- package/skills/weaver-e10-meeting/references/minutes-pipeline.md +56 -3
- package/skills/weaver-e10-meeting/references/room-recommend.md +2 -0
- package/skills/weaver-e10-recruit-stage/SKILL.md +61 -58
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +28 -25
- package/skills/weaver-e10-recruit-stage/lib/interview-summary.mjs +20 -14
- package/skills/weaver-e10-recruit-stage/lib/recruit-attach-probe.mjs +127 -0
- package/skills/weaver-e10-recruit-stage/lib/recruit-shortlist.mjs +71 -25
- package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +39 -7
- package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +2 -2
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +10 -10
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +8 -5
- package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +29 -31
- package/skills/weaver-e10-recruit-stage/references/recruit-failure-fallback.md +4 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +6 -6
- package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +4 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +3 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-maint.md +10 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +2 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +1 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-report-templates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +10 -28
- package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +2 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +1 -1
- package/skills/weaver-e10-recruit-stage/templates/candidate-evidence.html +2 -2
- package/skills/weaver-e10-recruit-stage/templates/interview-summary.html +1 -1
- package/skills/weaver-e10-recruit-stage/templates/match-report.html +14 -10
- package/skills/weaver-e10-shijingran/SKILL.md +2 -2
- package/skills/weaver-e10-shijingran/references/operations.md +5 -2
- package/skills/weaver-e10-shijingran/references/source-manifest.json +41 -40
- package/skills/weaver-e10-workflow/SKILL.md +13 -9
- package/skills/weaver-e10-workflow/references/todo-dialogue.md +33 -8
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +19 -14
- package/skills/weaver-e10-workflow/references/workflow-create.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +4 -2
- package/skills/weaver-e10-workflow/references/workflow-view.md +3 -3
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +132 -42
- package/templates/meeting/minute.docx +0 -0
- package/skills/weaver-e10-yepiaotong.zip +0 -0
|
@@ -4,18 +4,19 @@ import {
|
|
|
4
4
|
getMeetingOperation,
|
|
5
5
|
hasMeetingOperation,
|
|
6
6
|
meetingOperationDefinitions
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-BP7BONZO.js";
|
|
8
|
+
import "./chunk-E2EY3DMS.js";
|
|
9
|
+
import "./chunk-IBTGXLOT.js";
|
|
9
10
|
import "./chunk-WMRNO6IU.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-SWFTWNWL.js";
|
|
12
|
+
import "./chunk-Z44YFIN6.js";
|
|
13
|
+
import "./chunk-FAC4IFGQ.js";
|
|
14
|
+
import "./chunk-5VQ7JHV4.js";
|
|
15
|
+
import "./chunk-ZOTXXGUM.js";
|
|
16
|
+
import "./chunk-USYFVIUR.js";
|
|
17
|
+
import "./chunk-VNEU7OUN.js";
|
|
18
|
+
import "./chunk-7SQN5IZR.js";
|
|
19
|
+
import "./chunk-UZ2E3VNI.js";
|
|
19
20
|
import "./chunk-7BDPM5ST.js";
|
|
20
21
|
import "./chunk-QVKRNL7L.js";
|
|
21
22
|
import "./chunk-Y3C6MDL7.js";
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
loadRooms,
|
|
8
8
|
recommendRooms,
|
|
9
9
|
rememberFrequentRoom
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-USYFVIUR.js";
|
|
11
|
+
import "./chunk-VNEU7OUN.js";
|
|
12
|
+
import "./chunk-7SQN5IZR.js";
|
|
13
|
+
import "./chunk-UZ2E3VNI.js";
|
|
14
14
|
import "./chunk-7BDPM5ST.js";
|
|
15
15
|
import "./chunk-UG5G54VL.js";
|
|
16
16
|
import "./chunk-BUSC6UAE.js";
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
resolveMeetingScheduleTypeIds,
|
|
9
9
|
resolveMemberIdsByName,
|
|
10
10
|
runScheduleConflictFlow
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-FAC4IFGQ.js";
|
|
12
|
+
import "./chunk-VNEU7OUN.js";
|
|
13
|
+
import "./chunk-7SQN5IZR.js";
|
|
14
|
+
import "./chunk-UZ2E3VNI.js";
|
|
15
15
|
import "./chunk-7BDPM5ST.js";
|
|
16
16
|
import "./chunk-UG5G54VL.js";
|
|
17
17
|
import "./chunk-BUSC6UAE.js";
|
|
@@ -2,8 +2,8 @@ import { createRequire as __esbuildCreateRequire } from 'node:module';
|
|
|
2
2
|
const require = __esbuildCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
updateCommand
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-TD5IOEGN.js";
|
|
6
|
+
import "./chunk-LQLIXBJF.js";
|
|
7
7
|
import "./chunk-7DE3VMZD.js";
|
|
8
8
|
import "./chunk-2BZ7TY4M.js";
|
|
9
9
|
import "./chunk-UG5G54VL.js";
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunks/chunk-257JXJGD.js";
|
|
12
12
|
import {
|
|
13
13
|
UpdateService
|
|
14
|
-
} from "./chunks/chunk-
|
|
14
|
+
} from "./chunks/chunk-LQLIXBJF.js";
|
|
15
15
|
import "./chunks/chunk-7DE3VMZD.js";
|
|
16
16
|
import {
|
|
17
17
|
packageRootDir
|
|
@@ -85,7 +85,7 @@ async function bootstrap(argv = process.argv.slice(2)) {
|
|
|
85
85
|
const [{ createProgram }, { registerCommands }, { updateCommand }] = await Promise.all([
|
|
86
86
|
import("./chunks/root-YZG2TS5W.js"),
|
|
87
87
|
import("./chunks/register-SQOPIR2G.js"),
|
|
88
|
-
import("./chunks/update-
|
|
88
|
+
import("./chunks/update-77ZUIYSG.js")
|
|
89
89
|
]);
|
|
90
90
|
const { program, ctx } = createProgram();
|
|
91
91
|
await registerCommands(program, ctx, [updateCommand]);
|
|
@@ -112,7 +112,7 @@ async function bootstrap(argv = process.argv.slice(2)) {
|
|
|
112
112
|
var startup = await bootstrap();
|
|
113
113
|
if (!startup.handled) {
|
|
114
114
|
try {
|
|
115
|
-
await import("./chunks/cli-
|
|
115
|
+
await import("./chunks/cli-WA7FOQKC.js");
|
|
116
116
|
} finally {
|
|
117
117
|
startup.release?.();
|
|
118
118
|
}
|
|
@@ -7,6 +7,7 @@ import { isXiaoEHostEnvironment } from '../../core/runtime-agent.js';
|
|
|
7
7
|
import { compareVersions, findNpmCli, npmRunner } from './npm.js';
|
|
8
8
|
import { UPDATE_INTERVAL_MS, UpdateStore } from './store.js';
|
|
9
9
|
const NAME = 'weaver-work-cli';
|
|
10
|
+
export const UPDATE_REGISTRY = 'https://registry.npmmirror.com/';
|
|
10
11
|
const CHECK_TIMEOUT_MS = 3_000;
|
|
11
12
|
const INSTALL_TIMEOUT_MS = 120_000;
|
|
12
13
|
export class UpdateService {
|
|
@@ -47,7 +48,7 @@ export class UpdateService {
|
|
|
47
48
|
catch {
|
|
48
49
|
throw new Error('无法读取 npm 安装配置,请检查 npm 是否可用。');
|
|
49
50
|
}
|
|
50
|
-
if (typeof config.prefix !== 'string'
|
|
51
|
+
if (typeof config.prefix !== 'string')
|
|
51
52
|
throw new Error('无法识别 npm 安装配置。');
|
|
52
53
|
const prefix = resolve(config.prefix);
|
|
53
54
|
const expected = process.platform === 'win32'
|
|
@@ -60,11 +61,9 @@ export class UpdateService {
|
|
|
60
61
|
catch { /* Not this installation. */ }
|
|
61
62
|
if (!matches)
|
|
62
63
|
throw new Error('当前 CLI 不是此 npm 管理的全局安装,未执行更新。请使用原安装方式维护。');
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
return { prefix, registry: registry.href };
|
|
64
|
+
// Version lookup and installation use the same domestic mirror. Never mutate
|
|
65
|
+
// the user's npmrc, and never inherit registry overrides from their environment.
|
|
66
|
+
return { prefix, registry: UPDATE_REGISTRY };
|
|
68
67
|
}
|
|
69
68
|
status() {
|
|
70
69
|
if (this.skipReason)
|
|
@@ -79,7 +78,8 @@ export class UpdateService {
|
|
|
79
78
|
};
|
|
80
79
|
}
|
|
81
80
|
validPending(state) {
|
|
82
|
-
return
|
|
81
|
+
return state.registry === UPDATE_REGISTRY
|
|
82
|
+
&& typeof state.pending?.version === 'string'
|
|
83
83
|
&& typeof state.pending.token === 'string'
|
|
84
84
|
&& /^[a-f0-9-]{36}$/.test(state.pending.token)
|
|
85
85
|
&& compareVersions(state.pending.version, this.options.currentVersion) === 1;
|
|
@@ -115,11 +115,12 @@ export class UpdateService {
|
|
|
115
115
|
if (typeof latest !== 'string' || compareVersions(latest, this.options.currentVersion) === undefined) {
|
|
116
116
|
throw new Error('npm 返回的版本号无效。');
|
|
117
117
|
}
|
|
118
|
+
const samePending = this.validPending(state) && state.pending.version === latest;
|
|
118
119
|
state.latestVersion = latest;
|
|
119
120
|
state.prefix = install.prefix;
|
|
120
121
|
state.registry = install.registry;
|
|
121
122
|
if (compareVersions(latest, this.options.currentVersion) === 1) {
|
|
122
|
-
if (!
|
|
123
|
+
if (!samePending) {
|
|
123
124
|
state.pending = { version: latest, token: randomUUID() };
|
|
124
125
|
}
|
|
125
126
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PROJECT_CARD_OBJ_ID } from '../operations/page.js';
|
|
1
2
|
/**
|
|
2
3
|
* 收款节点台账 HTML(2026-11-29)。
|
|
3
4
|
*
|
|
@@ -49,6 +50,14 @@ td.num,th.num{text-align:right;font-variant-numeric:tabular-nums;white-space:now
|
|
|
49
50
|
.pill.g{color:var(--green);background:var(--green-bg)}
|
|
50
51
|
.pill.gray{color:var(--text-2);background:#eef0f4}
|
|
51
52
|
.overdue{color:var(--red);font-weight:600}
|
|
53
|
+
a.jump{color:var(--primary);text-decoration:none;border-bottom:1px dashed rgba(36,104,242,.45)}
|
|
54
|
+
a.jump:hover{color:#1a53cc;border-bottom-style:solid}
|
|
55
|
+
.sep{color:var(--text-3)}
|
|
56
|
+
tr.group>td{background:#fbfcff;border-top:1px solid var(--border)}
|
|
57
|
+
tr.detail>td{background:#fff}
|
|
58
|
+
tr.detail .term{color:var(--text);padding-left:12px;position:relative;line-height:1.6}
|
|
59
|
+
tr.detail .term::before{content:"└";position:absolute;left:0;color:var(--text-3)}
|
|
60
|
+
tr.detail .sub{font-size:12px;color:var(--text-3)}
|
|
52
61
|
.empty{padding:44px;text-align:center;color:var(--text-3)}
|
|
53
62
|
.footer-note{padding:12px 20px;font-size:12px;color:var(--text-3);border-top:1px solid var(--border);line-height:1.8}
|
|
54
63
|
.warnbar{background:var(--orange-bg);border:1px solid #f7d9b0;color:#8a5200;border-radius:8px;padding:10px 16px;font-size:12.5px;margin-top:16px;line-height:1.7}
|
|
@@ -74,45 +83,109 @@ function formatWan(value) {
|
|
|
74
83
|
return '—';
|
|
75
84
|
return (Number(value) / 10000).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
76
85
|
}
|
|
86
|
+
function groupRows(rows) {
|
|
87
|
+
const groups = new Map();
|
|
88
|
+
for (const row of rows) {
|
|
89
|
+
const contractNo = String(row.contractNo ?? '').trim();
|
|
90
|
+
const key = `${row.projectId}||${contractNo}`;
|
|
91
|
+
let group = groups.get(key);
|
|
92
|
+
if (!group) {
|
|
93
|
+
group = {
|
|
94
|
+
key,
|
|
95
|
+
projectId: row.projectId,
|
|
96
|
+
projectName: row.projectName,
|
|
97
|
+
contractNo,
|
|
98
|
+
contractAmount: row.contractAmount,
|
|
99
|
+
dueAmount: 0,
|
|
100
|
+
receivedAmount: 0,
|
|
101
|
+
unreceivedAmount: 0,
|
|
102
|
+
maxOverdueDays: 0,
|
|
103
|
+
overdueStages: 0,
|
|
104
|
+
stages: [],
|
|
105
|
+
};
|
|
106
|
+
groups.set(key, group);
|
|
107
|
+
}
|
|
108
|
+
// 合同金额是合同级属性:同组多行取**最大值**,不重复累加(避免虚增)
|
|
109
|
+
group.contractAmount = Math.max(group.contractAmount, row.contractAmount);
|
|
110
|
+
group.dueAmount = round2(group.dueAmount + row.dueAmount);
|
|
111
|
+
group.receivedAmount = round2(group.receivedAmount + row.receivedAmount);
|
|
112
|
+
group.unreceivedAmount = round2(group.unreceivedAmount + row.unreceivedAmount);
|
|
113
|
+
const overdue = row.overdueDays ?? 0;
|
|
114
|
+
if (overdue > 0) {
|
|
115
|
+
group.overdueStages += 1;
|
|
116
|
+
group.maxOverdueDays = Math.max(group.maxOverdueDays, overdue);
|
|
117
|
+
}
|
|
118
|
+
group.stages.push(row);
|
|
119
|
+
}
|
|
120
|
+
for (const group of groups.values()) {
|
|
121
|
+
group.stages.sort((a, b) => (b.overdueDays ?? -Infinity) - (a.overdueDays ?? -Infinity));
|
|
122
|
+
}
|
|
123
|
+
return [...groups.values()].sort((a, b) => b.maxOverdueDays - a.maxOverdueDays);
|
|
124
|
+
}
|
|
125
|
+
function round2(value) {
|
|
126
|
+
return Math.round(value * 100) / 100;
|
|
127
|
+
}
|
|
128
|
+
/** 单元格里的链接:能取到地址就渲染 `<a target="_blank">`,取不到就是纯文本。 */
|
|
129
|
+
function anchor(href, label) {
|
|
130
|
+
const text = esc(label || '—');
|
|
131
|
+
if (!href)
|
|
132
|
+
return text;
|
|
133
|
+
return `<a class="jump" href="${esc(href)}" target="_blank" rel="noopener">${text}</a>`;
|
|
134
|
+
}
|
|
135
|
+
function statusPill(overdue) {
|
|
136
|
+
if (overdue === null)
|
|
137
|
+
return '<span class="pill gray">无计划日</span>';
|
|
138
|
+
if (overdue > 0)
|
|
139
|
+
return '<span class="pill r">已逾期</span>';
|
|
140
|
+
if (overdue === 0)
|
|
141
|
+
return '<span class="pill o">今日到期</span>';
|
|
142
|
+
return '<span class="pill o">待到账</span>';
|
|
143
|
+
}
|
|
77
144
|
export function renderCollectionLedger(rows, totals, options = {}) {
|
|
78
145
|
const title = options.title?.trim() || '合同台账 · 收款节点';
|
|
79
146
|
const manager = options.managerName?.trim() || '—';
|
|
80
147
|
const generatedAt = (options.generatedAt ?? new Date()).toLocaleString('zh-CN', { hour12: false });
|
|
81
148
|
const warnings = options.warnings ?? [];
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
<td
|
|
106
|
-
<td
|
|
107
|
-
<td class="
|
|
149
|
+
const linkOf = options.linkOf ?? {};
|
|
150
|
+
const groups = groupRows(rows);
|
|
151
|
+
const body = groups.length === 0
|
|
152
|
+
? '<tr><td colspan="10"><div class="empty">该客户经理名下暂无「条件已达成且未收清」的付款阶段</div></td></tr>'
|
|
153
|
+
: groups.map((group) => {
|
|
154
|
+
const projectHref = group.projectId && linkOf.project ? linkOf.project(group.projectId) : '';
|
|
155
|
+
const contractParts = group.contractNo
|
|
156
|
+
? group.contractNo.split(',').map((item) => item.trim()).filter(Boolean)
|
|
157
|
+
: [];
|
|
158
|
+
const contractHtml = contractParts.length
|
|
159
|
+
? contractParts.map((no) => anchor(linkOf.contract ? linkOf.contract(no) : '', no)).join('<span class="sep">、</span>')
|
|
160
|
+
: '—';
|
|
161
|
+
const overdueText = group.overdueStages > 0
|
|
162
|
+
? `<span class="overdue">${group.maxOverdueDays}</span>`
|
|
163
|
+
: '—';
|
|
164
|
+
const mainRow = ` <tr class="group">
|
|
165
|
+
<td><div class="cname">${anchor(projectHref, group.projectName || '—')}</div><div class="ctype">合同号:${contractHtml}</div></td>
|
|
166
|
+
<td><div class="ctype">共 ${group.stages.length} 个收款节点${group.overdueStages ? `(逾期 ${group.overdueStages} 个)` : ''}</div></td>
|
|
167
|
+
<td class="num"><b>${formatMoney(group.contractAmount)}</b></td>
|
|
168
|
+
<td class="num">—</td>
|
|
169
|
+
<td class="num"><b>${formatMoney(group.dueAmount)}</b></td>
|
|
170
|
+
<td class="num">${formatMoney(group.receivedAmount)}</td>
|
|
171
|
+
<td class="num"><b>${formatMoney(group.unreceivedAmount)}</b></td>
|
|
172
|
+
<td class="mono">—</td>
|
|
173
|
+
<td class="num">${overdueText}</td>
|
|
174
|
+
<td>${group.overdueStages ? `<span class="pill r">${group.overdueStages} 个逾期</span>` : '<span class="pill g">未逾期</span>'}</td>
|
|
175
|
+
</tr>`;
|
|
176
|
+
const detailRows = group.stages.map((row) => ` <tr class="detail">
|
|
177
|
+
<td><div class="term">${esc(row.term || '—')}</div></td>
|
|
178
|
+
<td><span class="sub">└ 收款节点</span></td>
|
|
179
|
+
<td class="num">—</td>
|
|
108
180
|
<td class="num">${row.ratio ? `${row.ratio}%` : '—'}</td>
|
|
109
181
|
<td class="num">${formatMoney(row.dueAmount)}</td>
|
|
110
182
|
<td class="num">${formatMoney(row.receivedAmount)}</td>
|
|
111
|
-
<td class="num"
|
|
183
|
+
<td class="num">${formatMoney(row.unreceivedAmount)}</td>
|
|
112
184
|
<td class="mono">${esc(row.planReceiveDate || '—')}</td>
|
|
113
|
-
<td class="num">${
|
|
114
|
-
<td>${
|
|
115
|
-
</tr
|
|
185
|
+
<td class="num">${row.overdueDays !== null && row.overdueDays > 0 ? `<span class="overdue">${row.overdueDays}</span>` : '—'}</td>
|
|
186
|
+
<td>${statusPill(row.overdueDays)}</td>
|
|
187
|
+
</tr>`).join('\n');
|
|
188
|
+
return `${mainRow}\n${detailRows}`;
|
|
116
189
|
}).join('\n');
|
|
117
190
|
const warnHtml = warnings.length
|
|
118
191
|
? `<div class="warnbar">${warnings.map((item) => esc(item)).join('<br>')}</div>`
|
|
@@ -146,7 +219,7 @@ export function renderCollectionLedger(rows, totals, options = {}) {
|
|
|
146
219
|
<div class="stat">
|
|
147
220
|
<div class="k">合同金额合计</div>
|
|
148
221
|
<div class="v">${formatWan(totals.contractAmount)}<small> 万元</small></div>
|
|
149
|
-
<div class="sub"
|
|
222
|
+
<div class="sub">${totals.contracts} 份合同(同一合同多期只计一次)</div>
|
|
150
223
|
</div>
|
|
151
224
|
<div class="stat">
|
|
152
225
|
<div class="k">本期应收合计</div>
|
|
@@ -166,7 +239,7 @@ export function renderCollectionLedger(rows, totals, options = {}) {
|
|
|
166
239
|
</div>
|
|
167
240
|
|
|
168
241
|
<div class="table-card">
|
|
169
|
-
<div class="table-head"><span class="t">到收款节点的付款阶段</span><span class="n"
|
|
242
|
+
<div class="table-head"><span class="t">到收款节点的付款阶段</span><span class="n">${groups.length} 个项目·合同,共 ${totals.stages} 个收款节点</span></div>
|
|
170
243
|
<table>
|
|
171
244
|
<thead><tr>
|
|
172
245
|
<th>项目 / 合同号</th><th>付款条件</th><th class="num">合同金额(元)</th><th class="num">比例</th>
|
|
@@ -179,7 +252,10 @@ ${body}
|
|
|
179
252
|
</table>
|
|
180
253
|
<div class="footer-note">
|
|
181
254
|
数据来源:项目看板(客户经理 = ${esc(manager)},项目状态 ∈ 5 个未结束值)→ 项目合同付款阶段明细台账(关联项目 inC 批量过滤,台账仅返回未收清条款)。<br>
|
|
182
|
-
|
|
255
|
+
呈现口径:同一「项目 + 合同号」的多笔收款节点合并为一组 —— 主行给合同金额与应收/已收/未收合计,明细行(└)给每个收款节点;合同金额是合同级属性,只在主行出现一次,明细行不重复。<br>
|
|
256
|
+
口径:本期应收 = 合同金额 × 比例;未收 = 本期应收 − 已收;逾期天数 = 今天 − 计划收款日(本地计算,正数表示已逾期)。金额单位:元(KPI 卡另附万元概览)。<br>
|
|
257
|
+
KPI「合同金额合计」按合同去重统计(同一合同有多期只计一次,不是按行累加);应收/已收/未收则是各期之和。<br>
|
|
258
|
+
跳转:项目名 → 项目卡片页(/sp/ebdfpage/card/2/${PROJECT_CARD_OBJ_ID}/{项目ID});合同号 → 合同卡片页(/sp/ebdfpage/card/0/846297265322573825/{数据ID},数据 ID 由本链路按合同号解析;解析不到的合同号不带链接)。
|
|
183
259
|
</div>
|
|
184
260
|
</div>
|
|
185
261
|
</div>
|
|
@@ -207,13 +207,37 @@ export function daysBetween(dateText, today) {
|
|
|
207
207
|
const base = Date.UTC(today.getFullYear(), today.getMonth(), today.getDate());
|
|
208
208
|
return Math.round((base - target) / 86_400_000);
|
|
209
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* 合同金额的去重键:同一份合同无论出现几期(几行),合同金额只应计一次。
|
|
212
|
+
*
|
|
213
|
+
* 2026-12-01 事故:`summarize` 原先按**行**累加 `contractAmount`,同一合同有 2 期就被算了两遍
|
|
214
|
+
* (3 行 × 50 万 → KPI 显示 150 万,实际只有 2 份合同 100 万)。
|
|
215
|
+
* 合同号字段可能是多值(`HT-001,HT-002`)→ 先拆分排序再拼键,保证 `HT-001,HT-002` 与
|
|
216
|
+
* `HT-002,HT-001` 是同一把键。
|
|
217
|
+
*/
|
|
218
|
+
export function contractKeyOf(contractNo) {
|
|
219
|
+
return String(contractNo ?? '')
|
|
220
|
+
.split(',')
|
|
221
|
+
.map((item) => item.trim())
|
|
222
|
+
.filter(Boolean)
|
|
223
|
+
.sort()
|
|
224
|
+
.join('|');
|
|
225
|
+
}
|
|
210
226
|
export function summarize(rows) {
|
|
211
227
|
const overdue = rows.filter((row) => (row.overdueDays ?? 0) > 0);
|
|
228
|
+
// 合同金额按**合同**去重(同一合同多期只计一次,金额取该合同各行的最大值,避免脏数据放大)
|
|
229
|
+
const amountByContract = new Map();
|
|
230
|
+
for (const row of rows) {
|
|
231
|
+
const key = contractKeyOf(row.contractNo);
|
|
232
|
+
if (!key)
|
|
233
|
+
continue;
|
|
234
|
+
amountByContract.set(key, Math.max(amountByContract.get(key) ?? 0, row.contractAmount));
|
|
235
|
+
}
|
|
212
236
|
return {
|
|
213
237
|
stages: rows.length,
|
|
214
|
-
contracts: new Set(rows.map((row) => row.contractNo).filter(Boolean)).size,
|
|
238
|
+
contracts: amountByContract.size || new Set(rows.map((row) => row.contractNo).filter(Boolean)).size,
|
|
215
239
|
projects: new Set(rows.map((row) => row.projectId).filter(Boolean)).size,
|
|
216
|
-
contractAmount: round2(
|
|
240
|
+
contractAmount: round2([...amountByContract.values()].reduce((sum, value) => sum + value, 0)),
|
|
217
241
|
dueAmount: round2(rows.reduce((sum, row) => sum + row.dueAmount, 0)),
|
|
218
242
|
receivedAmount: round2(rows.reduce((sum, row) => sum + row.receivedAmount, 0)),
|
|
219
243
|
unreceivedAmount: round2(rows.reduce((sum, row) => sum + row.unreceivedAmount, 0)),
|
|
@@ -173,14 +173,21 @@ function dimensionLabel(data) {
|
|
|
173
173
|
const CHART_W = 960;
|
|
174
174
|
const CHART_H = 260;
|
|
175
175
|
const PAD = { top: 14, right: 18, bottom: 30, left: 68 };
|
|
176
|
-
|
|
176
|
+
/**
|
|
177
|
+
* 坐标系:`top` 由**调用方**按实际数据算(率值也要允许 >100%,见 renderLine)。
|
|
178
|
+
*
|
|
179
|
+
* 2026-12-01 修复:原签名是 `chartFrame(maxValue, rateMode)` 且内部写死
|
|
180
|
+
* `top = rateMode ? 100 : maxValue || 1` —— 折线图调用时传 `maxValue=0`(因为率值分支不需要它),
|
|
181
|
+
* 于是非率值折线的纵轴上限变成 **1**,所有描点飞出绘图区、刻度退化成「0,0,1,1,1」。
|
|
182
|
+
*/
|
|
183
|
+
function chartFrame(top, rateMode) {
|
|
177
184
|
const innerW = CHART_W - PAD.left - PAD.right;
|
|
178
185
|
const innerH = CHART_H - PAD.top - PAD.bottom;
|
|
179
|
-
const
|
|
180
|
-
const y = (value) => PAD.top + innerH - (value /
|
|
186
|
+
const safeTop = Number.isFinite(top) && top > 0 ? top : 1;
|
|
187
|
+
const y = (value) => PAD.top + innerH - (value / safeTop) * innerH;
|
|
181
188
|
const ticks = [0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
182
|
-
const value =
|
|
183
|
-
return { y: y(value), label: rateMode ? `${
|
|
189
|
+
const value = safeTop * ratio;
|
|
190
|
+
return { y: y(value), label: rateMode ? `${axisTick(value)}%` : axisTick(value) };
|
|
184
191
|
});
|
|
185
192
|
return { y, ticks, innerW, innerH };
|
|
186
193
|
}
|
|
@@ -190,11 +197,14 @@ function gridSvg(ticks) {
|
|
|
190
197
|
stroke="${LINE}" stroke-width="1" ${tick.label === '0' || tick.label === '0%' ? '' : 'stroke-dasharray="3 4"'} />
|
|
191
198
|
<text x="${PAD.left - 10}" y="${(tick.y + 3.5).toFixed(1)}" text-anchor="end" font-size="10.5" fill="${MUTED}">${esc(tick.label)}</text>`).join('');
|
|
192
199
|
}
|
|
193
|
-
function axisLabels(rows, innerW
|
|
200
|
+
function axisLabels(rows, innerW) {
|
|
194
201
|
const band = innerW / Math.max(rows.length, 1);
|
|
202
|
+
// 2026-12-01 修复:原先只在 >14 桶时显示全标签,13 个月(跨年)会把「2025-01 / 2026-01」都截成「01」;
|
|
203
|
+
// 客户/销售经理维度更会把企业名截成最后两个字。现在:≤8 桶水平显示全标签,>8 桶一律全标签 + 旋转。
|
|
204
|
+
const rotate = rows.length > 8;
|
|
195
205
|
return rows.map((row, index) => {
|
|
196
206
|
const cx = PAD.left + band * index + band / 2;
|
|
197
|
-
const label =
|
|
207
|
+
const label = bucketLabel(row);
|
|
198
208
|
return `<text x="${cx.toFixed(1)}" y="${CHART_H - 8}" text-anchor="${rotate ? 'end' : 'middle'}"
|
|
199
209
|
font-size="10.5" fill="${MUTED}"${rotate ? ` transform="rotate(-28 ${cx.toFixed(1)} ${CHART_H - 8})"` : ''}>${esc(label)}</text>`;
|
|
200
210
|
}).join('');
|
|
@@ -232,10 +242,27 @@ export function renderKpi(data, block) {
|
|
|
232
242
|
}).join('');
|
|
233
243
|
return `<section class="card">
|
|
234
244
|
<h2>${esc(block.title ?? '总览')}</h2>
|
|
235
|
-
<p class="hint">${esc(data.window.from)} ~ ${esc(data.window.to)}
|
|
245
|
+
<p class="hint">${esc(data.window.from)} ~ ${esc(data.window.to)}${grainHint(keys.map((key) => metricOf(data, key).aggregation))}${compareMode === 'yoy' ? ';同比为「去年同期」对比' : ''}</p>
|
|
236
246
|
<div class="kpis">${cards}</div>
|
|
237
247
|
</section>`;
|
|
238
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* KPI 卡的**口径说明**:不同聚合方式不能说成同一个"合计"。
|
|
251
|
+
*
|
|
252
|
+
* 2026-12-01 修复:原先一律写「合计」,而 `countDistinct`(新签客户数)是**整窗去重**、
|
|
253
|
+
* `ratio`(回款率)是 **Σ分子÷Σ分母**——把它们读成"可以相加的合计"正是本类口径事故的入口。
|
|
254
|
+
*/
|
|
255
|
+
function grainHint(aggregations) {
|
|
256
|
+
const unique = [...new Set(aggregations)];
|
|
257
|
+
const parts = unique.map((aggregation) => {
|
|
258
|
+
if (aggregation === 'countDistinct')
|
|
259
|
+
return '去重口径(整窗去重,不是各期相加)';
|
|
260
|
+
if (aggregation === 'ratio')
|
|
261
|
+
return '率值口径(Σ分子÷Σ分母,分母为 0 记「—」)';
|
|
262
|
+
return '金额口径(窗口内合计)';
|
|
263
|
+
});
|
|
264
|
+
return parts.length ? ` · ${parts.join(';')}` : '';
|
|
265
|
+
}
|
|
239
266
|
// ---------------------------------------------------------------- 积木:双柱
|
|
240
267
|
export function renderGroupedBar(data, block) {
|
|
241
268
|
const key = block.metric ?? data.metrics.find((metric) => metric.aggregation === 'sum')?.key;
|
|
@@ -245,31 +272,37 @@ export function renderGroupedBar(data, block) {
|
|
|
245
272
|
const unit = unitOf(metric.aggregation);
|
|
246
273
|
const compareMode = (block.compare ?? data.window.compare) === 'yoy';
|
|
247
274
|
const values = data.series.map((row) => {
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
|
|
275
|
+
const raw = row.values[key];
|
|
276
|
+
const previousRaw = compareMode ? row.previousYear?.values?.[key] : null;
|
|
277
|
+
// 2026-12-01 修复:null(不可用)**不得补 0** —— 补 0 会画出一根"0 柱"并在 tooltip 里断言 0.00,
|
|
278
|
+
// 与同页明细表的「—」、口径说明的「不代表 0」自相矛盾。这里保留 null,不画柱、tooltip 显示「—」。
|
|
279
|
+
return {
|
|
280
|
+
current: raw === null || raw === undefined ? null : Number(raw),
|
|
281
|
+
previous: previousRaw === null || previousRaw === undefined ? null : Number(previousRaw),
|
|
282
|
+
};
|
|
251
283
|
});
|
|
252
|
-
const maxValue = Math.max(...values.flatMap((item) => [item.current, item.previous ?? 0]),
|
|
253
|
-
const
|
|
284
|
+
const maxValue = Math.max(...values.flatMap((item) => [item.current ?? 0, item.previous ?? 0]), 0);
|
|
285
|
+
const rateMode = metric.aggregation === 'ratio';
|
|
286
|
+
const { y, ticks, innerW, innerH } = chartFrame(maxValue, rateMode);
|
|
254
287
|
const band = innerW / Math.max(values.length, 1);
|
|
255
288
|
const barW = Math.min(26, band * 0.26);
|
|
289
|
+
const rectOf = (value, x, color) => {
|
|
290
|
+
if (value === null)
|
|
291
|
+
return '';
|
|
292
|
+
const height = Math.max(value > 0 ? 2 : 0, innerH - (y(value) - PAD.top));
|
|
293
|
+
return `<rect x="${x.toFixed(1)}" y="${(PAD.top + innerH - height).toFixed(1)}" width="${barW.toFixed(1)}" height="${height.toFixed(1)}" rx="3" fill="${color}" />`;
|
|
294
|
+
};
|
|
295
|
+
const textOf = (value) => (value === null ? '—' : unit.value(value));
|
|
256
296
|
const bars = values.map((item, index) => {
|
|
257
297
|
const cx = PAD.left + band * index + band / 2;
|
|
258
298
|
const currentX = compareMode ? cx - barW - 1 : cx - barW / 2;
|
|
259
|
-
|
|
260
|
-
const currentRect = `<rect x="${currentX.toFixed(1)}" y="${(PAD.top + innerH - currentH).toFixed(1)}" width="${barW.toFixed(1)}" height="${currentH.toFixed(1)}" rx="3" fill="${ACCENT}" />`;
|
|
261
|
-
let previousRect = '';
|
|
262
|
-
if (item.previous !== null) {
|
|
263
|
-
const previousH = Math.max(item.previous > 0 ? 2 : 0, innerH - (y(item.previous) - PAD.top));
|
|
264
|
-
previousRect = `<rect x="${(cx + 1).toFixed(1)}" y="${(PAD.top + innerH - previousH).toFixed(1)}" width="${barW.toFixed(1)}" height="${previousH.toFixed(1)}" rx="3" fill="${ACCENT_SOFT}" />`;
|
|
265
|
-
}
|
|
266
|
-
return `<g><title>${esc(bucketLabel(data.series[index]))}|本期 ${esc(unit.value(item.current))}${item.previous === null ? '' : `|去年 ${esc(unit.value(item.previous))}`}</title>${previousRect}${currentRect}</g>`;
|
|
299
|
+
return `<g><title>${esc(bucketLabel(data.series[index]))}|本期 ${esc(textOf(item.current))}${compareMode ? `|去年 ${esc(textOf(item.previous))}` : ''}</title>${rectOf(item.previous, cx + 1, ACCENT_SOFT)}${rectOf(item.current, currentX, ACCENT)}</g>`;
|
|
267
300
|
}).join('');
|
|
268
301
|
return `<section class="card">
|
|
269
302
|
<h2>${esc(block.title ?? `${metric.label} · 按月`)}</h2>
|
|
270
|
-
<p class="hint">${esc(data.window.from)} ~ ${esc(data.window.to)}${compareMode ? ' 与去年同期对比' : ''},单位:${unit.header
|
|
303
|
+
<p class="hint">${esc(data.window.from)} ~ ${esc(data.window.to)}${compareMode ? ' 与去年同期对比' : ''},单位:${esc(unit.header)};「—」表示该期不可用(未补 0)</p>
|
|
271
304
|
<svg class="chart" viewBox="0 0 ${CHART_W} ${CHART_H}" role="img" aria-label="${esc(metric.label)}按月柱状图">
|
|
272
|
-
${gridSvg(ticks)}${bars}${axisLabels(data.series, innerW
|
|
305
|
+
${gridSvg(ticks)}${bars}${axisLabels(data.series, innerW)}
|
|
273
306
|
</svg>
|
|
274
307
|
<div class="legend">
|
|
275
308
|
<span><i class="swatch" style="background:${ACCENT}"></i>本期</span>
|
|
@@ -285,7 +318,11 @@ export function renderLine(data, block) {
|
|
|
285
318
|
const metric = metricOf(data, key);
|
|
286
319
|
const rateMode = metric.aggregation === 'ratio';
|
|
287
320
|
const compareMode = (block.compare ?? data.window.compare) === 'yoy';
|
|
288
|
-
|
|
321
|
+
// 2026-12-01 修复:纵轴上限必须按**实际数据**算(原先非率值分支传 0 → 上限 1 → 描点飞出画布);
|
|
322
|
+
// 率值分支也允许 >100%(分子有值而分母缺省时可能超过 100)。
|
|
323
|
+
const observed = Math.max(...data.series.flatMap((row) => [row.values[key], row.previousYear?.values?.[key]])
|
|
324
|
+
.map((value) => (value === null || value === undefined ? 0 : Number(value))), 0);
|
|
325
|
+
const { y, ticks, innerW } = chartFrame(rateMode ? Math.max(100, observed) : observed, rateMode);
|
|
289
326
|
const band = innerW / Math.max(data.series.length, 1);
|
|
290
327
|
const pointsOf = (source) => data.series.map((row, index) => {
|
|
291
328
|
const container = source === 'current' ? row.values : (row.previousYear?.values ?? null);
|
|
@@ -327,7 +364,7 @@ export function renderLine(data, block) {
|
|
|
327
364
|
${pathOf(current, ACCENT, false)}
|
|
328
365
|
${compareMode ? dotsOf(previous, '#94a3b8') : ''}
|
|
329
366
|
${dotsOf(current, ACCENT)}
|
|
330
|
-
${axisLabels(data.series, innerW
|
|
367
|
+
${axisLabels(data.series, innerW)}
|
|
331
368
|
</svg>
|
|
332
369
|
<div class="legend">
|
|
333
370
|
<span><i class="swatch" style="background:${ACCENT}"></i>本期</span>
|
|
@@ -344,11 +381,15 @@ export function renderHbar(data, block) {
|
|
|
344
381
|
const unit = unitOf(metric.aggregation);
|
|
345
382
|
const limit = block.limit ?? 10;
|
|
346
383
|
const sortDesc = (block.sort ?? 'desc') === 'desc';
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
384
|
+
// 2026-12-01 修复:原先把「超 limit 未展示」与「该口径不可用」合并成一句"其余 N 项未展示",
|
|
385
|
+
// 读者会把"取数失败/分母 0"误当成"只是没显示"。两种原因分开说。
|
|
386
|
+
const usable = data.series.filter((row) => (row.values[key] ?? null) !== null);
|
|
387
|
+
const rows = usable
|
|
388
|
+
.map((row) => ({ label: bucketLabel(row), value: row.values[key] }))
|
|
350
389
|
.sort((a, b) => (sortDesc ? Number(b.value) - Number(a.value) : Number(a.value) - Number(b.value)))
|
|
351
390
|
.slice(0, limit);
|
|
391
|
+
const droppedByLimit = usable.length - rows.length;
|
|
392
|
+
const droppedNull = data.series.length - usable.length;
|
|
352
393
|
const max = Math.max(...rows.map((row) => Math.abs(Number(row.value))), 1);
|
|
353
394
|
const bars = rows.map((row) => {
|
|
354
395
|
const width = Math.max(1, Math.round((Math.abs(Number(row.value)) / max) * 100));
|
|
@@ -358,11 +399,14 @@ export function renderHbar(data, block) {
|
|
|
358
399
|
<div class="rank-val">${esc(unit.value(Number(row.value)))}${esc(unit.suffix)}</div>
|
|
359
400
|
</div>`;
|
|
360
401
|
}).join('');
|
|
361
|
-
const
|
|
402
|
+
const notes = [
|
|
403
|
+
droppedByLimit > 0 ? `另有 ${droppedByLimit} 项未展示` : '',
|
|
404
|
+
droppedNull > 0 ? `${droppedNull} 项该口径不可用(计数/取值失败,未计入排行)` : '',
|
|
405
|
+
].filter(Boolean).join(';');
|
|
362
406
|
return `<section class="card">
|
|
363
407
|
<h2>${esc(block.title ?? `${metric.label} · ${dimensionLabel(data)}排行`)}</h2>
|
|
364
|
-
<p class="hint">按${esc(dimensionLabel(data))}聚合,${sortDesc ? '从高到低' : '从低到高'}取前 ${limit}${
|
|
365
|
-
<div class="rank">${bars || '<div class="hint"
|
|
408
|
+
<p class="hint">按${esc(dimensionLabel(data))}聚合,${sortDesc ? '从高到低' : '从低到高'}取前 ${limit}${notes ? `(共 ${data.series.length} 项:${notes})` : ''}</p>
|
|
409
|
+
<div class="rank">${bars || '<div class="hint">无可用数据</div>'}</div>
|
|
366
410
|
</section>`;
|
|
367
411
|
}
|
|
368
412
|
// ---------------------------------------------------------------- 积木:明细表
|
|
@@ -72,11 +72,25 @@ export function validateSpec(spec, data) {
|
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
74
|
// 图类:单指标 + 不允许跨量纲
|
|
75
|
+
// 2026-12-01 修复:图类渲染器只读 `block.metric`,此前传 `metrics:['某口径']` 会**校验通过但静默画默认口径**
|
|
76
|
+
// (违背本文件「不认识就报错,不猜、不静默降级」)。现在把单元素 metrics **提升为 metric**(尊重调用方选择),
|
|
77
|
+
// 与 metric 冲突则报错;多元素仍按「图类只接受一个口径」拒绝。
|
|
78
|
+
if (block.metrics !== undefined) {
|
|
79
|
+
if (!Array.isArray(block.metrics) || block.metrics.length === 0) {
|
|
80
|
+
throw new ReportSpecError('spec_metric_required', `${where}.metrics 必须是非空数组`);
|
|
81
|
+
}
|
|
82
|
+
if (block.metrics.length > 1) {
|
|
83
|
+
throw new ReportSpecError('spec_single_metric', `${where}:图类积木只接受一个口径(多口径请改用 table 或 kpi)`);
|
|
84
|
+
}
|
|
85
|
+
const only = checkMetric(block.metrics[0], 'metrics[]');
|
|
86
|
+
if (block.metric !== undefined && block.metric !== only) {
|
|
87
|
+
throw new ReportSpecError('spec_metric_conflict', `${where}:metric 与 metrics 给了不同口径(${block.metric} / ${only})`);
|
|
88
|
+
}
|
|
89
|
+
block.metric = only;
|
|
90
|
+
delete block.metrics;
|
|
91
|
+
}
|
|
75
92
|
if (block.metric !== undefined)
|
|
76
93
|
checkMetric(block.metric, 'metric');
|
|
77
|
-
if (block.metrics !== undefined && block.metrics.length > 1) {
|
|
78
|
-
throw new ReportSpecError('spec_single_metric', `${where}:图类积木只接受一个 metric`);
|
|
79
|
-
}
|
|
80
94
|
}
|
|
81
95
|
if (block.compare !== undefined && !['yoy', 'none'].includes(block.compare)) {
|
|
82
96
|
throw new ReportSpecError('spec_compare_invalid', `${where}.compare 只支持 yoy / none`);
|