@ys-knife-crud/vue 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/README.md +234 -0
- package/dist/index.cjs +1318 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +663 -0
- package/dist/index.d.ts +663 -0
- package/dist/index.js +1279 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
import * as ys_knife_query_js from 'ys.knife.query.js';
|
|
2
|
+
import { FilterInfo, Operator } from 'ys.knife.query.js';
|
|
3
|
+
import * as vue from 'vue';
|
|
4
|
+
import { Ref, Component, InjectionKey } from 'vue';
|
|
5
|
+
import * as _ys_knife_crud_core from '@ys-knife-crud/core';
|
|
6
|
+
import { DefaultProps, Meta, PagedList, Action, RowActionsProps, CustomConfigProps, CustomColumnConfig, CustomConfig, DraftColumn, PageFunc, ExportApiFunc, Column, ExportOption, ExportScope, DataColumn, ImportProcessor, ImportParser, ImportRow, ImportProcessSummary, FunctionNode, MainPanelProps, FilterItemApi, EnumOptionsSource, AdvancedCombinator, AdvancedOperator, AdvancedConditionGroup, AdvancedFieldType, AdvancedCondition, isConditionGroup } from '@ys-knife-crud/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 表格的默认状态与数据加载逻辑:列元数据、分页数据、当前页行数据、
|
|
10
|
+
* 两类加载态、当前页码,以及由 paged 派生的总条数、加载列元数据的动作。
|
|
11
|
+
*
|
|
12
|
+
* 刻意不处理任何依赖「当前生效每页条数」的逻辑:加载数据(loadData 的
|
|
13
|
+
* offset/limit)、是否显示分页组件(showPagination 的阈值)、pageSize/dataFun
|
|
14
|
+
* 变化时的重新加载——这些都依赖调用方视图层解析出的 innerPageSize(在
|
|
15
|
+
* element-plus 适配层中是「列设置对话框保存的默认值 ?? props.pageSize」),
|
|
16
|
+
* 留在调用方组件中,避免本 composable 耦合视图层的分页大小解析策略。
|
|
17
|
+
*
|
|
18
|
+
* 本 composable 只注册一个监听:props.metaFun 变化 → 重新加载 meta。
|
|
19
|
+
*
|
|
20
|
+
* @param props 含 metaFun(对齐 core 的 DefaultProps;其余成员本 composable 不直接消费)
|
|
21
|
+
*/
|
|
22
|
+
declare function useDefault(props: DefaultProps): {
|
|
23
|
+
meta: vue.Ref<{
|
|
24
|
+
displayName: string;
|
|
25
|
+
description: string | null;
|
|
26
|
+
columns: {
|
|
27
|
+
propertyPath: string;
|
|
28
|
+
displayName?: string | undefined;
|
|
29
|
+
description?: string | null | undefined;
|
|
30
|
+
showForDisplay?: boolean | undefined;
|
|
31
|
+
displayFormat?: string | null | undefined;
|
|
32
|
+
isArray?: boolean | undefined;
|
|
33
|
+
dataTypeName?: string | undefined;
|
|
34
|
+
displayOrder?: number | undefined;
|
|
35
|
+
dataSource?: unknown | null;
|
|
36
|
+
queryFilter?: unknown | null;
|
|
37
|
+
render?: ((row: unknown, value: unknown) => unknown) | undefined;
|
|
38
|
+
width?: string | undefined;
|
|
39
|
+
}[];
|
|
40
|
+
} | null, Meta | {
|
|
41
|
+
displayName: string;
|
|
42
|
+
description: string | null;
|
|
43
|
+
columns: {
|
|
44
|
+
propertyPath: string;
|
|
45
|
+
displayName?: string | undefined;
|
|
46
|
+
description?: string | null | undefined;
|
|
47
|
+
showForDisplay?: boolean | undefined;
|
|
48
|
+
displayFormat?: string | null | undefined;
|
|
49
|
+
isArray?: boolean | undefined;
|
|
50
|
+
dataTypeName?: string | undefined;
|
|
51
|
+
displayOrder?: number | undefined;
|
|
52
|
+
dataSource?: unknown | null;
|
|
53
|
+
queryFilter?: unknown | null;
|
|
54
|
+
render?: ((row: unknown, value: unknown) => unknown) | undefined;
|
|
55
|
+
width?: string | undefined;
|
|
56
|
+
}[];
|
|
57
|
+
} | null>;
|
|
58
|
+
paged: vue.Ref<{
|
|
59
|
+
limit: number;
|
|
60
|
+
offset: number;
|
|
61
|
+
totalCount?: number | null | undefined;
|
|
62
|
+
hasNext: boolean;
|
|
63
|
+
aggs?: (ys_knife_query_js.AggResult | null) | undefined;
|
|
64
|
+
items: unknown[];
|
|
65
|
+
} | null, PagedList<unknown> | {
|
|
66
|
+
limit: number;
|
|
67
|
+
offset: number;
|
|
68
|
+
totalCount?: number | null | undefined;
|
|
69
|
+
hasNext: boolean;
|
|
70
|
+
aggs?: (ys_knife_query_js.AggResult | null) | undefined;
|
|
71
|
+
items: unknown[];
|
|
72
|
+
} | null>;
|
|
73
|
+
rows: vue.ComputedRef<Record<string, unknown>[]>;
|
|
74
|
+
metaLoading: vue.Ref<boolean, boolean>;
|
|
75
|
+
dataLoading: vue.Ref<boolean, boolean>;
|
|
76
|
+
currentPage: vue.Ref<number, number>;
|
|
77
|
+
total: vue.ComputedRef<number>;
|
|
78
|
+
totalKnown: vue.ComputedRef<boolean>;
|
|
79
|
+
loadMeta: (signal?: AbortSignal) => Promise<void>;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 该行可见的操作(action.show 缺省视为可见)。
|
|
84
|
+
* 纯函数:不依赖 composable 内部 state,供 RowActionsCell 等组件复用。
|
|
85
|
+
*/
|
|
86
|
+
declare function visibleActions(actions: Action<unknown>[], row: unknown): Action<unknown>[];
|
|
87
|
+
/**
|
|
88
|
+
* 该操作对该行是否可用(action.enable 缺省视为可用)。
|
|
89
|
+
* 纯函数:供 RowActionsCell 等组件复用。
|
|
90
|
+
*/
|
|
91
|
+
declare function isEnabled(action: Action<unknown>, row: unknown): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* 行操作(Action)逻辑:加载行操作列表。
|
|
94
|
+
*
|
|
95
|
+
* 可见/禁用判断由 visibleActions / isEnabled 纯函数提供,
|
|
96
|
+
* 执行已下沉到 RowActionsCell 组件内部(直接调 Action.execute)。
|
|
97
|
+
*
|
|
98
|
+
* @param props 组件 props(只需 rowActionsFunc)
|
|
99
|
+
*/
|
|
100
|
+
declare function useRowActions(props: RowActionsProps): {
|
|
101
|
+
actions: vue.Ref<{
|
|
102
|
+
name: string;
|
|
103
|
+
desc: string;
|
|
104
|
+
icon?: unknown;
|
|
105
|
+
type?: _ys_knife_crud_core.ActionType | undefined;
|
|
106
|
+
show?: ((item: unknown) => boolean) | undefined;
|
|
107
|
+
enable?: ((item: unknown) => boolean) | undefined;
|
|
108
|
+
execute: (item: unknown, table: _ys_knife_crud_core.TableApi) => Promise<void>;
|
|
109
|
+
}[], Action<unknown>[] | {
|
|
110
|
+
name: string;
|
|
111
|
+
desc: string;
|
|
112
|
+
icon?: unknown;
|
|
113
|
+
type?: _ys_knife_crud_core.ActionType | undefined;
|
|
114
|
+
show?: ((item: unknown) => boolean) | undefined;
|
|
115
|
+
enable?: ((item: unknown) => boolean) | undefined;
|
|
116
|
+
execute: (item: unknown, table: _ys_knife_crud_core.TableApi) => Promise<void>;
|
|
117
|
+
}[]>;
|
|
118
|
+
actionsLoading: vue.Ref<boolean, boolean>;
|
|
119
|
+
loadActions: (signal?: AbortSignal) => Promise<void>;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 行选择(checkbox)逻辑:UI 库无关的跨页选中集合。
|
|
124
|
+
*
|
|
125
|
+
* 选中状态以 rowKey 为键保存在内部 Map 中(不依赖任何具体 UI 组件),
|
|
126
|
+
* 因此同一套状态可同时驱动:
|
|
127
|
+
* - 表格视图:el-table 的勾选列(受控模式——翻页后由 restoreSelection 恢复勾选);
|
|
128
|
+
* - 卡片视图:每张卡片上的 checkbox(isRowSelected / toggleRowSelection)。
|
|
129
|
+
*
|
|
130
|
+
* 两种视图切换、翻页、切换每页条数都不丢失累计选中。
|
|
131
|
+
*/
|
|
132
|
+
/** 适配 el-table 实例的最小结构(只用到选择相关的两个方法) */
|
|
133
|
+
interface SelectionTableLike {
|
|
134
|
+
clearSelection?: () => void;
|
|
135
|
+
toggleRowSelection?: (row: unknown, selected?: boolean) => void;
|
|
136
|
+
}
|
|
137
|
+
type RowRecord = Record<string, unknown>;
|
|
138
|
+
interface UseSelectionOptions {
|
|
139
|
+
/** el-table 实例引用;卡片视图下表格不挂载时为 null */
|
|
140
|
+
tableEl: Ref<SelectionTableLike | null>;
|
|
141
|
+
/** 当前页行数据(翻页后据此把累计选中恢复到 el-table 勾选态) */
|
|
142
|
+
rows: Ref<RowRecord[]>;
|
|
143
|
+
/** 行 key 字段名(与 el-table 的 row-key 一致) */
|
|
144
|
+
rowKey: Ref<string>;
|
|
145
|
+
}
|
|
146
|
+
declare function useSelection({ tableEl, rows, rowKey }: UseSelectionOptions): {
|
|
147
|
+
selectedRows: vue.ComputedRef<unknown[]>;
|
|
148
|
+
onSelectionChange: (selection: unknown[]) => void;
|
|
149
|
+
isRowSelected: (row: RowRecord) => boolean;
|
|
150
|
+
toggleRowSelection: (row: RowRecord, selected?: boolean) => void;
|
|
151
|
+
restoreSelection: () => Promise<void>;
|
|
152
|
+
clearSelection: () => void;
|
|
153
|
+
selectAllOnPage: () => void;
|
|
154
|
+
invertSelectionOnPage: () => void;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 列自定义配置逻辑:管理列的显隐、顺序、宽度以及用户默认分页大小,
|
|
159
|
+
* 并提供列设置面板的状态与操作。
|
|
160
|
+
*
|
|
161
|
+
* @param props 组件 props(只需 loadCustomConfigFun / saveCustomConfigFun)
|
|
162
|
+
* @param meta 列元数据 ref(用于获取 showForDisplay=true 的候选列)
|
|
163
|
+
*/
|
|
164
|
+
declare function useCustomConfig(props: Pick<CustomConfigProps, "loadCustomConfigFun" | "saveCustomConfigFun">, meta: Ref<Meta | null>): {
|
|
165
|
+
customConfigs: Ref<{
|
|
166
|
+
pageSize?: number | undefined;
|
|
167
|
+
columns: Record<string, CustomColumnConfig>;
|
|
168
|
+
}, CustomConfig | {
|
|
169
|
+
pageSize?: number | undefined;
|
|
170
|
+
columns: Record<string, CustomColumnConfig>;
|
|
171
|
+
}>;
|
|
172
|
+
customConfigLoading: Ref<boolean, boolean>;
|
|
173
|
+
defaultPageSize: Ref<number | undefined, number | undefined>;
|
|
174
|
+
configDialogVisible: Ref<boolean, boolean>;
|
|
175
|
+
draftColumns: Ref<{
|
|
176
|
+
propertyPath: string;
|
|
177
|
+
displayName: string;
|
|
178
|
+
visible: boolean;
|
|
179
|
+
width: string;
|
|
180
|
+
}[], DraftColumn[] | {
|
|
181
|
+
propertyPath: string;
|
|
182
|
+
displayName: string;
|
|
183
|
+
visible: boolean;
|
|
184
|
+
width: string;
|
|
185
|
+
}[]>;
|
|
186
|
+
columns: vue.ComputedRef<{
|
|
187
|
+
displayName: string;
|
|
188
|
+
width: string | undefined;
|
|
189
|
+
propertyPath: string;
|
|
190
|
+
description?: string | null;
|
|
191
|
+
showForDisplay?: boolean;
|
|
192
|
+
displayFormat?: string | null;
|
|
193
|
+
isArray?: boolean;
|
|
194
|
+
dataTypeName?: string;
|
|
195
|
+
displayOrder?: number;
|
|
196
|
+
dataSource?: unknown | null;
|
|
197
|
+
queryFilter?: unknown | null;
|
|
198
|
+
render?: (row: unknown, value: unknown) => unknown;
|
|
199
|
+
}[]>;
|
|
200
|
+
loadCustomConfigs: (signal?: AbortSignal) => Promise<void>;
|
|
201
|
+
updateDefaultPageSize: (size: number) => void;
|
|
202
|
+
updateColumnWidth: (propertyPath: string, width: number) => void;
|
|
203
|
+
openConfigDialog: () => void;
|
|
204
|
+
moveDraft: (index: number, delta: number) => void;
|
|
205
|
+
resetDraft: () => void;
|
|
206
|
+
saveConfigDialog: () => Promise<void>;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/** useExportExcel 需要从组件 props 中访问的成员 */
|
|
210
|
+
interface ExportProps {
|
|
211
|
+
readonly dataFun: PageFunc<unknown>;
|
|
212
|
+
readonly exportSelected: boolean;
|
|
213
|
+
readonly exportorFunc?: ExportApiFunc;
|
|
214
|
+
}
|
|
215
|
+
/** useExportExcel 的入参:组件内已有的响应式状态与工具函数 */
|
|
216
|
+
interface UseExportExcelOptions {
|
|
217
|
+
props: ExportProps;
|
|
218
|
+
/** 表名(用于 sheet 标识与导出文件名;undefined 时回退到「数据」/「导出数据」) */
|
|
219
|
+
tableName: Ref<string | undefined>;
|
|
220
|
+
/** 当前界面显示的列(已含 meta/customConfig 两层过滤与排序,导出与其所见即所得) */
|
|
221
|
+
columns: Ref<Column[]>;
|
|
222
|
+
/** 当前页行数据 */
|
|
223
|
+
currentRows: Ref<Record<string, unknown>[]>;
|
|
224
|
+
/** checkbox 列当前选中的行(跨页累计) */
|
|
225
|
+
selectedRows: Ref<unknown[]>;
|
|
226
|
+
/** 数据总条数 */
|
|
227
|
+
total: Ref<number>;
|
|
228
|
+
/** 导出所有时分页拉取的步长(独立于界面分页大小,避免用大页尺寸拖慢导出) */
|
|
229
|
+
exportPageSize: Ref<number>;
|
|
230
|
+
/** 是否还有下一页(决定「导出所有」选项是否出现) */
|
|
231
|
+
hasMorePage: Ref<boolean>;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* 导出 Excel 逻辑:范围选择对话框、逐页拉取边拉边写、进度与取消、
|
|
235
|
+
* 取消后的「保留部分文件 / 丢弃」流程。
|
|
236
|
+
*
|
|
237
|
+
* 组件只经 ExportApi 接口操作(renderHeader → renderRows → download/cancel),
|
|
238
|
+
* 不关心底层实现;未显式传 exportorFunc 时缺省使用 core 的控制台假实现
|
|
239
|
+
* (createConsoleExportApiFunc,只在控制台打日志、不产出文件),
|
|
240
|
+
* 真实导出由消费方注入(如 @ys-knife-crud/export-exceljs)。
|
|
241
|
+
*/
|
|
242
|
+
declare function useExportExcel({ props, tableName, columns, currentRows, selectedRows, total, exportPageSize, hasMorePage, }: UseExportExcelOptions): {
|
|
243
|
+
exportOptions: vue.ComputedRef<ExportOption[]>;
|
|
244
|
+
exportDialogVisible: Ref<boolean, boolean>;
|
|
245
|
+
exporting: Ref<boolean, boolean>;
|
|
246
|
+
exportFetched: Ref<number, number>;
|
|
247
|
+
exportTotal: Ref<number, number>;
|
|
248
|
+
exportTotalKnown: Ref<boolean, boolean>;
|
|
249
|
+
exportEtaSeconds: vue.ComputedRef<number | null>;
|
|
250
|
+
exportPercent: vue.ComputedRef<number>;
|
|
251
|
+
exportCancelledVisible: Ref<boolean, boolean>;
|
|
252
|
+
exportCancelledRows: Ref<number, number>;
|
|
253
|
+
onExportClick: () => void;
|
|
254
|
+
doExport: (scope: ExportScope) => Promise<void>;
|
|
255
|
+
cancelExport: () => void;
|
|
256
|
+
keepPartialExport: () => Promise<void>;
|
|
257
|
+
discardPartialExport: () => Promise<void>;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/** useImportExcel 入参(组件把 props 的相关字段以 Ref 形式传入,保持响应式追踪) */
|
|
261
|
+
interface UseImportExcelOptions {
|
|
262
|
+
/** 列定义(position → name → alias 定位) */
|
|
263
|
+
columns: Ref<DataColumn[]>;
|
|
264
|
+
/** 导入处理器(处理函数 + 批次大小;单行处理只是 batchSize=1 的特例) */
|
|
265
|
+
processor: Ref<ImportProcessor | undefined>;
|
|
266
|
+
/** Excel 文件解析器(如 @ys-knife-crud/import-exceljs 的 createExcelJsImportParser()) */
|
|
267
|
+
parser: Ref<ImportParser | undefined>;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Excel 数据导入逻辑(框架无关):
|
|
271
|
+
* 文件解析 → 列映射/校验(valid/invalid)→ 勾选同步 →
|
|
272
|
+
* 逐行业务处理(processing → success/failed,状态实时回写)。
|
|
273
|
+
*
|
|
274
|
+
* UI 层(如 YsImportExcel)只负责文件选择框、表格与状态标签渲染,
|
|
275
|
+
* 解析库经 parser 注入、业务操作经 processor 注入,本函数不绑定任何第三方库。
|
|
276
|
+
*/
|
|
277
|
+
declare function useImportExcel({ columns, processor, parser }: UseImportExcelOptions): {
|
|
278
|
+
rows: Ref<{
|
|
279
|
+
rowNumber: number;
|
|
280
|
+
raw: unknown[];
|
|
281
|
+
data: Record<string, unknown>;
|
|
282
|
+
selected: boolean;
|
|
283
|
+
status: _ys_knife_crud_core.ImportRowStatus;
|
|
284
|
+
errors: string[];
|
|
285
|
+
message?: string | undefined;
|
|
286
|
+
}[], ImportRow<Record<string, unknown>>[] | {
|
|
287
|
+
rowNumber: number;
|
|
288
|
+
raw: unknown[];
|
|
289
|
+
data: Record<string, unknown>;
|
|
290
|
+
selected: boolean;
|
|
291
|
+
status: _ys_knife_crud_core.ImportRowStatus;
|
|
292
|
+
errors: string[];
|
|
293
|
+
message?: string | undefined;
|
|
294
|
+
}[]>;
|
|
295
|
+
fileName: Ref<string, string>;
|
|
296
|
+
sheetName: Ref<string, string>;
|
|
297
|
+
loading: Ref<boolean, boolean>;
|
|
298
|
+
processing: Ref<boolean, boolean>;
|
|
299
|
+
stopping: Ref<boolean, boolean>;
|
|
300
|
+
processingTotal: Ref<number, number>;
|
|
301
|
+
progressDone: Ref<number, number>;
|
|
302
|
+
progressSuccess: Ref<number, number>;
|
|
303
|
+
progressFailed: Ref<number, number>;
|
|
304
|
+
hasData: vue.ComputedRef<boolean>;
|
|
305
|
+
invalidCount: vue.ComputedRef<number>;
|
|
306
|
+
successCount: vue.ComputedRef<number>;
|
|
307
|
+
failedCount: vue.ComputedRef<number>;
|
|
308
|
+
selectedCount: vue.ComputedRef<number>;
|
|
309
|
+
pendingCount: vue.ComputedRef<number>;
|
|
310
|
+
processedCount: vue.ComputedRef<number>;
|
|
311
|
+
loadFile: (file: File) => Promise<ImportRow[]>;
|
|
312
|
+
syncSelection: (selectedRows: ImportRow[]) => void;
|
|
313
|
+
saveRowEdit: (row: ImportRow, inputs: Record<string, unknown>) => {
|
|
314
|
+
row: ImportRow;
|
|
315
|
+
errors: string[];
|
|
316
|
+
};
|
|
317
|
+
removeRow: (row: ImportRow) => void;
|
|
318
|
+
startProcessing: () => Promise<ImportProcessSummary | null>;
|
|
319
|
+
stopProcessing: () => void;
|
|
320
|
+
clear: () => void;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* 分组节点判断:children 非空。
|
|
325
|
+
* 纯函数:不依赖 composable 内部状态,供主面板组件复用。
|
|
326
|
+
*/
|
|
327
|
+
declare function isGroupNode(node: FunctionNode): boolean;
|
|
328
|
+
/**
|
|
329
|
+
* 深度优先查找节点(按 key)。
|
|
330
|
+
* 纯函数:供主面板组件在菜单选择、初始激活时定位节点。
|
|
331
|
+
*/
|
|
332
|
+
declare function findNode(list: FunctionNode[], key: string): FunctionNode | undefined;
|
|
333
|
+
/**
|
|
334
|
+
* 收集功能树中所有分组节点的 key(深度优先)。
|
|
335
|
+
* 纯函数:搜索过滤后用于 el-menu 的 default-openeds,让命中分组一次性全部展开。
|
|
336
|
+
*/
|
|
337
|
+
declare function collectGroupKeys(list: FunctionNode[]): string[];
|
|
338
|
+
/**
|
|
339
|
+
* 按关键词模糊过滤功能树:
|
|
340
|
+
* - 匹配规则:关键词两端裁空白后按空白拆成多个 token(大小写不敏感),
|
|
341
|
+
* 叶子 label 同时包含全部 token 才算命中;单个 token 时即「子串包含」
|
|
342
|
+
* - 分组节点自身 label 命中时,保留其整棵子树;
|
|
343
|
+
* 否则只要后代有命中,保留该分组作为祖先链(children 替换为过滤结果)
|
|
344
|
+
* - 关键词为空时原样返回
|
|
345
|
+
*
|
|
346
|
+
* 纯函数:不修改入参节点(命中祖先链时浅拷贝分组节点挂接过滤后的 children)。
|
|
347
|
+
*/
|
|
348
|
+
declare function filterNodesByKeyword(list: FunctionNode[], keyword: string): FunctionNode[];
|
|
349
|
+
/**
|
|
350
|
+
* 主面板功能树加载逻辑:功能树数据与加载态、加载动作,
|
|
351
|
+
* 以及 nodesFunc 变化时自动重新加载。
|
|
352
|
+
*
|
|
353
|
+
* 刻意不处理 defaultActive(初始选项卡):它依赖选项卡状态(tabs composable),
|
|
354
|
+
* 由调用方组件在首次 loadNodes 完成后自行应用。
|
|
355
|
+
*
|
|
356
|
+
* @param props 组件 props(只需 nodesFunc)
|
|
357
|
+
*/
|
|
358
|
+
declare function useMainPanelNodes(props: Pick<MainPanelProps, "nodesFunc">): {
|
|
359
|
+
nodes: vue.Ref<{
|
|
360
|
+
readonly key: string;
|
|
361
|
+
readonly label: string;
|
|
362
|
+
readonly icon?: string | undefined;
|
|
363
|
+
readonly component?: string | undefined;
|
|
364
|
+
readonly props?: Record<string, unknown> | undefined;
|
|
365
|
+
readonly children?: /*elided*/ any[] | undefined;
|
|
366
|
+
}[], FunctionNode[] | {
|
|
367
|
+
readonly key: string;
|
|
368
|
+
readonly label: string;
|
|
369
|
+
readonly icon?: string | undefined;
|
|
370
|
+
readonly component?: string | undefined;
|
|
371
|
+
readonly props?: Record<string, unknown> | undefined;
|
|
372
|
+
readonly children?: /*elided*/ any[] | undefined;
|
|
373
|
+
}[]>;
|
|
374
|
+
menuLoading: vue.Ref<boolean, boolean>;
|
|
375
|
+
loadNodes: () => Promise<void>;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* 主面板选项卡(运行时结构):由功能树叶子节点打开时生成。
|
|
380
|
+
*/
|
|
381
|
+
interface MainPanelTab {
|
|
382
|
+
/** 选项卡 key = 叶子节点 key */
|
|
383
|
+
key: string;
|
|
384
|
+
/** 选项卡文案(含 icon 前缀) */
|
|
385
|
+
label: string;
|
|
386
|
+
/** 要渲染的组件路径字符串(空表示叶子未声明 component,渲染为空) */
|
|
387
|
+
componentPath: string;
|
|
388
|
+
/** 渲染面板组件时经 v-bind 透传的节点级 props(未声明为 undefined) */
|
|
389
|
+
props: Record<string, unknown> | undefined;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* 主面板选项卡逻辑:选项卡的打开(去重)、关闭联动、当前激活项,
|
|
393
|
+
* 以及叶子节点组件路径的解析与缓存。
|
|
394
|
+
*
|
|
395
|
+
* 组件解析与具体 UI 组件库无关:componentMap(消费方经 import.meta.glob 生成)
|
|
396
|
+
* 提供「路径 → 异步加载器」,内部用 defineAsyncComponent 包装并按路径缓存——
|
|
397
|
+
* 同一路径只加载一次,选项卡反复关闭再打开不会重复发起加载;未提供 componentMap
|
|
398
|
+
* 时回退为运行时动态 import(跳过打包器静态分析)。
|
|
399
|
+
*
|
|
400
|
+
* @param props 组件 props(只需 componentMap)
|
|
401
|
+
*/
|
|
402
|
+
declare function useMainPanelTabs(props: Pick<MainPanelProps, "componentMap">): {
|
|
403
|
+
openTabs: vue.Ref<{
|
|
404
|
+
key: string;
|
|
405
|
+
label: string;
|
|
406
|
+
componentPath: string;
|
|
407
|
+
props: Record<string, unknown> | undefined;
|
|
408
|
+
}[], MainPanelTab[] | {
|
|
409
|
+
key: string;
|
|
410
|
+
label: string;
|
|
411
|
+
componentPath: string;
|
|
412
|
+
props: Record<string, unknown> | undefined;
|
|
413
|
+
}[]>;
|
|
414
|
+
activeKey: vue.Ref<string, string>;
|
|
415
|
+
openTab: (node: FunctionNode) => void;
|
|
416
|
+
removeTab: (key: string | number) => void;
|
|
417
|
+
getComponent: (path: string) => Component | null;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* 搜索面板(FilterPanel)聚合子 FilterItem 的 FilterInfo 的逻辑:UI 库无关。
|
|
422
|
+
*
|
|
423
|
+
* 通过 provide/inject 收集子组件:
|
|
424
|
+
* - FilterPanel provide 一个 register(api) 函数,子 FilterItem 在 onMounted 时调用
|
|
425
|
+
* 把自己的 FilterItemApi 注册进来,返回反注册函数;onBeforeUnmount 调反注册。
|
|
426
|
+
* - 内部维护响应式 Map<string, FilterItemApi>,增删后整体替换触发 track
|
|
427
|
+
* (同 useSelection 的 selectedMap 范式)。
|
|
428
|
+
* - filter computed 迭代 Map,对每个 api.filter 调 .isEmpty() 过滤空条件,
|
|
429
|
+
* 全空时返回 emptyFilter(),否则用 FilterInfo.createAnd(...) 聚合。
|
|
430
|
+
*
|
|
431
|
+
* 响应式链路:panel filter computed 读 api.filter(getter)→ 读 item 的 filterInfo.value
|
|
432
|
+
* → 读 value ref → 整条链被 track。item 值变化时 panel filter 自动重算。
|
|
433
|
+
*/
|
|
434
|
+
/** FilterItem 向 Panel 注册自己用的函数签名;返回反注册函数 */
|
|
435
|
+
type FilterItemRegisterFn = (api: FilterItemApi) => () => void;
|
|
436
|
+
/** provide/inject token:Panel provide 一个 register 函数,Item inject 它 */
|
|
437
|
+
declare const FilterPanelKey: InjectionKey<FilterItemRegisterFn>;
|
|
438
|
+
declare function useFilterPanel(): {
|
|
439
|
+
filter: vue.ComputedRef<FilterInfo>;
|
|
440
|
+
register: FilterItemRegisterFn;
|
|
441
|
+
reset: () => void;
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* 文本(string)单字段查询条件逻辑:UI 库无关。
|
|
446
|
+
*
|
|
447
|
+
* 设计原则:每个具体 FilterItem 组件(Text/Number/Date/DateRange/Bool...)只负责
|
|
448
|
+
* 自己的一种类型,不在一个 composable 里实现 type 工厂模式;后续追加新类型时新建对应的
|
|
449
|
+
* useXxxFilterItem + XxxFilterItemProps。
|
|
450
|
+
*
|
|
451
|
+
* - value 为 string,op 由声明方指定(常为 Contains)
|
|
452
|
+
* - 值为空(null/空串/纯空白)时 filterInfo 返回 null(表示「无查询条件」,
|
|
453
|
+
* 由 panel 端聚合时直接跳过,不参与 createAnd)
|
|
454
|
+
* - 非空时 filterInfo 返回 filter(propertyPath, op, con(value));
|
|
455
|
+
* con 把原始值包装成 Constant(ys.knife.query.js 的标准右值类型)
|
|
456
|
+
*
|
|
457
|
+
* 返回结构供 TextFilterItem.vue 组装成 FilterItemApi(filter 是 getter 读 computed.value,
|
|
458
|
+
* 使 panel 端的 filter computed 能 track 到本 item 的 value 变化);value ref 留给模板 v-model 用。
|
|
459
|
+
*/
|
|
460
|
+
/**
|
|
461
|
+
* 文本 FilterItem 的 props 契约:composable 与 element-plus 组件共享。
|
|
462
|
+
* 不在 core 层定义通用 FilterItemProps,因各类型 props 字段差异较大
|
|
463
|
+
* (daterange 不需要 op、date 需要 valueFormat、number 可能需要 min/max 等)。
|
|
464
|
+
*/
|
|
465
|
+
interface TextFilterItemProps {
|
|
466
|
+
/** 运算符;常传 Operator.Contains,也可传 Equals/StartsWith/EndsWith 等 */
|
|
467
|
+
readonly op: Operator;
|
|
468
|
+
/** 实体属性路径(FilterInfo.left),如 "name" / "user.name" */
|
|
469
|
+
readonly propertyPath: string;
|
|
470
|
+
/** 初始值;缺省为空字符串 */
|
|
471
|
+
readonly defaultValue?: string;
|
|
472
|
+
}
|
|
473
|
+
declare function useTextFilterItem(props: TextFilterItemProps): {
|
|
474
|
+
value: vue.Ref<string, string>;
|
|
475
|
+
filter: vue.ComputedRef<FilterInfo | null>;
|
|
476
|
+
reset: () => void;
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* 日期(date)单字段查询条件逻辑:UI 库无关。
|
|
481
|
+
*
|
|
482
|
+
* 设计原则:每个具体 FilterItem 组件(Text/Number/Date/DateRange/Bool...)只负责
|
|
483
|
+
* 自己的一种类型,不在一个 composable 里实现 type 工厂模式。
|
|
484
|
+
*
|
|
485
|
+
* - value 为 string(YYYY-MM-DD 格式,由 UI 层 el-date-picker value-format 决定);
|
|
486
|
+
* composable 不处理 Date 对象,统一以字符串形式构造 FilterInfo
|
|
487
|
+
* - op 由声明方指定(常为 Equals,也可 GreaterThan/LessThan/GreaterThanOrEqual 等)
|
|
488
|
+
* - 值为空(null/空串/纯空白)时 filterInfo 返回 null(panel 端聚合时跳过)
|
|
489
|
+
* - 非空时 filterInfo 返回 filter(propertyPath, op, con(value));
|
|
490
|
+
* con 把日期字符串包装成 Constant(ys.knife.query.js 的标准右值类型)
|
|
491
|
+
*
|
|
492
|
+
* 返回结构供 DateFilterItem.vue 组装成 FilterItemApi。
|
|
493
|
+
*/
|
|
494
|
+
/**
|
|
495
|
+
* 日期 FilterItem 的 props 契约:composable 与 element-plus 组件共享。
|
|
496
|
+
* 不含 label/placeholder 等 UI 字段(由 element-plus 组件自己声明);
|
|
497
|
+
* 不含 valueFormat(composable 只处理字符串,不关心 UI 层格式约束)。
|
|
498
|
+
*/
|
|
499
|
+
interface DateFilterItemProps {
|
|
500
|
+
/** 运算符;常传 Operator.Equals,也可传 GreaterThan / LessThan /
|
|
501
|
+
* GreaterThanOrEqual / LessThanOrEqual 等对日期有意义的 op */
|
|
502
|
+
readonly op: Operator;
|
|
503
|
+
/** 实体属性路径(FilterInfo.left),如 "birthDate" / "user.createdAt" */
|
|
504
|
+
readonly propertyPath: string;
|
|
505
|
+
/** 初始值;YYYY-MM-DD 格式字符串,缺省为空 */
|
|
506
|
+
readonly defaultValue?: string;
|
|
507
|
+
}
|
|
508
|
+
declare function useDateFilterItem(props: DateFilterItemProps): {
|
|
509
|
+
value: vue.Ref<string, string>;
|
|
510
|
+
filter: vue.ComputedRef<FilterInfo | null>;
|
|
511
|
+
reset: () => void;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* 日期范围(daterange)单字段查询条件逻辑:UI 库无关。
|
|
516
|
+
*
|
|
517
|
+
* 设计原则:每个具体 FilterItem 组件(Text/Number/Date/DateRange/Bool...)只负责
|
|
518
|
+
* 自己的一种类型,不在一个 composable 里实现 type 工厂模式。
|
|
519
|
+
*
|
|
520
|
+
* - value 为 [start, end] 字符串数组(YYYY-MM-DD 格式,由 UI 层 el-date-picker
|
|
521
|
+
* value-format 决定),composable 不处理 Date 对象,统一以字符串数组构造 FilterInfo
|
|
522
|
+
* - op 内部固定为 Operator.Between,不需要声明方传 op(日期范围的语义天然是 between)
|
|
523
|
+
* - 值为空(null / 非数组 / 长度不足 / start 或 end 任一为空)时 filterInfo 返回 null
|
|
524
|
+
* - 非空时 filterInfo 返回 filter(propertyPath, Operator.Between, con([start, end]));
|
|
525
|
+
* con 接受 (string|null)[],正好适配 between op 的数组右值
|
|
526
|
+
*
|
|
527
|
+
* 返回结构供 DateRangeFilterItem.vue 组装成 FilterItemApi。
|
|
528
|
+
*/
|
|
529
|
+
type DateRangeValue = [string, string] | null;
|
|
530
|
+
/**
|
|
531
|
+
* 日期范围 FilterItem 的 props 契约:composable 与 element-plus 组件共享。
|
|
532
|
+
* 不含 op 字段——日期范围语义天然是 Between,op 由 composable 内部固定。
|
|
533
|
+
*/
|
|
534
|
+
interface DateRangeFilterItemProps {
|
|
535
|
+
/** 实体属性路径(FilterInfo.left),如 "createdAt" / "user.registeredAt" */
|
|
536
|
+
readonly propertyPath: string;
|
|
537
|
+
/** 初始值;[start, end] 字符串数组,缺省为 null */
|
|
538
|
+
readonly defaultValue?: [string, string];
|
|
539
|
+
}
|
|
540
|
+
declare function useDateRangeFilterItem(props: DateRangeFilterItemProps): {
|
|
541
|
+
value: vue.Ref<DateRangeValue, DateRangeValue>;
|
|
542
|
+
filter: vue.ComputedRef<FilterInfo | null>;
|
|
543
|
+
reset: () => void;
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* 枚举(enum)单字段查询条件逻辑:UI 库无关。
|
|
548
|
+
*
|
|
549
|
+
* 设计原则:每个具体 FilterItem 组件(Text/Date/DateRange/Enum...)只负责
|
|
550
|
+
* 自己的一种类型,不在一个 composable 里实现 type 工厂模式。
|
|
551
|
+
*
|
|
552
|
+
* 单选模式(multiple=false,默认):
|
|
553
|
+
* - value 为 string | number | null(null 表示未选)
|
|
554
|
+
* - 使用声明方指定的 op(常为 Equals)
|
|
555
|
+
* - 值为空时 filterInfo 返回 null;非空时 filter(propertyPath, op, con(value))
|
|
556
|
+
*
|
|
557
|
+
* 多选模式(multiple=true):
|
|
558
|
+
* - value 为 (string | number)[](空数组表示未选)
|
|
559
|
+
* - op 由 composable 自动派生(声明方的 op 被忽略):
|
|
560
|
+
* - 0 项 → filterInfo 返回 null(panel 端聚合时跳过)
|
|
561
|
+
* - 1 项 → filter(propertyPath, Operator.Equals, con(item))(自动 Equals)
|
|
562
|
+
* - 2+ 项 → filter(propertyPath, Operator.In, con(items))(自动 In)
|
|
563
|
+
*
|
|
564
|
+
* 数据源(options)、keyProperty、valueProperty 由 UI 层组件管理:
|
|
565
|
+
* composable 只关心选中值与 filter 构造,不关心选项如何加载/渲染。
|
|
566
|
+
*
|
|
567
|
+
* 返回结构供 EnumFilterItem.vue 组装成 FilterItemApi。
|
|
568
|
+
*/
|
|
569
|
+
/**
|
|
570
|
+
* 枚举 FilterItem 的 props 契约:composable 与 element-plus 组件共享。
|
|
571
|
+
* 不含 label/placeholder/dataFunc/keyProperty/valueProperty 等 UI 字段
|
|
572
|
+
* (由 element-plus 组件自己声明)。
|
|
573
|
+
*/
|
|
574
|
+
interface EnumFilterItemProps {
|
|
575
|
+
/**
|
|
576
|
+
* 运算符;仅在单选模式下使用(常为 Operator.Equals)。
|
|
577
|
+
* 多选模式下被忽略,composable 按「1 项→Equals,2+ 项→In」自动派生。
|
|
578
|
+
*/
|
|
579
|
+
readonly op: Operator;
|
|
580
|
+
/** 实体属性路径(FilterInfo.left),如 "status" / "user.roleId" */
|
|
581
|
+
readonly propertyPath: string;
|
|
582
|
+
/**
|
|
583
|
+
* 初始值;单选模式为 string | number | null(null=未选),
|
|
584
|
+
* 多选模式为 (string | number)[](空数组=未选)。
|
|
585
|
+
*/
|
|
586
|
+
readonly defaultValue?: string | number | null | (string | number)[];
|
|
587
|
+
/** 是否多选;默认 false。多选时 2+ 项用 In,1 项用 Equals */
|
|
588
|
+
readonly multiple?: boolean;
|
|
589
|
+
}
|
|
590
|
+
/** 多选模式下的值类型 */
|
|
591
|
+
type EnumMultiValue = (string | number)[];
|
|
592
|
+
/** 单选模式下的值类型 */
|
|
593
|
+
type EnumSingleValue = string | number | null;
|
|
594
|
+
declare function useEnumFilterItem(props: EnumFilterItemProps): {
|
|
595
|
+
value: vue.Ref<(string | number)[] | EnumSingleValue, (string | number)[] | EnumSingleValue | EnumMultiValue>;
|
|
596
|
+
filter: vue.ComputedRef<FilterInfo | null>;
|
|
597
|
+
reset: () => void;
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* 高级查询面板逻辑:UI 库无关。条件树形结构管理 + 递归聚合 FilterInfo。
|
|
602
|
+
*
|
|
603
|
+
* 数据模型为一棵 AdvancedConditionGroup 树:
|
|
604
|
+
* - 根节点 rootGroup(id 固定 "root",combinator 默认 and);
|
|
605
|
+
* - 每个 group 的 children 可混合 leaf 与子 group;
|
|
606
|
+
* - 每行 leaf = 字段 + 操作符 + 值,切换字段重置 op/value,切换 op 按 op 形态重置 value;
|
|
607
|
+
* - 聚合:递归 buildNodeFilter,group 内子项过滤空值(null)后用
|
|
608
|
+
* FilterInfo.createAnd / createOr 聚合;空 group → null(父级跳过);
|
|
609
|
+
* 单子项透传(避免 (a) 多余括号);全空 → emptyFilter()。
|
|
610
|
+
*
|
|
611
|
+
* 判空语义(仅针对 leaf):
|
|
612
|
+
* - string:null/空白串为空
|
|
613
|
+
* - number/date 单值:null/undefined/"" 为空(0 是合法值)
|
|
614
|
+
* - boolean:仅 null/undefined 为空(false 是合法值)
|
|
615
|
+
* - 区间:两端都要填
|
|
616
|
+
* - 多值:数组长度 > 0
|
|
617
|
+
*/
|
|
618
|
+
interface AdvancedFilterProps {
|
|
619
|
+
/** 可供选择的字段列表(通常直接传 Meta.columns;隐藏列也可查询,不做 showForDisplay 过滤) */
|
|
620
|
+
readonly columns: readonly Column[];
|
|
621
|
+
/**
|
|
622
|
+
* 枚举字段数据源,按 propertyPath 映射;命中的字段推断为 enum 类型,
|
|
623
|
+
* 值区域渲染带异步选项的下拉。
|
|
624
|
+
*/
|
|
625
|
+
readonly optionSources?: Record<string, EnumOptionsSource>;
|
|
626
|
+
}
|
|
627
|
+
/** 区间值(Between/NotBetween);元素可为 null 表示该端未填 */
|
|
628
|
+
type AdvancedRangeValue = [unknown, unknown] | null;
|
|
629
|
+
declare function useAdvancedFilter(props: AdvancedFilterProps): {
|
|
630
|
+
rootGroup: vue.Ref<{
|
|
631
|
+
id: string;
|
|
632
|
+
combinator: AdvancedCombinator;
|
|
633
|
+
children: (/*elided*/ any | {
|
|
634
|
+
id: string;
|
|
635
|
+
propertyPath: string;
|
|
636
|
+
op: AdvancedOperator;
|
|
637
|
+
value: unknown;
|
|
638
|
+
})[];
|
|
639
|
+
}, AdvancedConditionGroup | {
|
|
640
|
+
id: string;
|
|
641
|
+
combinator: AdvancedCombinator;
|
|
642
|
+
children: (/*elided*/ any | {
|
|
643
|
+
id: string;
|
|
644
|
+
propertyPath: string;
|
|
645
|
+
op: AdvancedOperator;
|
|
646
|
+
value: unknown;
|
|
647
|
+
})[];
|
|
648
|
+
}>;
|
|
649
|
+
fieldTypeOf: (propertyPath: string) => AdvancedFieldType;
|
|
650
|
+
operatorsOf: (propertyPath: string) => AdvancedOperator[];
|
|
651
|
+
addLeaf: (parentId: string, index?: number) => void;
|
|
652
|
+
addNestedGroup: (parentId: string, index?: number) => void;
|
|
653
|
+
removeNode: (id: string) => void;
|
|
654
|
+
changeField: (id: string, propertyPath: string) => void;
|
|
655
|
+
changeOperator: (id: string, op: AdvancedOperator) => void;
|
|
656
|
+
setGroupCombinator: (groupId: string, comb: AdvancedCombinator) => void;
|
|
657
|
+
isConditionEmpty: (row: AdvancedCondition) => boolean;
|
|
658
|
+
isConditionGroup: typeof isConditionGroup;
|
|
659
|
+
filter: vue.ComputedRef<FilterInfo>;
|
|
660
|
+
reset: () => void;
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
export { type AdvancedFilterProps, type AdvancedRangeValue, type DateFilterItemProps, type DateRangeFilterItemProps, type DateRangeValue, type EnumFilterItemProps, type EnumMultiValue, type EnumSingleValue, type FilterItemRegisterFn, FilterPanelKey, type MainPanelTab, type RowRecord, type SelectionTableLike, type TextFilterItemProps, type UseImportExcelOptions, collectGroupKeys, filterNodesByKeyword, findNode, isEnabled, isGroupNode, useAdvancedFilter, useCustomConfig, useDateFilterItem, useDateRangeFilterItem, useDefault, useEnumFilterItem, useExportExcel, useFilterPanel, useImportExcel, useMainPanelNodes, useMainPanelTabs, useRowActions, useSelection, useTextFilterItem, visibleActions };
|