@k-table/report 0.1.0 → 1.0.1
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/index.cjs +1 -1
- package/dist/index.css +31 -18
- package/dist/index.d.ts +491 -9
- package/dist/index.js +1 -1
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +491 -9
- package/dist/store.js +1 -1
- package/dist/styles.css +839 -8
- package/package.json +1 -1
package/dist/store.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
|
|
4
|
+
/** 预览/打印数据袋(b=绑定袋 m=映射袋 params=参数袋);与 @k-table/sheet-core 同形 */
|
|
5
|
+
export type ReportFieldData = {
|
|
6
|
+
m?: Record<string, unknown>;
|
|
7
|
+
b?: Record<string, unknown>;
|
|
8
|
+
params?: Record<string, unknown>;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
/** 模板工作簿状态(KTL 解析后);结构化细节见 @k-table/sheet-core */
|
|
12
|
+
export type TemplateWorkbookState = any;
|
|
13
|
+
export const SHEET_TEMPLATE_JSON_VERSION: 2;
|
|
2
14
|
|
|
3
15
|
export class KtStoreError extends Error {
|
|
4
16
|
readonly status?: number;
|
|
@@ -14,6 +26,24 @@ export class KtConflictError extends KtStoreError {
|
|
|
14
26
|
export function errorFromHttp(status: number, message: string, body?: unknown): KtStoreError;
|
|
15
27
|
|
|
16
28
|
export type ArtifactKind = "master" | "record" | "report" | "sheet";
|
|
29
|
+
export type ArtifactField = {
|
|
30
|
+
fieldId: string;
|
|
31
|
+
fieldCode: string;
|
|
32
|
+
label: string;
|
|
33
|
+
dataType: string;
|
|
34
|
+
sort: number;
|
|
35
|
+
formula?: string | null;
|
|
36
|
+
tableRelation?: number;
|
|
37
|
+
dictCode?: string | null;
|
|
38
|
+
paramId?: string | null;
|
|
39
|
+
roundKind?: string | null;
|
|
40
|
+
roundDigits?: number | null;
|
|
41
|
+
readOnly?: boolean;
|
|
42
|
+
defaultValue?: string | null;
|
|
43
|
+
optionsJson?: string | null;
|
|
44
|
+
inputKind?: string | null;
|
|
45
|
+
sampleAttrKey?: string | null;
|
|
46
|
+
};
|
|
17
47
|
export interface Artifact {
|
|
18
48
|
id: string;
|
|
19
49
|
name: string;
|
|
@@ -22,6 +52,12 @@ export interface Artifact {
|
|
|
22
52
|
masterId?: string;
|
|
23
53
|
faces?: { fill?: string; report?: string };
|
|
24
54
|
commonFieldKeys?: string[];
|
|
55
|
+
/** 字段目录(设计器字段/公式面板数据源) */
|
|
56
|
+
fields?: ArtifactField[];
|
|
57
|
+
/** 录入面/报表面显示闸(缺省 = 两面都显示) */
|
|
58
|
+
showFaces?: { entry?: boolean; report?: boolean };
|
|
59
|
+
/** 宿主角色语义,透传不解释 */
|
|
60
|
+
formRole?: string;
|
|
25
61
|
etag?: string;
|
|
26
62
|
}
|
|
27
63
|
export interface ArtifactMeta {
|
|
@@ -150,6 +186,84 @@ export interface KtTheme {
|
|
|
150
186
|
chrome?: KtThemeChrome;
|
|
151
187
|
styleId?: KtUiStyleId;
|
|
152
188
|
}
|
|
189
|
+
export interface KtPdfExportRequest {
|
|
190
|
+
title?: string;
|
|
191
|
+
pageRanges?: string;
|
|
192
|
+
pageSizeMm?: { width: number; height: number };
|
|
193
|
+
landscape?: boolean;
|
|
194
|
+
}
|
|
195
|
+
export interface KtPdfExportResult {
|
|
196
|
+
canceled?: boolean;
|
|
197
|
+
filePath?: string;
|
|
198
|
+
}
|
|
199
|
+
export interface KtPrintHooks {
|
|
200
|
+
/** 打印前(可异步);返回 false 取消本次打印 */
|
|
201
|
+
beforePrint?: (ctx: { title?: string }) => void | boolean | Promise<void | boolean>;
|
|
202
|
+
afterPrint?: () => void;
|
|
203
|
+
/** PDF 导出器(宿主注入桌面桥);缺省 = 浏览器「另存为 PDF」提示 */
|
|
204
|
+
pdfExporter?: (req: KtPdfExportRequest) => Promise<KtPdfExportResult>;
|
|
205
|
+
/** 「打印选项」菜单追加项 */
|
|
206
|
+
extraOptions?: { label: string; onClick: () => void }[];
|
|
207
|
+
/** 打印记忆 localStorage key 前缀;缺省 "kt-preview-print-mem" */
|
|
208
|
+
memoryKey?: string;
|
|
209
|
+
}
|
|
210
|
+
export interface KtPreviewHooks {
|
|
211
|
+
/** 灌数后处理:业务 enrich / 图表与签名图槽数据注入 */
|
|
212
|
+
enrichFieldData?: (
|
|
213
|
+
fieldData: ReportFieldData,
|
|
214
|
+
ctx: { artifactId?: string; instanceId?: string },
|
|
215
|
+
) => ReportFieldData | Promise<ReportFieldData>;
|
|
216
|
+
/** 页眉页脚 chrome 数据(审批意见/二维码/审核人区);null = 无 */
|
|
217
|
+
pageChrome?: (ctx: { artifactId?: string; instanceId?: string }) => Promise<{
|
|
218
|
+
showOpinion: boolean;
|
|
219
|
+
showQr: boolean;
|
|
220
|
+
showReviewer: boolean;
|
|
221
|
+
} | null>;
|
|
222
|
+
onPageChromeCommit?: (
|
|
223
|
+
next: { showOpinion: boolean; showQr: boolean; showReviewer: boolean },
|
|
224
|
+
remember: { rememberUnit?: boolean; rememberMaster?: boolean },
|
|
225
|
+
ctx: { artifactId?: string },
|
|
226
|
+
) => void;
|
|
227
|
+
}
|
|
228
|
+
export interface KtDesignerHooks {
|
|
229
|
+
/** 业务绑定字段目录,并入设计器字段面板 */
|
|
230
|
+
bindingSchemas?: unknown[];
|
|
231
|
+
/** 公式试算(宿主业务 API,按字段);缺省时公式面板只编辑不试算 */
|
|
232
|
+
trialFormula?: (ctx: {
|
|
233
|
+
artifactId?: string;
|
|
234
|
+
fieldCode: string;
|
|
235
|
+
formula: string;
|
|
236
|
+
roundKind?: string | null;
|
|
237
|
+
roundDigits?: number | null;
|
|
238
|
+
}) => Promise<{ rounded?: string; raw?: string; source?: string }>;
|
|
239
|
+
/** prepage 规则面板的字典选项源(dictCode → 选项);缺省隐藏字典相关入口 */
|
|
240
|
+
prepageDicts?: () => Promise<Record<string, { value: string; label: string }[]>>;
|
|
241
|
+
/** 服务端设计包导入(宿主自弹 UI);返回 "reload" 让设计器重取 artifact */
|
|
242
|
+
importDesignPack?: (ctx: {
|
|
243
|
+
artifactId: string;
|
|
244
|
+
name?: string;
|
|
245
|
+
masterId?: string;
|
|
246
|
+
ktl?: string;
|
|
247
|
+
hasFields?: boolean;
|
|
248
|
+
}) => Promise<"reload" | null>;
|
|
249
|
+
/** 实例联排数据源;缺省隐藏实例模式 */
|
|
250
|
+
instances?: {
|
|
251
|
+
list: (artifactId: string) => Promise<{ id: string; title: string }[]>;
|
|
252
|
+
fieldData: (instanceId: string, ctx: { artifactId: string }) => Promise<ReportFieldData>;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
export interface KtFillHooks {
|
|
256
|
+
/** 录入画布字典选项(dictCode → 选项);缺省无字典下拉 */
|
|
257
|
+
dicts?: () => Promise<Record<string, { value: string; label: string }[]>>;
|
|
258
|
+
/** 预览公共袋最后加工(单位名/人员签名等宿主语义);在包内 enrich 之后执行 */
|
|
259
|
+
enrichCommon?: (bag: Record<string, string>, ctx: { instanceId?: string }) => Record<string, string>;
|
|
260
|
+
}
|
|
261
|
+
export interface KtHooks {
|
|
262
|
+
print?: KtPrintHooks;
|
|
263
|
+
preview?: KtPreviewHooks;
|
|
264
|
+
designer?: KtDesignerHooks;
|
|
265
|
+
fill?: KtFillHooks;
|
|
266
|
+
}
|
|
153
267
|
export interface KtConfig {
|
|
154
268
|
sku: KtSku;
|
|
155
269
|
locale?: "zh-CN";
|
|
@@ -174,6 +288,8 @@ export interface KtConfig {
|
|
|
174
288
|
print?: boolean;
|
|
175
289
|
pdf?: boolean;
|
|
176
290
|
};
|
|
291
|
+
/** 宿主钩子:打印/PDF/预览灌数/设计器字段目录。全部可选。 */
|
|
292
|
+
hooks?: KtHooks;
|
|
177
293
|
}
|
|
178
294
|
export interface ResolvedFeatures {
|
|
179
295
|
master: boolean;
|
|
@@ -293,27 +409,28 @@ export function KtVersionPanel(props: {
|
|
|
293
409
|
onRestored?: () => void;
|
|
294
410
|
}): JSX.Element | null;
|
|
295
411
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
fieldCode: string;
|
|
299
|
-
label: string;
|
|
300
|
-
dataType: string;
|
|
301
|
-
sort: number;
|
|
302
|
-
formula?: string | null;
|
|
303
|
-
tableRelation?: number;
|
|
304
|
-
};
|
|
412
|
+
/** 向后兼容别名;正本为 ArtifactField(Artifact.fields 元素型) */
|
|
413
|
+
export type DesignerFormField = ArtifactField;
|
|
305
414
|
export function withSplitFaces(artifact: Artifact, workbook: unknown): Artifact;
|
|
306
415
|
export function previewKtlOf(artifact: Artifact): string;
|
|
307
416
|
export function KtReportDesigner(props: {
|
|
308
417
|
artifact?: Artifact;
|
|
309
418
|
artifactId?: string;
|
|
310
419
|
store?: ArtifactStore;
|
|
420
|
+
/** 母版清单/读取的独立 store(如目录 defs 适配器 + reports 母版);缺省同 store */
|
|
421
|
+
masterStore?: ArtifactStore;
|
|
311
422
|
masters?: { id: string; name: string }[];
|
|
312
423
|
values?: Record<string, unknown>;
|
|
313
424
|
formFields?: DesignerFormField[];
|
|
314
425
|
sheetFaceEnabled?: boolean;
|
|
315
426
|
onSave?: (a: Artifact) => void;
|
|
316
427
|
onConflict?: (e: KtConflictError) => void;
|
|
428
|
+
/** 提供则铬层出现「另存」,参数为当前内存稿(含未保存改动) */
|
|
429
|
+
onSaveAs?: (a: Artifact) => void;
|
|
430
|
+
/** true = 铬层名称可编辑(随保存落库) */
|
|
431
|
+
nameEditable?: boolean;
|
|
432
|
+
/** true 且 hooks.designer.importDesignPack 存在时,导入按钮带「导入设计包(服务端)」入口 */
|
|
433
|
+
allowImportPack?: boolean;
|
|
317
434
|
extraActions?: ReactNode;
|
|
318
435
|
leadingActions?: ReactNode;
|
|
319
436
|
}): JSX.Element;
|
|
@@ -324,15 +441,111 @@ export function KtReportPreview(props: {
|
|
|
324
441
|
rev?: string;
|
|
325
442
|
values?: ValueBag;
|
|
326
443
|
common?: ValueBag;
|
|
444
|
+
/** false = 极简纸面(无打印条);缺省走完整预览壳 */
|
|
327
445
|
print?: boolean;
|
|
328
446
|
showVersionPanel?: boolean;
|
|
329
447
|
extraActions?: ReactNode;
|
|
448
|
+
onBack?: () => void;
|
|
449
|
+
backDisabled?: boolean;
|
|
450
|
+
preferSampleContent?: boolean;
|
|
451
|
+
/** 当次附加绑定字段(与 hooks.designer.bindingSchemas 合并) */
|
|
452
|
+
bindingSchema?: unknown[];
|
|
453
|
+
/** 打印空白:空袋求值后的合成稿;null = 有闸门无默认不打页 */
|
|
454
|
+
blankWorkbook?: unknown;
|
|
455
|
+
blankEmptyHint?: string;
|
|
456
|
+
fieldDataForSheet?: (sheetId: string) => ReportFieldData;
|
|
457
|
+
/** 实例上下文:透传给 hooks 的 ctx.instanceId */
|
|
458
|
+
instanceId?: string;
|
|
459
|
+
/** 打印记忆表 key;缺省 artifact.id */
|
|
460
|
+
tableKey?: string;
|
|
461
|
+
/** 打印记忆种类(以下空白分槽);缺省按 artifact.kind 映射 */
|
|
462
|
+
printKind?: "record" | "report" | "consign";
|
|
463
|
+
/** 页眉页脚 chrome(优先于 hooks.preview.pageChrome) */
|
|
464
|
+
pageChrome?: { showOpinion: boolean; showQr: boolean; showReviewer: boolean } | null;
|
|
465
|
+
onPageChromeCommit?: (
|
|
466
|
+
next: { showOpinion: boolean; showQr: boolean; showReviewer: boolean },
|
|
467
|
+
remember: { rememberUnit?: boolean; rememberMaster?: boolean },
|
|
468
|
+
) => void;
|
|
469
|
+
/** page = 整页预览台;modal = 设计器弹层 */
|
|
470
|
+
chrome?: "page" | "modal";
|
|
471
|
+
}): JSX.Element;
|
|
472
|
+
// C3:低层逃生舱与通用预览工具
|
|
473
|
+
export type PageChromeRegions = { showOpinion: boolean; showQr: boolean; showReviewer: boolean };
|
|
474
|
+
export type PageChromePartial = Partial<PageChromeRegions>;
|
|
475
|
+
export type PageChromeRemember = { rememberUnit?: boolean; rememberMaster?: boolean };
|
|
476
|
+
export const DEFAULT_PAGE_CHROME: PageChromeRegions;
|
|
477
|
+
export function overlayPageChrome(...layers: Array<PageChromePartial | null | undefined>): PageChromeRegions;
|
|
478
|
+
export function pageChromeEquals(a: PageChromeRegions, b: PageChromeRegions): boolean;
|
|
479
|
+
export function parsePageChromeFromBag(bag: Record<string, unknown> | null | undefined): PageChromePartial | null;
|
|
480
|
+
export function parsePageChromeFromSearch(search: { get(name: string): string | null } | null | undefined): PageChromePartial | null;
|
|
481
|
+
export function parsePageChromePartial(raw: unknown): PageChromePartial | null;
|
|
482
|
+
export function stringifyPageChrome(chrome: PageChromeRegions): string;
|
|
483
|
+
export function writePageChromeToBag(bag: Record<string, string>, chrome: PageChromeRegions): Record<string, string>;
|
|
484
|
+
export type PreviewPrintKind = "record" | "report" | "consign";
|
|
485
|
+
export function resolvePrintMemoryTableKey(legacyCode?: string | null, formDefId?: string | null): string;
|
|
486
|
+
export type BindingField = { label: string; value: string; group?: string };
|
|
487
|
+
export function mergeBindingSchema(base: BindingField[], extra?: BindingField[]): BindingField[];
|
|
488
|
+
export function bindingFieldsFromFieldData(fieldData?: ReportFieldData | null): BindingField[];
|
|
489
|
+
export function bindingFieldsFromWorkbook(workbook: unknown): BindingField[];
|
|
490
|
+
export function readBindingExtras(workbook: unknown): BindingField[];
|
|
491
|
+
export const SAMPLE_FIELD_DATA: ReportFieldData;
|
|
492
|
+
export function applySampleInfoCompose(
|
|
493
|
+
bag: Record<string, string>,
|
|
494
|
+
keys: string[],
|
|
495
|
+
labelOf: (key: string) => string,
|
|
496
|
+
): Record<string, string>;
|
|
497
|
+
export const SAMPLE_INFO_PAPER_LABEL: string;
|
|
498
|
+
export function enrichLabNameFieldData(fieldData?: ReportFieldData | null, fallbackLabName?: string): ReportFieldData;
|
|
499
|
+
export function resolvePreviewLabName(
|
|
500
|
+
bag?: Record<string, unknown> | null,
|
|
501
|
+
extras?: { queryLabName?: string; homeOrgName?: string },
|
|
502
|
+
): string;
|
|
503
|
+
// C3:导入设计包/母版拼接工具
|
|
504
|
+
export type MasterZones = any;
|
|
505
|
+
export type MasterComposeFail = { fail: true; reason?: string; [key: string]: unknown };
|
|
506
|
+
export function isMasterFail(v: unknown): boolean;
|
|
507
|
+
export function deriveMasterZones(sheet: unknown): MasterZones | MasterComposeFail;
|
|
508
|
+
export function fitWorkbookToMasterBodySlot(
|
|
509
|
+
workbook: TemplateWorkbookState,
|
|
510
|
+
master: unknown,
|
|
511
|
+
masterId?: string,
|
|
512
|
+
opts?: { resetBorder?: boolean; sheetIds?: string[] },
|
|
513
|
+
): TemplateWorkbookState;
|
|
514
|
+
export function normalizeWorkbookBordersToThinSolid(workbook: TemplateWorkbookState): TemplateWorkbookState;
|
|
515
|
+
export function mergeImportedPrepage(
|
|
516
|
+
currentEntryKtl: string | null | undefined,
|
|
517
|
+
incomingEntryKtl: string | null | undefined,
|
|
518
|
+
opts: { replaceLayout: boolean; replaceRules: boolean },
|
|
519
|
+
): string;
|
|
520
|
+
export function prepageDisplayName(raw?: string | null): string;
|
|
521
|
+
export function KtReportPreviewSurface(props: {
|
|
522
|
+
workbook: unknown;
|
|
523
|
+
blankWorkbook?: unknown;
|
|
524
|
+
blankEmptyHint?: string;
|
|
525
|
+
fieldData?: ReportFieldData;
|
|
526
|
+
fieldDataForSheet?: (sheetId: string) => ReportFieldData;
|
|
527
|
+
bindingSchema?: BindingField[];
|
|
528
|
+
preferSampleContent?: boolean;
|
|
529
|
+
title?: string;
|
|
530
|
+
composeWarn?: string | null;
|
|
531
|
+
chrome?: "page" | "modal";
|
|
532
|
+
onBack?: () => void;
|
|
533
|
+
backDisabled?: boolean;
|
|
534
|
+
extraActions?: ReactNode;
|
|
535
|
+
tableKey?: string;
|
|
536
|
+
printKind?: PreviewPrintKind;
|
|
537
|
+
fallbackLabName?: string;
|
|
538
|
+
pageChrome?: PageChromeRegions | null;
|
|
539
|
+
onPageChromeCommit?: (next: PageChromeRegions, remember: PageChromeRemember) => void;
|
|
540
|
+
watermarkOverride?: unknown;
|
|
330
541
|
}): JSX.Element;
|
|
331
542
|
export function KtReportCatalog(props: {
|
|
332
543
|
store?: ArtifactStore;
|
|
333
544
|
kinds?: ArtifactKind[];
|
|
334
545
|
onOpenDesign: (id: string) => void;
|
|
335
546
|
onOpenPreview: (id: string) => void;
|
|
547
|
+
/** 提供且 features.fill 开启时,行内出现「录入」入口 */
|
|
548
|
+
onOpenFill?: (id: string) => void;
|
|
336
549
|
}): JSX.Element;
|
|
337
550
|
export function KtThemeBar(props?: { variant?: "default" | "onPrimary" }): JSX.Element;
|
|
338
551
|
export function KtBrandBar(props: { title: string; themeBar?: boolean }): JSX.Element;
|
|
@@ -346,3 +559,272 @@ export function composeKtlForPreview(
|
|
|
346
559
|
ktl: string,
|
|
347
560
|
fetchMasterKtl: (masterId: string) => Promise<string | null>,
|
|
348
561
|
): Promise<{ workbook: unknown; masterId?: string; composed: boolean; error?: string }>;
|
|
562
|
+
|
|
563
|
+
// ---- C1c:目录设计器适配器用纯函数 ----
|
|
564
|
+
export function splitFormFaceKtls(workbook: unknown): { entryKtl: string; reportKtl: string };
|
|
565
|
+
export function mergeFormFaceKtls(entryKtl?: string | null, reportKtl?: string | null): string;
|
|
566
|
+
export function hasUsableFaceLayout(ktl: string): boolean;
|
|
567
|
+
export function mergeMiddleComposeMeta(
|
|
568
|
+
workbook: unknown,
|
|
569
|
+
meta: { masterId?: string; importColWidths?: number[]; importRowHeights?: number[] },
|
|
570
|
+
): unknown;
|
|
571
|
+
export function readMiddleComposeMeta(workbook: unknown): {
|
|
572
|
+
masterId?: string;
|
|
573
|
+
importColWidths?: number[];
|
|
574
|
+
importRowHeights?: number[];
|
|
575
|
+
columnPrecisionMul?: number;
|
|
576
|
+
} | null;
|
|
577
|
+
export function validateFieldsFormulas(fields: FormulaField[]): string | null;
|
|
578
|
+
export function prepageSaveError(workbook: unknown): string | null;
|
|
579
|
+
export function readPrepage(workbook: unknown): { sheetId?: string; rules: unknown[] } | null;
|
|
580
|
+
export function isPrepageSheet(workbook: unknown, sheetId: string): boolean;
|
|
581
|
+
export function parseKtlSafe(ktl: string): { workbook: any; diagnostics: { severity: string; message: string }[] };
|
|
582
|
+
export function workbookToKtlText(workbook: unknown): string;
|
|
583
|
+
|
|
584
|
+
// ---- C2a:实例填报(KtReportFill + 画布三件套) ----
|
|
585
|
+
export interface SheetCommonStore {
|
|
586
|
+
legacy: Record<string, string>;
|
|
587
|
+
byReport: Record<string, Record<string, string>>;
|
|
588
|
+
}
|
|
589
|
+
export function parseSheetCommonStore(raw?: string | null): SheetCommonStore;
|
|
590
|
+
export function stringifySheetCommonStore(store?: SheetCommonStore | null): string;
|
|
591
|
+
|
|
592
|
+
export type KtFillCommonField = { fieldKey: string; label: string; dataType?: string; enabled?: boolean };
|
|
593
|
+
export type KtFillSheet = {
|
|
594
|
+
sheetId: string;
|
|
595
|
+
formDefId: string;
|
|
596
|
+
formName?: string;
|
|
597
|
+
tabTitle?: string;
|
|
598
|
+
formRole?: string;
|
|
599
|
+
entryMiddleKtl?: string | null;
|
|
600
|
+
reportMiddleKtl?: string | null;
|
|
601
|
+
middleKtl?: string | null;
|
|
602
|
+
showEntry?: boolean;
|
|
603
|
+
showReport?: boolean;
|
|
604
|
+
commonFieldKeys?: string[];
|
|
605
|
+
fields?: ArtifactField[];
|
|
606
|
+
};
|
|
607
|
+
export type KtFillComboMember = { formDefId: string; tabTitle?: string; formRole?: string };
|
|
608
|
+
export type ComboMapRule = {
|
|
609
|
+
sourceFormDefId: string;
|
|
610
|
+
sourceFieldCode: string;
|
|
611
|
+
targetFormDefId: string;
|
|
612
|
+
targetFieldCode: string;
|
|
613
|
+
mode?: string;
|
|
614
|
+
formula?: string;
|
|
615
|
+
whenMode?: string;
|
|
616
|
+
sourceRoundKind?: string;
|
|
617
|
+
sourceRoundDigits?: number | null;
|
|
618
|
+
targetRoundKind?: string;
|
|
619
|
+
targetRoundDigits?: number | null;
|
|
620
|
+
sourceSlot?: number | null;
|
|
621
|
+
};
|
|
622
|
+
export type KtFillSnapshot = {
|
|
623
|
+
common: Record<string, string>;
|
|
624
|
+
tabCommons: Record<string, SheetCommonStore>;
|
|
625
|
+
values: Record<string, Record<string, string>>;
|
|
626
|
+
handEdited: Record<string, string[]>;
|
|
627
|
+
};
|
|
628
|
+
export interface KtReportFillHandle {
|
|
629
|
+
collect(): KtFillSnapshot;
|
|
630
|
+
getCommonField(key: string): string;
|
|
631
|
+
setCommonField(key: string, val: string): void;
|
|
632
|
+
}
|
|
633
|
+
export type KtCommonFieldCtx = {
|
|
634
|
+
value: string;
|
|
635
|
+
readOnly: boolean;
|
|
636
|
+
setValue: (v: string) => void;
|
|
637
|
+
setField: (key: string, v: string) => void;
|
|
638
|
+
bag: (key: string) => string;
|
|
639
|
+
label: string;
|
|
640
|
+
};
|
|
641
|
+
export const KtReportFill: React.ForwardRefExoticComponent<
|
|
642
|
+
React.RefAttributes<KtReportFillHandle> & {
|
|
643
|
+
instanceId: string;
|
|
644
|
+
kind: string;
|
|
645
|
+
sheets: KtFillSheet[];
|
|
646
|
+
commonFields: KtFillCommonField[];
|
|
647
|
+
comboMembers?: KtFillComboMember[];
|
|
648
|
+
comboMappings?: ComboMapRule[];
|
|
649
|
+
comboCommonFieldKeys?: string[];
|
|
650
|
+
initialCommon?: Record<string, string>;
|
|
651
|
+
initialTabCommons?: Record<string, SheetCommonStore>;
|
|
652
|
+
initialValues?: Record<string, Record<string, string>>;
|
|
653
|
+
initialHandEdited?: Record<string, string[]>;
|
|
654
|
+
version?: unknown;
|
|
655
|
+
readOnly?: boolean;
|
|
656
|
+
onSnapshot?: (snap: KtFillSnapshot) => void;
|
|
657
|
+
onActiveSheetChange?: (sheet: KtFillSheet | undefined) => void;
|
|
658
|
+
previewBar?: ReactNode;
|
|
659
|
+
toolbar?: ReactNode;
|
|
660
|
+
hint?: ReactNode;
|
|
661
|
+
title?: string;
|
|
662
|
+
leftTitle?: string;
|
|
663
|
+
renderCommonField?: (f: KtFillCommonField, ctx: KtCommonFieldCtx) => ReactNode;
|
|
664
|
+
leftFooter?: ReactNode;
|
|
665
|
+
withPreview?: boolean;
|
|
666
|
+
previewExtra?: {
|
|
667
|
+
fallbackLabName?: string;
|
|
668
|
+
staffSigners?: unknown[];
|
|
669
|
+
sampleComposeKeys?: string[] | null;
|
|
670
|
+
sampleFieldLabel?: (key: string) => string;
|
|
671
|
+
pageChrome?: unknown;
|
|
672
|
+
request?: <T>(path: string, init?: RequestInit) => Promise<T>;
|
|
673
|
+
scheme?: any;
|
|
674
|
+
onSchemeChange?: (s: any, b: any) => void;
|
|
675
|
+
loadMaster?: (masterId: string) => Promise<string | null>;
|
|
676
|
+
};
|
|
677
|
+
dicts?: Record<string, { value: string; label: string }[]>;
|
|
678
|
+
className?: string;
|
|
679
|
+
}
|
|
680
|
+
>;
|
|
681
|
+
export function InstanceFillSheet(props: {
|
|
682
|
+
ktl?: string | null;
|
|
683
|
+
fields?: ArtifactField[];
|
|
684
|
+
values?: Record<string, string>;
|
|
685
|
+
readOnly?: boolean;
|
|
686
|
+
hideBoundCodesHint?: boolean;
|
|
687
|
+
showBoundCodes?: boolean;
|
|
688
|
+
mappedCodes?: string[];
|
|
689
|
+
handEditedCodes?: string[];
|
|
690
|
+
mappingTips?: Record<string, string>;
|
|
691
|
+
dicts?: Record<string, { value: string; label: string }[]>;
|
|
692
|
+
digitOverlays?: unknown;
|
|
693
|
+
omitTrailingZerosOverride?: boolean;
|
|
694
|
+
reportSheets?: { id: string; name: string }[];
|
|
695
|
+
reportSheetId?: string;
|
|
696
|
+
onReportSheetChange?: (id: string) => void;
|
|
697
|
+
/** 组合设计:点绑定格挑字段 */
|
|
698
|
+
onPickBind?: (info: { fieldCode: string; bagKey: string }) => void;
|
|
699
|
+
pickedBagKey?: string | null;
|
|
700
|
+
face?: "entry" | "report";
|
|
701
|
+
onChange?: (code: string, val: string, meta?: { handEdit?: boolean; restore?: boolean; blur?: boolean; remove?: boolean }) => void;
|
|
702
|
+
}): JSX.Element;
|
|
703
|
+
export function InstanceFillLayout(props: any): JSX.Element;
|
|
704
|
+
// ---- C2b:宿主薄壳用纯函数 ----
|
|
705
|
+
export function applyComboMappingsToSheets(
|
|
706
|
+
valuesBySheet: Record<string, Record<string, string>>,
|
|
707
|
+
sheets: { sheetId: string; formDefId: string; fields?: any[] }[],
|
|
708
|
+
mappings: ComboMapRule[],
|
|
709
|
+
handsBySheet: Record<string, string[]>,
|
|
710
|
+
): Record<string, Record<string, string>>;
|
|
711
|
+
export function applyComboMappings(...args: any[]): any;
|
|
712
|
+
export function mappingLine(opts: any): string;
|
|
713
|
+
export function applySheetFormulas(bag: Record<string, string>, fields: any[], hands?: string[]): Record<string, string>;
|
|
714
|
+
export function codesMatch(list: string[] | undefined, code: string): boolean;
|
|
715
|
+
export function fieldCodeFromBindKey(bindKey: string): string | null;
|
|
716
|
+
export function fieldHasFormula(field: any): boolean;
|
|
717
|
+
export function evalFormula(formula: string, bag: Record<string, string>): string | null;
|
|
718
|
+
export function validateFormula(formula?: string | null, knownCodes?: string[]): string | null;
|
|
719
|
+
// C2c:公式引擎全量面(正本单源)
|
|
720
|
+
export type FormulaField = {
|
|
721
|
+
fieldCode: string;
|
|
722
|
+
formula?: string | null;
|
|
723
|
+
roundKind?: string | null;
|
|
724
|
+
roundDigits?: number | null;
|
|
725
|
+
readOnly?: boolean;
|
|
726
|
+
tableRelation?: number | null;
|
|
727
|
+
};
|
|
728
|
+
export const FORMULA_FNS: { label: string; insert: string }[];
|
|
729
|
+
export function normalizeDialect(formula: string): string;
|
|
730
|
+
export function currentToken(text: string, caret: number): { start: number; end: number; token: string };
|
|
731
|
+
export function suggestFormulaTokens(
|
|
732
|
+
text: string,
|
|
733
|
+
caret: number,
|
|
734
|
+
fields: { fieldCode: string; label: string }[],
|
|
735
|
+
): { insert: string; label: string; kind: "field" | "fn" }[];
|
|
736
|
+
export const OMIT_TRAILING_ZEROS_KEY: string;
|
|
737
|
+
export const OMIT_TRAILING_ZEROS_EVENT: string;
|
|
738
|
+
export function loadOmitTrailingZeros(): boolean;
|
|
739
|
+
export function saveOmitTrailingZeros(on: boolean): void;
|
|
740
|
+
export function applyRound(raw: string, kind?: string | null, digits?: number | null): string;
|
|
741
|
+
export function formatRoundDisplay(raw: string, kind?: string | null, digits?: number | null, omitTrailingZeros?: boolean): string;
|
|
742
|
+
export function formatFieldBag(
|
|
743
|
+
bag: Record<string, string>,
|
|
744
|
+
fields: { fieldCode: string; roundKind?: string | null; roundDigits?: number | null }[],
|
|
745
|
+
omitTrailingZeros?: boolean,
|
|
746
|
+
): Record<string, string>;
|
|
747
|
+
export function formatReportFieldData<T extends { m?: Record<string, unknown> }>(
|
|
748
|
+
data: T,
|
|
749
|
+
fields: { fieldCode: string; roundKind?: string | null; roundDigits?: number | null }[],
|
|
750
|
+
omitTrailingZeros?: boolean,
|
|
751
|
+
): T;
|
|
752
|
+
export function stripFieldDataTrailingZeros<T extends { m?: Record<string, unknown> }>(data: T): T;
|
|
753
|
+
export function expandFormulaFns(formula: string): string;
|
|
754
|
+
export function isSubField(f: { fieldCode: string; tableRelation?: number | null }): boolean;
|
|
755
|
+
export function isSubtableField(f: FormulaField | undefined, fieldCode: string): boolean;
|
|
756
|
+
export function markLabel(code?: string | null): string;
|
|
757
|
+
export function listSubRows(bag: Record<string, string>): { sid: number; slot: number }[];
|
|
758
|
+
export function projectRow(bag: Record<string, string>, sid: number, slot: number): Record<string, string>;
|
|
759
|
+
export function fieldHandLocked(hands: Set<string>, code: string, sid?: number, slot?: number): boolean;
|
|
760
|
+
export function readFieldSlots(
|
|
761
|
+
bag: Record<string, string>,
|
|
762
|
+
fieldCode: string,
|
|
763
|
+
): { key: string; value: string; sid?: number; slot: number }[];
|
|
764
|
+
export function inferSubSid(field: FormulaField | undefined, bag: Record<string, string>, fieldCode: string, srcSid?: number): number;
|
|
765
|
+
export function writeMappedValue(
|
|
766
|
+
bag: Record<string, string>,
|
|
767
|
+
field: FormulaField | undefined,
|
|
768
|
+
fieldCode: string,
|
|
769
|
+
value: string,
|
|
770
|
+
srcSid: number | undefined,
|
|
771
|
+
slot: number,
|
|
772
|
+
): void;
|
|
773
|
+
export function extractFieldRefs(formula: string): string[];
|
|
774
|
+
export function trialFormula(formula: string, fields: { fieldCode: string }[], kind?: string | null, digits?: number | null): string | null;
|
|
775
|
+
export function emptySheetCommonStore(): SheetCommonStore;
|
|
776
|
+
export const FILL_LEFT_COLLAPSED_KEY: string;
|
|
777
|
+
export const FILL_LEFT_COMMON: string;
|
|
778
|
+
export const FILL_LEFT_MEMBER: string;
|
|
779
|
+
export function loadFillLeftCollapsed(): boolean;
|
|
780
|
+
export function saveFillLeftCollapsed(collapsed: boolean): void;
|
|
781
|
+
export function coalesceCommon(
|
|
782
|
+
inst: Record<string, string>,
|
|
783
|
+
tab: Record<string, string>,
|
|
784
|
+
skipNos?: boolean,
|
|
785
|
+
): Record<string, string>;
|
|
786
|
+
export function isSignCommonField(fieldKey?: string | null): boolean;
|
|
787
|
+
export const RECORD_SIGN_LABELS: Record<string, string>;
|
|
788
|
+
export const REPORT_SIGN_LABELS: Record<string, string>;
|
|
789
|
+
export const SHEET_COMMON_BY_REPORT: string;
|
|
790
|
+
export function coalesceMemberCommon(inst: Record<string, string>, store?: SheetCommonStore | null): Record<string, string>;
|
|
791
|
+
export function coalesceReportPageCommon(inst: Record<string, string>, store: SheetCommonStore | null | undefined, reportSheetId: string): Record<string, string>;
|
|
792
|
+
export function reportPageOverlay(store: SheetCommonStore | null | undefined, reportSheetId: string): Record<string, string>;
|
|
793
|
+
export function setReportPageOverlayField(store: SheetCommonStore | null | undefined, reportSheetId: string, key: string, val: string): SheetCommonStore;
|
|
794
|
+
export function setSheetLegacyField(store: SheetCommonStore | null | undefined, key: string, val: string): SheetCommonStore;
|
|
795
|
+
export function commonFieldLabel(key: string, kind: string | undefined, fallback?: string): string;
|
|
796
|
+
export function orderFillEntryFields<T extends { fieldKey: string }>(fields: T[]): T[];
|
|
797
|
+
export function isFillNoKey(key: string): boolean;
|
|
798
|
+
export function enrichPreviewCommon(common: Record<string, string>, opts?: any): Record<string, string>;
|
|
799
|
+
export function stripFillDefaultBag(bag: Record<string, string>): Record<string, string>;
|
|
800
|
+
export function stripFillDefaultStore(store?: SheetCommonStore | null): SheetCommonStore;
|
|
801
|
+
export function recordNoLabelForKind(kind?: string): string;
|
|
802
|
+
export const DEFAULT_SAMPLE_COMPOSE_KEYS: string[];
|
|
803
|
+
export const SAMPLE_INFO_KEY: string;
|
|
804
|
+
export const SAMPLE_INFO_LABEL: string;
|
|
805
|
+
export function normalizeSampleComposeKeys(keys?: string[] | null): string[];
|
|
806
|
+
export function parseSampleComposeKeys(raw?: string | null): string[];
|
|
807
|
+
export function listVisibleReportSheets(reportKtl?: string | null, entryKtl?: string | null, bag?: any, opts?: { showReport?: boolean }): { id: string; name: string }[];
|
|
808
|
+
export function reportWorkbookForPreview(reportKtl: string | null | undefined, entryKtl: string | null | undefined, bag: any, opts?: { treatAsEmpty?: boolean; showReport?: boolean }): { workbook: any; emptyHint: string };
|
|
809
|
+
export const PREPAGE_EMPTY_HINT: string;
|
|
810
|
+
export type KtFormField = ArtifactField;
|
|
811
|
+
export type StaffSignerLite = { staffId: string; displayName: string; certNos: string[]; hasSignImage?: boolean; signImageSrc?: string };
|
|
812
|
+
export const PERSON_SIGN_SLOTS: readonly { personKey: string; label: string }[];
|
|
813
|
+
export function staffIdKey(personKey: string): string;
|
|
814
|
+
export function certNoKey(personKey: string): string;
|
|
815
|
+
export function formatTestDateCn(raw?: string): string;
|
|
816
|
+
export function formatTestDateText(start?: string, end?: string): string;
|
|
817
|
+
export function sampleNoFromRecordNo(recordNo?: string): string;
|
|
818
|
+
export function useFillLeftScope(
|
|
819
|
+
reportSheets: { id: string; name: string }[],
|
|
820
|
+
resetKey?: string,
|
|
821
|
+
combo?: boolean,
|
|
822
|
+
): {
|
|
823
|
+
leftScope: string;
|
|
824
|
+
scopeLocked: boolean;
|
|
825
|
+
editingMember: boolean;
|
|
826
|
+
editingReport: boolean;
|
|
827
|
+
previewSheetId?: string;
|
|
828
|
+
onLeftScopeChange: (v: string) => void;
|
|
829
|
+
};
|
|
830
|
+
export function InstanceFillPreviewPane(props: any): JSX.Element;
|