weaver-work-cli 0.1.73 → 0.1.76
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 +37 -1
- package/dist/chunks/{archive-THZV4ND4.js → archive-ENBSUMHV.js} +14 -9
- package/dist/chunks/{archive-oa-PQ23OLEV.js → archive-oa-7BFPQ6M5.js} +10 -7
- package/dist/chunks/{asset-RGPROZYH.js → asset-V5SUD3PW.js} +10 -7
- package/dist/chunks/{asset-idle-Z2PDX7NA.js → asset-idle-3CEL7WFX.js} +7 -4
- package/dist/chunks/{attachment-content-R3RPVOYE.js → attachment-content-24RL44SE.js} +3 -3
- package/dist/chunks/{blog-7U3QZPIF.js → blog-FLI4SS3P.js} +10 -7
- package/dist/chunks/{caizhilian-3AB42GCV.js → caizhilian-7WCTKCCP.js} +10 -7
- package/dist/chunks/{calendar-KINM64E4.js → calendar-G726HUUH.js} +10 -7
- package/dist/chunks/chunk-257JXJGD.js +30 -0
- package/dist/chunks/chunk-2BZ7TY4M.js +49 -0
- package/dist/chunks/{chunk-4BXR6CNB.js → chunk-2KW7AI6P.js} +2 -2
- package/dist/chunks/{chunk-WM33BSIL.js → chunk-2QCCXPNU.js} +1 -1
- package/dist/chunks/chunk-2UV4IZIT.js +473 -0
- package/dist/chunks/{chunk-R3MK2RBN.js → chunk-5E2FDXBU.js} +1 -1
- package/dist/chunks/{chunk-DRUND2PJ.js → chunk-5QUTQHXF.js} +225 -152
- package/dist/chunks/chunk-7DE3VMZD.js +35 -0
- package/dist/chunks/{chunk-PAFOLIYQ.js → chunk-AZC53XSQ.js} +1 -1
- package/dist/chunks/{chunk-6HT73VOI.js → chunk-BWFCTE43.js} +2 -2
- package/dist/chunks/{chunk-4YXAK6OA.js → chunk-FEZK536Z.js} +12 -7
- package/dist/chunks/{chunk-IU6UB2TD.js → chunk-FPWCCRKT.js} +48 -6
- package/dist/chunks/{chunk-LLCMOZ5L.js → chunk-H6N6U2D6.js} +11 -11
- package/dist/chunks/{chunk-54ST55IJ.js → chunk-JJONWB5N.js} +11 -1
- package/dist/chunks/{chunk-GWJLAF6B.js → chunk-JWF2R6EQ.js} +0 -462
- package/dist/chunks/chunk-KINXYJXM.js +205 -0
- package/dist/chunks/{chunk-F4HM25K4.js → chunk-KJA7CRES.js} +1 -1
- package/dist/chunks/chunk-L5SCNJKX.js +1166 -0
- package/dist/chunks/{chunk-TV46Q4NY.js → chunk-MS7MKBGJ.js} +74 -68
- package/dist/chunks/{chunk-XZBYRYWX.js → chunk-NZQRW4KL.js} +2 -2
- package/dist/chunks/chunk-OJ4JPD25.js +428 -0
- package/dist/chunks/chunk-OVTCWLNQ.js +1346 -0
- package/dist/chunks/{chunk-NUP4RYZK.js → chunk-PMRNIGKZ.js} +2 -2
- package/dist/chunks/{chunk-2CHGUYMG.js → chunk-Q7RXCK2Y.js} +4 -4
- package/dist/chunks/{chunk-AMAPQVBT.js → chunk-QVKRNL7L.js} +286 -305
- package/dist/chunks/{chunk-7QFVXP2X.js → chunk-R4PN3OFK.js} +8 -7
- package/dist/chunks/{chunk-L7TYG5SN.js → chunk-RVEKGVZU.js} +2 -2
- package/dist/chunks/{chunk-2XED2FKY.js → chunk-SQFKBWTR.js} +38 -36
- package/dist/chunks/chunk-SU6IJD6D.js +49 -0
- package/dist/chunks/{chunk-IBSJJGXL.js → chunk-T7HVQ2WP.js} +2 -2
- package/dist/chunks/{chunk-ZWLWXHJC.js → chunk-TBCKK6LH.js} +2 -2
- package/dist/chunks/{chunk-JMJBPP4B.js → chunk-UDBQJLQF.js} +2 -2
- package/dist/chunks/chunk-UUJK76HV.js +209 -0
- package/dist/chunks/{chunk-4I26YMBY.js → chunk-WHI6YAUE.js} +7 -3
- package/dist/chunks/{chunk-BWYVS62Z.js → chunk-WJQJ7YEX.js} +4 -4
- package/dist/chunks/{chunk-GAMGDNTF.js → chunk-XNN5PZTI.js} +1 -1
- package/dist/chunks/chunk-Y3C6MDL7.js +28 -0
- package/dist/chunks/chunk-ZM7RN2IM.js +38 -0
- package/dist/chunks/cli-DFLV57LO.js +226 -0
- package/dist/chunks/commands-J52MJ6NF.js +70 -0
- package/dist/chunks/{conflict-VPAR7E6F.js → conflict-72Q6DM4I.js} +2 -2
- package/dist/chunks/{contract-DDXAO2DZ.js → contract-IRNRQ5FY.js} +12446 -5964
- package/dist/chunks/{cowork-34QCHMDD.js → cowork-GZDODGKF.js} +11 -8
- package/dist/chunks/{create-flow-52PU2OBI.js → create-flow-UGTDI7SP.js} +6 -6
- package/dist/chunks/{data-CLQ62QGD.js → data-HTQZRPPI.js} +6 -3
- package/dist/chunks/{ebuilder-form-W5R7Q22S.js → ebuilder-form-GHNIZ7ET.js} +9 -6
- package/dist/chunks/{ehr-LCNAVMK5.js → ehr-PHIBBUIG.js} +23 -16
- package/dist/chunks/{entry-mode-6Z3ZV3DE.js → entry-mode-5WOXFE67.js} +3 -3
- package/dist/chunks/{env-RDKWAARB.js → env-H4ALHESA.js} +2 -2
- package/dist/chunks/{esb-ANKPUU65.js → esb-ATRKVHCD.js} +10 -7
- package/dist/chunks/{factory-434B7RAT.js → factory-COX6AVK7.js} +1 -1
- package/dist/chunks/{fna-AKBSG5HI.js → fna-IKYI3SST.js} +13 -8
- package/dist/chunks/{group-chat-PROTW22R.js → group-chat-ZIWQQO4G.js} +3 -3
- package/dist/chunks/{host-5R2SNFWD.js → host-6UOXYOOY.js} +6 -3
- package/dist/chunks/{host-7FJW4E7R.js → host-EJSJSLVK.js} +6 -3
- package/dist/chunks/{host-WO4L5G5I.js → host-EYNLB6S4.js} +6 -3
- package/dist/chunks/{host-PDJAKCT7.js → host-OT4KNR3G.js} +6 -3
- package/dist/chunks/{host-CGXUFQO4.js → host-UY4LQPN4.js} +6 -3
- package/dist/chunks/{host-XIYG4F4B.js → host-XXGDQM7D.js} +6 -3
- package/dist/chunks/{hrm-WGODDTEH.js → hrm-5JQ7QZ6A.js} +8 -5
- package/dist/chunks/{im-YKTKAJU3.js → im-2YJW3EI5.js} +7 -4
- package/dist/chunks/{invoice-PVYCCCVM.js → invoice-37HR6L3W.js} +956 -566
- package/dist/chunks/{jiuchuanhui-RKOQW7BY.js → jiuchuanhui-KBWUZ7WT.js} +17 -10
- package/dist/chunks/{lazy-dispatch-DW45AFQ5.js → lazy-dispatch-MZ3EZYDL.js} +22 -8
- package/dist/chunks/{mail-BNB5S4NW.js → mail-YBKUM6HM.js} +11 -8
- package/dist/chunks/{meeting-O2KDJH66.js → meeting-XE6CTXYA.js} +22 -18
- package/dist/chunks/{minute-doc-JUCG56GY.js → minute-doc-4BA2R5EA.js} +4 -4
- package/dist/chunks/{okr-LWFGWOE7.js → okr-HW7IULIR.js} +10 -7
- package/dist/chunks/{operations-532PN5OB.js → operations-4P2UYVLH.js} +7 -4
- package/dist/chunks/{performance-7W5COCFU.js → performance-PM2G6L3E.js} +6 -3
- package/dist/chunks/{plan-ZVY3IYTL.js → plan-3YYGZ7ZM.js} +10 -7
- package/dist/chunks/{project-SA62B7MH.js → project-XREEXFU2.js} +10 -7
- package/dist/chunks/{reception-NGIONPQ3.js → reception-7G3J2MA6.js} +8 -4
- package/dist/chunks/{recruit-stage-WOSN6MGP.js → recruit-stage-TSQWOGQD.js} +199 -74
- package/dist/chunks/register-SQOPIR2G.js +16 -0
- package/dist/chunks/{registry-N7P3W2RD.js → registry-3VTB3KLV.js} +7 -4
- package/dist/chunks/registry-7UDUWYB5.js +30 -0
- package/dist/chunks/{registry-R72GWXOG.js → registry-F4YFZLOD.js} +7 -3
- package/dist/chunks/{room-recommend-KCGIVUFR.js → room-recommend-FO3HLPNB.js} +4 -4
- package/dist/chunks/root-YZG2TS5W.js +16 -0
- package/dist/chunks/{schedule-6UP27HQ4.js → schedule-DHNNOHVS.js} +4 -4
- package/dist/chunks/{smart-extract-DDOQSPRB.js → smart-extract-T5Z4AULN.js} +15 -7
- package/dist/chunks/update-AV5VOXGY.js +13 -0
- package/dist/chunks/{workflow-V5ALD6QZ.js → workflow-MAGCHWYZ.js} +15 -10
- package/dist/cli.js +40 -0
- package/dist/cmd/action.js +3 -1
- package/dist/cmd/doctor/index.js +1 -1
- package/dist/cmd/e10/index.js +1 -1
- package/dist/cmd/identity/index.js +5 -8
- package/dist/cmd/index.js +2 -0
- package/dist/cmd/setup/index.js +1 -1
- package/dist/cmd/update/index.js +38 -0
- package/dist/core/manifest-view.js +1 -1
- package/dist/core/output.js +8 -1
- package/dist/core/runtime-agent.js +13 -0
- package/dist/core/update-notice.js +23 -0
- package/dist/index.js +105 -198
- package/dist/internal/e10/auth/agent-host-key.js +16 -0
- package/dist/internal/e10/auth/agent-hosts.js +45 -9
- package/dist/internal/e10/auth/commands.js +66 -36
- package/dist/internal/e10/auth/session.js +30 -15
- package/dist/internal/e10/auth/xiaoe.js +4 -20
- package/dist/internal/e10/auth-recovery.js +44 -4
- package/dist/internal/e10/context.js +5 -2
- package/dist/internal/update/bootstrap.js +96 -0
- package/dist/internal/update/npm.js +78 -0
- package/dist/internal/update/service.js +252 -0
- package/dist/internal/update/store.js +135 -0
- package/dist/shortcuts/archive/index.js +2 -2
- package/dist/shortcuts/archive/manifest.js +1 -0
- package/dist/shortcuts/archive/operations/search.js +3 -1
- package/dist/shortcuts/archive-oa/index.js +1 -1
- package/dist/shortcuts/asset/index.js +1 -1
- package/dist/shortcuts/asset-idle/index.js +1 -1
- package/dist/shortcuts/blog/index.js +1 -1
- package/dist/shortcuts/caizhilian/index.js +1 -1
- package/dist/shortcuts/calendar/index.js +1 -1
- package/dist/shortcuts/contract/data/bi-config.js +156 -0
- package/dist/shortcuts/contract/data/collection-ledger-html.js +189 -0
- package/dist/shortcuts/contract/data/collection-node-catalog.js +226 -0
- package/dist/shortcuts/contract/data/metric-catalog.js +154 -20
- package/dist/shortcuts/contract/data/report-renderers.js +414 -0
- package/dist/shortcuts/contract/data/report-spec.js +132 -0
- package/dist/shortcuts/contract/error-actions.js +114 -0
- package/dist/shortcuts/contract/host.js +12 -3
- package/dist/shortcuts/contract/index.js +17 -1
- package/dist/shortcuts/contract/manifest.js +398 -3
- package/dist/shortcuts/contract/ooxml/docx-table.js +48 -0
- package/dist/shortcuts/contract/operations/bi-preview.js +131 -0
- package/dist/shortcuts/contract/operations/bizreview-report.js +496 -0
- package/dist/shortcuts/contract/operations/collection-node.js +229 -0
- package/dist/shortcuts/contract/operations/docx-slots.js +735 -16
- package/dist/shortcuts/contract/operations/draft-build.js +940 -0
- package/dist/shortcuts/contract/operations/draft-submit.js +229 -0
- package/dist/shortcuts/contract/operations/first-screen.js +3 -2
- package/dist/shortcuts/contract/operations/generated-submit.js +175 -0
- package/dist/shortcuts/contract/operations/ledger-report.js +233 -0
- package/dist/shortcuts/contract/operations/ledger-stat.js +1400 -0
- package/dist/shortcuts/contract/operations/ledger.js +4 -1
- package/dist/shortcuts/contract/operations/metrics.js +9 -3
- package/dist/shortcuts/contract/operations/ops-draft.js +527 -0
- package/dist/shortcuts/contract/operations/page.js +9 -0
- package/dist/shortcuts/contract/operations/quote-submit.js +55 -229
- package/dist/shortcuts/contract/operations/registry.js +20 -0
- package/dist/shortcuts/contract/operations/sign-launch.js +256 -0
- package/dist/shortcuts/contract/operations/viewlink.js +334 -0
- package/dist/shortcuts/cowork/index.js +2 -2
- package/dist/shortcuts/ebuilder-form/index.js +1 -1
- package/dist/shortcuts/ehr/index.js +2 -2
- package/dist/shortcuts/ehr/manifest.js +1 -1
- package/dist/shortcuts/ehr/operations/recruit-position.js +7 -2
- package/dist/shortcuts/ehr/operations/recruit-write.js +7 -6
- package/dist/shortcuts/ehr/operations/recruit.js +318 -248
- package/dist/shortcuts/ehr/operations/shared.js +22 -2
- package/dist/shortcuts/esb/index.js +1 -1
- package/dist/shortcuts/fna/index.js +1 -1
- package/dist/shortcuts/fna/manifest.js +1 -0
- package/dist/shortcuts/fna/operations/expense-chart.js +3 -1
- package/dist/shortcuts/hrm/index.js +1 -1
- package/dist/shortcuts/invoice/business-response.js +13 -0
- package/dist/shortcuts/invoice/calendar.js +24 -0
- package/dist/shortcuts/invoice/host.js +26 -15
- package/dist/shortcuts/invoice/index.js +3 -3
- package/dist/shortcuts/invoice/invoice-record.js +7 -2
- package/dist/shortcuts/invoice/manifest.js +179 -155
- package/dist/shortcuts/invoice/operations/get.js +9 -3
- package/dist/shortcuts/invoice/operations/issuing-red-requests.js +138 -0
- package/dist/shortcuts/invoice/operations/registry.js +4 -5
- package/dist/shortcuts/invoice/operations/reim-auto.js +40 -2
- package/dist/shortcuts/invoice/operations/reim-customer-projects.js +79 -0
- package/dist/shortcuts/invoice/operations/reim-customer.js +79 -30
- package/dist/shortcuts/invoice/operations/reim-relation.js +0 -146
- package/dist/shortcuts/invoice/operations/reim.js +2 -126
- package/dist/shortcuts/invoice/operations/shared.js +15 -17
- package/dist/shortcuts/invoice/preapproval-enrichment.js +180 -0
- package/dist/shortcuts/invoice/projection.js +14 -0
- package/dist/shortcuts/invoice/read-enrichment.js +123 -0
- package/dist/shortcuts/jiuchuanhui/index.js +2 -2
- package/dist/shortcuts/jiuchuanhui/manifest.js +3 -0
- package/dist/shortcuts/mail/index.js +2 -2
- package/dist/shortcuts/meeting/index.js +1 -1
- package/dist/shortcuts/meeting/manifest.js +1 -0
- package/dist/shortcuts/meeting/operations/eb/catalog.js +5 -3
- package/dist/shortcuts/meeting/operations/eb/conflict.js +3 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +10 -9
- package/dist/shortcuts/meeting/operations/eb/factory.js +2 -0
- package/dist/shortcuts/meeting/operations/eb/member-expand.js +3 -2
- package/dist/shortcuts/meeting/operations/invitation-publish.js +3 -3
- package/dist/shortcuts/meeting/operations/invitation.js +4 -4
- package/dist/shortcuts/meeting/operations/link.js +3 -1
- package/dist/shortcuts/okr/index.js +1 -1
- package/dist/shortcuts/performance/index.js +1 -1
- package/dist/shortcuts/plan/index.js +1 -1
- package/dist/shortcuts/project/index.js +1 -1
- package/dist/shortcuts/reception/manifest.js +2 -2
- package/dist/shortcuts/recruit-stage/context.js +10 -2
- package/dist/shortcuts/recruit-stage/index.js +16 -3
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +1 -1
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +1 -1
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +17 -8
- package/dist/shortcuts/recruit-stage/operations/list.js +1 -1
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +178 -35
- package/dist/shortcuts/recruit-stage/operations/search.js +2 -2
- package/dist/shortcuts/recruit-stage/operations/shortlist.js +4 -2
- package/dist/shortcuts/recruit-stage/shared.js +27 -53
- package/dist/shortcuts/smart-extract/manifest.js +1 -0
- package/dist/shortcuts/smart-extract/operations/fill.js +7 -2
- package/dist/shortcuts/smart-extract/operations/validate.js +4 -1
- package/dist/shortcuts/workflow/index.js +2 -2
- package/dist/shortcuts/workflow/manifest.js +1 -0
- package/dist/shortcuts/workflow/operations/aiDeepRead/render.js +4 -1
- package/dist/shortcuts/workflow/operations/deepRead.js +23 -2
- package/dist/shortcuts/workflow/operations/form.js +8 -2
- package/docs/agent-invoice.md +28 -2
- package/docs/contract.md +6 -1
- package/docs/e10-auth.md +25 -7
- package/docs/invoice.md +60 -9
- package/docs/operation-manual.md +15 -0
- package/package.json +2 -2
- package/skill-template/business-info.json +28 -0
- package/skill-template/domains/jinchengda.md +13 -1
- package/skill-template/domains/yepiaotong.md +36 -7
- package/skills/weaver-e10-archive-oa/references/source-manifest.json +3 -3
- package/skills/weaver-e10-caizhilian/references/auth-and-install.md +2 -1
- package/skills/weaver-e10-caizhilian/references/source-manifest.json +3 -3
- package/skills/weaver-e10-esb/references/source-manifest.json +3 -3
- package/skills/weaver-e10-jinchengda/SKILL.md +90 -32
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +45 -0
- package/skills/weaver-e10-jinchengda/references/contract-bizreview-report-template.html +68 -0
- package/skills/weaver-e10-jinchengda/references/contract-bizreview.md +216 -0
- package/skills/weaver-e10-jinchengda/references/contract-clause-negotiate.md +215 -0
- package/skills/weaver-e10-jinchengda/references/contract-collection-node.md +113 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +19 -3
- package/skills/weaver-e10-jinchengda/references/contract-decisions.md +114 -0
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +53 -44
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-firstscreen-guide.md +200 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +18 -1
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +138 -3
- package/skills/weaver-e10-jinchengda/references/contract-ledger-report.md +158 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +3 -1
- package/skills/weaver-e10-jinchengda/references/contract-material-gap.md +139 -0
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +10 -3
- package/skills/weaver-e10-jinchengda/references/contract-ops-draft.md +106 -0
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +176 -56
- package/skills/weaver-e10-jinchengda/references/contract-sign-launch.md +123 -0
- package/skills/weaver-e10-jinchengda/references/contract-smart-draft.md +410 -0
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-viewlink.md +110 -0
- package/skills/weaver-e10-jinchengda/references/orchestration.md +38 -24
- package/skills/weaver-e10-meeting/SKILL.md +13 -0
- package/skills/weaver-e10-okr/SKILL.md +11 -0
- package/skills/weaver-e10-okr/references/source-manifest.json +7 -6
- package/skills/weaver-e10-performance/SKILL.md +131 -39
- package/skills/weaver-e10-performance/agents/openai.yaml +48 -17
- package/skills/weaver-e10-performance/references/default-assembly.md +3 -0
- package/skills/weaver-e10-performance/references/extraction-guide.md +17 -3
- package/skills/weaver-e10-performance/references/flow-assess.md +38 -5
- package/skills/weaver-e10-performance/references/scheme-setting-page.md +20 -3
- package/skills/weaver-e10-performance/scripts/assemble_scheme.py +461 -0
- package/skills/weaver-e10-performance/scripts/parse_appraisal_doc.py +41 -0
- package/skills/weaver-e10-plan/SKILL.md +10 -0
- package/skills/weaver-e10-plan/references/source-manifest.json +13 -13
- package/skills/weaver-e10-qiyecheng/SKILL.md +2 -2
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +9 -9
- package/skills/weaver-e10-recruit-stage/SKILL.md +230 -202
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +74 -46
- package/skills/weaver-e10-recruit-stage/lib/interview-conflict.mjs +3 -0
- package/skills/weaver-e10-recruit-stage/lib/interview-summary.mjs +201 -36
- package/skills/weaver-e10-recruit-stage/lib/recruit-shortlist.mjs +336 -27
- package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +3 -0
- package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +15 -1
- package/skills/weaver-e10-recruit-stage/lib/report-attachment.mjs +38 -0
- package/skills/weaver-e10-recruit-stage/lib/xiaoe-session.mjs +5 -1
- package/skills/weaver-e10-recruit-stage/references/env-fixed-values.md +4 -0
- package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +4 -0
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +12 -8
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +20 -18
- package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +11 -7
- package/skills/weaver-e10-recruit-stage/references/recruit-check-install.md +5 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-detail-process.md +4 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +8 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-failure-fallback.md +6 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +7 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +32 -25
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +4 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +4 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +5 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-maint.md +4 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +16 -10
- package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +6 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +148 -40
- package/skills/weaver-e10-recruit-stage/references/recruit-platform-compat.md +5 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-report-templates.md +32 -8
- package/skills/weaver-e10-recruit-stage/references/recruit-resolve-creator.md +4 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +8 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +6 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +41 -41
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +7 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +7 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +8 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +5 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +5 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +5 -1
- package/skills/weaver-e10-recruit-stage/templates/candidate-evidence.html +41 -28
- package/skills/weaver-e10-recruit-stage/templates/interview-summary.html +23 -26
- package/skills/weaver-e10-recruit-stage/templates/match-report.html +44 -36
- package/skills/weaver-e10-shared/SKILL.md +40 -5
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +11 -1
- package/skills/weaver-e10-shared/references/json-output-contract.md +144 -8
- package/skills/weaver-e10-shared/references/weaver-e10-installation.md +11 -0
- package/skills/weaver-e10-shijingran/references/source-manifest.json +3 -3
- package/skills/weaver-e10-wenshuding/references/source-manifest.json +3 -3
- package/skills/weaver-e10-workflow/references/source-manifest.json +3 -3
- package/skills/weaver-e10-yepiaotong/SKILL.md +133 -61
- package/skills/weaver-e10-yepiaotong/references/invoice-add.md +3 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +18 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +3 -3
- package/skills/weaver-e10-yepiaotong/references/invoice-download.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +13 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +3 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +6 -4
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +42 -45
- package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +18 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +14 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-red-workflow.md +96 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +56 -369
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +16 -6
- package/skills/weaver-e10-yepiaotong/references/name-fuzzy-search.md +38 -0
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +163 -646
- package/skills/weaver-e10-yepiaotong/references/reim-customer-search.md +90 -44
- package/skills/weaver-e10-yepiaotong/references/reim-eligibility-rules.md +85 -0
- package/skills/weaver-e10-yepiaotong/references/reim-fill-validation.md +61 -0
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +91 -280
- package/skills/weaver-e10-yepiaotong/references/reim-preapproval-rules.md +98 -0
- package/skills/weaver-e10-yepiaotong/references/reim-travel-invoice-matching.md +48 -0
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +234 -695
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +395 -204
- package/skills/weaver-e10-yepiaotong/references/travel-application-fill.md +84 -0
- package/skills/weaver-e10-yepiaotong/references/workflow-direct-fill.md +165 -0
- package/skills/weaver-e10-yepiaotong.zip +0 -0
- package/dist/chunks/chunk-ICP53R52.js +0 -2849
- package/dist/chunks/registry-RIQ67ZT7.js +0 -27
- package/scripts/pysite/__pycache__/sitecustomize.cpython-312.pyc +0 -0
- package/scripts/pysite/__pycache__/sitecustomize.cpython-313.pyc +0 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +0 -93
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +0 -774
- package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +0 -111
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +0 -360
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +0 -167
|
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { dirname, resolve } from 'node:path';
|
|
3
3
|
import { contractValidationError } from '../errors.js';
|
|
4
4
|
import { readZip, rewriteZip } from '../ooxml/zip.js';
|
|
5
|
-
import { allTableGrids, collectRanges, deleteTableRows, insertTableRows, parseTables, paragraphText, setCellText, setParagraphText, } from '../ooxml/docx-table.js';
|
|
5
|
+
import { allTableGrids, collectRanges, deleteTableRows, firstRunPropsXml, insertTableRows, makeParagraphXml, paragraphPropsXml, parseTables, paragraphText, setCellText, setParagraphText, topParagraphRanges, topTableRanges, } from '../ooxml/docx-table.js';
|
|
6
6
|
import { findMoneyPlaceholder, hasCurrencySymbol } from './money.js';
|
|
7
7
|
import { RESIDUE_PATTERNS, residueTextOfDocx, scanResidue } from './placeholder-scan.js';
|
|
8
8
|
import { assertQuoteRefsResolved, resolveQuoteRefs } from './quote-ref.js';
|
|
@@ -29,6 +29,21 @@ import { assertQuoteRefsResolved, resolveQuoteRefs } from './quote-ref.js';
|
|
|
29
29
|
* 删行、写后回读校验。
|
|
30
30
|
*
|
|
31
31
|
* 语义映射交给模型,代码只保证「找得到位、写得进去、错得出来」。
|
|
32
|
+
*
|
|
33
|
+
* ## 2026-11-29:从「固定填空」升级为「模板作参考的动态生成」
|
|
34
|
+
*
|
|
35
|
+
* 上一版把模板当填空表:条款与表格行数完全由模板决定,付款计划模板印 2 行就只能 2 行,
|
|
36
|
+
* 多一期装不下、少一期留空行。但**模板只是参考**——付款计划可能是 1 笔、2 笔、3 笔,
|
|
37
|
+
* 明细项数与费用分节也随项目变化。因此在原有能力之上补两类**动态区块**:
|
|
38
|
+
*
|
|
39
|
+
* - `regions`(表格区块):任意带表头的可扩缩表格(付款计划、费用分节、交付清单…)
|
|
40
|
+
* 按方案给的 `rows` 长度**自动增删行**,再按列名逐格写值;行数由需求决定,不由模板决定。
|
|
41
|
+
* - `clauses`(条款区块):按需求**新增条款段落**(继承模板已有段落的版式),
|
|
42
|
+
* **删除**模板里不适用的条款段落 / 表格。
|
|
43
|
+
*
|
|
44
|
+
* 口径仍然是确定性的:代码只负责「加得进、删得掉、写得上、错得出」,**条款写什么、
|
|
45
|
+
* 分几期、每期多少由模型按实际需求决定**。新增能力同样进六类校验(另加必填区块覆盖与
|
|
46
|
+
* 区块小计勾稽),校验不过一律不得交付。
|
|
32
47
|
*/
|
|
33
48
|
const PLACEHOLDER_PATTERNS = [
|
|
34
49
|
'xxx公司',
|
|
@@ -70,14 +85,21 @@ function moneyText(value) {
|
|
|
70
85
|
return String(value);
|
|
71
86
|
return `¥${num.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
72
87
|
}
|
|
88
|
+
function round2(value) {
|
|
89
|
+
return Math.round(value * 100) / 100;
|
|
90
|
+
}
|
|
73
91
|
function inferConstraint(text) {
|
|
92
|
+
// 列约束只在**短标签**上判:模板里常用整段说明当表头(如「…如需现场服务,根据情况再计算费用。」),
|
|
93
|
+
// 长句里出现「费用」会被误判成金额列,进而要求每行给纯数值 → 误报 FAIL。
|
|
94
|
+
// 真实金额/比例/日期列的表头都是短标签(金额 / 付款金额 / 合计 / 收费标准 / 比例…)。
|
|
95
|
+
const isLabel = text.trim().length <= 16;
|
|
74
96
|
if (PERCENT_HINTS.some((key) => text.includes(key)))
|
|
75
97
|
return 'percent';
|
|
76
|
-
if (MONEY_HINTS.some((key) => text.includes(key)))
|
|
98
|
+
if (isLabel && MONEY_HINTS.some((key) => text.includes(key)))
|
|
77
99
|
return 'money';
|
|
78
|
-
if (DATE_HINTS.some((key) => text.includes(key)))
|
|
100
|
+
if (isLabel && DATE_HINTS.some((key) => text.includes(key)))
|
|
79
101
|
return 'date';
|
|
80
|
-
if (QTY_HINTS.some((key) => text.includes(key)))
|
|
102
|
+
if (isLabel && QTY_HINTS.some((key) => text.includes(key)))
|
|
81
103
|
return 'qty';
|
|
82
104
|
return 'text';
|
|
83
105
|
}
|
|
@@ -177,6 +199,52 @@ function findHeaderRow(table) {
|
|
|
177
199
|
}
|
|
178
200
|
return -1;
|
|
179
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* 区块表头(比 `findHeaderRow` 宽松一档)。
|
|
204
|
+
*
|
|
205
|
+
* 实测形态:付款表的最后一列表头常常是空的(如「付款阶段 | 付款比例 | 付款金额 | 」,付款时间列没有表头),
|
|
206
|
+
* 严格版要求整行非空,于是整张付款表拿不到表头 → 退回逐格填空(正是本次要修的现象)。
|
|
207
|
+
* 这里只放宽「个别表头格为空」,并加两道防误判:**出现数值形态的格子即判为数据行**、
|
|
208
|
+
* **至少 2 个强表头锚词**(付款 / 期数 / 比例 / 金额 / 单价 / 数量…)。
|
|
209
|
+
*/
|
|
210
|
+
function findRegionHeaderRow(table) {
|
|
211
|
+
const strict = findHeaderRow(table);
|
|
212
|
+
if (strict >= 0)
|
|
213
|
+
return strict;
|
|
214
|
+
const VALUE_SHAPE = /^[¥¥$]?\s*[\d,]+(?:\.\d+)?\s*(?:%|元|万元)?$/u;
|
|
215
|
+
for (const row of table.rows) {
|
|
216
|
+
const cells = row.cells.map((cell) => cell.text.trim());
|
|
217
|
+
if (cells.length < 2)
|
|
218
|
+
continue;
|
|
219
|
+
if (cells.filter(Boolean).length < 2)
|
|
220
|
+
continue;
|
|
221
|
+
if (cells.some((text) => VALUE_SHAPE.test(text)))
|
|
222
|
+
continue;
|
|
223
|
+
const strong = cells.filter((text) => /付款|期数|阶段|比例|账期|金额|合计|单价|数量/u.test(text)).length;
|
|
224
|
+
if (strong >= 2)
|
|
225
|
+
return row.index;
|
|
226
|
+
}
|
|
227
|
+
return -1;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 动态区块的语义类别(2026-11-29 新增)。
|
|
231
|
+
*
|
|
232
|
+
* 付款计划的列名千变万化(付款阶段 / 付款比例 / 付款金额 / 付款时间,或 期数 / 比例 / 金额 / 账期),
|
|
233
|
+
* 但只要出现「付款 / 分期 / 期款 / 比例」这类锚词就按 payment 处理——**它必须由模型按实际
|
|
234
|
+
* 谈定的期数动态生成**,不是从模板照抄几行。
|
|
235
|
+
*/
|
|
236
|
+
function classifyRegion(headerNames, rowLabels) {
|
|
237
|
+
const text = [...headerNames, ...rowLabels].join(' ');
|
|
238
|
+
if (/付款|支付|分期|期款|首付|尾款|账期|比例/u.test(text))
|
|
239
|
+
return 'payment';
|
|
240
|
+
if (MONEY_HINTS.some((key) => text.includes(key)))
|
|
241
|
+
return 'amount';
|
|
242
|
+
return 'items';
|
|
243
|
+
}
|
|
244
|
+
/** 是否为需要方案显式写入的区块:付款计划与金额构成必须写(不写即固定填空,退回旧形态)。 */
|
|
245
|
+
function isRequiredRegion(kind) {
|
|
246
|
+
return kind === 'payment' || kind === 'amount';
|
|
247
|
+
}
|
|
180
248
|
/** 每个物理单元格覆盖的**起始逻辑列**(按 w:gridSpan 累加)。合并行的物理索引与表头列并不对应。 */
|
|
181
249
|
function logicalStarts(cells) {
|
|
182
250
|
const starts = [];
|
|
@@ -249,7 +317,7 @@ function scanSlots(xml) {
|
|
|
249
317
|
const chapter = chapterFor(blocks, table.index);
|
|
250
318
|
const detailHeaderRow = findDetailHeaderRow(table);
|
|
251
319
|
const detailSegments = detailHeaderRow >= 0 ? findDetailSegments(table, detailHeaderRow) : [];
|
|
252
|
-
const headerRow = detailHeaderRow >= 0 ? detailHeaderRow :
|
|
320
|
+
const headerRow = detailHeaderRow >= 0 ? detailHeaderRow : findRegionHeaderRow(table);
|
|
253
321
|
// 明细区按段逐个成位点:同一张表里「产品费」「服务费用」各一段,行数与列名分别给出
|
|
254
322
|
if (detailHeaderRow >= 0) {
|
|
255
323
|
const headerCells = table.rows[detailHeaderRow]?.cells ?? [];
|
|
@@ -285,18 +353,80 @@ function scanSlots(xml) {
|
|
|
285
353
|
});
|
|
286
354
|
});
|
|
287
355
|
}
|
|
356
|
+
// 动态表格区块(2026-11-29 新增):不是「名称 + 单价 + 数量」形态、但带表头且有多行数据的
|
|
357
|
+
// 表格,一律视为**可按需求扩缩的区块**(付款计划、费用构成、交付清单…)。
|
|
358
|
+
// 行数由方案 `regions[].rows` 长度决定:模板印了 2 行,方案给 3 行就插 1 行,给 1 行就删 1 行。
|
|
359
|
+
const regionSegments = detailHeaderRow >= 0 || headerRow < 0 ? [] : findDetailSegments(table, headerRow);
|
|
360
|
+
const regionByRow = new Map();
|
|
361
|
+
const regionSummaryRows = new Set();
|
|
362
|
+
if (regionSegments.length > 0) {
|
|
363
|
+
const regionHeaderCells = table.rows[headerRow]?.cells ?? [];
|
|
364
|
+
const headerNames = regionHeaderCells.map((cell) => cell.text.trim());
|
|
365
|
+
regionSegments.forEach((segment, segmentIndex) => {
|
|
366
|
+
const rowCount = Math.max(0, segment.endRow - segment.startRow + 1);
|
|
367
|
+
const currentRows = [];
|
|
368
|
+
for (let rowIndex = segment.startRow; rowIndex <= segment.endRow; rowIndex += 1) {
|
|
369
|
+
const rowCells = table.rows[rowIndex]?.cells ?? [];
|
|
370
|
+
const values = rowCells.map((cell) => cell.text.trim());
|
|
371
|
+
currentRows.push({
|
|
372
|
+
row: rowIndex,
|
|
373
|
+
label: leftLabelAt(values, 0) ?? values[0] ?? '',
|
|
374
|
+
values,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
const rowLabels = currentRows.map((item) => `${item.label} ${item.values.join(' ')}`);
|
|
378
|
+
const kind = classifyRegion(headerNames, rowLabels);
|
|
379
|
+
const slotId = segmentIndex === 0 ? `t${table.index}.region` : `t${table.index}.region.${segmentIndex + 1}`;
|
|
380
|
+
// 段末的合并行是该区块的合计行(如「合计 | 100% | ¥…」)
|
|
381
|
+
const stopRow = segment.endRow + 1;
|
|
382
|
+
const stopCells = table.rows[stopRow]?.cells ?? [];
|
|
383
|
+
const stopLastText = (stopCells[stopCells.length - 1]?.text ?? '').trim();
|
|
384
|
+
const looksMoneyCell = stopLastText === ''
|
|
385
|
+
|| /^[¥¥]?[\d,.]+$/u.test(stopLastText)
|
|
386
|
+
|| stopLastText.includes('[[MONEY');
|
|
387
|
+
const summarySlotId = stopCells.length > 1 && stopCells.length < regionHeaderCells.length && looksMoneyCell
|
|
388
|
+
? `t${table.index}r${stopRow}c${stopCells.length - 1}`
|
|
389
|
+
: '';
|
|
390
|
+
slots.push({
|
|
391
|
+
slotId,
|
|
392
|
+
type: 'table-region',
|
|
393
|
+
table: table.index,
|
|
394
|
+
headerRow,
|
|
395
|
+
startRow: segment.startRow,
|
|
396
|
+
endRow: segment.endRow,
|
|
397
|
+
availableRows: rowCount,
|
|
398
|
+
columns: regionHeaderCells.map((cell, index) => ({ cell: index, name: cell.text.trim() })),
|
|
399
|
+
kind,
|
|
400
|
+
currentRows,
|
|
401
|
+
label: segmentIndex === 0 ? `可扩缩区块(${kind})` : `可扩缩区块${segmentIndex + 1}(${kind})`,
|
|
402
|
+
current: `${rowCount} 行:${currentRows.map((item) => item.values.join(' | ')).join(' / ')}`.slice(0, 300),
|
|
403
|
+
...(summarySlotId ? { summarySlotId } : {}),
|
|
404
|
+
constraint: 'text',
|
|
405
|
+
required: isRequiredRegion(kind),
|
|
406
|
+
chapter,
|
|
407
|
+
});
|
|
408
|
+
for (let rowIndex = segment.startRow; rowIndex <= segment.endRow; rowIndex += 1) {
|
|
409
|
+
regionByRow.set(rowIndex, { slotId, kind });
|
|
410
|
+
}
|
|
411
|
+
if (summarySlotId)
|
|
412
|
+
regionSummaryRows.add(stopRow);
|
|
413
|
+
});
|
|
414
|
+
}
|
|
288
415
|
for (const row of table.rows) {
|
|
289
416
|
const texts = row.cells.map((cell) => cell.text.trim());
|
|
290
417
|
if (row.index === headerRow)
|
|
291
418
|
continue;
|
|
292
419
|
if (detailSegments.some((segment) => row.index >= segment.startRow && row.index <= segment.endRow))
|
|
293
420
|
continue;
|
|
421
|
+
const region = regionByRow.get(row.index);
|
|
422
|
+
if (region)
|
|
423
|
+
continue;
|
|
294
424
|
const startCols = logicalStarts(row.cells);
|
|
295
425
|
// 明细表内的合并行是小计行或节标题行:小计由 details.subtotal 负责写入,节标题是模板固定内容,
|
|
296
426
|
// 都不属于「模型必须逐格给值」的必填位点(2026-11-16 实测:误判为必填会整单校验失败)。
|
|
297
427
|
const headerCellCount = table.rows[headerRow]?.cells.length ?? row.cells.length;
|
|
298
428
|
const isMergedRow = row.cells.length < headerCellCount;
|
|
299
|
-
const requiredByDetail = detailHeaderRow >= 0 && isMergedRow;
|
|
429
|
+
const requiredByDetail = (detailHeaderRow >= 0 && isMergedRow) || regionSummaryRows.has(row.index);
|
|
300
430
|
row.cells.forEach((cell, cellIndex) => {
|
|
301
431
|
const text = texts[cellIndex] ?? '';
|
|
302
432
|
const hasPlaceholder = PLACEHOLDER_PATTERNS.some((pattern) => text.includes(pattern));
|
|
@@ -352,6 +482,17 @@ function scanSlots(xml) {
|
|
|
352
482
|
columns: (table.rows[detailHeaderRow]?.cells ?? []).map((cell) => cell.text.trim()),
|
|
353
483
|
}
|
|
354
484
|
: null,
|
|
485
|
+
region: regionSegments.length > 0
|
|
486
|
+
? {
|
|
487
|
+
headerRow,
|
|
488
|
+
segments: regionSegments.map((segment) => ({
|
|
489
|
+
startRow: segment.startRow,
|
|
490
|
+
endRow: segment.endRow,
|
|
491
|
+
availableRows: Math.max(0, segment.endRow - segment.startRow + 1),
|
|
492
|
+
})),
|
|
493
|
+
columns: (table.rows[headerRow]?.cells ?? []).map((cell) => cell.text.trim()),
|
|
494
|
+
}
|
|
495
|
+
: null,
|
|
355
496
|
});
|
|
356
497
|
}
|
|
357
498
|
return {
|
|
@@ -364,6 +505,77 @@ function scanSlots(xml) {
|
|
|
364
505
|
},
|
|
365
506
|
};
|
|
366
507
|
}
|
|
508
|
+
/** 章节 / 条款标题形态(用于把范文段落切成「条款骨架」,供模型决定增删哪一条)。 */
|
|
509
|
+
const CLAUSE_HEADING_RE = /^(?:第[一二三四五六七八九十百零〇\d]+[条章节]|[一二三四五六七八九十]+、|附件[一二三四五六七八九十\d]*[::、.]?)/u;
|
|
510
|
+
/**
|
|
511
|
+
* 范文骨架(2026-11-29 新增):把模板按条款切块,给模型一份**可读、可指认**的结构清单。
|
|
512
|
+
*
|
|
513
|
+
* 为什么需要:动态生成要求模型「知道范文里有哪些条款、各自在哪」,才能按需求插入缺失条款、
|
|
514
|
+
* 删除不适用的条款。位点清单只覆盖可填位置,看不出条款结构。
|
|
515
|
+
*
|
|
516
|
+
* 文本截断到 120 字符:条款正文原样保留在成品里,模型只需辨认「这一条讲什么」,
|
|
517
|
+
* 不需要逐字复述,截断可把长模板的读取成本压下来(`textTruncated` 标出被截断项)。
|
|
518
|
+
*/
|
|
519
|
+
function buildOutline(blocks, tables) {
|
|
520
|
+
const entries = [];
|
|
521
|
+
const clauses = [];
|
|
522
|
+
let current = { id: 'C0', heading: '', headingSlotId: null, paragraphSlotIds: [], tableIndexes: [] };
|
|
523
|
+
clauses.push(current);
|
|
524
|
+
for (const block of blocks) {
|
|
525
|
+
if (block.kind === 'p') {
|
|
526
|
+
const text = block.text;
|
|
527
|
+
if (!text)
|
|
528
|
+
continue;
|
|
529
|
+
const heading = CLAUSE_HEADING_RE.test(text);
|
|
530
|
+
if (heading) {
|
|
531
|
+
if (current.headingSlotId || current.paragraphSlotIds.length > 0 || current.tableIndexes.length > 0) {
|
|
532
|
+
current = {
|
|
533
|
+
id: `C${clauses.length}`,
|
|
534
|
+
heading: text.slice(0, 60),
|
|
535
|
+
headingSlotId: `p${block.index}`,
|
|
536
|
+
paragraphSlotIds: [],
|
|
537
|
+
tableIndexes: [],
|
|
538
|
+
};
|
|
539
|
+
clauses.push(current);
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
current.heading = text.slice(0, 60);
|
|
543
|
+
current.headingSlotId = `p${block.index}`;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
current.paragraphSlotIds.push(`p${block.index}`);
|
|
548
|
+
}
|
|
549
|
+
const truncated = text.length > 120;
|
|
550
|
+
entries.push({
|
|
551
|
+
slotId: `p${block.index}`,
|
|
552
|
+
kind: 'p',
|
|
553
|
+
text: truncated ? text.slice(0, 120) : text,
|
|
554
|
+
...(truncated ? { textTruncated: true } : {}),
|
|
555
|
+
heading,
|
|
556
|
+
clauseId: current.id,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
const table = tables[block.index];
|
|
561
|
+
current.tableIndexes.push(block.index);
|
|
562
|
+
entries.push({
|
|
563
|
+
slotId: `t${block.index}`,
|
|
564
|
+
kind: 'tbl',
|
|
565
|
+
text: table ? (table.rows[0]?.text ?? '').slice(0, 80) : '',
|
|
566
|
+
heading: false,
|
|
567
|
+
clauseId: current.id,
|
|
568
|
+
tableIndex: block.index,
|
|
569
|
+
rows: table?.rows.length ?? 0,
|
|
570
|
+
cols: table?.cols ?? 0,
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
// C0 既没有标题也没有内容(模板第一段就是标题)时丢弃,避免空的伪条款
|
|
575
|
+
const useful = clauses.filter((clause) => clause.headingSlotId || clause.paragraphSlotIds.length > 0 || clause.tableIndexes.length > 0);
|
|
576
|
+
const keptIds = new Set(useful.map((clause) => clause.id));
|
|
577
|
+
return { entries: entries.filter((entry) => keptIds.has(entry.clauseId)), clauses: useful };
|
|
578
|
+
}
|
|
367
579
|
function parseSlotId(slotId) {
|
|
368
580
|
const paragraph = /^p(\d+)$/u.exec(slotId);
|
|
369
581
|
if (paragraph)
|
|
@@ -376,6 +588,11 @@ function parseSlotId(slotId) {
|
|
|
376
588
|
if (detail) {
|
|
377
589
|
return { kind: 'detail', table: Number(detail[1]), segment: detail[2] ? Number(detail[2]) - 1 : 0 };
|
|
378
590
|
}
|
|
591
|
+
// t4.region 为首段,t4.region.2 为第二段(动态表格区块,行数由方案决定)
|
|
592
|
+
const region = /^t(\d+)\.region(?:\.(\d+))?$/u.exec(slotId);
|
|
593
|
+
if (region) {
|
|
594
|
+
return { kind: 'region', table: Number(region[1]), segment: region[2] ? Number(region[2]) - 1 : 0 };
|
|
595
|
+
}
|
|
379
596
|
return null;
|
|
380
597
|
}
|
|
381
598
|
/** 一次性按绝对偏移从后往前写入,避免偏移漂移。 */
|
|
@@ -448,6 +665,18 @@ const COLUMN_ALIAS = {
|
|
|
448
665
|
合计: ['amount', '合计', '金额'],
|
|
449
666
|
备注: ['remark', '备注', '说明'],
|
|
450
667
|
版本: ['version', '版本'],
|
|
668
|
+
// 付款计划类列名(2026-11-29 动态区块):模型可能用英文键或同义写法,缺别名会被整列清空
|
|
669
|
+
付款阶段: ['stage', '阶段', '付款阶段', '付款节点', '款项', '期次', '期数', 'label'],
|
|
670
|
+
阶段: ['stage', '阶段', '付款阶段', '付款节点'],
|
|
671
|
+
付款方式: ['method', '付款方式', '支付方式'],
|
|
672
|
+
付款比例: ['percent', 'ratio', '比例', '付款比例', '支付比例'],
|
|
673
|
+
比例: ['percent', 'ratio', '比例', '付款比例'],
|
|
674
|
+
付款金额: ['amount', '金额', '付款金额', '支付金额', '款额'],
|
|
675
|
+
期数: ['period', '期数', '期次', 'stage'],
|
|
676
|
+
付款时间: ['dueDate', 'date', 'time', '时间', '付款时间', '支付时间', '期限', '账期'],
|
|
677
|
+
时间: ['date', 'time', '时间', '付款时间', '期限'],
|
|
678
|
+
项目: ['item', '项目', '名称', '费用项目'],
|
|
679
|
+
费用项目: ['item', '项目', '费用项目', '名称'],
|
|
451
680
|
};
|
|
452
681
|
function normalizeKey(input) {
|
|
453
682
|
return input.replace(/[\s()()¥]/gu, '');
|
|
@@ -530,6 +759,36 @@ function auditPlanValues(plan, scannedSlots) {
|
|
|
530
759
|
}
|
|
531
760
|
}
|
|
532
761
|
}
|
|
762
|
+
// 动态表格区块:行值同样逐个过守卫(付款比例、期数金额都可能是占位符形态)
|
|
763
|
+
for (const region of Array.isArray(plan.regions) ? plan.regions : []) {
|
|
764
|
+
const slotId = typeof region?.slotId === 'string' ? region.slotId : '';
|
|
765
|
+
const scanned = slotId ? slotById.get(slotId) : undefined;
|
|
766
|
+
const columns = scanned && scanned.type === 'table-region' ? scanned.columns.map((column) => column.name) : [];
|
|
767
|
+
const label = scanned?.label ?? '可扩缩区块';
|
|
768
|
+
inspect(slotId, `${label}·小计`, region?.subtotal ?? region?.total, true);
|
|
769
|
+
const rows = Array.isArray(region?.rows) ? region.rows : [];
|
|
770
|
+
rows.forEach((row, index) => {
|
|
771
|
+
if (typeof row !== 'object' || row === null)
|
|
772
|
+
return;
|
|
773
|
+
for (const [key, value] of Object.entries(row)) {
|
|
774
|
+
const isMoney = columns.length > 0
|
|
775
|
+
? columns.some((name) => normalizeKey(name) === normalizeKey(key) && inferConstraint(name) === 'money')
|
|
776
|
+
: inferConstraint(key) === 'money';
|
|
777
|
+
inspect(slotId, `${label}·第 ${index + 1} 行·${key}`, value, isMoney);
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
// 新增条款正文:占位符残留写进正式合同同样是事故(金额必须走 amount/区块,不写进正文)
|
|
782
|
+
for (const clause of Array.isArray(plan.clauses) ? plan.clauses : []) {
|
|
783
|
+
if (typeof clause !== 'object' || clause === null)
|
|
784
|
+
continue;
|
|
785
|
+
const texts = [clause.heading, ...(Array.isArray(clause.paragraphs) ? clause.paragraphs : [])];
|
|
786
|
+
texts.forEach((text, index) => {
|
|
787
|
+
if (typeof text !== 'string' || !text)
|
|
788
|
+
return;
|
|
789
|
+
inspect('', `新增条款第 ${index + 1} 段`, text, false);
|
|
790
|
+
});
|
|
791
|
+
}
|
|
533
792
|
if (plan.totals && typeof plan.totals === 'object') {
|
|
534
793
|
inspect('totals.grandTotal', '合同总额', plan.totals.grandTotal, true);
|
|
535
794
|
const installments = Array.isArray(plan.totals.installments) ? plan.totals.installments : [];
|
|
@@ -589,6 +848,148 @@ export function validateXmlWellFormed(xml) {
|
|
|
589
848
|
}
|
|
590
849
|
return { ok: true };
|
|
591
850
|
}
|
|
851
|
+
function paragraphStyleFrom(xml, paragraphIndex) {
|
|
852
|
+
if (paragraphIndex === null)
|
|
853
|
+
return { pPr: '', rPr: '' };
|
|
854
|
+
const range = topParagraphRanges(xml)[paragraphIndex];
|
|
855
|
+
if (!range)
|
|
856
|
+
return { pPr: '', rPr: '' };
|
|
857
|
+
const pXml = xml.slice(range.start, range.end);
|
|
858
|
+
return { pPr: paragraphPropsXml(pXml), rPr: firstRunPropsXml(pXml) };
|
|
859
|
+
}
|
|
860
|
+
function resolveParagraphIndex(value) {
|
|
861
|
+
if (typeof value === 'number' && Number.isInteger(value) && value >= 0)
|
|
862
|
+
return value;
|
|
863
|
+
if (typeof value === 'string') {
|
|
864
|
+
const match = /^p?(\d+)$/u.exec(value.trim());
|
|
865
|
+
if (match)
|
|
866
|
+
return Number(match[1]);
|
|
867
|
+
}
|
|
868
|
+
return null;
|
|
869
|
+
}
|
|
870
|
+
function applyClauseOps(xml, ops, warnings, remapParagraph) {
|
|
871
|
+
const results = [];
|
|
872
|
+
const removedTableIndexes = new Set();
|
|
873
|
+
const paragraphs = topParagraphRanges(xml);
|
|
874
|
+
const paragraphByIndex = new Map(paragraphs.map((range) => [range.index, range]));
|
|
875
|
+
const tables = topTableRanges(xml);
|
|
876
|
+
const tableByIndex = new Map(tables.map((range) => [range.index, range]));
|
|
877
|
+
const edits = [];
|
|
878
|
+
const removals = [];
|
|
879
|
+
// 方案里的 p{n} 取自 scan(模板下标);行增删会让表格内段落数变化,先重映射到当前 xml
|
|
880
|
+
const currentParagraphIndex = (value) => {
|
|
881
|
+
const index = resolveParagraphIndex(value);
|
|
882
|
+
return index === null ? null : remapParagraph(index);
|
|
883
|
+
};
|
|
884
|
+
ops.forEach((op, order) => {
|
|
885
|
+
const kind = typeof op?.op === 'string' ? op.op : '';
|
|
886
|
+
if (kind === 'insert') {
|
|
887
|
+
const anchorIndex = currentParagraphIndex(op?.after) ?? currentParagraphIndex(op?.before);
|
|
888
|
+
const anchorSlot = op?.after ?? op?.before;
|
|
889
|
+
if (anchorIndex === null) {
|
|
890
|
+
throw contractValidationError('clause_anchor_unknown', `clauses[${order}] 缺少可用锚点:请传 after / before(段落 slotId,如 "p12",取自 slots.scan 的 outline)`);
|
|
891
|
+
}
|
|
892
|
+
const anchor = paragraphByIndex.get(anchorIndex);
|
|
893
|
+
if (!anchor) {
|
|
894
|
+
throw contractValidationError('clause_anchor_unknown', `clauses[${order}] 的锚点 ${String(anchorSlot)} 不是模板顶层段落(可能落在表格内或下标越界)。`
|
|
895
|
+
+ '请用 slots.scan 返回的 outline/clauses 里的 p{n} 作为锚点。');
|
|
896
|
+
}
|
|
897
|
+
const heading = typeof op?.heading === 'string' ? op.heading.trim() : '';
|
|
898
|
+
const bodyTexts = (Array.isArray(op?.paragraphs) ? op.paragraphs : [])
|
|
899
|
+
.map((text) => (typeof text === 'string' ? text : ''))
|
|
900
|
+
.filter((text) => text.trim() !== '');
|
|
901
|
+
if (!heading && bodyTexts.length === 0) {
|
|
902
|
+
throw contractValidationError('clause_content_required', `clauses[${order}] 没有任何内容:至少给 heading 或 paragraphs 之一(新增条款不能是空条款)`);
|
|
903
|
+
}
|
|
904
|
+
const fallback = paragraphStyleFrom(xml, anchorIndex);
|
|
905
|
+
const styleFromIndex = currentParagraphIndex(op?.styleFrom);
|
|
906
|
+
const headingStyle = paragraphStyleFrom(xml, currentParagraphIndex(op?.headingStyleFrom) ?? styleFromIndex);
|
|
907
|
+
const bodyStyle = paragraphStyleFrom(xml, currentParagraphIndex(op?.bodyStyleFrom) ?? styleFromIndex);
|
|
908
|
+
const useHeading = headingStyle.pPr || headingStyle.rPr ? headingStyle : fallback;
|
|
909
|
+
const useBody = bodyStyle.pPr || bodyStyle.rPr ? bodyStyle : fallback;
|
|
910
|
+
const lines = [
|
|
911
|
+
...(heading ? [makeParagraphXml(useHeading.pPr, useHeading.rPr, heading)] : []),
|
|
912
|
+
...bodyTexts.map((text) => makeParagraphXml(useBody.pPr, useBody.rPr, text)),
|
|
913
|
+
];
|
|
914
|
+
const insertAt = op?.before !== undefined && op?.after === undefined ? anchor.start : anchor.end;
|
|
915
|
+
edits.push({
|
|
916
|
+
pos: insertAt,
|
|
917
|
+
end: insertAt,
|
|
918
|
+
content: lines.join(''),
|
|
919
|
+
label: `clauses[${order}] insert(${lines.length} 段)`,
|
|
920
|
+
});
|
|
921
|
+
results.push({ op: 'insert', applied: true, insertedParagraphs: lines.length });
|
|
922
|
+
}
|
|
923
|
+
else if (kind === 'remove') {
|
|
924
|
+
const slotIds = [
|
|
925
|
+
...(Array.isArray(op?.slotIds) ? op.slotIds : []),
|
|
926
|
+
...(Array.isArray(op?.paragraphs) ? op.paragraphs : []),
|
|
927
|
+
...(op?.slotId ? [op.slotId] : []),
|
|
928
|
+
];
|
|
929
|
+
const tableIndexes = [
|
|
930
|
+
...(Array.isArray(op?.tableIndexes) ? op.tableIndexes : []),
|
|
931
|
+
...(op?.tableIndex !== undefined ? [op.tableIndex] : []),
|
|
932
|
+
];
|
|
933
|
+
if (slotIds.length === 0 && tableIndexes.length === 0) {
|
|
934
|
+
throw contractValidationError('clause_op_invalid', `clauses[${order}] remove 没有给出删除目标:需要 slotIds(段落 p{n} 数组)或 tableIndexes(表格下标数组)`);
|
|
935
|
+
}
|
|
936
|
+
let removedParagraphs = 0;
|
|
937
|
+
for (const slotId of slotIds) {
|
|
938
|
+
const index = currentParagraphIndex(slotId);
|
|
939
|
+
const range = index === null ? undefined : paragraphByIndex.get(index);
|
|
940
|
+
if (!range) {
|
|
941
|
+
throw contractValidationError('clause_anchor_unknown', `clauses[${order}] remove 的目标 ${String(slotId)} 不是模板顶层段落,无法删除`);
|
|
942
|
+
}
|
|
943
|
+
removals.push({ start: range.start, end: range.end });
|
|
944
|
+
edits.push({ pos: range.start, end: range.end, content: '', label: `clauses[${order}] remove ${String(slotId)}` });
|
|
945
|
+
removedParagraphs += 1;
|
|
946
|
+
}
|
|
947
|
+
let removedTables = 0;
|
|
948
|
+
for (const tableIndexRaw of tableIndexes) {
|
|
949
|
+
const tableIndex = resolveParagraphIndex(tableIndexRaw);
|
|
950
|
+
const range = tableIndex === null ? undefined : tableByIndex.get(tableIndex);
|
|
951
|
+
if (!range) {
|
|
952
|
+
throw contractValidationError('clause_anchor_unknown', `clauses[${order}] remove 的目标表格 ${String(tableIndexRaw)} 不存在(表格下标取自 slots.scan 的 t{n})`);
|
|
953
|
+
}
|
|
954
|
+
removedTableIndexes.add(tableIndex);
|
|
955
|
+
edits.push({ pos: range.start, end: range.end, content: '', label: `clauses[${order}] remove table t${tableIndex}` });
|
|
956
|
+
removedTables += 1;
|
|
957
|
+
}
|
|
958
|
+
results.push({ op: 'remove', applied: true, removedParagraphs, removedTables });
|
|
959
|
+
}
|
|
960
|
+
else {
|
|
961
|
+
throw contractValidationError('clause_op_invalid', `clauses[${order}] 的 op「${kind}」不支持:只支持 insert(新增条款)与 remove(删除条款/表格)。`
|
|
962
|
+
+ '替换段落正文用 plan.slots 里的 p{n} 位点。');
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
// 插入点落在被删除区间内属方案自相矛盾:删掉的段落里再插内容,结果无法预期
|
|
966
|
+
for (const edit of edits) {
|
|
967
|
+
if (edit.end !== edit.pos)
|
|
968
|
+
continue;
|
|
969
|
+
const conflict = removals.find((range) => edit.pos > range.start && edit.pos < range.end);
|
|
970
|
+
if (conflict) {
|
|
971
|
+
throw contractValidationError('clause_op_conflict', `${edit.label} 的插入点落在同一方案要删除的区间内(偏移 ${edit.pos});`
|
|
972
|
+
+ '请把插入锚点改到未被删除的段落上。');
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
let out = xml;
|
|
976
|
+
// 同一位置上「先删后插」:删除会让后续偏移平移,先删再插才能保证插入点准确。
|
|
977
|
+
const all = [...edits].sort((a, b) => {
|
|
978
|
+
if (b.pos !== a.pos)
|
|
979
|
+
return b.pos - a.pos;
|
|
980
|
+
const aRemove = a.end > a.pos ? 0 : 1;
|
|
981
|
+
const bRemove = b.end > b.pos ? 0 : 1;
|
|
982
|
+
return aRemove - bRemove;
|
|
983
|
+
});
|
|
984
|
+
for (const edit of all) {
|
|
985
|
+
out = edit.end > edit.pos
|
|
986
|
+
? out.slice(0, edit.pos) + out.slice(edit.end)
|
|
987
|
+
: out.slice(0, edit.pos) + edit.content + out.slice(edit.pos);
|
|
988
|
+
}
|
|
989
|
+
if (all.length === 0 && ops.length > 0)
|
|
990
|
+
warnings.push('clauses 方案没有产生任何可应用的编辑');
|
|
991
|
+
return { xml: out, results, removedTableIndexes };
|
|
992
|
+
}
|
|
592
993
|
export const contractDocxSlotsOperations = [
|
|
593
994
|
{
|
|
594
995
|
name: 'contract.docx.slots.scan',
|
|
@@ -607,14 +1008,20 @@ export const contractDocxSlotsOperations = [
|
|
|
607
1008
|
paragraph: slots.filter((slot) => slot.type === 'paragraph').length,
|
|
608
1009
|
cell: slots.filter((slot) => slot.type === 'cell').length,
|
|
609
1010
|
detailArea: slots.filter((slot) => slot.type === 'detail-area').length,
|
|
1011
|
+
region: slots.filter((slot) => slot.type === 'table-region').length,
|
|
610
1012
|
required: slots.filter((slot) => slot.required).length,
|
|
1013
|
+
requiredRegion: slots.filter((slot) => slot.type === 'table-region' && slot.required).length,
|
|
611
1014
|
};
|
|
1015
|
+
// 范文骨架:条款结构(哪一条、在哪个段落、带哪张表),供模型决定按需增删条款。
|
|
1016
|
+
// 默认给出(动态生成需要它);模板很长时可用 includeText:false 关掉以省上下文。
|
|
1017
|
+
const includeText = input.includeText !== false;
|
|
1018
|
+
const outline = includeText ? buildOutline(topBlocks(xml), parseTables(xml)) : null;
|
|
612
1019
|
const outInput = typeof input.out === 'string' ? input.out.trim() : '';
|
|
613
1020
|
let outPath = null;
|
|
614
1021
|
if (outInput) {
|
|
615
1022
|
outPath = resolve(outInput);
|
|
616
1023
|
mkdirSync(dirname(outPath), { recursive: true });
|
|
617
|
-
writeFileSync(outPath, JSON.stringify({ slots, profile }, null, 2), 'utf8');
|
|
1024
|
+
writeFileSync(outPath, JSON.stringify({ slots, profile, outline }, null, 2), 'utf8');
|
|
618
1025
|
}
|
|
619
1026
|
return {
|
|
620
1027
|
status: 'COMPLETE',
|
|
@@ -625,8 +1032,11 @@ export const contractDocxSlotsOperations = [
|
|
|
625
1032
|
summary,
|
|
626
1033
|
profile,
|
|
627
1034
|
slots,
|
|
1035
|
+
...(outline ? { outline: outline.entries, clauses: outline.clauses } : {}),
|
|
628
1036
|
...(outPath ? { out: outPath } : {}),
|
|
629
|
-
note: '
|
|
1037
|
+
note: '模板只是参考:slots 是可填位点;table-region 位点(付款计划 / 费用构成等)'
|
|
1038
|
+
+ '用 plan.regions 按实际需要决定行数;outline/clauses 是范文条款骨架,'
|
|
1039
|
+
+ '用 plan.clauses 新增或删除条款',
|
|
630
1040
|
},
|
|
631
1041
|
};
|
|
632
1042
|
},
|
|
@@ -664,8 +1074,13 @@ export const contractDocxSlotsOperations = [
|
|
|
664
1074
|
const plan = refOutcome.value;
|
|
665
1075
|
const strict = input.strict !== false;
|
|
666
1076
|
const allowRowInsert = input.allowRowInsert !== false;
|
|
1077
|
+
// 动态区块的覆盖校验:默认为真。要求「付款计划 / 费用构成」这类区块必须由方案显式给出
|
|
1078
|
+
// rows(哪怕内容与模板一致也要写一次),否则又退回「照模板填空」。排障时可置 false。
|
|
1079
|
+
const strictRegions = input.strictRegions !== false;
|
|
667
1080
|
const slotWrites = Array.isArray(plan.slots) ? plan.slots : [];
|
|
668
1081
|
const detailPlans = Array.isArray(plan.details) ? plan.details : [];
|
|
1082
|
+
const regionPlans = Array.isArray(plan.regions) ? plan.regions : [];
|
|
1083
|
+
const clauseOps = Array.isArray(plan.clauses) ? plan.clauses : [];
|
|
669
1084
|
const unsupported = Array.isArray(plan.unsupported) ? plan.unsupported : [];
|
|
670
1085
|
const totals = typeof plan.totals === 'object' && plan.totals !== null ? plan.totals : null;
|
|
671
1086
|
let xml = readDocumentXml(templatePath);
|
|
@@ -676,11 +1091,22 @@ export const contractDocxSlotsOperations = [
|
|
|
676
1091
|
const tablesBefore = parseTables(xml).length;
|
|
677
1092
|
const warnings = [];
|
|
678
1093
|
const detailAdjust = [];
|
|
1094
|
+
const regionAdjust = [];
|
|
679
1095
|
// 明细行增删造成的行号偏移。位点坐标来自模板扫描(模板行号),
|
|
680
1096
|
// 行数一变就必须重映射,否则固定位点会落到错行或已删除的行上。
|
|
681
1097
|
// 2026-11-16 实测:删 6 行后 3r17c1 / 3r18c1 / 3r21c1 全部写空,
|
|
682
1098
|
// 回读报「位点不存在」,而 applied 仍把它们计入成功数,属双重静默失败。
|
|
683
1099
|
const rowShifts = [];
|
|
1100
|
+
/**
|
|
1101
|
+
* 段落下标偏移(2026-11-29 新增)。
|
|
1102
|
+
*
|
|
1103
|
+
* 行增删会连带增删**表格单元格里的段落**,而 `p{n}` 位点与条款锚点用的是
|
|
1104
|
+
* `collectRanges('w:p')` 的**全量下标**(含表格内段落)。插 1 行 = 多 4 个段落,
|
|
1105
|
+
* 其后所有段落下标整体后移——不重映射就会写到别的段落上,或报「锚点不是顶层段落」。
|
|
1106
|
+
*/
|
|
1107
|
+
const paragraphShifts = [];
|
|
1108
|
+
const originalParagraphs = collectRanges(templateXml, 'w:p');
|
|
1109
|
+
const originalTables = parseTables(templateXml);
|
|
684
1110
|
// ── 阶段 0:写前守卫。必须在做任何写入之前判定,确保残次品根本不会落盘。
|
|
685
1111
|
// 2026-11-20 事故:占位符被当成值写入,写后五项校验全过,残次品直接交付。
|
|
686
1112
|
const audit = auditPlanValues(plan, templateSlots);
|
|
@@ -696,6 +1122,11 @@ export const contractDocxSlotsOperations = [
|
|
|
696
1122
|
+ `${describeIssues(audit.displayMoney)}。展示文本与脱敏值无法区分、也不会被还原,`
|
|
697
1123
|
+ '请改传纯数值(如 144000 或 "144000.00"),数值以报价单解析结果的 totals / sections 为准。', { displayMoney: audit.displayMoney });
|
|
698
1124
|
}
|
|
1125
|
+
// 表格内段落数:行增删的副产物,用于重映射 `p{n}` 段落下标
|
|
1126
|
+
const tableParagraphCount = (xmlNow, tableIndex) => {
|
|
1127
|
+
const table = parseTables(xmlNow)[tableIndex];
|
|
1128
|
+
return table ? collectRanges(xmlNow.slice(table.start, table.end), 'w:p').length : 0;
|
|
1129
|
+
};
|
|
699
1130
|
// ── 阶段 1:明细区行数调整(插行 / 删行),必须在写单元格之前完成,否则行号会漂移
|
|
700
1131
|
for (const detail of detailPlans) {
|
|
701
1132
|
const parsed = typeof detail?.slotId === 'string' ? parseSlotId(detail.slotId) : null;
|
|
@@ -724,6 +1155,7 @@ export const contractDocxSlotsOperations = [
|
|
|
724
1155
|
const range = segment;
|
|
725
1156
|
const have = Math.max(0, range.endRow - range.startRow + 1);
|
|
726
1157
|
const need = items.length;
|
|
1158
|
+
const parasBefore = tableParagraphCount(xml, tableIndex);
|
|
727
1159
|
let adjusted = have;
|
|
728
1160
|
if (need > have) {
|
|
729
1161
|
if (!allowRowInsert) {
|
|
@@ -768,6 +1200,87 @@ export const contractDocxSlotsOperations = [
|
|
|
768
1200
|
endRow: range.endRow,
|
|
769
1201
|
delta: adjusted - have,
|
|
770
1202
|
});
|
|
1203
|
+
paragraphShifts.push({ table: tableIndex, delta: tableParagraphCount(xml, tableIndex) - parasBefore });
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
// ── 阶段 1b:动态表格区块行数调整(2026-11-29 新增)
|
|
1207
|
+
//
|
|
1208
|
+
// 区块行数**由方案给的 rows 长度决定**,不由模板决定:付款计划给 1 期就删到 1 行、
|
|
1209
|
+
// 给 3 期就插到 3 行。模板里原本几行只是参考值。
|
|
1210
|
+
for (const region of regionPlans) {
|
|
1211
|
+
const slotId = typeof region?.slotId === 'string' ? region.slotId.trim() : '';
|
|
1212
|
+
const parsed = slotId ? parseSlotId(slotId) : null;
|
|
1213
|
+
if (!parsed || parsed.kind !== 'region') {
|
|
1214
|
+
throw contractValidationError('region_slot_invalid', `regions 方案缺少合法 slotId(形如 t4.region / t4.region.2,取自 slots.scan 的 table-region 位点):${slotId || '(空)'}`);
|
|
1215
|
+
}
|
|
1216
|
+
const templateRegion = templateSlots.find((slot) => slot.type === 'table-region' && slot.slotId === slotId);
|
|
1217
|
+
if (!templateRegion) {
|
|
1218
|
+
throw contractValidationError('region_slot_unknown', `模板里没有可扩缩区块位点 ${slotId}。可用区块位点:`
|
|
1219
|
+
+ `${templateSlots.filter((slot) => slot.type === 'table-region').map((slot) => slot.slotId).join('、') || '(无)'}`);
|
|
1220
|
+
}
|
|
1221
|
+
// rows 必须是数组:写成对象/字符串会让「区块不适用」与「方案写错」无法区分,
|
|
1222
|
+
// 而这两种情况的行数调整方向完全相反,必须当场报错。
|
|
1223
|
+
if (!Array.isArray(region?.rows)) {
|
|
1224
|
+
throw contractValidationError('region_rows_required', `区块 ${slotId} 缺少 rows 数组。按实际需求给整块内容(1 期就 1 条、3 期就 3 条);`
|
|
1225
|
+
+ '确实不适用的区块显式传 rows: [](数据行全部删除)。');
|
|
1226
|
+
}
|
|
1227
|
+
const rows = region.rows;
|
|
1228
|
+
const table = parseTables(xml)[parsed.table];
|
|
1229
|
+
if (!table) {
|
|
1230
|
+
throw contractValidationError('region_table_missing', `区块 ${slotId} 指向的表格 T${parsed.table} 不存在`);
|
|
1231
|
+
}
|
|
1232
|
+
// 段边界按**当前** xml 重新推导:同一张表里前一个区块增删行后,模板行号会漂移
|
|
1233
|
+
const segment = findDetailSegments(table, templateRegion.headerRow)[parsed.segment];
|
|
1234
|
+
if (!segment) {
|
|
1235
|
+
throw contractValidationError('region_segment_missing', `区块 ${slotId} 在表格 T${parsed.table} 中已不存在(可能被前面的方案行数调整覆盖)`);
|
|
1236
|
+
}
|
|
1237
|
+
const have = Math.max(0, segment.endRow - segment.startRow + 1);
|
|
1238
|
+
const need = rows.length;
|
|
1239
|
+
const parasBefore = tableParagraphCount(xml, parsed.table);
|
|
1240
|
+
let adjusted = have;
|
|
1241
|
+
if (need > have) {
|
|
1242
|
+
if (!allowRowInsert) {
|
|
1243
|
+
warnings.push(`区块 ${slotId} 需 ${need} 行、模板仅 ${have} 行;allowRowInsert=false,未插行`);
|
|
1244
|
+
}
|
|
1245
|
+
else {
|
|
1246
|
+
const res = insertTableRows(xml, parsed.table, segment.startRow, segment.startRow, need - have);
|
|
1247
|
+
if (res.ok) {
|
|
1248
|
+
xml = res.xml;
|
|
1249
|
+
adjusted = need;
|
|
1250
|
+
}
|
|
1251
|
+
else {
|
|
1252
|
+
warnings.push(`区块 ${slotId} 插入行失败:${res.reason ?? 'unknown'}`);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
else if (need < have) {
|
|
1257
|
+
const res = deleteTableRows(xml, parsed.table, segment.startRow, need, have);
|
|
1258
|
+
if (res.ok) {
|
|
1259
|
+
xml = res.xml;
|
|
1260
|
+
adjusted = need;
|
|
1261
|
+
}
|
|
1262
|
+
else {
|
|
1263
|
+
warnings.push(`区块 ${slotId} 删除多余行失败:${res.reason ?? 'unknown'}`);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
regionAdjust.push({
|
|
1267
|
+
slotId,
|
|
1268
|
+
table: parsed.table,
|
|
1269
|
+
kind: templateRegion.kind,
|
|
1270
|
+
templateRows: have,
|
|
1271
|
+
needRows: need,
|
|
1272
|
+
finalRows: adjusted,
|
|
1273
|
+
inserted: Math.max(0, adjusted - have),
|
|
1274
|
+
removed: Math.max(0, have - adjusted),
|
|
1275
|
+
});
|
|
1276
|
+
if (adjusted !== have) {
|
|
1277
|
+
rowShifts.push({
|
|
1278
|
+
table: parsed.table,
|
|
1279
|
+
startRow: segment.startRow,
|
|
1280
|
+
endRow: segment.endRow,
|
|
1281
|
+
delta: adjusted - have,
|
|
1282
|
+
});
|
|
1283
|
+
paragraphShifts.push({ table: parsed.table, delta: tableParagraphCount(xml, parsed.table) - parasBefore });
|
|
771
1284
|
}
|
|
772
1285
|
}
|
|
773
1286
|
/**
|
|
@@ -787,6 +1300,25 @@ export const contractDocxSlotsOperations = [
|
|
|
787
1300
|
}
|
|
788
1301
|
return out;
|
|
789
1302
|
};
|
|
1303
|
+
/**
|
|
1304
|
+
* 模板段落下标 → 行数调整后的段落下标。
|
|
1305
|
+
*
|
|
1306
|
+
* 判据用**模板原始坐标**:某张表在模板里的起始偏移小于该段落的起始偏移,
|
|
1307
|
+
* 就说明这张表的行增删发生在这个段落之前,其段落数变化要累加到段落下标上。
|
|
1308
|
+
* 顶层段落自身不会被行增删影响位置,因此只需按表累加。
|
|
1309
|
+
*/
|
|
1310
|
+
const remapParagraph = (index) => {
|
|
1311
|
+
const range = originalParagraphs[index];
|
|
1312
|
+
if (!range)
|
|
1313
|
+
return index;
|
|
1314
|
+
let out = index;
|
|
1315
|
+
for (const shift of paragraphShifts) {
|
|
1316
|
+
const tableStart = originalTables[shift.table]?.start ?? 0;
|
|
1317
|
+
if (tableStart < range.start)
|
|
1318
|
+
out += shift.delta;
|
|
1319
|
+
}
|
|
1320
|
+
return out;
|
|
1321
|
+
};
|
|
790
1322
|
// 行数调整后的表结构,供写入前做存在性判定(禁止把不存在的位点算进 applied)
|
|
791
1323
|
const tablesAdjusted = parseTables(xml);
|
|
792
1324
|
// ── 阶段 2:收集单元格 / 段落写入(基于行数调整后的 xml)
|
|
@@ -821,9 +1353,12 @@ export const contractDocxSlotsOperations = [
|
|
|
821
1353
|
applied.push(slotId);
|
|
822
1354
|
}
|
|
823
1355
|
else if (parsed.kind === 'paragraph') {
|
|
824
|
-
paragraphWrites.push({ index: parsed.index, value });
|
|
1356
|
+
paragraphWrites.push({ index: remapParagraph(parsed.index), value });
|
|
825
1357
|
applied.push(slotId);
|
|
826
1358
|
}
|
|
1359
|
+
else if (parsed.kind === 'region') {
|
|
1360
|
+
warnings.push(`可扩缩区块位点不能用单值写入:${slotId},请改用 regions`);
|
|
1361
|
+
}
|
|
827
1362
|
else {
|
|
828
1363
|
warnings.push(`明细区位点不能用单值写入:${slotId},请改用 details`);
|
|
829
1364
|
}
|
|
@@ -898,6 +1433,108 @@ export const contractDocxSlotsOperations = [
|
|
|
898
1433
|
unmappedColumns: unmapped,
|
|
899
1434
|
});
|
|
900
1435
|
}
|
|
1436
|
+
// ── 阶段 3b:动态区块逐行写值(2026-11-29 新增)
|
|
1437
|
+
//
|
|
1438
|
+
// 与 details 的关键差别:区块行**整行按列重建**——方案没给的列一律置空,
|
|
1439
|
+
// 不再沿用克隆行带过来的模板旧值。否则「模板 2 行 → 需求 3 行」时,
|
|
1440
|
+
// 新插入的行会带着模板示例值(如重复的 50%)进正式合同,且回读校验发现不了。
|
|
1441
|
+
const regionResults = [];
|
|
1442
|
+
for (const region of regionPlans) {
|
|
1443
|
+
const slotId = typeof region?.slotId === 'string' ? region.slotId.trim() : '';
|
|
1444
|
+
const parsed = slotId ? parseSlotId(slotId) : null;
|
|
1445
|
+
if (!parsed || parsed.kind !== 'region')
|
|
1446
|
+
continue;
|
|
1447
|
+
const templateRegion = templateSlots.find((slot) => slot.type === 'table-region' && slot.slotId === slotId);
|
|
1448
|
+
if (!templateRegion)
|
|
1449
|
+
continue;
|
|
1450
|
+
const rows = Array.isArray(region?.rows) ? region.rows : [];
|
|
1451
|
+
const table = parseTables(xml)[parsed.table];
|
|
1452
|
+
if (!table)
|
|
1453
|
+
continue;
|
|
1454
|
+
const segment = findDetailSegments(table, templateRegion.headerRow)[parsed.segment];
|
|
1455
|
+
if (!segment)
|
|
1456
|
+
continue;
|
|
1457
|
+
const headerCells = table.rows[templateRegion.headerRow]?.cells ?? [];
|
|
1458
|
+
const columns = headerCells.map((cell, index) => ({ cell: index, name: cell.text.trim() }));
|
|
1459
|
+
const emptyColumns = [];
|
|
1460
|
+
rows.forEach((row, offset) => {
|
|
1461
|
+
const rowIndex = segment.startRow + offset;
|
|
1462
|
+
const rowRef = table.rows[rowIndex];
|
|
1463
|
+
if (!rowRef)
|
|
1464
|
+
return;
|
|
1465
|
+
const record = (typeof row === 'object' && row !== null ? row : {});
|
|
1466
|
+
for (const column of columns) {
|
|
1467
|
+
if (column.cell >= rowRef.cells.length)
|
|
1468
|
+
continue;
|
|
1469
|
+
const value = pickColumnValue(record, column.name);
|
|
1470
|
+
if (value === null) {
|
|
1471
|
+
if (!emptyColumns.includes(column.name))
|
|
1472
|
+
emptyColumns.push(column.name);
|
|
1473
|
+
}
|
|
1474
|
+
const constraint = inferConstraint(column.name);
|
|
1475
|
+
const text = value === null || value === '' ? '' : (constraint === 'money' ? moneyText(value) : value);
|
|
1476
|
+
cellWrites.push({ table: parsed.table, row: rowIndex, cell: column.cell, value: text });
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
// 区块合计行(段末合并行):方案给了 subtotal 时写入其最后一格
|
|
1480
|
+
const subtotal = region?.subtotal ?? region?.total;
|
|
1481
|
+
const stopRow = segment.endRow + 1;
|
|
1482
|
+
const stopRowCells = table.rows[stopRow]?.cells ?? [];
|
|
1483
|
+
const hasSummaryRow = stopRowCells.length > 1 && stopRowCells.length < columns.length;
|
|
1484
|
+
if (hasSummaryRow && subtotal !== null && subtotal !== undefined && subtotal !== '') {
|
|
1485
|
+
cellWrites.push({
|
|
1486
|
+
table: parsed.table,
|
|
1487
|
+
row: stopRow,
|
|
1488
|
+
cell: stopRowCells.length - 1,
|
|
1489
|
+
value: moneyText(subtotal),
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
// 区块求和勾稽:默认取第一个金额约束列(付款金额 / 金额),可用 sumColumn 指定
|
|
1493
|
+
const moneyColumn = columns.find((column) => inferConstraint(column.name) === 'money')?.name ?? '';
|
|
1494
|
+
const sumColumn = typeof region?.sumColumn === 'string' && region.sumColumn.trim()
|
|
1495
|
+
? region.sumColumn.trim()
|
|
1496
|
+
: moneyColumn;
|
|
1497
|
+
let rowSum = null;
|
|
1498
|
+
if (sumColumn) {
|
|
1499
|
+
let sum = 0;
|
|
1500
|
+
let computable = rows.length > 0;
|
|
1501
|
+
for (const row of rows) {
|
|
1502
|
+
const record = (typeof row === 'object' && row !== null ? row : {});
|
|
1503
|
+
const raw = pickColumnValue(record, sumColumn);
|
|
1504
|
+
if (raw === null || raw === '') {
|
|
1505
|
+
computable = false;
|
|
1506
|
+
break;
|
|
1507
|
+
}
|
|
1508
|
+
const num = Number(String(raw).replace(/[¥¥,\s]/gu, ''));
|
|
1509
|
+
if (!Number.isFinite(num)) {
|
|
1510
|
+
computable = false;
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
sum += num;
|
|
1514
|
+
}
|
|
1515
|
+
if (computable)
|
|
1516
|
+
rowSum = round2(sum);
|
|
1517
|
+
}
|
|
1518
|
+
regionResults.push({
|
|
1519
|
+
slotId,
|
|
1520
|
+
table: parsed.table,
|
|
1521
|
+
kind: templateRegion.kind,
|
|
1522
|
+
rowsFilled: rows.length,
|
|
1523
|
+
columns: columns.map((column) => column.name).filter(Boolean),
|
|
1524
|
+
moneyColumn: moneyColumn || null,
|
|
1525
|
+
sumColumn: sumColumn || null,
|
|
1526
|
+
rowSum,
|
|
1527
|
+
subtotal: subtotal === null || subtotal === undefined || subtotal === '' ? null : Number(String(subtotal).replace(/[¥¥,\s]/gu, '')),
|
|
1528
|
+
summaryRowWritten: hasSummaryRow && subtotal !== null && subtotal !== undefined && subtotal !== '',
|
|
1529
|
+
emptyColumns,
|
|
1530
|
+
});
|
|
1531
|
+
if (emptyColumns.length > 0) {
|
|
1532
|
+
warnings.push(`区块 ${slotId} 有列在方案中无值:${emptyColumns.join('、')}(已置空,未保留模板旧值)`);
|
|
1533
|
+
}
|
|
1534
|
+
if (rows.length === 0) {
|
|
1535
|
+
warnings.push(`区块 ${slotId} 方案给的是空行数组:该区块所有数据行已删除(表示本区块不适用)`);
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
901
1538
|
// 同一格被多处写入时必须去重:位点与 details.subtotal 会同时命中小计行。
|
|
902
1539
|
// 2026-11-16 实测:两处写同一格时 applyCellWrites 按原始绝对偏移各替换一次,
|
|
903
1540
|
// 第一次替换已改变字符串长度,第二次仍用旧偏移切片 → 标签被切碎、Word 打不开
|
|
@@ -917,6 +1554,19 @@ export const contractDocxSlotsOperations = [
|
|
|
917
1554
|
xml = cellResult.xml;
|
|
918
1555
|
const paraResult = applyParagraphWrites(xml, paragraphWrites);
|
|
919
1556
|
xml = paraResult.xml;
|
|
1557
|
+
// ── 阶段 4b:条款级动态编辑(新增 / 删除条款段落与表格;2026-11-29 新增)
|
|
1558
|
+
// 放在单元格 / 段落文字写完之后:位置在**同一次快照**里解析成绝对偏移,
|
|
1559
|
+
// 因此段落文字写入用的原始 p{n} 下标不受插入删除影响。
|
|
1560
|
+
const clauseOutcome = clauseOps.length > 0
|
|
1561
|
+
? applyClauseOps(xml, clauseOps, warnings, remapParagraph)
|
|
1562
|
+
: { xml, results: [], removedTableIndexes: new Set() };
|
|
1563
|
+
xml = clauseOutcome.xml;
|
|
1564
|
+
for (const result of clauseOutcome.results) {
|
|
1565
|
+
if (result.op === 'insert' && result.insertedParagraphs)
|
|
1566
|
+
applied.push(`clauses:insert×${result.insertedParagraphs}`);
|
|
1567
|
+
if (result.op === 'remove')
|
|
1568
|
+
applied.push(`clauses:remove×${(result.removedParagraphs ?? 0) + (result.removedTables ?? 0)}`);
|
|
1569
|
+
}
|
|
920
1570
|
const outPath = resolve(outInput);
|
|
921
1571
|
mkdirSync(dirname(outPath), { recursive: true });
|
|
922
1572
|
writeFileSync(outPath, rewriteZip(templatePath, { 'word/document.xml': xml }));
|
|
@@ -925,9 +1575,9 @@ export const contractDocxSlotsOperations = [
|
|
|
925
1575
|
const verifyTables = parseTables(verifyXml);
|
|
926
1576
|
const checks = [];
|
|
927
1577
|
const fails = [];
|
|
928
|
-
// 5.1
|
|
1578
|
+
// 5.1 必填位点必须已覆盖(可扩缩区块走 5.1b 的区块口径,不在这里重复判定)
|
|
929
1579
|
const scanned = templateSlots;
|
|
930
|
-
const requiredSlots = scanned.filter((slot) => slot.required);
|
|
1580
|
+
const requiredSlots = scanned.filter((slot) => slot.required && slot.type !== 'table-region');
|
|
931
1581
|
const covered = new Set([...applied]);
|
|
932
1582
|
const uncovered = requiredSlots
|
|
933
1583
|
.filter((slot) => !covered.has(slot.slotId) && !missing.includes(slot.slotId))
|
|
@@ -946,6 +1596,65 @@ export const contractDocxSlotsOperations = [
|
|
|
946
1596
|
fails.push(`必填位点传空值:${missing.join('、')}`);
|
|
947
1597
|
checks.push({ level: 'FAIL', item: '必填位点空值', detail: missing.join('、') });
|
|
948
1598
|
}
|
|
1599
|
+
// 5.1b 动态区块必须由方案显式给出(2026-11-29 新增)
|
|
1600
|
+
//
|
|
1601
|
+
// 付款计划 / 费用构成这类区块是「内容决策」而不是「模板填空」:方案不给 rows,
|
|
1602
|
+
// 成品就会照抄模板的期数与金额,正是本次要消除的固定填空。因此默认要求显式覆盖。
|
|
1603
|
+
const plannedRegions = new Set(regionPlans
|
|
1604
|
+
.map((region) => (typeof region?.slotId === 'string' ? region.slotId.trim() : ''))
|
|
1605
|
+
.filter(Boolean));
|
|
1606
|
+
const requiredRegions = scanned.filter((slot) => slot.type === 'table-region' && slot.required);
|
|
1607
|
+
const missingRegions = requiredRegions
|
|
1608
|
+
.filter((slot) => !plannedRegions.has(slot.slotId))
|
|
1609
|
+
.map((slot) => `${slot.slotId}(${slot.label})`);
|
|
1610
|
+
if (strict && strictRegions && missingRegions.length > 0) {
|
|
1611
|
+
fails.push(`必填区块未覆盖(付款计划 / 费用构成必须按实际需求给 rows):${missingRegions.join('、')}`);
|
|
1612
|
+
checks.push({ level: 'FAIL', item: '必填区块覆盖', detail: missingRegions.join('、') });
|
|
1613
|
+
}
|
|
1614
|
+
else if (missingRegions.length > 0) {
|
|
1615
|
+
checks.push({ level: 'WARN', item: '必填区块覆盖', detail: missingRegions.join('、') });
|
|
1616
|
+
}
|
|
1617
|
+
else {
|
|
1618
|
+
checks.push({
|
|
1619
|
+
level: 'PASS',
|
|
1620
|
+
item: '必填区块覆盖',
|
|
1621
|
+
detail: requiredRegions.length > 0 ? `${requiredRegions.length} 个必填区块已给方案` : '模板无必填区块',
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
// 5.1c 区块金额勾稽:区块行求和 = 区块小计 = 合同总额
|
|
1625
|
+
//
|
|
1626
|
+
// 金额列取不到值时**必须 FAIL**,不能静默放过:方案键名写错(如把「付款金额」写成别的字段)
|
|
1627
|
+
// 会让整列被置空,而"没有数字"恰好跳过求和校验——这正是残次品最容易钻的缝。
|
|
1628
|
+
for (const result of regionResults) {
|
|
1629
|
+
const rowSum = result.rowSum;
|
|
1630
|
+
const subtotal = result.subtotal;
|
|
1631
|
+
const moneyColumn = result.moneyColumn ?? null;
|
|
1632
|
+
const rowsFilled = Number(result.rowsFilled ?? 0);
|
|
1633
|
+
if (rowSum === null) {
|
|
1634
|
+
if (rowsFilled > 0 && moneyColumn && (result.kind === 'payment' || result.kind === 'amount')) {
|
|
1635
|
+
fails.push(`区块 ${result.slotId} 的金额列「${moneyColumn}」没有任何可计算的值`
|
|
1636
|
+
+ `(方案每行必须给出该列,且为纯数值或 $quote 引用;当前列为空:${result.emptyColumns.join('、') || '—'})`);
|
|
1637
|
+
checks.push({ level: 'FAIL', item: '区块金额列有值', detail: `${result.slotId}·${moneyColumn}` });
|
|
1638
|
+
}
|
|
1639
|
+
continue;
|
|
1640
|
+
}
|
|
1641
|
+
if (subtotal !== null && Number.isFinite(subtotal)) {
|
|
1642
|
+
if (Math.abs(rowSum - subtotal) > 0.01) {
|
|
1643
|
+
fails.push(`区块 ${result.slotId} 行求和与小计不符:求和 ${rowSum.toFixed(2)} / 小计 ${subtotal.toFixed(2)}`);
|
|
1644
|
+
checks.push({ level: 'FAIL', item: '区块求和=小计', detail: `${result.slotId}:${rowSum.toFixed(2)} / ${subtotal.toFixed(2)}` });
|
|
1645
|
+
}
|
|
1646
|
+
else {
|
|
1647
|
+
checks.push({ level: 'PASS', item: '区块求和=小计', detail: `${result.slotId}:${rowSum.toFixed(2)}` });
|
|
1648
|
+
}
|
|
1649
|
+
if (totals && totals.grandTotal !== null && totals.grandTotal !== undefined) {
|
|
1650
|
+
const grand = Number(String(totals.grandTotal).replace(/[¥¥,\s]/gu, ''));
|
|
1651
|
+
if (Number.isFinite(grand) && Math.abs(subtotal - grand) > 0.01) {
|
|
1652
|
+
fails.push(`区块 ${result.slotId} 小计与合同总额不符:小计 ${subtotal.toFixed(2)} / 总额 ${grand.toFixed(2)}`);
|
|
1653
|
+
checks.push({ level: 'FAIL', item: '区块小计=合同总额', detail: `${result.slotId}:${subtotal.toFixed(2)} / ${grand.toFixed(2)}` });
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
949
1658
|
// 5.2 写入回读一致(单元格)
|
|
950
1659
|
const mismatched = [];
|
|
951
1660
|
for (const write of cellWritesFinal) {
|
|
@@ -1030,16 +1739,20 @@ export const contractDocxSlotsOperations = [
|
|
|
1030
1739
|
}
|
|
1031
1740
|
}
|
|
1032
1741
|
// 5.5 表格数量与网格列宽未变(插行不得改结构)
|
|
1742
|
+
//
|
|
1743
|
+
// 2026-11-29 调整:条款方案**显式删除**的表格从基准里剔除——「删条款连表一起删」是
|
|
1744
|
+
// 预期行为,不该被判成结构损坏;其余表格仍要求数量与网格列宽完全一致。
|
|
1745
|
+
const expectedGrids = gridsBefore.filter((_, index) => !clauseOutcome.removedTableIndexes.has(index));
|
|
1033
1746
|
const gridsAfter = allTableGrids(verifyXml);
|
|
1034
1747
|
const tablesAfter = verifyTables.length;
|
|
1035
|
-
const gridSame = tablesAfter ===
|
|
1036
|
-
gridsAfter.length ===
|
|
1748
|
+
const gridSame = tablesAfter === expectedGrids.length &&
|
|
1749
|
+
gridsAfter.length === expectedGrids.length &&
|
|
1037
1750
|
gridsAfter.every((grid, index) => {
|
|
1038
|
-
const before =
|
|
1751
|
+
const before = expectedGrids[index] ?? [];
|
|
1039
1752
|
return grid.length === before.length && grid.every((width, cellIndex) => width === before[cellIndex]);
|
|
1040
1753
|
});
|
|
1041
1754
|
if (!gridSame) {
|
|
1042
|
-
fails.push(`表格结构发生变化:表数 ${tablesBefore}
|
|
1755
|
+
fails.push(`表格结构发生变化:表数 ${tablesBefore}(方案删表 ${clauseOutcome.removedTableIndexes.size} 张)→ ${tablesAfter},或网格列宽改变`);
|
|
1043
1756
|
checks.push({ level: 'FAIL', item: '表格结构未变', detail: `表数 ${tablesBefore}→${tablesAfter}` });
|
|
1044
1757
|
}
|
|
1045
1758
|
else {
|
|
@@ -1091,6 +1804,11 @@ export const contractDocxSlotsOperations = [
|
|
|
1091
1804
|
unsupported,
|
|
1092
1805
|
warnings,
|
|
1093
1806
|
detailAdjust,
|
|
1807
|
+
regionAdjust,
|
|
1808
|
+
regions: regionResults,
|
|
1809
|
+
clauses: clauseOutcome.results,
|
|
1810
|
+
removedTableIndexes: [...clauseOutcome.removedTableIndexes],
|
|
1811
|
+
requiredRegionsMissing: missingRegions,
|
|
1094
1812
|
rowShifts,
|
|
1095
1813
|
details: detailResults,
|
|
1096
1814
|
resolvedQuoteRefs: refOutcome.resolved,
|
|
@@ -1098,7 +1816,8 @@ export const contractDocxSlotsOperations = [
|
|
|
1098
1816
|
selfCheckPassed: validateOk,
|
|
1099
1817
|
selfCheck: fails,
|
|
1100
1818
|
note: validateOk
|
|
1101
|
-
? `通过:${applied.length}
|
|
1819
|
+
? `通过:${applied.length} 处写入(含区块 ${regionResults.length} 个、条款编辑 ${clauseOutcome.results.length} 条),`
|
|
1820
|
+
+ '必填覆盖、必填区块覆盖、回读一致、金额勾稽、表结构、XML 良构与占位符残留校验均通过'
|
|
1102
1821
|
: '不通过:见 validate.fails;未通过校验的产物不得交付',
|
|
1103
1822
|
},
|
|
1104
1823
|
};
|