@jzg223/design-runtime 0.0.0-stage → 0.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/CHANGELOG.md +176 -0
- package/README.md +275 -2
- package/dist/_virtual/_plugin-vue_export-helper.js +10 -0
- package/dist/api.js +149 -0
- package/dist/comb/design-comb.vue.js +7 -0
- package/dist/comb/design-comb2.vue.js +591 -0
- package/dist/compat.js +74 -0
- package/dist/components/ApiSwitch.vue.js +7 -0
- package/dist/components/ApiSwitch2.vue.js +98 -0
- package/dist/components/design-debug/dev-mode-toggle.vue.js +7 -0
- package/dist/components/design-debug/dev-mode-toggle2.vue.js +41 -0
- package/dist/components/design-debug/dev-mode.js +45 -0
- package/dist/components/design-debug/dev-state-button.vue.js +7 -0
- package/dist/components/design-debug/dev-state-button2.vue.js +447 -0
- package/dist/components/design-debug/expr-eval.js +81 -0
- package/dist/components/design-shared/host-api.js +47 -0
- package/dist/components/design-shared/popup-host.js +11 -0
- package/dist/components/design-table/design-table-inner.vue.js +7 -0
- package/dist/components/design-table/design-table-inner2.vue.js +39 -0
- package/dist/components/design-table/design-table.vue.js +7 -0
- package/dist/components/design-table/design-table2.vue.js +937 -0
- package/dist/components/design-table/row-actions/delete-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/delete-action2.vue.js +42 -0
- package/dist/components/design-table/row-actions/edit-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/edit-action2.vue.js +145 -0
- package/dist/components/design-table/row-actions/index.js +36 -0
- package/dist/components/design-table/row-actions/modal-comb-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/modal-comb-action2.vue.js +66 -0
- package/dist/components/design-table/row-actions/modal-custom-action.vue.js +7 -0
- package/dist/components/design-table/row-actions/modal-custom-action2.vue.js +105 -0
- package/dist/components/design-table/row-actions/modal-form-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/modal-form-action2.vue.js +82 -0
- package/dist/components/design-table/row-actions/modal-table-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/modal-table-action2.vue.js +67 -0
- package/dist/components/design-table/row-actions/modal-tree-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/modal-tree-action2.vue.js +70 -0
- package/dist/components/design-table/row-actions/navigate-comb-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/navigate-comb-action2.vue.js +47 -0
- package/dist/components/design-table/row-actions/navigate-form-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/navigate-form-action2.vue.js +47 -0
- package/dist/components/design-table/row-actions/navigate-table-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/navigate-table-action2.vue.js +47 -0
- package/dist/components/design-table/row-actions/navigate-tree-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/navigate-tree-action2.vue.js +47 -0
- package/dist/components/design-table/row-actions/other-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/other-action2.vue.js +44 -0
- package/dist/components/design-tools/add-tool.vue.js +4 -0
- package/dist/components/design-tools/add-tool2.vue.js +136 -0
- package/dist/components/design-tools/command-executor.js +135 -0
- package/dist/components/design-tools/export-tool.vue.js +4 -0
- package/dist/components/design-tools/export-tool2.vue.js +46 -0
- package/dist/components/design-tools/import-tool.vue.js +4 -0
- package/dist/components/design-tools/import-tool2.vue.js +101 -0
- package/dist/components/design-tools/index.js +36 -0
- package/dist/components/design-tools/modal-comb-tool.vue.js +4 -0
- package/dist/components/design-tools/modal-comb-tool2.vue.js +56 -0
- package/dist/components/design-tools/modal-form-tool.vue.js +4 -0
- package/dist/components/design-tools/modal-form-tool2.vue.js +66 -0
- package/dist/components/design-tools/modal-hcm-tool.vue.js +7 -0
- package/dist/components/design-tools/modal-hcm-tool2.vue.js +85 -0
- package/dist/components/design-tools/modal-table-tool.vue.js +4 -0
- package/dist/components/design-tools/modal-table-tool2.vue.js +54 -0
- package/dist/components/design-tools/modal-tree-tool.vue.js +4 -0
- package/dist/components/design-tools/modal-tree-tool2.vue.js +57 -0
- package/dist/components/design-tools/navigate-comb-tool.vue.js +4 -0
- package/dist/components/design-tools/navigate-comb-tool2.vue.js +34 -0
- package/dist/components/design-tools/navigate-form-tool.vue.js +4 -0
- package/dist/components/design-tools/navigate-form-tool2.vue.js +34 -0
- package/dist/components/design-tools/navigate-table-tool.vue.js +4 -0
- package/dist/components/design-tools/navigate-table-tool2.vue.js +33 -0
- package/dist/components/design-tools/other-tool.vue.js +4 -0
- package/dist/components/design-tools/other-tool2.vue.js +34 -0
- package/dist/components/flow-status-cell/flow-status-cell.vue.js +7 -0
- package/dist/components/flow-status-cell/flow-status-cell2.vue.js +124 -0
- package/dist/flow.js +22 -0
- package/dist/form/cell-condition.js +122 -0
- package/dist/form/derived-express.js +34 -0
- package/dist/form/design-form-inner.vue.js +7 -0
- package/dist/form/design-form-inner2.vue.js +449 -0
- package/dist/form/design-form.vue.js +7 -0
- package/dist/form/design-form2.vue.js +681 -0
- package/dist/form/fields/checkbox-field.vue.js +88 -0
- package/dist/form/fields/checkbox-field2.vue.js +4 -0
- package/dist/form/fields/custom-field.vue.js +36 -0
- package/dist/form/fields/custom-field2.vue.js +4 -0
- package/dist/form/fields/date-field.vue.js +64 -0
- package/dist/form/fields/date-field2.vue.js +4 -0
- package/dist/form/fields/embedded-list-field.vue.js +7 -0
- package/dist/form/fields/embedded-list-field2.vue.js +437 -0
- package/dist/form/fields/file-field.vue.js +88 -0
- package/dist/form/fields/file-field2.vue.js +4 -0
- package/dist/form/fields/image-field.vue.js +90 -0
- package/dist/form/fields/image-field2.vue.js +4 -0
- package/dist/form/fields/index.js +106 -0
- package/dist/form/fields/month-field.vue.js +51 -0
- package/dist/form/fields/month-field2.vue.js +4 -0
- package/dist/form/fields/org-select-field.vue.js +7 -0
- package/dist/form/fields/org-select-field2.vue.js +187 -0
- package/dist/form/fields/orgs-select-field.vue.js +182 -0
- package/dist/form/fields/orgs-select-field2.vue.js +4 -0
- package/dist/form/fields/radio-field.vue.js +91 -0
- package/dist/form/fields/radio-field2.vue.js +4 -0
- package/dist/form/fields/select-field.vue.js +7 -0
- package/dist/form/fields/select-field2.vue.js +317 -0
- package/dist/form/fields/splitline-field.vue.js +7 -0
- package/dist/form/fields/splitline-field2.vue.js +50 -0
- package/dist/form/fields/switch-field.vue.js +32 -0
- package/dist/form/fields/switch-field2.vue.js +4 -0
- package/dist/form/fields/text-field.vue.js +78 -0
- package/dist/form/fields/text-field2.vue.js +4 -0
- package/dist/form/fields/time-field.vue.js +50 -0
- package/dist/form/fields/time-field2.vue.js +4 -0
- package/dist/form/fields/tree-field.vue.js +157 -0
- package/dist/form/fields/tree-field2.vue.js +4 -0
- package/dist/form/number-precision.js +18 -0
- package/dist/form/transformer.js +162 -0
- package/dist/host.js +76 -0
- package/dist/http.js +19 -0
- package/dist/index.js +166 -0
- package/dist/mapping.js +44 -0
- package/dist/org/dept-api.js +30 -0
- package/dist/org/dept-tree-source.js +53 -0
- package/dist/org/dept-tree.js +122 -0
- package/dist/registry.js +77 -0
- package/dist/search/design-search.vue.js +7 -0
- package/dist/search/design-search2.vue.js +232 -0
- package/dist/search/transformer.js +115 -0
- package/dist/style.css +1220 -0
- package/dist/table/data.js +18 -0
- package/dist/table/load-gate.js +19 -0
- package/dist/table/query-body.js +59 -0
- package/dist/table/query-dedupe.js +54 -0
- package/dist/table/query-search.js +9 -0
- package/dist/table/row-action-mapping.js +34 -0
- package/dist/table/transformer.js +328 -0
- package/dist/tree/design-tree.vue.js +7 -0
- package/dist/tree/design-tree2.vue.js +783 -0
- package/dist/types/api.d.ts +83 -0
- package/dist/types/comb/design-comb.vue.d.ts +38 -0
- package/dist/types/compat.d.ts +46 -0
- package/dist/types/components/ApiSwitch.vue.d.ts +31 -0
- package/dist/types/components/design-debug/dev-mode-toggle.vue.d.ts +2 -0
- package/dist/types/components/design-debug/dev-mode.d.ts +8 -0
- package/dist/types/components/design-debug/dev-state-button.vue.d.ts +55 -0
- package/dist/types/components/design-debug/expr-eval.d.ts +55 -0
- package/dist/types/components/design-shared/host-api.d.ts +60 -0
- package/dist/types/components/design-shared/popup-host.d.ts +13 -0
- package/dist/types/components/design-table/design-table-inner.vue.d.ts +19 -0
- package/dist/types/components/design-table/design-table.vue.d.ts +70 -0
- package/dist/types/components/design-table/row-actions/delete-action.vue.d.ts +12 -0
- package/dist/types/components/design-table/row-actions/edit-action.vue.d.ts +14 -0
- package/dist/types/components/design-table/row-actions/index.d.ts +25 -0
- package/dist/types/components/design-table/row-actions/modal-comb-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/modal-custom-action.vue.d.ts +15 -0
- package/dist/types/components/design-table/row-actions/modal-form-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/modal-table-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/modal-tree-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/navigate-comb-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/navigate-form-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/navigate-table-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/navigate-tree-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/other-action.vue.d.ts +14 -0
- package/dist/types/components/design-tools/add-tool.vue.d.ts +23 -0
- package/dist/types/components/design-tools/command-executor.d.ts +80 -0
- package/dist/types/components/design-tools/export-tool.vue.d.ts +9 -0
- package/dist/types/components/design-tools/import-tool.vue.d.ts +14 -0
- package/dist/types/components/design-tools/index.d.ts +23 -0
- package/dist/types/components/design-tools/modal-comb-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/modal-form-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/modal-hcm-tool.vue.d.ts +23 -0
- package/dist/types/components/design-tools/modal-table-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/modal-tree-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/navigate-comb-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/navigate-form-tool.vue.d.ts +11 -0
- package/dist/types/components/design-tools/navigate-table-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/other-tool.vue.d.ts +16 -0
- package/dist/types/components/flow-status-cell/flow-status-cell.vue.d.ts +14 -0
- package/dist/types/components/index.d.ts +33 -0
- package/dist/types/flow.d.ts +50 -0
- package/dist/types/form/cell-condition.d.ts +35 -0
- package/dist/types/form/derived-express.d.ts +28 -0
- package/dist/types/form/design-form-inner.vue.d.ts +55 -0
- package/dist/types/form/design-form.vue.d.ts +96 -0
- package/dist/types/form/fields/checkbox-field.vue.d.ts +14 -0
- package/dist/types/form/fields/custom-field.vue.d.ts +22 -0
- package/dist/types/form/fields/date-field.vue.d.ts +12 -0
- package/dist/types/form/fields/embedded-list-field.vue.d.ts +26 -0
- package/dist/types/form/fields/file-field.vue.d.ts +12 -0
- package/dist/types/form/fields/image-field.vue.d.ts +12 -0
- package/dist/types/form/fields/index.d.ts +34 -0
- package/dist/types/form/fields/month-field.vue.d.ts +12 -0
- package/dist/types/form/fields/org-select-field.vue.d.ts +14 -0
- package/dist/types/form/fields/orgs-select-field.vue.d.ts +12 -0
- package/dist/types/form/fields/radio-field.vue.d.ts +14 -0
- package/dist/types/form/fields/select-field.vue.d.ts +14 -0
- package/dist/types/form/fields/splitline-field.vue.d.ts +7 -0
- package/dist/types/form/fields/switch-field.vue.d.ts +12 -0
- package/dist/types/form/fields/text-field.vue.d.ts +12 -0
- package/dist/types/form/fields/time-field.vue.d.ts +12 -0
- package/dist/types/form/fields/tree-field.vue.d.ts +12 -0
- package/dist/types/form/number-precision.d.ts +15 -0
- package/dist/types/form/transformer.d.ts +27 -0
- package/dist/types/host.d.ts +182 -0
- package/dist/types/http.d.ts +59 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/mapping.d.ts +39 -0
- package/dist/types/org/dept-api.d.ts +12 -0
- package/dist/types/org/dept-tree-source.d.ts +15 -0
- package/dist/types/org/dept-tree.d.ts +62 -0
- package/dist/types/registry.d.ts +79 -0
- package/dist/types/search/design-search.vue.d.ts +46 -0
- package/dist/types/search/transformer.d.ts +36 -0
- package/dist/types/table/data.d.ts +30 -0
- package/dist/types/table/index.d.ts +20 -0
- package/dist/types/table/load-gate.d.ts +24 -0
- package/dist/types/table/query-body.d.ts +46 -0
- package/dist/types/table/query-dedupe.d.ts +42 -0
- package/dist/types/table/query-search.d.ts +21 -0
- package/dist/types/table/row-action-mapping.d.ts +36 -0
- package/dist/types/table/transformer.d.ts +59 -0
- package/dist/types/tree/design-tree.vue.d.ts +33 -0
- package/dist/types/types.d.ts +525 -0
- package/dist/types/utils/default-value.d.ts +16 -0
- package/dist/types/utils/download.d.ts +9 -0
- package/dist/types/utils/popup-width.d.ts +21 -0
- package/dist/utils/default-value.js +38 -0
- package/dist/utils/download.js +19 -0
- package/dist/utils/popup-width.js +19 -0
- package/package.json +73 -4
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 网络层契约(本库**不**依赖 axios / alova / fetch,只依赖这个接口)
|
|
3
|
+
*
|
|
4
|
+
* 为什么这么做:
|
|
5
|
+
* - 宿主(vben / 任意项目)已经有全站唯一的请求实例,token 头、clientid、401 跳登录、
|
|
6
|
+
* 刷新 token、baseURL、租户、日志、错误提示策略全在那里。本库若自己 `new axios`,
|
|
7
|
+
* 就会出现**第二套拦截器**:库里的请求不带 token ⇒ 一打开设计表格就 401,
|
|
8
|
+
* 而且宿主的"刷新 token / 踢回登录"逻辑对库的请求不生效。
|
|
9
|
+
* - 本库要能发到 npm 独立安装,所以不能 `import` 宿主模块(`#/utils/http` 之类)。
|
|
10
|
+
* 唯一合法的连接方式是**运行时注入**(见 host.ts 的 installDesignPlatform)。
|
|
11
|
+
*
|
|
12
|
+
* 返回口径:**resolve 业务数据**(宿主拦截器里已经把 `{code,data}` 剥掉了)。
|
|
13
|
+
* 库内不要再判断 `res.code === 200`,避免跟宿主两套口径打架。
|
|
14
|
+
*/
|
|
15
|
+
export interface DesignRequestOptions {
|
|
16
|
+
/** query 参数 */
|
|
17
|
+
params?: Record<string, any>;
|
|
18
|
+
headers?: Record<string, string | undefined>;
|
|
19
|
+
/** 取消(库内所有取数都应支持中途取消) */
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
/**
|
|
22
|
+
* 静默:不要弹成功/失败提示。
|
|
23
|
+
* 列表、树这类一次页面并发多条请求的场景必须传 true,否则一次操作弹十条 toast;
|
|
24
|
+
* 具体怎么提示交给调用方。
|
|
25
|
+
*/
|
|
26
|
+
silent?: boolean;
|
|
27
|
+
timeout?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface DesignHttp {
|
|
30
|
+
get: <T = any>(url: string, options?: DesignRequestOptions) => Promise<T>;
|
|
31
|
+
post: <T = any>(url: string, data?: any, options?: DesignRequestOptions) => Promise<T>;
|
|
32
|
+
/** 可选能力:宿主没提供时,导出/附件类功能降级(工具条按钮提示不可用) */
|
|
33
|
+
download?: (url: string, data?: any, options?: DesignRequestOptions) => Promise<Blob>;
|
|
34
|
+
/** 可选能力:宿主没提供时,上传类功能降级 */
|
|
35
|
+
upload?: <T = any>(url: string, form: FormData, options?: DesignRequestOptions & {
|
|
36
|
+
onProgress?: (percent: number) => void;
|
|
37
|
+
}) => Promise<T>;
|
|
38
|
+
}
|
|
39
|
+
/** 一次请求的形态(memory 实现与调试日志共用) */
|
|
40
|
+
export interface DesignRequestRecord {
|
|
41
|
+
data?: any;
|
|
42
|
+
method: 'GET' | 'POST';
|
|
43
|
+
options?: DesignRequestOptions;
|
|
44
|
+
url: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 内存版 http:给**开发/演示/自测**用,不需要宿主后端。
|
|
48
|
+
*
|
|
49
|
+
* 用法:
|
|
50
|
+
* ```ts
|
|
51
|
+
* const http = createMemoryHttp((req) => {
|
|
52
|
+
* if (req.url.endsWith('/find/pager')) return { records: [], total: 0 }
|
|
53
|
+
* })
|
|
54
|
+
* installDesignPlatform({ http })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function createMemoryHttp(handler: (req: DesignRequestRecord) => any): DesignHttp & {
|
|
58
|
+
readonly log: DesignRequestRecord[];
|
|
59
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 公开面(package.json 的 types/main 都指向这里)
|
|
3
|
+
*
|
|
4
|
+
* 原则:**只导出稳定的东西**。内部实现(组件内部的响应式状态、渲染细节)不从这里出去,
|
|
5
|
+
* 免得宿主依赖上不该依赖的细节,把库的版本升级空间锁死。
|
|
6
|
+
*/
|
|
7
|
+
import './styles/index.css';
|
|
8
|
+
export { ApiSwitch, buildHostApi, DESIGN_POPUP_HOST_KEY, DesignTable, DesignTree, DesignTableFlowStatusCell, DesignTableInner, DesignComb, DesignDevModeToggle, DesignSearch, DesignDevStateButton, DesignForm, DesignFormInner, evalExpression, executeCommand, hostRequest, openComponent, pendingRowActionTypes, pendingToolTypes, platformMessage, resolveRowActionComponent, resolveToolComponent, rowActionComponentMap, rowActionTypes, setDevMode, useDevMode, toolComponentMap, toolTypes, usePopupHost, } from './components';
|
|
9
|
+
export type { CommandContext, CommandHelpers, CommandNav, DesignHostApi, DesignHostSlot, DesignPopupHost, OpenComponentOptions, } from './components';
|
|
10
|
+
export { checkDesignRuntimeCompat, satisfiesRange, SUPPORTED_VERSIONS, } from './compat';
|
|
11
|
+
export type { CompatCheckItem, CompatReport } from './compat';
|
|
12
|
+
export { getDesignHost, getHostDict, getHostPopup, getHostUi, getHostWorkflow, hostT, installDesignPlatform, requireHttp, requireVxeGrid, resetDesignHost, } from './host';
|
|
13
|
+
export type { DesignAuthSnapshot, DesignHost, DesignHostUpload, DesignUploadOptions, DesignUploadResult, DesignHostDict, DesignHostMessage, DesignHostModal, DesignHostUi, DesignHostWorkflow, } from './host';
|
|
14
|
+
export { createMemoryHttp } from './http';
|
|
15
|
+
export type { DesignHttp, DesignRequestOptions, DesignRequestRecord, } from './http';
|
|
16
|
+
export { buildComponentsManifest, clearDesignComponents, hasDesignComponent, listDesignComponents, registerComponents, requireDesignComponent, resolveDesignComponent, } from './registry';
|
|
17
|
+
export type { DesignComponentEntry, DesignComponentLoader, DesignComponentMeta, } from './registry';
|
|
18
|
+
export type { DesignMapping, DesignTableTool, PlatformCellStyle, PlatformColumn, PlatformCombConfig, PlatformCombItem, PlatformDerivedField, PlatformDictItem, PlatformFormCell, PlatformFormConfig, PlatformFormContent, PlatformSearchConfig, PlatformTableConfig, PlatformTreeMapping, PlatformTreeViewConfig, PlatformViewComponent, PlatformViewConfig, PlatformViewContent, RowAction, RowActionMapping, SearchFieldCell, SearchFormConfig, TableDataResponse, TreeNodeCountConfig, } from './types';
|
|
19
|
+
export { clearDesignApiCache, fetchCombConfig, fetchCombData, fetchDataSetData, fetchDataSetListData, fetchDataSetMeta, fetchDataSetTreeAsync, fetchDataSetTreeSync, fetchDesignUiConfig, fetchFormConfig, fetchSearchConfig, fetchTableConfig, fetchTreeNodeCount, fetchTreeViewConfig, fetchViewConfig, } from './api';
|
|
20
|
+
export type { DataSetMeta } from './api';
|
|
21
|
+
export { designFlowRemove, designFlowStatus, designFlowSubmit, } from './flow';
|
|
22
|
+
export type { DesignFlowQueryParams, DesignFlowStartResult, DesignFlowStatusVo, DesignFlowSubmitParams, } from './flow';
|
|
23
|
+
export { buildCustomParams, buildNavigateQuery, buildQuerySearch, buildTableDataBody, createQueryDedupe, evaluateExpress, evaluateLoadGate, fetchTableData, parseConfigParams, transformTableConfig, } from './table';
|
|
24
|
+
export type { FetchTableDataParams, LoadGateResult, QueryDedupe, QueryDedupeOptions, QueryDedupeStats, TransformHost, TransformTableResult, } from './table';
|
|
25
|
+
export { DEFAULT_POPUP_WIDTH, resolvePopupWidth, toPopupWidth, } from './utils/popup-width';
|
|
26
|
+
export { downloadByData } from './utils/download';
|
|
27
|
+
export { buildExpressId, buildExtraParams, buildMappedParams, evaluateMappedExpress, isOwnRoutePage, } from './mapping';
|
|
28
|
+
export { buildConditionScope, computeConditionDebug, evalCellCondition, isConditionHidden, isInjectableScopeKey, } from './form/cell-condition';
|
|
29
|
+
export type { CellConditionDebugItem, CellConditionResult, } from './form/cell-condition';
|
|
30
|
+
export { buildDerivedScope, computeDerivedFills, evalDerivedExpress, } from './form/derived-express';
|
|
31
|
+
export { parsePrecision, roundToPrecision } from './form/number-precision';
|
|
32
|
+
export { transformFormConfig } from './form/transformer';
|
|
33
|
+
export type { FormGridConfig } from './form/transformer';
|
|
34
|
+
export { hasCustomComponent, listCustomComponents, pendingFieldTypes, register, registerFields, resolveCellComponent, resolveComponent, } from './form/fields';
|
|
35
|
+
export { deptChildren, deptInfo, deptList, getDeptSubTree } from './org/dept-api';
|
|
36
|
+
export { attachChildren, createLazyDeptTree, normalizeParentId, toTreeNode, } from './org/dept-tree';
|
|
37
|
+
export type { DeptNode, DeptTreeNode, DeptTreeSource, } from './org/dept-tree';
|
|
38
|
+
export { createDeptTreeSource, normalizeDeptNode } from './org/dept-tree-source';
|
|
39
|
+
export { buildSearchFormOptions, normalizeSearchCells } from './search/transformer';
|
|
40
|
+
export type { DesignFormOptions, DesignFormSchema, } from './search/transformer';
|
|
41
|
+
export { formatNow, resolveDefaultValue } from './utils/default-value';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DesignTableTool } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 字段映射工具(从 vben 基座搬过来的真实实现,行为逐字保持一致)
|
|
4
|
+
*
|
|
5
|
+
* 统一模型:
|
|
6
|
+
* - 组件自身参数 extraParams = 路由参数(去 module/name)+ 上游 parentParams(推送优先)。
|
|
7
|
+
* - 渲染工具条时以组件自己的 extraParams 作为映射数据源(表达式写 `params.xxx`),
|
|
8
|
+
* 各组件可附加自有数据源(树形 `node`、表单/组合 `data`)。
|
|
9
|
+
* - 目标推送:navigate → 路由 query;add → 表单 extraParams(随保存下发后端)。
|
|
10
|
+
*
|
|
11
|
+
* 注意:表达式来自**设计端配置**,属于可信来源(与宿主同一口径),故用 `new Function` 动态求值。
|
|
12
|
+
*/
|
|
13
|
+
/** 执行映射表达式:以 scope 的键作为函数参数名求值(scope 为空 / 表达式为空返回 undefined) */
|
|
14
|
+
export declare function evaluateMappedExpress(express: string | undefined, scope: Record<string, any>): any;
|
|
15
|
+
/** 按 `tool.mappings` 求值生成目标参数;未配置映射返回空对象 */
|
|
16
|
+
export declare function buildMappedParams(tool: DesignTableTool, scope: Record<string, any>): Record<string, any>;
|
|
17
|
+
/**
|
|
18
|
+
* id 提取表达式求值(工具条「跳转/打开」目标组件需要 source-id 时用):
|
|
19
|
+
* 与字段映射同作用域,结果为空则返回 undefined(调用方据此决定不传 id)。
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildExpressId(tool: DesignTableTool, scope: Record<string, any>): any;
|
|
22
|
+
/**
|
|
23
|
+
* 组装组件自身 extraParams:路由参数(去掉 module/name)+ 上游 parentParams(推送优先)。
|
|
24
|
+
*
|
|
25
|
+
* 这是「参数从哪来」的统一口径 —— 以前散在 vben 各组件里,抽包后集中在这里,
|
|
26
|
+
* 宿主只要按需传入 routeParams / parentParams。
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildExtraParams(routeParams?: Record<string, any>, parentParams?: Record<string, any>): Record<string, any>;
|
|
29
|
+
/**
|
|
30
|
+
* 判断组件是否位于自己的路由页:路由路径以 `/category/name` 结尾。
|
|
31
|
+
*
|
|
32
|
+
* 独立路由页(`/design/table/xxx/yyy` 或动态菜单 `.../table/xxx/yyy`)→ true,可并入路由参数;
|
|
33
|
+
* 被其他组件打开/内嵌(抽屉、弹窗、组合视图 Tab、树形关联目标)→ false,
|
|
34
|
+
* extraParams 只来自 parentParams。
|
|
35
|
+
*
|
|
36
|
+
* (宿主里这段叫 `isOwnRoutePage`,在 `design-tools/src/mapping.ts`——那份与本库 `mapping.ts`
|
|
37
|
+
* 是同一组函数,迁到本库后宿主那份就只是重复实现,见 TODO P2-9。)
|
|
38
|
+
*/
|
|
39
|
+
export declare function isOwnRoutePage(routePath: string, category?: string, name?: string): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 部门列表(`parentId` 只取该父级下的直属子部门;`deptName` 为服务端过滤) */
|
|
2
|
+
export declare function deptList(params?: {
|
|
3
|
+
deptName?: string;
|
|
4
|
+
parentId?: number | string;
|
|
5
|
+
status?: string;
|
|
6
|
+
}): Promise<any[]>;
|
|
7
|
+
/** 取某个父级下的**直属子部门**(一层一取;根层 parentId=0) */
|
|
8
|
+
export declare function deptChildren(parentId?: number | string): Promise<any[]>;
|
|
9
|
+
/** 部门详情(回显/拼全名路径用) */
|
|
10
|
+
export declare function deptInfo(deptId: number | string): Promise<any>;
|
|
11
|
+
/** 取某父级下的**整棵子树**(403 回退通道,见 dept-tree-source) */
|
|
12
|
+
export declare function getDeptSubTree(parentId?: number | string): Promise<any[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 部门树懒加载的「取数源」装配(搬自宿主 `#/utils/dept-tree-source.ts`)
|
|
3
|
+
*
|
|
4
|
+
* 为什么要有这一层:
|
|
5
|
+
* - `/system/dept/list?parentId=<id>`:**真·只回一层**(最省),权限 `system:dept:list`;
|
|
6
|
+
* - `/system/user/deptTree?parentId=<id>`:回该父级下的**整棵子树**(服务端不省),但权限是
|
|
7
|
+
* `system:user:list` —— 与老「一次性取整棵树」的权限完全一致。
|
|
8
|
+
* 生产上角色权限不一定同时具备,所以优先用前者,**403 时自动回退**后者(只取返回子树的第一层),
|
|
9
|
+
* 避免「换了懒加载后某些角色看不到树」。回退会打 warn,便于发现权限没配好。
|
|
10
|
+
*/
|
|
11
|
+
import type { DeptNode, DeptTreeSource } from './dept-tree';
|
|
12
|
+
/** 归一:`/system/dept/list`(deptId/deptName) 与 `/system/user/deptTree`(id/label) 两种形状都吃 */
|
|
13
|
+
export declare function normalizeDeptNode(raw: any): DeptNode;
|
|
14
|
+
/** 造懒加载取数源(带 403 回退;treeData 变深由调用方 attachChildren 处理) */
|
|
15
|
+
export declare function createDeptTreeSource(): DeptTreeSource;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 部门树「异步加载」共享内核(纯逻辑,不 import 任何 api/组件,便于单测)。
|
|
3
|
+
*
|
|
4
|
+
* 背景:`/system/user/deptTree` 一次性返回整棵树(生产库 1000+ 节点),
|
|
5
|
+
* 系统页左树 / 低代码表单的组织选择器打开即全量渲染会有明显卡顿,改为**按层懒加载**:
|
|
6
|
+
* - 一层一取:`/system/dept/list?parentId=<id>`(后端已支持 parentId 过滤)
|
|
7
|
+
* - 回显:只有 id 时用 `/system/dept/{id}` 逐级向上拼「A / B / C」全名(带缓存)
|
|
8
|
+
* - 搜索:本地没有全量树,改由调用方用服务端 `deptName` 过滤后交进来做平铺展示
|
|
9
|
+
*
|
|
10
|
+
* 注意(依赖后端数据约定):根节点 `sys_dept.parent_id` 必须是 **0**(不能用 NULL),
|
|
11
|
+
* 否则第一层(parentId=0)就是空的 —— 2026-09-28 排查的 deptTree 返回 [] 正是这个原因。
|
|
12
|
+
*/
|
|
13
|
+
/** 后端部门节点最小字段(SysDeptVo 的子集,允许带业务扩展字段) */
|
|
14
|
+
export interface DeptNode {
|
|
15
|
+
deptId: number | string;
|
|
16
|
+
deptName: string;
|
|
17
|
+
parentId: number | string | null;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
/** 异步取数接口(由调用方注入,便于测试与复用) */
|
|
21
|
+
export interface DeptTreeSource {
|
|
22
|
+
/** 取某父级下的直属子部门;根层 parentId=0 */
|
|
23
|
+
loadChildren: (parentId: number | string) => Promise<DeptNode[]>;
|
|
24
|
+
/** 取单个部门(回显/拼全名路径用);取不到返回 undefined */
|
|
25
|
+
loadNode: (deptId: number | string) => Promise<DeptNode | undefined>;
|
|
26
|
+
}
|
|
27
|
+
/** 树节点(antd Tree 消费的形态) */
|
|
28
|
+
export interface DeptTreeNode {
|
|
29
|
+
key: string;
|
|
30
|
+
title: string;
|
|
31
|
+
/** 已知没有子节点时置 true(未取过则 undefined:保留展开箭头,取回空列表后由缓存纠偏) */
|
|
32
|
+
isLeaf?: boolean;
|
|
33
|
+
children?: DeptTreeNode[];
|
|
34
|
+
/** 原始部门数据(选中时取 id / 派生取值用) */
|
|
35
|
+
raw: DeptNode;
|
|
36
|
+
}
|
|
37
|
+
/** parentId 归一:null/''/'0'/0 → '0'(RuoYi 根层口径) */
|
|
38
|
+
export declare function normalizeParentId(parentId: null | number | string | undefined): string;
|
|
39
|
+
export declare function toTreeNode(dept: DeptNode, isLeaf?: boolean): DeptTreeNode;
|
|
40
|
+
/**
|
|
41
|
+
* 不可变地把 children 挂到指定 key 的节点上(antd Tree 懒加载用;返回新数组触发响应式)
|
|
42
|
+
* 找不到该 key 时原样返回(不改引用)。
|
|
43
|
+
*/
|
|
44
|
+
export declare function attachChildren(nodes: DeptTreeNode[] | undefined, key: number | string, children: DeptTreeNode[]): DeptTreeNode[];
|
|
45
|
+
/**
|
|
46
|
+
* 懒加载部门树:一层一取 + 缓存 + 在途请求合并 + 全名路径解析。
|
|
47
|
+
* 同一个 parentId 重复调用不会重复请求(除非 force)。
|
|
48
|
+
*/
|
|
49
|
+
export declare function createLazyDeptTree(source: DeptTreeSource): {
|
|
50
|
+
childrenOf: (parentId: number | string, force?: boolean) => Promise<DeptNode[]>;
|
|
51
|
+
treeNodesOf: (parentId: number | string, force?: boolean) => Promise<DeptTreeNode[]>;
|
|
52
|
+
nodeOf: (deptId: number | string) => Promise<DeptNode | undefined>;
|
|
53
|
+
pathOf: (deptId: number | string) => Promise<{
|
|
54
|
+
chain: DeptNode[];
|
|
55
|
+
fullName: string;
|
|
56
|
+
node?: DeptNode;
|
|
57
|
+
}>;
|
|
58
|
+
searchNodes: (list: DeptNode[]) => Promise<DeptTreeNode[]>;
|
|
59
|
+
cachedLeaf: (parentId: number | string) => boolean | undefined;
|
|
60
|
+
clear: () => void;
|
|
61
|
+
readonly size: number;
|
|
62
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 自定义组件注册表(宿主注入)
|
|
4
|
+
*
|
|
5
|
+
* 背景:设计端配置里,自定义组件是用 **comname 字符串**引用的
|
|
6
|
+
* (`edit.type === 'hcm'`、`tool.type === 'hcm-tool'`、行操作 `action.comname`、表单 `type: 'my'`)。
|
|
7
|
+
* 这些组件属于**业务项目**,不能长在本库里,所以:
|
|
8
|
+
*
|
|
9
|
+
* 宿主启动时 `registerComponents({ comname: loader })` → 本库用 comname 查表渲染。
|
|
10
|
+
*
|
|
11
|
+
* 三个刻意的设计决定:
|
|
12
|
+
* 1. **键就是配置里的 comname,一个字都不能变**(数据库里存的是它);
|
|
13
|
+
* 2. 值是**懒加载器**,本库统一用 `defineAsyncComponent` 包一层 —— 组件本体不进首屏 bundle,
|
|
14
|
+
* 且加载中有占位、加载失败有明确提示(不是空白一片,现场最好排查);
|
|
15
|
+
* 3. 只有 `comname` 一条路,**不再支持按源码路径找组件**(旧 `import.meta.glob('/src/**')` 已废弃:
|
|
16
|
+
* 它把配置绑死在宿主的源码结构上,一重构就全废;线上发布快照里也没有这种用法)。
|
|
17
|
+
*/
|
|
18
|
+
/** 组件元信息(也用于「设计端可选项清单」与诊断页) */
|
|
19
|
+
export interface DesignComponentMeta {
|
|
20
|
+
/** comname(注册表键,与设计端配置里的一致) */
|
|
21
|
+
name: string;
|
|
22
|
+
/** 给人看的名字(设计端下拉、诊断页用) */
|
|
23
|
+
title?: string;
|
|
24
|
+
/** 适用的宿主插槽,如 ['form-field'] / ['row-action'] / ['table-cell'] / ['toolbar'] / ['views'] */
|
|
25
|
+
slots?: string[];
|
|
26
|
+
/** 弹窗类组件的默认宽度(px),省得业务组件里再写一遍 */
|
|
27
|
+
modalWidth?: number | string;
|
|
28
|
+
}
|
|
29
|
+
/** 懒加载器:`() => import('...')` */
|
|
30
|
+
export type DesignComponentLoader = () => Promise<any> | any;
|
|
31
|
+
export interface DesignComponentEntry extends Omit<DesignComponentMeta, 'name'> {
|
|
32
|
+
loader: DesignComponentLoader;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 注册(可多次调用、支持增量)。同 comname 后注册的覆盖先前的。
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* registerComponents({
|
|
39
|
+
* 'employee-select': () => import('./form-field/employee-select/index.vue'),
|
|
40
|
+
* 'salary-issue': {
|
|
41
|
+
* loader: () => import('./row-action/salary-issue/index.vue'),
|
|
42
|
+
* title: '薪资发放',
|
|
43
|
+
* slots: ['row-action'],
|
|
44
|
+
* modalWidth: 1000,
|
|
45
|
+
* },
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function registerComponents(map: Record<string, DesignComponentEntry | DesignComponentLoader>): void;
|
|
50
|
+
/** 是否已注册 */
|
|
51
|
+
export declare function hasDesignComponent(name: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* 按 comname 取组件(异步包装过)。未注册返回 undefined ——
|
|
54
|
+
* 需要"必须存在"语义时用 `requireDesignComponent()`。
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveDesignComponent(name: string): Component | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* 按 comname 取组件,未注册直接抛错(错误信息里带插槽名,便于定位是哪种配置写错了)。
|
|
59
|
+
* 五类插槽(表单单元格 / 自定义列 / 工具条 / 行操作弹窗 / 整页)都走它,
|
|
60
|
+
* 保证"没注册"这件事在控制台和页面上是同一个说法。
|
|
61
|
+
*/
|
|
62
|
+
export declare function requireDesignComponent(name: string, slot?: string): Component;
|
|
63
|
+
/** 已注册清单(诊断 / 启动日志用;不是设计端的选项来源,见 buildComponentsManifest 说明) */
|
|
64
|
+
export declare function listDesignComponents(): DesignComponentMeta[];
|
|
65
|
+
/**
|
|
66
|
+
* 生成「已注册组件」的清单(JSON 可序列化,诊断 / 自检用)。
|
|
67
|
+
*
|
|
68
|
+
* ⚠ 2026-10-27 拍板:**不再用清单给设计端下发**(原方案是宿主落成
|
|
69
|
+
* `public/ext-components.json` 或后端 `GET /design/extComponents`,design-ui 读它)。
|
|
70
|
+
* 现在设计端的 comname 是**手填**,真源是宿主工程的注册表文件本身
|
|
71
|
+
* (见工作区 `documents/comname-contract.md`)。本函数只用于诊断页、启动日志与自检,
|
|
72
|
+
* 不要拿它当"设计端选项来源"。
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildComponentsManifest(): {
|
|
75
|
+
components: DesignComponentMeta[];
|
|
76
|
+
version: 1;
|
|
77
|
+
};
|
|
78
|
+
/** 仅测试用 */
|
|
79
|
+
export declare function clearDesignComponents(): void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { SearchFieldCell, SearchFormConfig } from '../types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** 模块分类 */
|
|
4
|
+
category?: string;
|
|
5
|
+
/** 配置名称 */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** 直接传入配置(可选,跳过 API 请求),{cells:[[]]} 或二维数组 */
|
|
8
|
+
config?: SearchFormConfig | SearchFieldCell[][] | null;
|
|
9
|
+
/** label 宽度:'auto' 或像素值 */
|
|
10
|
+
labelWidth?: string | number;
|
|
11
|
+
/** 查询时是否过滤空值 */
|
|
12
|
+
filterEmpty?: boolean;
|
|
13
|
+
/** 是否显示查询/重置按钮 */
|
|
14
|
+
showActions?: boolean;
|
|
15
|
+
/** dev 悬浮按钮距容器顶部距离(px);嵌套在其它设计组件内时下移,避免与父组件按钮重叠 */
|
|
16
|
+
devButtonTop?: number;
|
|
17
|
+
};
|
|
18
|
+
declare function getValues(): Record<string, any>;
|
|
19
|
+
declare function getQueryValues(): Record<string, any>;
|
|
20
|
+
declare function setValues(values: Record<string, any>): void;
|
|
21
|
+
declare function handleQuery(): void;
|
|
22
|
+
declare function handleReset(): void;
|
|
23
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {
|
|
24
|
+
getQueryValues: typeof getQueryValues;
|
|
25
|
+
getValues: typeof getValues;
|
|
26
|
+
handleQuery: typeof handleQuery;
|
|
27
|
+
handleReset: typeof handleReset;
|
|
28
|
+
setValues: typeof setValues;
|
|
29
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
30
|
+
change: (values: Record<string, any>) => any;
|
|
31
|
+
reset: () => any;
|
|
32
|
+
query: (values: Record<string, any>) => any;
|
|
33
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
34
|
+
onChange?: ((values: Record<string, any>) => any) | undefined;
|
|
35
|
+
onReset?: (() => any) | undefined;
|
|
36
|
+
onQuery?: ((values: Record<string, any>) => any) | undefined;
|
|
37
|
+
}>, {
|
|
38
|
+
name: string;
|
|
39
|
+
config: SearchFormConfig | SearchFieldCell[][] | null;
|
|
40
|
+
labelWidth: string | number;
|
|
41
|
+
category: string;
|
|
42
|
+
devButtonTop: number;
|
|
43
|
+
filterEmpty: boolean;
|
|
44
|
+
showActions: boolean;
|
|
45
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
46
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SearchFieldCell } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 查询表单配置 → 表单 schema(搬自宿主 `design-search/src/transformer.ts`)
|
|
4
|
+
*
|
|
5
|
+
* 迁移时只改类型:`VbenFormSchema` / `VbenFormProps` 来自 `#/adapter/form` 与 `@vben/common-ui`,
|
|
6
|
+
* 都是 vben 源码导出(不能进 .d.ts,见 host.ts 文件头)⇒ 这里用结构化宽类型。
|
|
7
|
+
* 产出的对象形状与 vben 的 `VbenFormProps` 一致,宿主原样丢给表单组件即可。
|
|
8
|
+
*/
|
|
9
|
+
/** vben 表单字段 schema 的**最小结构**(只声明我们真正产出的字段,其余交给宿主类型) */
|
|
10
|
+
export interface DesignFormSchema {
|
|
11
|
+
component: string;
|
|
12
|
+
componentProps?: Record<string, any>;
|
|
13
|
+
defaultValue?: any;
|
|
14
|
+
fieldName: string;
|
|
15
|
+
label: string;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
/** vben 表单配置的最小结构 */
|
|
19
|
+
export interface DesignFormOptions {
|
|
20
|
+
commonConfig?: Record<string, any>;
|
|
21
|
+
schema: DesignFormSchema[];
|
|
22
|
+
wrapperClass?: string;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 兼容多种后端返回结构:
|
|
27
|
+
* - `{cells: [[...]]}`(sform 接口)
|
|
28
|
+
* - 直接二维数组 `[[...]]`
|
|
29
|
+
* - 扁平数组 `[...]`(包装成单行)
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeSearchCells(resp: any): SearchFieldCell[][];
|
|
32
|
+
/**
|
|
33
|
+
* 将查询表单配置转换为 vben 查询表单配置(与角色管理等标准列表页风格一致)。
|
|
34
|
+
* 接受 sform 接口原始响应或二维数组。
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildSearchFormOptions(resp: any): DesignFormOptions;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { TableDataResponse } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 表格取数(从宿主 `components/design/api.ts` 的 `fetchTableData` 搬入)
|
|
4
|
+
*
|
|
5
|
+
* 与宿主的差别只有一处:宿主直接用自己的 alova 实例,这里走**注入的 http**
|
|
6
|
+
* (见 http.ts 顶部说明:库里绝不能自建请求实例,否则没有登录态、也没宿主的 401 处理)。
|
|
7
|
+
*
|
|
8
|
+
* 请求体契约(后端 `SelectBean`)见 `buildTableDataBody`:
|
|
9
|
+
* - `search` = 查询表单/查询页传进来的值(**只供动作条件 `${search.x}` 取值,后端不再自动按列过滤**)
|
|
10
|
+
* - `params` = 表达式 env = 组件自身参数(extraParams)+ 列表「查询参数」
|
|
11
|
+
* - `pageNo` 后端真正读的分页字段(`pageNum` 仅为兼容保留)
|
|
12
|
+
*
|
|
13
|
+
* `silent: true` 是硬要求:表格一次翻页会并发多条取数,让宿主每条都弹一次 toast 是不可接受的
|
|
14
|
+
* (见 documents/TODO.md 里 DesignRequestOptions.silent 的约定)。
|
|
15
|
+
*/
|
|
16
|
+
export interface FetchTableDataParams {
|
|
17
|
+
/** 列表基本信息里配的「查询参数」:只并入请求体 params(见 buildTableDataBody) */
|
|
18
|
+
configParams?: Record<string, any>;
|
|
19
|
+
/**
|
|
20
|
+
* 组件自身参数(路由参数 + 上游 parentParams)→ 只并入请求体 `params`(表达式 env),
|
|
21
|
+
* **不进 `search`**(2026-09-29 口径修正:进去会按列别名意外过滤,详见 buildQuerySearch)
|
|
22
|
+
*/
|
|
23
|
+
envParams?: Record<string, any>;
|
|
24
|
+
pageNum: number;
|
|
25
|
+
pageSize: number;
|
|
26
|
+
search?: Record<string, any>;
|
|
27
|
+
/** 取消(翻页/换页签时应当中断上一次取数) */
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
export declare function fetchTableData(url: string, params: FetchTableDataParams): Promise<TableDataResponse>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格(design-table)纯逻辑层
|
|
3
|
+
*
|
|
4
|
+
* 为什么先搬这些而不是先搬 `.vue`:
|
|
5
|
+
* - 这些是「配置 → 请求体 / vxe 配置」的转换规则,是设计端与后端之间的**契约实现**,
|
|
6
|
+
* 最容易在复制粘贴中悄悄漂移,也最容易单测(见 scripts/test-table-logic.mjs);
|
|
7
|
+
* - 组件层(design-table.vue 等)依赖宿主的 vxe 适配、路由、图标、弹窗,迁移成本高一个量级,
|
|
8
|
+
* 见 documents/TODO.md 的 P2-9。
|
|
9
|
+
*/
|
|
10
|
+
export { fetchTableData } from './data';
|
|
11
|
+
export type { FetchTableDataParams } from './data';
|
|
12
|
+
export { buildQuerySearch } from './query-search';
|
|
13
|
+
export { buildTableDataBody, parseConfigParams } from './query-body';
|
|
14
|
+
export { evaluateLoadGate } from './load-gate';
|
|
15
|
+
export type { LoadGateResult } from './load-gate';
|
|
16
|
+
export { createQueryDedupe } from './query-dedupe';
|
|
17
|
+
export type { QueryDedupe, QueryDedupeOptions, QueryDedupeStats, } from './query-dedupe';
|
|
18
|
+
export { buildCustomParams, buildNavigateQuery, evaluateExpress, } from './row-action-mapping';
|
|
19
|
+
export { transformTableConfig } from './transformer';
|
|
20
|
+
export type { TransformHost, TransformTableResult } from './transformer';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 列表「数据加载条件」求值(搬自宿主 `components/design/design-runtime/load-gate.ts`)
|
|
3
|
+
*
|
|
4
|
+
* 配置位置:列表 `extra_config` 的 `query.when`(字符串表达式),作用域只有两个:
|
|
5
|
+
* - `search`:查询表单当前值(第一次加载时是默认值)
|
|
6
|
+
* - `params`:组件自身参数(含配置的查询参数)
|
|
7
|
+
*
|
|
8
|
+
* 与行操作 mappings 用同一套 JS 表达式写法(`new Function`),只是这里结果按布尔用。
|
|
9
|
+
*
|
|
10
|
+
* 求值策略(刻意这么定):
|
|
11
|
+
* - 表达式为空 → 视为「不门禁」,放行;
|
|
12
|
+
* - 求值抛错(语法错/引用了不存在的变量导致异常)→ **拦截**,并返回错误信息。
|
|
13
|
+
* 放行会变成「静默加载全量数据」,比不加载更危险;拦截至少看得见提示。
|
|
14
|
+
*/
|
|
15
|
+
export interface LoadGateResult {
|
|
16
|
+
/** 表达式本身有问题时的原因(调用方可以展示出来,便于设计者排查) */
|
|
17
|
+
error?: string;
|
|
18
|
+
/** 是否允许加载 */
|
|
19
|
+
ok: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function evaluateLoadGate(expression: null | string | undefined, scope: {
|
|
22
|
+
params?: Record<string, any>;
|
|
23
|
+
search?: Record<string, any>;
|
|
24
|
+
}): LoadGateResult;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格取数请求体的组装(纯函数、无三方依赖 —— 便于单测,见 scripts/test-table-logic.mjs)。
|
|
3
|
+
*
|
|
4
|
+
* 后端契约(`ruoyi-vue-plus-5-demo`,权威):
|
|
5
|
+
* 表格的 url 由 `ModuleGenerater` 固定生成为 `{module}/{code}/pager`,
|
|
6
|
+
* 对应 `DesignDataController` 的 `POST /{moduleName}/{code}/pager`,
|
|
7
|
+
* 用 `@RequestBody org.dromara.design.bean.SelectBean` 绑定。字段含义:
|
|
8
|
+
*
|
|
9
|
+
* - `search` —— **查询表单/查询页传进来的值**:后端**不再**拿它自动按列别名拼 WHERE
|
|
10
|
+
* (2026-09-29 口径修正:`ListProcesser`/`PagerProcesser` 里那段自动过滤已删除 —— 设计者没配过的键
|
|
11
|
+
* 也会静默多出一个过滤条件,实测把查询页传的 `name=1` 变成 `and name = ?`、数据被意外过滤)。
|
|
12
|
+
* 它现在**只**作为表达式 env(见下)供**动作条件**取值,如 `jobClass = search.code`。
|
|
13
|
+
* - `params` —— **表达式 env**:`envs.put("params", ...)`,给配置里 `${params.x}` 这类条件用。
|
|
14
|
+
* (与 search 是两套语义,不要混为一谈)
|
|
15
|
+
* - `pageNo` / `pageSize` —— 分页:`PagerProcesser` / `ListProcesser` 走 `buildPageSql(..., getPageNo(), getPageSize())`。
|
|
16
|
+
* - `id` —— 单条语义(本接口的列表取数不用)。
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* 组装表格取数请求体。
|
|
20
|
+
*
|
|
21
|
+
* 分页字段**同时下发 `pageNo` 与 `pageNum`**:
|
|
22
|
+
* - `pageNo` 是 SelectBean 的字段,后端真正读它;
|
|
23
|
+
* 此前只发 `pageNum` ⇒ `pageNo` 恒为默认值 1 ⇒ **翻页被忽略,第 2 页仍返回第 1 页数据**。
|
|
24
|
+
* - `pageNum` 一并保留:兼容 url 被手工改成标准 RuoYi 分页接口(`PageQuery` 读 `pageNum`)的配置。
|
|
25
|
+
*
|
|
26
|
+
* `configParams`(列表基本信息里配的「查询参数」)**只并入 `params`**、不进 `search`:
|
|
27
|
+
* 设计者写的是表达式环境的常量(如 `{"deptId":100}`),不是要拼进 WHERE 的条件;
|
|
28
|
+
* 同名键**以配置为准**(配置是设计者写死的强制约束),运行时参数排在后面被覆盖。
|
|
29
|
+
*
|
|
30
|
+
* 【2026-09-29 口径修正】**`search` 与 `params` 彻底分开**:
|
|
31
|
+
* search = 查询条件(页面 search + 查询表单值,见 buildQuerySearch)
|
|
32
|
+
* params = 表达式 env(组件自身参数 envParams + 配置的 configParams)
|
|
33
|
+
* 旧实现把整份 search 也并进了 params ⇒ 「查询表单的值」会出现在 params 里(语义混淆,
|
|
34
|
+
* 且上游参数被塞进 search 造成意外过滤)。现在两者各走各的,需要 `${params.x}` 取查询表单值的配置
|
|
35
|
+
* 应改为「按列别名的 search 过滤」,或把该值作为组件参数/「查询参数」下发。
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildTableDataBody(pageNum: number, pageSize: number, search?: Record<string, any> | null, configParams?: Record<string, any> | null, envParams?: Record<string, any> | null): Record<string, any>;
|
|
38
|
+
/**
|
|
39
|
+
* 解析列表配置里的「查询参数」为对象(config.queryParams,后端 query_params)。
|
|
40
|
+
*
|
|
41
|
+
* 容错口径(设计端/发布健康检查已各拦一道,这里只兜底,不抛错打断取数):
|
|
42
|
+
* - 空白 / null / undefined → `{}`
|
|
43
|
+
* - 已是对象(后端若直接反序列化成 Map 也能接)→ 原样返回(浅拷贝)
|
|
44
|
+
* - 字符串 → JSON.parse;解析失败、或结果不是对象(数组/数字/字符串/null)→ `{}` + console.warn
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseConfigParams(raw: null | Record<string, any> | string | undefined): Record<string, any>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 自动重建后的重复取数抑制(纯逻辑,便于单测,见 scripts/test-table-logic.mjs)。
|
|
3
|
+
*
|
|
4
|
+
* 背景:design-table 在「配置替换 / 表格高度实测 / 流程列追加」时会自增 gridKey,
|
|
5
|
+
* 让 vxe-grid 重建(列原地重排会触发 insertBefore,必须重建)。新实例挂载时
|
|
6
|
+
* proxyConfig 会再自动取一次同参数数据 —— 表现为点开一个页签后
|
|
7
|
+
* pager 请求两次、flowData/status 也两次。
|
|
8
|
+
*
|
|
9
|
+
* 方案:重建前 markRebuild(),重建后到来的同 key 查询直接复用上一次结果:
|
|
10
|
+
* - 上一次请求仍在进行中 → 共享同一个 Promise(flowData/status 也只发一次)
|
|
11
|
+
* - 上一次请求已完成 → 复用其结果对象
|
|
12
|
+
* 另外,任何时刻的「同 key 并发请求」都合并(同参数读接口重复请求恒为冗余)。
|
|
13
|
+
* 窗口期外、或 key 不同(翻页/排序/查询条件变了)则照常发请求。
|
|
14
|
+
* 用户显式刷新(工具条刷新按钮 / 外部 reload)前调用 reset() 可强制真实请求。
|
|
15
|
+
*/
|
|
16
|
+
export interface QueryDedupeOptions {
|
|
17
|
+
/** 重建后多久内到来的同参查询视为重复,默认 1500ms */
|
|
18
|
+
now?: () => number;
|
|
19
|
+
/** 可注入时钟(测试用),默认 Date.now */
|
|
20
|
+
windowMs?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface QueryDedupeStats {
|
|
23
|
+
/** 实际发起请求的次数 */
|
|
24
|
+
fetched: number;
|
|
25
|
+
/** 命中进行中请求并共享 Promise 的次数 */
|
|
26
|
+
merged: number;
|
|
27
|
+
/** 命中已完成结果并复用数据的次数 */
|
|
28
|
+
reused: number;
|
|
29
|
+
}
|
|
30
|
+
export interface QueryDedupe {
|
|
31
|
+
/** 计数快照(开发面板可读) */
|
|
32
|
+
getStats: () => QueryDedupeStats;
|
|
33
|
+
/** 当前是否处在「自动重建后的去重窗口」内 */
|
|
34
|
+
isDedupeWindow: () => boolean;
|
|
35
|
+
/** gridKey 自增前调用:标记发生了一次自动重建 */
|
|
36
|
+
markRebuild: () => void;
|
|
37
|
+
/** 显式刷新前调用:关闭去重窗口,保证真实请求 */
|
|
38
|
+
reset: () => void;
|
|
39
|
+
/** 执行一次查询:命中重复则复用,否则调用 factory */
|
|
40
|
+
run: <T>(key: string, factory: () => Promise<T>) => Promise<T>;
|
|
41
|
+
}
|
|
42
|
+
export declare function createQueryDedupe(options?: QueryDedupeOptions): QueryDedupe;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格取数**查询条件**的组装(纯函数,无组件/三方依赖 —— 便于单测,
|
|
3
|
+
* 见 scripts/test-table-logic.mjs)。
|
|
4
|
+
*
|
|
5
|
+
* 产出交给 `fetchTableData` 作为请求体的 `search`。**注意后端口径(2026-09-29 修正)**:
|
|
6
|
+
* `search` 不再被自动按列别名拼成 WHERE,它只是**动作条件的取值来源**(`${search.x}`,如 `jobClass = search.code`);
|
|
7
|
+
* 要不要过滤、过滤哪一列,由设计者在动作条件里显式写。请求体的 `params`(表达式 env)不在这里产出,
|
|
8
|
+
* 见 query-body.ts 的 buildTableDataBody。
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 组装取数用的 `search`(查询表单/查询页的值)。
|
|
12
|
+
*
|
|
13
|
+
* 优先级(后者覆盖前者,同名键):
|
|
14
|
+
* 1. pageSearch 页面显式传入的查询条件(如 DesignSearch 点「查询」后的值)
|
|
15
|
+
* 2. formValues 表格自身绑定的查询表单值(config.searchForm,vben 代理查询注入)
|
|
16
|
+
*
|
|
17
|
+
* 【2026-09-29 口径修正】**不再并入组件自身参数(extraParams)**:
|
|
18
|
+
* 它是**页面上下文**(自己的路由参数 + 上游 parentParams),混进来会让请求体里出现设计者没打算要的键;
|
|
19
|
+
* extraParams 现在只进请求体的 `params`(表达式 env)。
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildQuerySearch(pageSearch?: null | Record<string, any>, formValues?: null | Record<string, any>): Record<string, any>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RowActionMapping } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 行操作「跳转 / 弹窗」动作的映射工具(从宿主 design-table/src/row-actions/mapping.ts 搬入)。
|
|
4
|
+
*
|
|
5
|
+
* `mappings: [{ paramName, express }]`,表示式作用域为 `{ params, row }`:
|
|
6
|
+
* - params:当前表格参数(外部注入的 extraParams / 路由 query)
|
|
7
|
+
* - row:当前行数据
|
|
8
|
+
*
|
|
9
|
+
* 表达式求值复用 `mapping.ts` 的 `evaluateMappedExpress`(同一套 `new Function` 口径,
|
|
10
|
+
* 作用域就是 `{ params, row }` 两个键 ⇒ 与旧实现的 `new Function('params','row', …)` 等价)。
|
|
11
|
+
*/
|
|
12
|
+
/** 执行映射表达式(字符串 JS 表达式),作用域注入 params、row。 */
|
|
13
|
+
export declare function evaluateExpress(express: string | undefined, params: Record<string, any>, row: Record<string, any>): any;
|
|
14
|
+
/**
|
|
15
|
+
* 「弹窗自定义组件」用的参数映射(2026-10-21)
|
|
16
|
+
*
|
|
17
|
+
* 与 {@link buildNavigateQuery} 的区别:那是**路由 query**,值必须字符串化(`String(val)`);
|
|
18
|
+
* 这里是直接交给扩展包组件的 `params`,要**保留原值** —— 设计者配 `表达式=row` 时,
|
|
19
|
+
* 组件应该拿到整个对象,而不是 `"[object Object]"`。
|
|
20
|
+
*
|
|
21
|
+
* 同样没有兜底:没配 mappings 就返回 `{}`,不自动塞 row / id。
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildCustomParams(mappings: RowActionMapping[] | undefined, params: Record<string, any>, row: Record<string, any>): Record<string, any>;
|
|
24
|
+
/**
|
|
25
|
+
* 根据 mappings 生成跳转 query 参数。
|
|
26
|
+
*
|
|
27
|
+
* **没有任何兜底**(2026-10-21 用户口径:"没配 mappings 时不需要任何参数,不要有兜底"):
|
|
28
|
+
* - 配了 mappings → 按 express 求值映射为 paramName 参数;
|
|
29
|
+
* - 没配 mappings → 返回 `{}`,目标视图一个参数都收不到。
|
|
30
|
+
*
|
|
31
|
+
* 以前这里在 mappings 为空时回退成 `{ id: row[pfield] }`,结果「跳转到列表」这类动作凭空带上
|
|
32
|
+
* `id=33333`,目标页把它当 extraParams 塞进请求体 —— 属于设计者没配的参数。
|
|
33
|
+
* 现在要传行 id 就在设计端显式配一条映射(paramName=id / express=row.id);
|
|
34
|
+
* 「跳转表单 / 弹窗表单」同理:不配 id 映射就打开一张新表单,不再隐式按行 id 打开记录。
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildNavigateQuery(mappings: RowActionMapping[] | undefined, params: Record<string, any>, row: Record<string, any>, _pfield?: string): Record<string, string>;
|