weaver-work-cli 0.1.53 → 0.1.56
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/dist/chunks/{archive-ZQ4A4TV6.js → archive-4SQAVTIB.js} +3 -2
- package/dist/chunks/{archive-oa-57R2FYHV.js → archive-oa-W2UEJ67L.js} +137 -8
- package/dist/chunks/{asset-ZOJVBWZH.js → asset-EGZEABBI.js} +3 -2
- package/dist/chunks/{asset-idle-XGB5IPGT.js → asset-idle-EBUZBB6M.js} +3 -2
- package/dist/chunks/{attachment-content-W3TSJC3Y.js → attachment-content-QGM5MLQE.js} +4 -3
- package/dist/chunks/{blog-QSHLZSFW.js → blog-2YKMWOWI.js} +3 -2
- package/dist/chunks/{caizhilian-KCQYFH72.js → caizhilian-QJ4FLSQJ.js} +5 -4
- package/dist/chunks/{calendar-DLGMRJQA.js → calendar-H4QTJCUY.js} +3 -2
- package/dist/chunks/{chunk-XPQN4E5O.js → chunk-44KJ7WFA.js} +300 -55
- package/dist/chunks/{chunk-CZNZKOHR.js → chunk-4GG72JAT.js} +2 -2
- package/dist/chunks/{chunk-YIKSL36S.js → chunk-5N222HK6.js} +2 -2
- package/dist/chunks/{chunk-6GCXWKG6.js → chunk-6DVL5IN5.js} +4 -1
- package/dist/chunks/{chunk-WTLQGS6D.js → chunk-6MS3RLPO.js} +5 -334
- package/dist/chunks/{chunk-Z4G7LLDD.js → chunk-7EBV7Q3R.js} +124 -27
- package/dist/chunks/{chunk-76PRVYH4.js → chunk-AHJZIMCX.js} +1 -1
- package/dist/chunks/{chunk-TGAGQV4I.js → chunk-CQ4OVCKG.js} +2 -2
- package/dist/chunks/{chunk-2BQESR2U.js → chunk-DVR2EDUU.js} +99 -34
- package/dist/chunks/{chunk-QQXMHM3J.js → chunk-FDAJC7R4.js} +4 -4
- package/dist/chunks/{chunk-GR76ZDDX.js → chunk-FMNCSYIG.js} +2 -2
- package/dist/chunks/{chunk-IF33CG4V.js → chunk-L2LMBFG5.js} +1 -1
- package/dist/chunks/{chunk-DLY5GUXX.js → chunk-PH7N4UFT.js} +1 -1
- package/dist/chunks/{chunk-U6R6FZHD.js → chunk-SFM3M2L3.js} +286 -93
- package/dist/chunks/chunk-SHYQUBY3.js +48 -0
- package/dist/chunks/{chunk-HFXK54M4.js → chunk-TGM7BWEH.js} +2 -2
- package/dist/chunks/{chunk-2J3XY4ED.js → chunk-TJUAGZU7.js} +11 -11
- package/dist/chunks/{chunk-PE334WL3.js → chunk-UI66EMOR.js} +4 -4
- package/dist/chunks/{chunk-762M5XJS.js → chunk-VMCCRWFO.js} +2 -2
- package/dist/chunks/{chunk-U7ROML5E.js → chunk-WHJIUKJW.js} +681 -48
- package/dist/chunks/{chunk-PGO4ILMQ.js → chunk-WMB3SMXI.js} +1 -1
- package/dist/chunks/chunk-WMRNO6IU.js +337 -0
- package/dist/chunks/{chunk-6NXT4ICB.js → chunk-WVH5ESDA.js} +1 -1
- package/dist/chunks/{chunk-DEHJ7PMA.js → chunk-XU3FL3AW.js} +4 -4
- package/dist/chunks/{chunk-Z6UUBY37.js → chunk-Z4IPY5GV.js} +2 -2
- package/dist/chunks/{conflict-57WDJWL7.js → conflict-VAFFPUY3.js} +2 -2
- package/dist/chunks/{contract-LJRAXVZU.js → contract-LLRKMLQQ.js} +2655 -1319
- package/dist/chunks/{cowork-3ACICHDQ.js → cowork-2RDFBZWB.js} +3 -2
- package/dist/chunks/{create-flow-3FMMZBCA.js → create-flow-TVYE3IOH.js} +6 -6
- package/dist/chunks/{data-WK5CQXNF.js → data-WVICO3DT.js} +57 -11
- package/dist/chunks/{ebuilder-form-CBYI6CQ6.js → ebuilder-form-TWSXS5NA.js} +7 -6
- package/dist/chunks/{ehr-XI4BIVR2.js → ehr-52GBKNJR.js} +3 -2
- package/dist/chunks/{env-JYZE3BZB.js → env-BVVFIN4P.js} +2 -2
- package/dist/chunks/{esb-4BQHNP5C.js → esb-HJSXCEOM.js} +5 -4
- package/dist/chunks/{factory-66SCIKW3.js → factory-RCQ36LLE.js} +1 -1
- package/dist/chunks/{fna-ECOYBQYL.js → fna-OBACRT3J.js} +72 -3
- package/dist/chunks/{group-chat-MNRYMLNG.js → group-chat-YFZDUUY3.js} +3 -3
- package/dist/chunks/{host-TUOIOEMC.js → host-2BKMPWDH.js} +4 -3
- package/dist/chunks/{host-3TNBMDTR.js → host-KJT3G5D2.js} +4 -3
- package/dist/chunks/{host-7OWWPLM4.js → host-KOWUMNAY.js} +4 -3
- package/dist/chunks/{host-M4XP5URR.js → host-MFXRA2MY.js} +4 -3
- package/dist/chunks/{host-7NTIBSPK.js → host-TTSGY5NZ.js} +4 -3
- package/dist/chunks/{host-G3VU7SDW.js → host-W4JCNRFS.js} +4 -3
- package/dist/chunks/{hrm-YGIR3HGF.js → hrm-AK3WGBMN.js} +4 -3
- package/dist/chunks/{im-TN2JYVGJ.js → im-JZSBPO4Z.js} +4 -3
- package/dist/chunks/{invoice-V7ZTITUO.js → invoice-V6KD4TZE.js} +4 -3
- package/dist/chunks/{jiuchuanhui-ASFZBMPU.js → jiuchuanhui-K4EQU6GK.js} +3 -2
- package/dist/chunks/{lazy-dispatch-XSAHDK6Z.js → lazy-dispatch-JHGFCKJN.js} +5 -4
- package/dist/chunks/{mail-M3HJF5ER.js → mail-IKVCQCVZ.js} +3 -2
- package/dist/chunks/{meeting-IIY4UAJL.js → meeting-JOHV4RH3.js} +14 -12
- package/dist/chunks/minute-doc-JLS4KMFZ.js +156 -0
- package/dist/chunks/{okr-EVX7FB5G.js → okr-KV43FPPX.js} +3 -2
- package/dist/chunks/{operations-J7PUIVWZ.js → operations-ZPWBMYKE.js} +5 -4
- package/dist/chunks/{plan-2QJQEPBO.js → plan-WOYR4WEG.js} +3 -2
- package/dist/chunks/{project-XELELW2T.js → project-CQJKBUIL.js} +3 -2
- package/dist/chunks/{reception-QGPNTGHG.js → reception-MPBU3JXC.js} +3 -2
- package/dist/chunks/{recruit-stage-XCMVEQA2.js → recruit-stage-USTTRHOX.js} +3 -2
- package/dist/chunks/{registry-CJOVECZD.js → registry-GURQG4ZV.js} +3 -2
- package/dist/chunks/{registry-METZ2LWE.js → registry-LITYOH2W.js} +12 -10
- package/dist/chunks/{registry-QJCZ2GVG.js → registry-SS5J2FZQ.js} +5 -4
- package/dist/chunks/{room-recommend-YFY7HTOF.js → room-recommend-62MECG4J.js} +4 -4
- package/dist/chunks/{schedule-6I63TERA.js → schedule-6QRXIBGU.js} +4 -4
- package/dist/chunks/{smart-extract-FOUYNIG3.js → smart-extract-APX2PNIN.js} +3 -2
- package/dist/chunks/{workflow-YHXFIU63.js → workflow-WMPW3WSB.js} +5 -4
- package/dist/index.js +33 -32
- package/dist/internal/e10/auth/agent-host-key.js +68 -0
- package/dist/internal/e10/auth/agent-hosts.js +250 -0
- package/dist/internal/e10/auth/commands.js +99 -30
- package/dist/internal/e10/auth/paths.js +9 -0
- package/dist/internal/e10/auth/session.js +17 -0
- package/dist/internal/e10/auth/xiaoe.js +37 -3
- package/dist/shortcuts/archive-oa/operations/contract-modules.js +106 -0
- package/dist/shortcuts/archive-oa/operations/contract.js +38 -4
- package/dist/shortcuts/archive-oa/operations/registry.js +2 -1
- package/dist/shortcuts/contract/index.js +6 -7
- package/dist/shortcuts/contract/manifest.js +101 -24
- package/dist/shortcuts/contract/ooxml/docx-table.js +75 -3
- package/dist/shortcuts/contract/ooxml/xlsx.js +49 -13
- package/dist/shortcuts/contract/operations/card-action.js +113 -12
- package/dist/shortcuts/contract/operations/card-ebdf-list.js +29 -7
- package/dist/shortcuts/contract/operations/card-plan.js +75 -9
- package/dist/shortcuts/contract/operations/card-risk-report.js +2 -2
- package/dist/shortcuts/contract/operations/card.js +1 -1
- package/dist/shortcuts/contract/operations/clause-library.js +88 -16
- package/dist/shortcuts/contract/operations/compare-screen.js +378 -0
- package/dist/shortcuts/contract/operations/compare.js +1 -1
- package/dist/shortcuts/contract/operations/credit-page.js +1 -1
- package/dist/shortcuts/contract/operations/docx-slots.js +1000 -0
- package/dist/shortcuts/contract/operations/flow.js +2 -2
- package/dist/shortcuts/contract/operations/quote-to-contract.js +495 -0
- package/dist/shortcuts/contract/operations/quote.js +2 -229
- package/dist/shortcuts/contract/operations/recommend.js +1 -1
- package/dist/shortcuts/contract/operations/registry.js +6 -2
- package/dist/shortcuts/contract/operations/review.js +230 -4
- package/dist/shortcuts/contract/operations/save-recognize.js +122 -3
- package/dist/shortcuts/contract/operations/template.js +11 -10
- package/dist/shortcuts/data/operations/ds.js +5 -5
- package/dist/shortcuts/data/operations/shared.js +76 -4
- package/dist/shortcuts/fna/manifest.js +7 -2
- package/dist/shortcuts/fna/operations/budget.js +68 -0
- package/dist/shortcuts/meeting/minute-doc.js +153 -0
- package/dist/shortcuts/meeting/operations/compose-outcome.js +176 -0
- package/dist/shortcuts/meeting/operations/eb/catalog.js +1 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +47 -0
- package/dist/shortcuts/meeting/operations/eb/decision-task-batch.js +144 -0
- package/dist/shortcuts/meeting/operations/eb/decision.js +92 -4
- package/dist/shortcuts/meeting/operations/eb/index.js +133 -4
- package/dist/shortcuts/meeting/operations/eb/meeting-link.js +90 -0
- package/dist/shortcuts/meeting/operations/from-group-chat.js +46 -0
- package/dist/shortcuts/meeting/operations/minute-content.js +61 -0
- package/dist/shortcuts/meeting/operations/registry.js +14 -1
- package/dist/shortcuts/meeting/operations/self-check.js +49 -0
- package/dist/shortcuts/workflow/endpoints.js +2 -0
- package/dist/shortcuts/workflow/operations/read.js +114 -8
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +72 -46
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +41 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +46 -11
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +18 -1
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroupAdd.js +51 -0
- package/docs/e10-auth.md +78 -0
- package/docs/fna.md +8 -3
- package/package.json +4 -2
- package/scripts/pack-offline.mjs +228 -0
- package/scripts/package-skill.mjs +14 -5
- package/skill-template/business-info.json +3 -0
- package/skill-template/domains/qiyecheng.md +4 -3
- package/skills/weaver-e10-archive-oa/SKILL.md +6 -1
- package/skills/weaver-e10-archive-oa/references/contract-search.md +91 -4
- package/skills/weaver-e10-jinchengda/SKILL.md +100 -81
- package/skills/weaver-e10-jinchengda/references/contract-action-card-template.html +11 -6
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +5 -4
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +38 -12
- package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +20 -6
- package/skills/weaver-e10-jinchengda/references/contract-card-render-internals.md +8 -3
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +56 -13
- package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +7 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +11 -5
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +38 -7
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +13 -25
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +9 -8
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +8 -6
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +10 -7
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +3 -1
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +26 -18
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +18 -13
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +5 -3
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +105 -49
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +3 -6
- package/skills/weaver-e10-meeting/SKILL.md +48 -9
- package/skills/weaver-e10-qiyecheng/SKILL.md +16 -7
- package/skills/weaver-e10-qiyecheng/references/budget.md +77 -3
- package/skills/weaver-e10-qiyecheng/references/catalog.md +6 -4
- package/skills/weaver-e10-qiyecheng/references/getEnabledTemplate-api.md +255 -0
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +70 -25
- package/skills/weaver-e10-workflow/SKILL.md +54 -40
- package/skills/weaver-e10-workflow/references/todo-dialogue.md +134 -0
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +102 -80
- package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +23 -13
- package/skills/weaver-e10-workflow/references/workflow-query.md +68 -46
- package/skills/weaver-e10-workflow/references/workflow-view.md +21 -13
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +317 -332
- package/dist/shortcuts/contract/ooxml/docx.js +0 -295
- package/dist/shortcuts/contract/operations/docx-fillfromquote.js +0 -532
- package/skills/weaver-e10-jinchengda/references/contract-risk-report-template.html +0 -178
- package/skills/weaver-e10-jinchengda/references/source-manifest.json +0 -1270
- package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +0 -998
- package/skills/weaver-e10-workflow/tools/todo-serve.cjs +0 -327
|
@@ -59,6 +59,115 @@ export function normalizeRecognizeResult(value) {
|
|
|
59
59
|
}
|
|
60
60
|
return JSON.stringify({ isSuccess: parsed.isSuccess, mainTable, subTables: parsed.subTables });
|
|
61
61
|
}
|
|
62
|
+
/** 本次识别记录可用的真实附件 ID 列表(attachmentIds 全部 + attachmentFileId)。 */
|
|
63
|
+
export function collectFileIds(attachmentIds, attachmentFileId) {
|
|
64
|
+
const list = attachmentIds
|
|
65
|
+
.split(',')
|
|
66
|
+
.map((item) => item.trim())
|
|
67
|
+
.filter(Boolean);
|
|
68
|
+
const extra = attachmentFileId.trim();
|
|
69
|
+
if (extra && !list.includes(extra))
|
|
70
|
+
list.unshift(extra);
|
|
71
|
+
return list;
|
|
72
|
+
}
|
|
73
|
+
function splitOriginText(value) {
|
|
74
|
+
const text = typeof value === 'string' ? value : String(value ?? '');
|
|
75
|
+
const index = text.indexOf('#');
|
|
76
|
+
if (index < 0)
|
|
77
|
+
return { prefix: '', snippet: text };
|
|
78
|
+
return { prefix: text.slice(0, index).trim(), snippet: text.slice(index + 1) };
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 纠正 `origin` / `origins` 的附件前缀(2026-11-16 新增)。
|
|
82
|
+
*
|
|
83
|
+
* 背景:识别记录里 `origin` 的元素格式是 `附件ID#原文片段`,后端按 `#` 前半段的附件 ID
|
|
84
|
+
* 回查原文。历史上文档示例通篇写 `att001` 却未声明它是占位符,手写 `recognizeResult`
|
|
85
|
+
* 时照抄会导致「要素值正确、合同原文列全空」,且接口不报错。
|
|
86
|
+
*
|
|
87
|
+
* 规则:
|
|
88
|
+
* - 前缀命中本次 `attachmentIds` / `attachmentFileId` → 原样保留;
|
|
89
|
+
* - 前缀未知、且本次只有一个附件 → 自动改写成该 fileId,并记入 `fixups`;
|
|
90
|
+
* - 前缀未知、且本次有多个附件 → 收集到 `unknown`,由调用方报错(不猜是哪个文件);
|
|
91
|
+
* - 元素没有 `#` 前缀 → 单附件时补上 fileId;
|
|
92
|
+
* - 未提供任何附件 ID → 不做校验(`skipped: true`),保持原样,不误伤外部调用方。
|
|
93
|
+
*/
|
|
94
|
+
export function applyOriginFixups(recognizeResultText, fileIds) {
|
|
95
|
+
const known = new Set(fileIds.filter(Boolean));
|
|
96
|
+
if (!known.size) {
|
|
97
|
+
return { text: recognizeResultText, fixups: [], unknown: [], skipped: true };
|
|
98
|
+
}
|
|
99
|
+
const parsed = JSON.parse(recognizeResultText);
|
|
100
|
+
const fallback = fileIds.length === 1 ? fileIds[0] : '';
|
|
101
|
+
const counters = new Map();
|
|
102
|
+
const unknown = [];
|
|
103
|
+
const bump = (from, to) => {
|
|
104
|
+
const key = `${from}=>${to}`;
|
|
105
|
+
const existing = counters.get(key);
|
|
106
|
+
if (existing)
|
|
107
|
+
existing.count += 1;
|
|
108
|
+
else
|
|
109
|
+
counters.set(key, { from, to, count: 1 });
|
|
110
|
+
};
|
|
111
|
+
const fixOne = (raw, where) => {
|
|
112
|
+
if (raw === null || raw === undefined)
|
|
113
|
+
return null;
|
|
114
|
+
const { prefix, snippet } = splitOriginText(raw);
|
|
115
|
+
const body = snippet.trim();
|
|
116
|
+
if (!body)
|
|
117
|
+
return typeof raw === 'string' ? raw : String(raw);
|
|
118
|
+
if (prefix && known.has(prefix))
|
|
119
|
+
return `${prefix}#${snippet}`;
|
|
120
|
+
if (!fallback) {
|
|
121
|
+
unknown.push(`${where} 的前缀「${prefix || '空'}」不在本次附件中`);
|
|
122
|
+
return `${prefix}#${snippet}`;
|
|
123
|
+
}
|
|
124
|
+
bump(prefix, fallback);
|
|
125
|
+
return `${fallback}#${snippet}`;
|
|
126
|
+
};
|
|
127
|
+
for (const row of parsed.mainTable?.rows ?? []) {
|
|
128
|
+
for (const result of row.fieldResults ?? []) {
|
|
129
|
+
const origins = result?.origin;
|
|
130
|
+
if (!Array.isArray(origins))
|
|
131
|
+
continue;
|
|
132
|
+
const where = String(result?.fieldInfo || 'fieldResults');
|
|
133
|
+
const next = [];
|
|
134
|
+
for (const item of origins) {
|
|
135
|
+
const fixed = fixOne(item, where);
|
|
136
|
+
if (fixed !== null)
|
|
137
|
+
next.push(fixed);
|
|
138
|
+
}
|
|
139
|
+
result.origin = next.length ? next : null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
for (const table of parsed.subTables ?? []) {
|
|
143
|
+
const tableName = String(table?.subFormName || table?.subFormId || 'subTables');
|
|
144
|
+
for (const row of table?.rows ?? []) {
|
|
145
|
+
const origins = row?.origins;
|
|
146
|
+
if (!Array.isArray(origins))
|
|
147
|
+
continue;
|
|
148
|
+
row.origins = origins.map((column, index) => {
|
|
149
|
+
const where = `${tableName} 第 ${index + 1} 列`;
|
|
150
|
+
if (!Array.isArray(column)) {
|
|
151
|
+
const fixed = fixOne(column, where);
|
|
152
|
+
return fixed === null ? column : fixed;
|
|
153
|
+
}
|
|
154
|
+
const out = [];
|
|
155
|
+
for (const item of column) {
|
|
156
|
+
const fixed = fixOne(item, where);
|
|
157
|
+
if (fixed !== null)
|
|
158
|
+
out.push(fixed);
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
text: JSON.stringify(parsed),
|
|
166
|
+
fixups: [...counters.values()],
|
|
167
|
+
unknown: unknown.slice(0, 5),
|
|
168
|
+
skipped: false,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
62
171
|
function extractAiExtraId(value) {
|
|
63
172
|
const root = (value ?? {});
|
|
64
173
|
const data = (root.data ?? root);
|
|
@@ -106,10 +215,7 @@ export const contractSaveRecognizeOperations = [
|
|
|
106
215
|
throw contractValidationError('workflow_id_invalid', 'workflowId 必须是纯数字的流程模板 ID');
|
|
107
216
|
}
|
|
108
217
|
const recognizeResult = normalizeRecognizeResult(input.recognizeResult);
|
|
109
|
-
const body = { workflowId, recognizeResult };
|
|
110
218
|
const attachmentIds = typeof input.attachmentIds === 'string' ? input.attachmentIds.trim() : '';
|
|
111
|
-
if (attachmentIds)
|
|
112
|
-
body.attachmentIds = attachmentIds;
|
|
113
219
|
// 合同文件字段:必须随 customParams 交给流程组件,否则附件挂不到表单字段上。
|
|
114
220
|
// 未显式传 attachmentFileId 时,取 attachmentIds 的首个文件。
|
|
115
221
|
const attachmentFieldId = input.attachmentFieldId === undefined
|
|
@@ -125,6 +231,17 @@ export const contractSaveRecognizeOperations = [
|
|
|
125
231
|
if (attachmentFieldId && !attachmentFileId) {
|
|
126
232
|
throw contractValidationError('attachment_file_id_missing', '传了 attachmentFieldId 就必须有文件 ID:请传 attachmentFileId,或在 attachmentIds 里带上本次文件');
|
|
127
233
|
}
|
|
234
|
+
// origin 前缀兜底(2026-11-16):前缀必须是真实 fileId,否则后端按前缀回查不到附件,
|
|
235
|
+
// 表现是「要素值正常、合同原文列全空」且保存与出卡都不报错。
|
|
236
|
+
// 单附件时自动改写为真实 fileId;多附件时拒绝猜测,直接报错让人指认。
|
|
237
|
+
const fileIds = collectFileIds(attachmentIds, attachmentFileId);
|
|
238
|
+
const originFixed = applyOriginFixups(recognizeResult, fileIds);
|
|
239
|
+
if (originFixed.unknown.length) {
|
|
240
|
+
throw contractValidationError('origin_attachment_unknown', `origin 里的附件前缀无法匹配本次附件:${originFixed.unknown.join(';')}。请把前缀改写为 attachmentIds 中的真实 fileId。`);
|
|
241
|
+
}
|
|
242
|
+
const body = { workflowId, recognizeResult: originFixed.text };
|
|
243
|
+
if (attachmentIds)
|
|
244
|
+
body.attachmentIds = attachmentIds;
|
|
128
245
|
const response = await host.contractRequest({
|
|
129
246
|
method: 'POST',
|
|
130
247
|
path: SAVE_RECOGNIZE_PATH,
|
|
@@ -144,6 +261,8 @@ export const contractSaveRecognizeOperations = [
|
|
|
144
261
|
attachmentFieldId: attachmentFieldId || null,
|
|
145
262
|
attachmentFileId: attachmentFileId || null,
|
|
146
263
|
customParams,
|
|
264
|
+
originFixups: originFixed.fixups,
|
|
265
|
+
originCheck: originFixed.skipped ? 'skipped' : 'checked',
|
|
147
266
|
},
|
|
148
267
|
};
|
|
149
268
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClauseProbeOperation } from './clause-library.js';
|
|
1
2
|
import { ContractReadOperation } from './read.js';
|
|
2
3
|
import { queryFrom, requireId } from './shared.js';
|
|
3
4
|
export const contractTypeTreeOperation = new ContractReadOperation('contract.type.tree', {
|
|
@@ -25,12 +26,12 @@ export const contractTemplateDetailOperation = new ContractReadOperation('contra
|
|
|
25
26
|
path: '/api/ebd/contract/tplinfo/getById',
|
|
26
27
|
query: (input) => ({ id: requireId(input.id, '模板 id') }),
|
|
27
28
|
});
|
|
28
|
-
export const contractClauseTreeOperation = new ContractReadOperation('contract.clause.tree', {
|
|
29
|
+
export const contractClauseTreeOperation = new ClauseProbeOperation('contract.clause.tree', new ContractReadOperation('contract.clause.tree', {
|
|
29
30
|
method: 'GET',
|
|
30
31
|
path: '/api/ebd/contract/tree/queryList',
|
|
31
32
|
shape: (value) => ({ code: value.code, msg: value.msg, tree: value.data }),
|
|
32
|
-
});
|
|
33
|
-
export const contractClauseListOperation = new ContractReadOperation('contract.clause.list', {
|
|
33
|
+
}));
|
|
34
|
+
export const contractClauseListOperation = new ClauseProbeOperation('contract.clause.list', new ContractReadOperation('contract.clause.list', {
|
|
34
35
|
method: 'GET',
|
|
35
36
|
path: '/api/ebd/contract/clauseinfo/getListPage',
|
|
36
37
|
defaults: { pageNo: 1, pageSize: 10 },
|
|
@@ -38,27 +39,27 @@ export const contractClauseListOperation = new ContractReadOperation('contract.c
|
|
|
38
39
|
'belongId', 'clauseName', 'clauseNum', 'clauseStatus', 'clauseGroup',
|
|
39
40
|
'contractType', 'clauseVersion', 'orgId', 'belongSub', 'pageNo', 'pageSize',
|
|
40
41
|
]),
|
|
41
|
-
});
|
|
42
|
-
export const contractClauseGroupListOperation = new ContractReadOperation('contract.clause.group.list', {
|
|
42
|
+
}));
|
|
43
|
+
export const contractClauseGroupListOperation = new ClauseProbeOperation('contract.clause.group.list', new ContractReadOperation('contract.clause.group.list', {
|
|
43
44
|
method: 'GET',
|
|
44
45
|
path: '/api/ebd/contract/clausegroup/getListPage',
|
|
45
46
|
defaults: { pageNo: 1, pageSize: 10 },
|
|
46
47
|
query: (input) => queryFrom(input, [
|
|
47
48
|
'belongId', 'clauseName', 'clauseNum', 'clauseStatus', 'contractType', 'pageNo', 'pageSize',
|
|
48
49
|
]),
|
|
49
|
-
});
|
|
50
|
-
export const contractClauseSearchOperation = new ContractReadOperation('contract.clause.search', {
|
|
50
|
+
}));
|
|
51
|
+
export const contractClauseSearchOperation = new ClauseProbeOperation('contract.clause.search', new ContractReadOperation('contract.clause.search', {
|
|
51
52
|
method: 'GET',
|
|
52
53
|
path: '/api/ebd/contract/clauseinfo/getClauses',
|
|
53
54
|
defaults: { pageNum: 0, pageSize: 10 },
|
|
54
55
|
query: (input) => queryFrom(input, ['id', 'title', 'tagId', 'content', 'group', 'mark', 'pageNum', 'pageSize']),
|
|
55
|
-
});
|
|
56
|
-
export const contractClauseTagsOperation = new ContractReadOperation('contract.clause.tags', {
|
|
56
|
+
}));
|
|
57
|
+
export const contractClauseTagsOperation = new ClauseProbeOperation('contract.clause.tags', new ContractReadOperation('contract.clause.tags', {
|
|
57
58
|
method: 'GET',
|
|
58
59
|
path: '/api/ebd/contract/clauseinfo/getClausesConfig',
|
|
59
60
|
defaults: { pageNum: 0, pageSize: 10 },
|
|
60
61
|
query: (input) => queryFrom(input, ['label', 'value', 'pageNum', 'pageSize']),
|
|
61
|
-
});
|
|
62
|
+
}));
|
|
62
63
|
export const contractClauseReferenceGetOperation = new ContractReadOperation('contract.clause.reference.get', {
|
|
63
64
|
method: 'POST',
|
|
64
65
|
path: '/api/ebd/contract/clauseReference/selectData',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { needArg } from '../host.js';
|
|
2
2
|
import { dataValidationError } from '../errors.js';
|
|
3
|
-
import { applyAppId, baseDto, parseOrder, parseStat,
|
|
3
|
+
import { applyAppId, baseDto, parseOrder, parseStat, parseWhereArg, readListArg, renderTable, scanTips, tipsLines, } from './shared.js';
|
|
4
4
|
// ---------------------------------------------------------------- 分组清单
|
|
5
5
|
//
|
|
6
6
|
// 这 58 个分组**仅作 `ds find` 的默认扫描候选集**,不参与任何取数参数推导。
|
|
@@ -188,7 +188,7 @@ export async function dsList(input, host) {
|
|
|
188
188
|
const dto = applyAppId(baseDto(session, tableId, groupId, Number(input.page || '1') || 1, Number(input.size || '20') || 20, 'getListData'), input.app_id);
|
|
189
189
|
dto.queryFields = fieldIds.map((field) => ({ fieldId: field, fieldName: field, objId: String(tableId), mainField: true }));
|
|
190
190
|
dto.orderFields = parseOrder(input.order);
|
|
191
|
-
const conditionTree =
|
|
191
|
+
const conditionTree = parseWhereArg(input);
|
|
192
192
|
if (conditionTree)
|
|
193
193
|
dto.conditionTrees = conditionTree;
|
|
194
194
|
dto.queryCount = true;
|
|
@@ -212,7 +212,7 @@ export async function dsChart(input, host) {
|
|
|
212
212
|
const dto = applyAppId(baseDto(session, tableId, groupId, Number(input.page || '1') || 1, Number(input.size || '100') || 100, 'getChartData'), input.app_id);
|
|
213
213
|
dto.groupFields = groupBy.map((field) => ({ fieldId: field, fieldName: field, objId: String(tableId), mainField: true }));
|
|
214
214
|
dto.groupStatFields = statFields.map((stat) => ({ ...stat, objId: String(tableId) }));
|
|
215
|
-
const conditionTree =
|
|
215
|
+
const conditionTree = parseWhereArg(input);
|
|
216
216
|
if (conditionTree)
|
|
217
217
|
dto.conditionTrees = conditionTree;
|
|
218
218
|
const response = await host.request({
|
|
@@ -234,7 +234,7 @@ export async function dsStat(input, host) {
|
|
|
234
234
|
const session = await host.session();
|
|
235
235
|
const dto = applyAppId(baseDto(session, tableId, groupId, 1, 10, 'getStatData'), input.app_id);
|
|
236
236
|
dto.statFields = statFields.map((stat) => ({ ...stat, objId: String(tableId) }));
|
|
237
|
-
const conditionTree =
|
|
237
|
+
const conditionTree = parseWhereArg(input);
|
|
238
238
|
if (conditionTree)
|
|
239
239
|
dto.conditionTrees = conditionTree;
|
|
240
240
|
const response = await host.request({
|
|
@@ -257,7 +257,7 @@ export async function dsCount(input, host) {
|
|
|
257
257
|
const tableId = needArg(input, 'table');
|
|
258
258
|
const session = await host.session();
|
|
259
259
|
const dto = applyAppId(baseDto(session, tableId, groupId, 1, 10, 'getCountData'), input.app_id);
|
|
260
|
-
const conditionTree =
|
|
260
|
+
const conditionTree = parseWhereArg(input);
|
|
261
261
|
if (conditionTree)
|
|
262
262
|
dto.conditionTrees = conditionTree;
|
|
263
263
|
const response = await host.request({
|
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { dataValidationError } from '../errors.js';
|
|
3
|
+
const LONG_INT_PATTERN = /([:[,]\s*)(-?\d{16,})(?=\s*[,}\]])/g;
|
|
3
4
|
/**
|
|
4
5
|
* 把 JSON 文本里的长整数(≥16 位)预置为字符串。
|
|
5
6
|
*
|
|
6
7
|
* E10 的雪花 ID 是 19 位,超出 `Number.MAX_SAFE_INTEGER`(2^53-1);`JSON.parse` 直接解析会
|
|
7
8
|
* 把末几位归零(`1060565684758507544` → `1060565684758507500`),再原样下发就查不到任何数据、
|
|
8
9
|
* 且后端不报错。e10-data 用同样的「先引号化再解析」策略,这里保持口径一致。
|
|
10
|
+
*
|
|
11
|
+
* 引号化只在 JSON 结构层进行:先按字符串字面量切分(含转义处理),字符串内部的内容
|
|
12
|
+
* (如备注里的「卡号:6222020200112233,xxx」或内嵌转义 JSON)原样保留,否则往字符串里
|
|
13
|
+
* 插引号会让 `JSON.parse` 误判字符串边界、把合法入参误报成 json_invalid。
|
|
9
14
|
*/
|
|
10
15
|
function quoteLongInts(raw) {
|
|
11
|
-
|
|
16
|
+
let out = '';
|
|
17
|
+
let i = 0;
|
|
18
|
+
while (i < raw.length) {
|
|
19
|
+
if (raw[i] === '"') {
|
|
20
|
+
// 整段复制字符串字面量:跳过转义(\\ 与 \"),直到收尾引号(未闭合则到文末,交给 JSON.parse 报错)
|
|
21
|
+
let end = i + 1;
|
|
22
|
+
while (end < raw.length) {
|
|
23
|
+
const ch = raw[end];
|
|
24
|
+
if (ch === '\\') {
|
|
25
|
+
end += 2;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (ch === '"') {
|
|
29
|
+
end += 1;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
end += 1;
|
|
33
|
+
}
|
|
34
|
+
out += raw.slice(i, end);
|
|
35
|
+
i = end;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
// 字符串外:整段跑引号化正则(引号化匹配本身不含引号,跨字符串边界的匹配不存在)
|
|
39
|
+
let end = i;
|
|
40
|
+
while (end < raw.length && raw[end] !== '"')
|
|
41
|
+
end += 1;
|
|
42
|
+
out += raw.slice(i, end).replace(LONG_INT_PATTERN, '$1"$2"');
|
|
43
|
+
i = end;
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
12
46
|
}
|
|
13
47
|
export function parseJsonSafe(raw) {
|
|
14
48
|
return JSON.parse(quoteLongInts(String(raw).replace(/^\uFEFF+/, '')));
|
|
@@ -71,18 +105,37 @@ export function applyAppId(dto, appId) {
|
|
|
71
105
|
function normRelationship(value) {
|
|
72
106
|
return value === '0' || value === 0 || value === false ? '0' : '1';
|
|
73
107
|
}
|
|
108
|
+
/** conditionStr 是否为有效 SQL 串过滤(排除 null / 非字符串 / 全空白)。 */
|
|
109
|
+
function hasEffectiveConditionStr(node) {
|
|
110
|
+
return !!node && typeof node.conditionStr === 'string' && node.conditionStr.trim() !== '';
|
|
111
|
+
}
|
|
74
112
|
function isConditionGroup(node) {
|
|
75
|
-
|
|
113
|
+
if (!node)
|
|
114
|
+
return false;
|
|
115
|
+
if (Array.isArray(node.conditionList) && node.conditionList.length > 0)
|
|
116
|
+
return true;
|
|
117
|
+
// 无子节点但携带有效 conditionStr(SQL 串过滤)的节点:按 SQL 组节点处理,
|
|
118
|
+
// 不能当叶子(没有 fieldId 会误报 where_invalid),也不能在 parseWhere 入口被丢弃。
|
|
119
|
+
// 典型来源:数据权限 SQL 直接透传到根节点 conditionStr、conditionList 为 null。
|
|
120
|
+
return !node.fieldId && !node.conditionId && hasEffectiveConditionStr(node);
|
|
76
121
|
}
|
|
77
122
|
function buildConditionNode(node, key, parentKey) {
|
|
78
123
|
if (isConditionGroup(node)) {
|
|
124
|
+
// 组节点「展开 + 覆盖」:结构键(key/relationship/isParent/parentNode/conditionList)按重写规则覆盖,
|
|
125
|
+
// 未识别键(conditionStr、filterConditionType、tableAlias 等)原样保留——
|
|
126
|
+
// 白名单重建会把 conditionStr 这类 SQL 串过滤静默丢掉,导致过滤变宽且不报错。
|
|
79
127
|
return {
|
|
128
|
+
...node,
|
|
80
129
|
key,
|
|
81
130
|
relationship: normRelationship(node.relationship),
|
|
82
131
|
isParent: true,
|
|
83
132
|
parentNode: parentKey,
|
|
84
133
|
mainField: node.mainField !== false,
|
|
85
|
-
|
|
134
|
+
// 纯 conditionStr 组(conditionList 为 null/空)原样透传,后端靠根节点 conditionStr 过滤;
|
|
135
|
+
// 有子节点才递归重建,保证 parentNode/key 逐级挂接。
|
|
136
|
+
conditionList: Array.isArray(node.conditionList) && node.conditionList.length
|
|
137
|
+
? node.conditionList.map((child, index) => buildConditionNode(child, `${key}_${index}`, key))
|
|
138
|
+
: (node.conditionList ?? null),
|
|
86
139
|
};
|
|
87
140
|
}
|
|
88
141
|
const fieldId = (node && (node.fieldId || node.conditionId)) || '';
|
|
@@ -103,6 +156,9 @@ function buildConditionNode(node, key, parentKey) {
|
|
|
103
156
|
fieldValue: node.fieldValue || '',
|
|
104
157
|
mainField: node.mainField !== false,
|
|
105
158
|
ignoreCaseMark: node.ignoreCaseMark || false,
|
|
159
|
+
// SQL 串过滤两个关键字段透传(缺失时补 null,与后端 DTO 口径一致)
|
|
160
|
+
conditionStr: node.conditionStr ?? null,
|
|
161
|
+
filterConditionType: node.filterConditionType ?? null,
|
|
106
162
|
};
|
|
107
163
|
}
|
|
108
164
|
/** `--where`:数组 = AND 根(元素可为叶子或内嵌条件组),对象 = 完整条件树。 */
|
|
@@ -125,10 +181,26 @@ export function parseWhere(value) {
|
|
|
125
181
|
}
|
|
126
182
|
if (typeof raw !== 'object')
|
|
127
183
|
throw dataValidationError('where_invalid', '--where 须为条件数组或条件树对象');
|
|
128
|
-
|
|
184
|
+
// 条件树对象:无子节点时,只要有有效 conditionStr(数据权限 SQL 透传)仍须保留整棵树,
|
|
185
|
+
// 不能因 conditionList 为空就丢弃——否则 SQL 过滤串到不了后端,查询退化为全表。
|
|
186
|
+
if ((!Array.isArray(raw.conditionList) || !raw.conditionList.length) && !hasEffectiveConditionStr(raw))
|
|
129
187
|
return null;
|
|
130
188
|
return buildConditionNode(raw, rootKey, '');
|
|
131
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* ds 系列条件树入口。
|
|
192
|
+
*
|
|
193
|
+
* `--where-raw`:整份 JSON(@file 或内联)直塞 `dto.conditionTrees`,**不做任何重建**——
|
|
194
|
+
* key/parentNode 保持原样,供上游组件产物(如 skill 生成的完整条件树)透传,保证逐字等价。
|
|
195
|
+
* `--where`:走 parseWhere 结构等价重写。两者同传时 `--where-raw` 优先。
|
|
196
|
+
*/
|
|
197
|
+
export function parseWhereArg(input) {
|
|
198
|
+
const raw = input.where_raw;
|
|
199
|
+
if (raw !== undefined && raw !== null && raw !== true && raw !== '') {
|
|
200
|
+
return readJsonArg(raw, '--where-raw');
|
|
201
|
+
}
|
|
202
|
+
return parseWhere(input.where);
|
|
203
|
+
}
|
|
132
204
|
/** `--stat`:单个对象或数组;聚合键走 aggregator(大写枚举)。 */
|
|
133
205
|
export function parseStat(value) {
|
|
134
206
|
const raw = readJsonArg(value, '--stat');
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { fnaOperationDefinitions } from './operations/registry.js';
|
|
2
2
|
/**
|
|
3
3
|
* FNA 费控中心(齐业成)模块禁用/暂缓边界。
|
|
4
|
-
*
|
|
4
|
+
* 14 个源接口全部落地;以下几类能力不在本 CLI,写入 manifest 供 Agent 判断,
|
|
5
5
|
* 不得编造 operation 或绕过 CLI 直连接口:
|
|
6
6
|
* - 姓名/流程名 → employeeId/workflowId 的人员与流程解析不在本模块;
|
|
7
7
|
* - 借款「确认已还 confirmRepay」、核销明细等页面按钮能力未随源资料提供接口,未实现;
|
|
8
8
|
* - 报销报表 AI 问答只暴露自然语言问题,不接受也不回传 AI 生成的 SQL;
|
|
9
|
-
* - AI 规则预审只执行流程配置的规则,不支持增删改规则配置,也不回传 formDataList
|
|
9
|
+
* - AI 规则预审只执行流程配置的规则,不支持增删改规则配置,也不回传 formDataList 明细;
|
|
10
|
+
* - getEnabledTemplateNoAuth 免菜单权限且跳过 e-builder 与执行权限过滤,不暴露给调用方。
|
|
10
11
|
*/
|
|
11
12
|
const FNA_WITHHELD = [
|
|
12
13
|
{
|
|
13
14
|
name: 'fna.loan.confirm.repay',
|
|
14
15
|
reason: '借款管理菜单提供「确认已还 confirmRepay」按钮,但源资料未提供其接口路径、请求方法、关键字段与确认条件,未实现;不得猜测接口。',
|
|
15
16
|
},
|
|
17
|
+
{
|
|
18
|
+
name: 'fna.budget.template.noauth',
|
|
19
|
+
reason: 'getEnabledTemplateNoAuth 为 @WeaPermission(publicPermission=true) 的免菜单权限版本,跳过 e-builder 模板过滤与模板执行权限过滤,能返回租户下全部已发布模板(含当前人无权执行的模板);仅限 AI 报表等受控内部场景,暴露给 Agent 会绕过权限边界,故不封装。需要模板清单时用 fna.budget.template.list。',
|
|
20
|
+
},
|
|
16
21
|
{
|
|
17
22
|
name: 'fna.resolve.person.workflow',
|
|
18
23
|
reason: '姓名→employeeId、流程名→workflowId 的解析依赖人员/流程基表接口,源资料未提供;需要时请使用已提供的 ID 或由用户在对话中提供。',
|
|
@@ -118,7 +118,75 @@ const fnaBudgetExecuteList = {
|
|
|
118
118
|
});
|
|
119
119
|
},
|
|
120
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* 预算:有效模板清单。
|
|
123
|
+
* GET /api/fna/template/information/getEnabledTemplate(@WeaPermission,需登录态 + 菜单权限)。
|
|
124
|
+
* 返回「已发布 + 当前人有模板执行权限」的平铺节点,标题形如「差旅预算(2026年)」;
|
|
125
|
+
* 传 yearsValue 时服务端条件为 group_year=:yearsValue OR compile_method=2,无周期模板仍会出现。
|
|
126
|
+
*/
|
|
127
|
+
const fnaBudgetTemplateList = {
|
|
128
|
+
name: 'fna.budget.template.list',
|
|
129
|
+
resource: 'budget',
|
|
130
|
+
method: 'budget.template.list',
|
|
131
|
+
action: 'fna.budget.template.list',
|
|
132
|
+
summary: '预算模板清单:按年度返回当前租户已发布、且当前登录人有模板执行权限的预算模板,剥离标题末尾「(YYYY年)」给出 baseName 与 budgetYear,用于选 templateId 再查预算执行报表',
|
|
133
|
+
capability: 'budget',
|
|
134
|
+
risk: READ,
|
|
135
|
+
inputSchema: schemaOf({
|
|
136
|
+
yearsValue: {
|
|
137
|
+
type: 'integer',
|
|
138
|
+
minimum: 1900,
|
|
139
|
+
maximum: 2999,
|
|
140
|
+
description: '预算年度(可选,如 2026)。不传返回全部已发布模板;传入时结果仍可能包含无周期模板(服务端条件为 group_year=:yearsValue OR compile_method=2),需按 budgetYear 自行二次判断',
|
|
141
|
+
},
|
|
142
|
+
}, { description: '预算:有效模板清单(业务年度可选,只读)' }),
|
|
143
|
+
handler: async (args, { host }) => {
|
|
144
|
+
let yearsValue;
|
|
145
|
+
if (args.yearsValue !== undefined && args.yearsValue !== null && args.yearsValue !== '') {
|
|
146
|
+
const text = String(args.yearsValue).trim();
|
|
147
|
+
if (!/^\d+$/.test(text)) {
|
|
148
|
+
throw fnaValidationError('number_invalid', 'yearsValue 必须是整数年份(如 2026)');
|
|
149
|
+
}
|
|
150
|
+
yearsValue = Number(text);
|
|
151
|
+
if (!Number.isSafeInteger(yearsValue) || yearsValue < 1900 || yearsValue > 2999) {
|
|
152
|
+
throw fnaValidationError('years_value_invalid', 'yearsValue 必须是 1900-2999 的四位年份(如 2026)');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const response = await host.request({
|
|
156
|
+
method: 'GET',
|
|
157
|
+
path: '/api/fna/template/information/getEnabledTemplate',
|
|
158
|
+
...(yearsValue === undefined ? {} : { query: { yearsValue } }),
|
|
159
|
+
});
|
|
160
|
+
const tree = unwrapData(response);
|
|
161
|
+
const nodes = Array.isArray(tree?.data) ? tree.data : [];
|
|
162
|
+
const templates = nodes
|
|
163
|
+
.map((node) => {
|
|
164
|
+
const templateId = node?.id === undefined || node?.id === null ? '' : String(node.id).trim();
|
|
165
|
+
const title = typeof node?.title === 'string' && node.title
|
|
166
|
+
? node.title
|
|
167
|
+
: (typeof node?.content === 'string' ? node.content : '');
|
|
168
|
+
// 服务端标题为「模板名称(YYYY年)」,无周期模板无后缀;兼容全角括号
|
|
169
|
+
const matched = title.match(/^(.*?)\s*[((]\s*(\d{4})\s*年\s*[))]\s*$/);
|
|
170
|
+
const baseName = matched ? matched[1].trim() : title.trim();
|
|
171
|
+
return {
|
|
172
|
+
templateId,
|
|
173
|
+
title: title.trim(),
|
|
174
|
+
baseName: baseName || title.trim(),
|
|
175
|
+
budgetYear: matched ? Number(matched[2]) : null,
|
|
176
|
+
};
|
|
177
|
+
})
|
|
178
|
+
.filter((item) => item.templateId.length > 0);
|
|
179
|
+
return fnaSuccess('fna.budget.template.list', {
|
|
180
|
+
total: templates.length,
|
|
181
|
+
yearsValue: yearsValue ?? null,
|
|
182
|
+
templates,
|
|
183
|
+
}, {
|
|
184
|
+
hint: '结果只含「已发布 + 当前人有执行权限」的模板,同一租户不同人条数可能不同;templateId 一律按字符串使用(超 2^53 转数字会丢精度);budgetYear 为 null 表示无周期模板(不受年度限制,任何年度查询都会返回);本接口无排序保证,需要时在本地排序',
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
};
|
|
121
188
|
export const budgetOperations = [
|
|
122
189
|
fnaBudgetApplicationDetail,
|
|
123
190
|
fnaBudgetExecuteList,
|
|
191
|
+
fnaBudgetTemplateList,
|
|
124
192
|
];
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会议纪要 docx 生成(2026-11-16 用户要求:纪要文件字段不能空)。
|
|
3
|
+
*
|
|
4
|
+
* 系统不会"根据正文自动出文档"——`doc_file` 是附件 id 字段,必须自己渲染 docx、
|
|
5
|
+
* 上传拿 fileId、再写回纪要。这里用最小 OOXML 包([Content_Types] + rels + document.xml),
|
|
6
|
+
* Word/WPS 都能正常打开。
|
|
7
|
+
*/
|
|
8
|
+
import { writeDocxEntries } from './invitation/docx.js';
|
|
9
|
+
function esc(text) {
|
|
10
|
+
return String(text ?? '')
|
|
11
|
+
.replace(/&/g, '&')
|
|
12
|
+
.replace(/</g, '<')
|
|
13
|
+
.replace(/>/g, '>')
|
|
14
|
+
.replace(/"/g, '"');
|
|
15
|
+
}
|
|
16
|
+
function para(text, options = {}) {
|
|
17
|
+
const props = [
|
|
18
|
+
options.bold ? '<w:b/>' : '',
|
|
19
|
+
options.size ? `<w:sz w:val="${options.size}"/><w:szCs w:val="${options.size}"/>` : '',
|
|
20
|
+
options.align ? `<w:jc w:val="${options.align}"/>` : '',
|
|
21
|
+
].join('');
|
|
22
|
+
return `<w:p><w:pPr>${props}</w:pPr><w:r><w:t xml:space="preserve">${esc(text)}</w:t></w:r></w:p>`;
|
|
23
|
+
}
|
|
24
|
+
const CONTENT_TYPES = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
25
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
26
|
+
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
27
|
+
<Default Extension="xml" ContentType="application/xml"/>
|
|
28
|
+
<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
|
|
29
|
+
</Types>`;
|
|
30
|
+
const RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
31
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
32
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
|
|
33
|
+
</Relationships>`;
|
|
34
|
+
export function buildMinuteDocx(input) {
|
|
35
|
+
const body = [];
|
|
36
|
+
body.push(para(input.title, { bold: true, size: 36, align: 'center' }));
|
|
37
|
+
for (const line of input.meta) {
|
|
38
|
+
if (String(line).trim() !== '')
|
|
39
|
+
body.push(para(line, { size: 21 }));
|
|
40
|
+
}
|
|
41
|
+
body.push(para('', { size: 21 }));
|
|
42
|
+
for (const raw of String(input.content ?? '').split(/\r?\n/)) {
|
|
43
|
+
const line = raw.replace(/\s+$/, '');
|
|
44
|
+
if (line.trim() === '') {
|
|
45
|
+
body.push(para('', { size: 21 }));
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const heading = line.match(/^#{1,4}\s+(.*)$/);
|
|
49
|
+
if (heading) {
|
|
50
|
+
body.push(para(heading[1], { bold: true, size: 28 }));
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
body.push(para(line.replace(/^[-*]\s+/, '· '), { size: 21 }));
|
|
54
|
+
}
|
|
55
|
+
const documentXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
56
|
+
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
57
|
+
<w:body>${body.join('')}<w:sectPr><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"/></w:sectPr></w:body>
|
|
58
|
+
</w:document>`;
|
|
59
|
+
const entries = [
|
|
60
|
+
{ name: '[Content_Types].xml', data: Buffer.from(CONTENT_TYPES, 'utf8') },
|
|
61
|
+
{ name: '_rels/.rels', data: Buffer.from(RELS, 'utf8') },
|
|
62
|
+
{ name: 'word/document.xml', data: Buffer.from(documentXml, 'utf8') },
|
|
63
|
+
];
|
|
64
|
+
return writeDocxEntries(entries);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 生成 docx → 上传 → 回写纪要的 doc_file / mt_minutes → 回读校验。
|
|
68
|
+
* create / writeContent / fromGroupChat 三条路径共用,避免再漏某一条。
|
|
69
|
+
*/
|
|
70
|
+
/** 文件名净化:Windows 非法字符(尤其时间里的冒号)会让上传预检直接失败。 */
|
|
71
|
+
export function safeDocxName(subject) {
|
|
72
|
+
return String(subject ?? '')
|
|
73
|
+
.replace(/[\\/:*?"<>|]+/g, '-')
|
|
74
|
+
.replace(/\s+/g, ' ')
|
|
75
|
+
.trim()
|
|
76
|
+
.slice(0, 80) || '会议纪要';
|
|
77
|
+
}
|
|
78
|
+
export async function ensureMinuteDoc(env, input) {
|
|
79
|
+
const id = String(input.id ?? '').trim();
|
|
80
|
+
const mtId = String(input.mtId ?? '').trim();
|
|
81
|
+
if (!id || !mtId)
|
|
82
|
+
return null;
|
|
83
|
+
const { getMeetingOperation } = await import('./operations/registry.js');
|
|
84
|
+
const { meetingStateDir } = await import('./operations/env.js');
|
|
85
|
+
const { mkdir, writeFile } = await import('node:fs/promises');
|
|
86
|
+
const { join } = await import('node:path');
|
|
87
|
+
const subject = String(input.subject ?? '').trim() || `会议纪要-${mtId}`;
|
|
88
|
+
const fileName = safeDocxName(subject);
|
|
89
|
+
const buf = buildMinuteDocx({
|
|
90
|
+
title: subject,
|
|
91
|
+
meta: [`会议 id:${mtId}`],
|
|
92
|
+
content: String(input.content ?? ''),
|
|
93
|
+
});
|
|
94
|
+
const dir = join(meetingStateDir(env.ctx), 'minute-docs');
|
|
95
|
+
await mkdir(dir, { recursive: true });
|
|
96
|
+
const filePath = join(dir, `${id}.docx`);
|
|
97
|
+
await writeFile(filePath, buf);
|
|
98
|
+
const upload = await getMeetingOperation('meeting.attachment.upload').handler({ file: filePath, name: `${fileName}.docx`, module: 'meeting', refId: mtId }, env);
|
|
99
|
+
const fileId = String(upload?.data?.fileId ?? '').trim();
|
|
100
|
+
if (!fileId)
|
|
101
|
+
return null;
|
|
102
|
+
// 纪要文件(mt_minutes)是**文档组件**,只认文档中心 id。
|
|
103
|
+
// 直接塞附件 fileId 会被服务端静默丢弃(页面「纪要文件」仍为空、只有「文档附件」有值)。
|
|
104
|
+
let docId = '';
|
|
105
|
+
let docError = '';
|
|
106
|
+
try {
|
|
107
|
+
const { executeCaizhilianOperation } = await import('../caizhilian/operations.js');
|
|
108
|
+
const { createCaizhilianHost } = await import('../caizhilian/host.js');
|
|
109
|
+
const { createCaizhilianContinuationSigner } = await import('../caizhilian/continuation.js');
|
|
110
|
+
const caizhilianEnv = {
|
|
111
|
+
ctx: env.ctx,
|
|
112
|
+
host: createCaizhilianHost(env.ctx),
|
|
113
|
+
continuation: createCaizhilianContinuationSigner(env.ctx),
|
|
114
|
+
};
|
|
115
|
+
const session = await env.host.getSession();
|
|
116
|
+
const base = {
|
|
117
|
+
file_path: (await import('node:path')).win32.normalize(filePath),
|
|
118
|
+
name: fileName,
|
|
119
|
+
folder_id: '300',
|
|
120
|
+
folder_type: 'company',
|
|
121
|
+
author_id: String(session?.userId ?? '').trim(),
|
|
122
|
+
};
|
|
123
|
+
const preparedDoc = await executeCaizhilianOperation('caizhilian.document.create-office.prepare', base, caizhilianEnv);
|
|
124
|
+
const continuation = String(preparedDoc?.data?.continuation ?? '');
|
|
125
|
+
if (continuation) {
|
|
126
|
+
const appliedDoc = await executeCaizhilianOperation('caizhilian.document.create-office.apply', { ...base, continuation, confirm: true }, caizhilianEnv);
|
|
127
|
+
docId = String(appliedDoc?.data?.doc_id ?? '').trim();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
docId = '';
|
|
132
|
+
docError = String(error?.message ?? error).slice(0, 160);
|
|
133
|
+
}
|
|
134
|
+
const prepared = await getMeetingOperation('meeting.eb.minute.update.prepare').handler({
|
|
135
|
+
id,
|
|
136
|
+
mt_id: mtId,
|
|
137
|
+
doc_file: fileId,
|
|
138
|
+
...(docId ? { mt_minutes: JSON.stringify([{ id: docId, name: `${fileName}.docx` }]) } : {}),
|
|
139
|
+
file_type: '0',
|
|
140
|
+
minutes_status: '2',
|
|
141
|
+
}, env);
|
|
142
|
+
await getMeetingOperation('meeting.eb.minute.update.apply').handler({ confirm: true, continuation: prepared?.data?.continuation }, env);
|
|
143
|
+
const detail = await getMeetingOperation('meeting.eb.minute.detail').handler({ id }, env);
|
|
144
|
+
const row = detail?.data?.data ?? {};
|
|
145
|
+
return {
|
|
146
|
+
fileId,
|
|
147
|
+
docId,
|
|
148
|
+
...(docError ? { docError } : {}),
|
|
149
|
+
name: `${fileName}.docx`,
|
|
150
|
+
size: buf.length,
|
|
151
|
+
attached: String(row.doc_file ?? '') === fileId && (docId === '' || String(row.mt_minutes ?? '').includes(docId)),
|
|
152
|
+
};
|
|
153
|
+
}
|