@ys-knife-crud/vue 0.0.13 → 0.0.15
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 +1 -0
- package/dist/index.cjs +214 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -3
- package/dist/index.d.ts +52 -3
- package/dist/index.js +209 -44
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { FilterInfo, Operator } from 'ys.knife.query.js';
|
|
|
3
3
|
import * as vue from 'vue';
|
|
4
4
|
import { Ref, Component, InjectionKey, ComponentPublicInstance, AppContext } from 'vue';
|
|
5
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, ActionType } from '@ys-knife-crud/core';
|
|
6
|
+
import { DefaultProps, Meta, PagedList, Action, RowActionsProps, CustomConfigProps, CustomColumnConfig, CustomConfig, DraftColumn, PageFunc, ExportApiFunc, Column, ExportOption, ExportScope, CollectorFunc, DataColumn, ImportProcessor, ImportParser, ImportRow, ImportProcessSummary, FunctionNode, MainPanelProps, FilterItemApi, EnumOptionsSource, AdvancedCombinator, AdvancedOperator, AdvancedConditionGroup, AdvancedFieldType, AdvancedCondition, isConditionGroup, ActionType } from '@ys-knife-crud/core';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* 表格的默认状态与数据加载逻辑:列元数据、分页数据、当前页行数据、
|
|
@@ -225,6 +225,8 @@ interface UseExportExcelOptions {
|
|
|
225
225
|
selectedRows: Ref<unknown[]>;
|
|
226
226
|
/** 数据总条数 */
|
|
227
227
|
total: Ref<number>;
|
|
228
|
+
/** 总条数是否已知(dataFun 返回了 totalCount);已知时「导出所有」选项带「共 N 条」 */
|
|
229
|
+
totalKnown: Ref<boolean>;
|
|
228
230
|
/** 导出所有时分页拉取的步长(独立于界面分页大小,避免用大页尺寸拖慢导出) */
|
|
229
231
|
exportPageSize: Ref<number>;
|
|
230
232
|
/** 是否还有下一页(决定「导出所有」选项是否出现) */
|
|
@@ -244,7 +246,7 @@ interface UseExportExcelOptions {
|
|
|
244
246
|
* (createConsoleExportApiFunc,只在控制台打日志、不产出文件),
|
|
245
247
|
* 真实导出由消费方注入(如 @ys-knife-crud/export-exceljs)。
|
|
246
248
|
*/
|
|
247
|
-
declare function useExportExcel({ props, tableName, columns, currentRows, selectedRows, total, exportPageSize, hasMorePage, pageScopeLabel, }: UseExportExcelOptions): {
|
|
249
|
+
declare function useExportExcel({ props, tableName, columns, currentRows, selectedRows, total, totalKnown, exportPageSize, hasMorePage, pageScopeLabel, }: UseExportExcelOptions): {
|
|
248
250
|
exportOptions: vue.ComputedRef<ExportOption[]>;
|
|
249
251
|
exportDialogVisible: Ref<boolean, boolean>;
|
|
250
252
|
exporting: Ref<boolean, boolean>;
|
|
@@ -262,6 +264,53 @@ declare function useExportExcel({ props, tableName, columns, currentRows, select
|
|
|
262
264
|
discardPartialExport: () => Promise<void>;
|
|
263
265
|
};
|
|
264
266
|
|
|
267
|
+
/** useCollectData 需要从组件 props 中访问的成员 */
|
|
268
|
+
interface CollectProps {
|
|
269
|
+
readonly dataFun: PageFunc<unknown>;
|
|
270
|
+
readonly collectorFunc?: CollectorFunc;
|
|
271
|
+
readonly maxCollectCount: number;
|
|
272
|
+
}
|
|
273
|
+
/** useCollectData 的入参:组件内已有的响应式状态与工具函数 */
|
|
274
|
+
interface UseCollectDataOptions {
|
|
275
|
+
props: CollectProps;
|
|
276
|
+
/** 界面是否显示勾选列——决定「选中」范围是否出现 */
|
|
277
|
+
selectable: Ref<boolean>;
|
|
278
|
+
/** 当前页行数据 */
|
|
279
|
+
currentRows: Ref<Record<string, unknown>[]>;
|
|
280
|
+
/** checkbox 列当前选中的行(跨页累计) */
|
|
281
|
+
selectedRows: Ref<unknown[]>;
|
|
282
|
+
/** 数据总条数(驱动进度条初始分母;响应带回 totalCount 时会被修正) */
|
|
283
|
+
total: Ref<number>;
|
|
284
|
+
/** 总条数是否已知(dataFun 返回了 totalCount);已知时「所有数据」选项带「共 N 条」 */
|
|
285
|
+
totalKnown: Ref<boolean>;
|
|
286
|
+
/** 收集所有时分页拉取的步长(独立于界面分页大小) */
|
|
287
|
+
collectPageSize: Ref<number>;
|
|
288
|
+
/** 是否还有下一页(决定「所有数据」选项是否出现) */
|
|
289
|
+
hasMorePage: Ref<boolean>;
|
|
290
|
+
/** 「page」范围的文案前缀;缺省「当前页的数据」 */
|
|
291
|
+
pageScopeLabel?: Ref<string | undefined>;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* 收集数据逻辑:范围选择对话框、逐页拉取并累积、进度与取消。
|
|
295
|
+
*
|
|
296
|
+
* 与 useExportExcel 同构,区别在于不写文件——全部分页拉取完成后,
|
|
297
|
+
* 把原始行对象数组一次性交给 collectorFunc(附范围与截断信息)。
|
|
298
|
+
* 单次收集受 maxCollectCount 上限保护:达到上限即停止并标记 truncated。
|
|
299
|
+
*/
|
|
300
|
+
declare function useCollectData({ props, selectable, currentRows, selectedRows, total, totalKnown, collectPageSize, hasMorePage, pageScopeLabel, }: UseCollectDataOptions): {
|
|
301
|
+
collectOptions: vue.ComputedRef<ExportOption[]>;
|
|
302
|
+
collectDialogVisible: Ref<boolean, boolean>;
|
|
303
|
+
collecting: Ref<boolean, boolean>;
|
|
304
|
+
collectFetched: Ref<number, number>;
|
|
305
|
+
collectTotal: Ref<number, number>;
|
|
306
|
+
collectTotalKnown: Ref<boolean, boolean>;
|
|
307
|
+
collectEtaSeconds: vue.ComputedRef<number | null>;
|
|
308
|
+
collectPercent: vue.ComputedRef<number>;
|
|
309
|
+
onCollectClick: () => void;
|
|
310
|
+
doCollect: (scope: ExportScope) => Promise<void>;
|
|
311
|
+
cancelCollect: () => void;
|
|
312
|
+
};
|
|
313
|
+
|
|
265
314
|
/** useImportExcel 入参(组件把 props 的相关字段以 Ref 形式传入,保持响应式追踪) */
|
|
266
315
|
interface UseImportExcelOptions {
|
|
267
316
|
/** 列定义(position → name → alias 定位) */
|
|
@@ -779,4 +828,4 @@ interface DialogOptions<P extends Record<string, unknown> = Record<string, unkno
|
|
|
779
828
|
onConfirm?: (handle: ModalHandle, instance: ExtractComponentInstance<C>) => unknown | Promise<unknown>;
|
|
780
829
|
}
|
|
781
830
|
|
|
782
|
-
export { type AdvancedFilterProps, type AdvancedRangeValue, type DateFilterItemProps, type DateRangeFilterItemProps, type DateRangeValue, type DialogOptions, type EnumFilterItemProps, type EnumMultiValue, type EnumSingleValue, type ExtractComponentInstance, type FilterItemRegisterFn, FilterPanelKey, type MainPanelTab, type ModalAction, type ModalHandle, type ModalOptions, type RowRecord, type SelectionTableLike, type TextFilterItemProps, type UseImportExcelOptions, collectGroupKeys, filterNodesByKeyword, findNode, getDefaultModalAppContext, isEnabled, isGroupNode, setDefaultModalAppContext, useAdvancedFilter, useCustomConfig, useDateFilterItem, useDateRangeFilterItem, useDefault, useEnumFilterItem, useExportExcel, useFilterPanel, useImportExcel, useMainPanelNodes, useMainPanelTabs, useRowActions, useSelection, useTextFilterItem, visibleActions };
|
|
831
|
+
export { type AdvancedFilterProps, type AdvancedRangeValue, type DateFilterItemProps, type DateRangeFilterItemProps, type DateRangeValue, type DialogOptions, type EnumFilterItemProps, type EnumMultiValue, type EnumSingleValue, type ExtractComponentInstance, type FilterItemRegisterFn, FilterPanelKey, type MainPanelTab, type ModalAction, type ModalHandle, type ModalOptions, type RowRecord, type SelectionTableLike, type TextFilterItemProps, type UseImportExcelOptions, collectGroupKeys, filterNodesByKeyword, findNode, getDefaultModalAppContext, isEnabled, isGroupNode, setDefaultModalAppContext, useAdvancedFilter, useCollectData, useCustomConfig, useDateFilterItem, useDateRangeFilterItem, useDefault, useEnumFilterItem, useExportExcel, useFilterPanel, useImportExcel, useMainPanelNodes, useMainPanelTabs, useRowActions, useSelection, useTextFilterItem, visibleActions };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { FilterInfo, Operator } from 'ys.knife.query.js';
|
|
|
3
3
|
import * as vue from 'vue';
|
|
4
4
|
import { Ref, Component, InjectionKey, ComponentPublicInstance, AppContext } from 'vue';
|
|
5
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, ActionType } from '@ys-knife-crud/core';
|
|
6
|
+
import { DefaultProps, Meta, PagedList, Action, RowActionsProps, CustomConfigProps, CustomColumnConfig, CustomConfig, DraftColumn, PageFunc, ExportApiFunc, Column, ExportOption, ExportScope, CollectorFunc, DataColumn, ImportProcessor, ImportParser, ImportRow, ImportProcessSummary, FunctionNode, MainPanelProps, FilterItemApi, EnumOptionsSource, AdvancedCombinator, AdvancedOperator, AdvancedConditionGroup, AdvancedFieldType, AdvancedCondition, isConditionGroup, ActionType } from '@ys-knife-crud/core';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* 表格的默认状态与数据加载逻辑:列元数据、分页数据、当前页行数据、
|
|
@@ -225,6 +225,8 @@ interface UseExportExcelOptions {
|
|
|
225
225
|
selectedRows: Ref<unknown[]>;
|
|
226
226
|
/** 数据总条数 */
|
|
227
227
|
total: Ref<number>;
|
|
228
|
+
/** 总条数是否已知(dataFun 返回了 totalCount);已知时「导出所有」选项带「共 N 条」 */
|
|
229
|
+
totalKnown: Ref<boolean>;
|
|
228
230
|
/** 导出所有时分页拉取的步长(独立于界面分页大小,避免用大页尺寸拖慢导出) */
|
|
229
231
|
exportPageSize: Ref<number>;
|
|
230
232
|
/** 是否还有下一页(决定「导出所有」选项是否出现) */
|
|
@@ -244,7 +246,7 @@ interface UseExportExcelOptions {
|
|
|
244
246
|
* (createConsoleExportApiFunc,只在控制台打日志、不产出文件),
|
|
245
247
|
* 真实导出由消费方注入(如 @ys-knife-crud/export-exceljs)。
|
|
246
248
|
*/
|
|
247
|
-
declare function useExportExcel({ props, tableName, columns, currentRows, selectedRows, total, exportPageSize, hasMorePage, pageScopeLabel, }: UseExportExcelOptions): {
|
|
249
|
+
declare function useExportExcel({ props, tableName, columns, currentRows, selectedRows, total, totalKnown, exportPageSize, hasMorePage, pageScopeLabel, }: UseExportExcelOptions): {
|
|
248
250
|
exportOptions: vue.ComputedRef<ExportOption[]>;
|
|
249
251
|
exportDialogVisible: Ref<boolean, boolean>;
|
|
250
252
|
exporting: Ref<boolean, boolean>;
|
|
@@ -262,6 +264,53 @@ declare function useExportExcel({ props, tableName, columns, currentRows, select
|
|
|
262
264
|
discardPartialExport: () => Promise<void>;
|
|
263
265
|
};
|
|
264
266
|
|
|
267
|
+
/** useCollectData 需要从组件 props 中访问的成员 */
|
|
268
|
+
interface CollectProps {
|
|
269
|
+
readonly dataFun: PageFunc<unknown>;
|
|
270
|
+
readonly collectorFunc?: CollectorFunc;
|
|
271
|
+
readonly maxCollectCount: number;
|
|
272
|
+
}
|
|
273
|
+
/** useCollectData 的入参:组件内已有的响应式状态与工具函数 */
|
|
274
|
+
interface UseCollectDataOptions {
|
|
275
|
+
props: CollectProps;
|
|
276
|
+
/** 界面是否显示勾选列——决定「选中」范围是否出现 */
|
|
277
|
+
selectable: Ref<boolean>;
|
|
278
|
+
/** 当前页行数据 */
|
|
279
|
+
currentRows: Ref<Record<string, unknown>[]>;
|
|
280
|
+
/** checkbox 列当前选中的行(跨页累计) */
|
|
281
|
+
selectedRows: Ref<unknown[]>;
|
|
282
|
+
/** 数据总条数(驱动进度条初始分母;响应带回 totalCount 时会被修正) */
|
|
283
|
+
total: Ref<number>;
|
|
284
|
+
/** 总条数是否已知(dataFun 返回了 totalCount);已知时「所有数据」选项带「共 N 条」 */
|
|
285
|
+
totalKnown: Ref<boolean>;
|
|
286
|
+
/** 收集所有时分页拉取的步长(独立于界面分页大小) */
|
|
287
|
+
collectPageSize: Ref<number>;
|
|
288
|
+
/** 是否还有下一页(决定「所有数据」选项是否出现) */
|
|
289
|
+
hasMorePage: Ref<boolean>;
|
|
290
|
+
/** 「page」范围的文案前缀;缺省「当前页的数据」 */
|
|
291
|
+
pageScopeLabel?: Ref<string | undefined>;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* 收集数据逻辑:范围选择对话框、逐页拉取并累积、进度与取消。
|
|
295
|
+
*
|
|
296
|
+
* 与 useExportExcel 同构,区别在于不写文件——全部分页拉取完成后,
|
|
297
|
+
* 把原始行对象数组一次性交给 collectorFunc(附范围与截断信息)。
|
|
298
|
+
* 单次收集受 maxCollectCount 上限保护:达到上限即停止并标记 truncated。
|
|
299
|
+
*/
|
|
300
|
+
declare function useCollectData({ props, selectable, currentRows, selectedRows, total, totalKnown, collectPageSize, hasMorePage, pageScopeLabel, }: UseCollectDataOptions): {
|
|
301
|
+
collectOptions: vue.ComputedRef<ExportOption[]>;
|
|
302
|
+
collectDialogVisible: Ref<boolean, boolean>;
|
|
303
|
+
collecting: Ref<boolean, boolean>;
|
|
304
|
+
collectFetched: Ref<number, number>;
|
|
305
|
+
collectTotal: Ref<number, number>;
|
|
306
|
+
collectTotalKnown: Ref<boolean, boolean>;
|
|
307
|
+
collectEtaSeconds: vue.ComputedRef<number | null>;
|
|
308
|
+
collectPercent: vue.ComputedRef<number>;
|
|
309
|
+
onCollectClick: () => void;
|
|
310
|
+
doCollect: (scope: ExportScope) => Promise<void>;
|
|
311
|
+
cancelCollect: () => void;
|
|
312
|
+
};
|
|
313
|
+
|
|
265
314
|
/** useImportExcel 入参(组件把 props 的相关字段以 Ref 形式传入,保持响应式追踪) */
|
|
266
315
|
interface UseImportExcelOptions {
|
|
267
316
|
/** 列定义(position → name → alias 定位) */
|
|
@@ -779,4 +828,4 @@ interface DialogOptions<P extends Record<string, unknown> = Record<string, unkno
|
|
|
779
828
|
onConfirm?: (handle: ModalHandle, instance: ExtractComponentInstance<C>) => unknown | Promise<unknown>;
|
|
780
829
|
}
|
|
781
830
|
|
|
782
|
-
export { type AdvancedFilterProps, type AdvancedRangeValue, type DateFilterItemProps, type DateRangeFilterItemProps, type DateRangeValue, type DialogOptions, type EnumFilterItemProps, type EnumMultiValue, type EnumSingleValue, type ExtractComponentInstance, type FilterItemRegisterFn, FilterPanelKey, type MainPanelTab, type ModalAction, type ModalHandle, type ModalOptions, type RowRecord, type SelectionTableLike, type TextFilterItemProps, type UseImportExcelOptions, collectGroupKeys, filterNodesByKeyword, findNode, getDefaultModalAppContext, isEnabled, isGroupNode, setDefaultModalAppContext, useAdvancedFilter, useCustomConfig, useDateFilterItem, useDateRangeFilterItem, useDefault, useEnumFilterItem, useExportExcel, useFilterPanel, useImportExcel, useMainPanelNodes, useMainPanelTabs, useRowActions, useSelection, useTextFilterItem, visibleActions };
|
|
831
|
+
export { type AdvancedFilterProps, type AdvancedRangeValue, type DateFilterItemProps, type DateRangeFilterItemProps, type DateRangeValue, type DialogOptions, type EnumFilterItemProps, type EnumMultiValue, type EnumSingleValue, type ExtractComponentInstance, type FilterItemRegisterFn, FilterPanelKey, type MainPanelTab, type ModalAction, type ModalHandle, type ModalOptions, type RowRecord, type SelectionTableLike, type TextFilterItemProps, type UseImportExcelOptions, collectGroupKeys, filterNodesByKeyword, findNode, getDefaultModalAppContext, isEnabled, isGroupNode, setDefaultModalAppContext, useAdvancedFilter, useCollectData, useCustomConfig, useDateFilterItem, useDateRangeFilterItem, useDefault, useEnumFilterItem, useExportExcel, useFilterPanel, useImportExcel, useMainPanelNodes, useMainPanelTabs, useRowActions, useSelection, useTextFilterItem, visibleActions };
|
package/dist/index.js
CHANGED
|
@@ -293,6 +293,7 @@ function useExportExcel({
|
|
|
293
293
|
currentRows,
|
|
294
294
|
selectedRows,
|
|
295
295
|
total,
|
|
296
|
+
totalKnown,
|
|
296
297
|
exportPageSize,
|
|
297
298
|
hasMorePage,
|
|
298
299
|
pageScopeLabel
|
|
@@ -308,7 +309,11 @@ function useExportExcel({
|
|
|
308
309
|
}
|
|
309
310
|
opts.push({ value: "page", label: `${pageScopeLabel?.value ?? "\u5BFC\u51FA\u5F53\u524D\u9875\u6570\u636E"}\uFF08${currentRows.value.length} \u6761\uFF09`, disabled: false });
|
|
310
311
|
if (hasMorePage.value) {
|
|
311
|
-
opts.push({
|
|
312
|
+
opts.push({
|
|
313
|
+
value: "all",
|
|
314
|
+
label: totalKnown.value ? `\u5BFC\u51FA\u6240\u6709\u6570\u636E\uFF08\u5171 ${total.value} \u6761\uFF09` : "\u5BFC\u51FA\u6240\u6709\u6570\u636E",
|
|
315
|
+
disabled: false
|
|
316
|
+
});
|
|
312
317
|
}
|
|
313
318
|
return opts;
|
|
314
319
|
});
|
|
@@ -462,8 +467,167 @@ function useExportExcel({
|
|
|
462
467
|
};
|
|
463
468
|
}
|
|
464
469
|
|
|
470
|
+
// src/table/collectData.ts
|
|
471
|
+
import { computed as computed5, onScopeDispose as onScopeDispose2, ref as ref6 } from "vue";
|
|
472
|
+
function useCollectData({
|
|
473
|
+
props,
|
|
474
|
+
selectable,
|
|
475
|
+
currentRows,
|
|
476
|
+
selectedRows,
|
|
477
|
+
total,
|
|
478
|
+
totalKnown,
|
|
479
|
+
collectPageSize,
|
|
480
|
+
hasMorePage,
|
|
481
|
+
pageScopeLabel
|
|
482
|
+
}) {
|
|
483
|
+
function maxCount() {
|
|
484
|
+
return Math.max(1, Math.floor(props.maxCollectCount));
|
|
485
|
+
}
|
|
486
|
+
const collectOptions = computed5(() => {
|
|
487
|
+
const opts = [];
|
|
488
|
+
if (selectable.value) {
|
|
489
|
+
opts.push({
|
|
490
|
+
value: "selected",
|
|
491
|
+
label: `\u9009\u4E2D\u7684\u6570\u636E\uFF08\u5DF2\u9009 ${selectedRows.value.length} \u9879\uFF09`,
|
|
492
|
+
disabled: selectedRows.value.length === 0
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
opts.push({
|
|
496
|
+
value: "page",
|
|
497
|
+
label: `${pageScopeLabel?.value ?? "\u5F53\u524D\u9875\u7684\u6570\u636E"}\uFF08${currentRows.value.length} \u6761\uFF09`,
|
|
498
|
+
disabled: false
|
|
499
|
+
});
|
|
500
|
+
if (hasMorePage.value) {
|
|
501
|
+
opts.push({
|
|
502
|
+
value: "all",
|
|
503
|
+
label: totalKnown.value ? `\u6240\u6709\u6570\u636E\uFF08\u5171 ${total.value} \u6761\uFF09` : "\u6240\u6709\u6570\u636E",
|
|
504
|
+
disabled: false
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
return opts;
|
|
508
|
+
});
|
|
509
|
+
const collectDialogVisible = ref6(false);
|
|
510
|
+
const collecting = ref6(false);
|
|
511
|
+
const collectFetched = ref6(0);
|
|
512
|
+
const collectTotal = ref6(0);
|
|
513
|
+
const collectTotalKnown = ref6(false);
|
|
514
|
+
let collectCancelled = false;
|
|
515
|
+
let collectAbort = null;
|
|
516
|
+
let collectStartedAt = 0;
|
|
517
|
+
let etaTimer = null;
|
|
518
|
+
const etaNow = ref6(0);
|
|
519
|
+
onScopeDispose2(stopEtaTimer);
|
|
520
|
+
function stopEtaTimer() {
|
|
521
|
+
if (etaTimer != null) {
|
|
522
|
+
clearInterval(etaTimer);
|
|
523
|
+
etaTimer = null;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const collectEtaSeconds = computed5(() => {
|
|
527
|
+
if (!collectTotalKnown.value || collectFetched.value === 0) return null;
|
|
528
|
+
const elapsed = (etaNow.value - collectStartedAt) / 1e3;
|
|
529
|
+
if (elapsed < 0.5) return null;
|
|
530
|
+
const remaining = collectTotal.value - collectFetched.value;
|
|
531
|
+
if (remaining <= 0) return null;
|
|
532
|
+
return Math.max(1, Math.ceil(remaining / (collectFetched.value / elapsed)));
|
|
533
|
+
});
|
|
534
|
+
const collectPercent = computed5(() => {
|
|
535
|
+
if (collectTotalKnown.value && collectTotal.value > 0)
|
|
536
|
+
return Math.min(100, Math.round(collectFetched.value / collectTotal.value * 100));
|
|
537
|
+
return collectFetched.value > 0 ? 99 : 0;
|
|
538
|
+
});
|
|
539
|
+
function onCollectClick() {
|
|
540
|
+
if (!props.collectorFunc) return;
|
|
541
|
+
const enabled = collectOptions.value.filter((o) => !o.disabled);
|
|
542
|
+
if (enabled.length === 1) {
|
|
543
|
+
void doCollect(enabled[0].value);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
collectDialogVisible.value = true;
|
|
547
|
+
}
|
|
548
|
+
async function doCollect(scope) {
|
|
549
|
+
collectDialogVisible.value = false;
|
|
550
|
+
const collector = props.collectorFunc;
|
|
551
|
+
if (!collector) return;
|
|
552
|
+
if (scope === "all") {
|
|
553
|
+
await collectAllStreaming(collector);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const source = scope === "selected" ? selectedRows.value : currentRows.value;
|
|
557
|
+
const max = maxCount();
|
|
558
|
+
const truncated = source.length > max;
|
|
559
|
+
const rows = (truncated ? source.slice(0, max) : source).slice();
|
|
560
|
+
await collector(rows, { scope, truncated, maxCount: max });
|
|
561
|
+
}
|
|
562
|
+
async function collectAllStreaming(collector) {
|
|
563
|
+
collecting.value = true;
|
|
564
|
+
collectCancelled = false;
|
|
565
|
+
collectFetched.value = 0;
|
|
566
|
+
collectTotal.value = total.value;
|
|
567
|
+
collectTotalKnown.value = false;
|
|
568
|
+
collectStartedAt = Date.now();
|
|
569
|
+
etaNow.value = collectStartedAt;
|
|
570
|
+
stopEtaTimer();
|
|
571
|
+
etaTimer = setInterval(() => {
|
|
572
|
+
etaNow.value = Date.now();
|
|
573
|
+
}, 500);
|
|
574
|
+
collectAbort = new AbortController();
|
|
575
|
+
const collected = [];
|
|
576
|
+
const max = maxCount();
|
|
577
|
+
let truncated = false;
|
|
578
|
+
try {
|
|
579
|
+
const limit = Math.max(1, Math.floor(collectPageSize.value));
|
|
580
|
+
let offset = 0;
|
|
581
|
+
for (; ; ) {
|
|
582
|
+
const res = await props.dataFun({ limit, offset }, collectAbort.signal);
|
|
583
|
+
if (res.totalCount != null) {
|
|
584
|
+
collectTotal.value = res.totalCount;
|
|
585
|
+
collectTotalKnown.value = true;
|
|
586
|
+
}
|
|
587
|
+
const items = res.items;
|
|
588
|
+
const remaining = max - collected.length;
|
|
589
|
+
if (items.length >= remaining) {
|
|
590
|
+
collected.push(...items.slice(0, remaining));
|
|
591
|
+
collectFetched.value = collected.length;
|
|
592
|
+
truncated = res.hasNext || items.length > remaining;
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
collected.push(...items);
|
|
596
|
+
collectFetched.value = collected.length;
|
|
597
|
+
if (collectCancelled || !res.hasNext || items.length === 0) break;
|
|
598
|
+
offset += limit;
|
|
599
|
+
}
|
|
600
|
+
} catch (e) {
|
|
601
|
+
if (!collectCancelled) throw e;
|
|
602
|
+
} finally {
|
|
603
|
+
collecting.value = false;
|
|
604
|
+
stopEtaTimer();
|
|
605
|
+
collectAbort = null;
|
|
606
|
+
}
|
|
607
|
+
if (collectCancelled) return;
|
|
608
|
+
await collector(collected, { scope: "all", truncated, maxCount: max });
|
|
609
|
+
}
|
|
610
|
+
function cancelCollect() {
|
|
611
|
+
collectCancelled = true;
|
|
612
|
+
collectAbort?.abort();
|
|
613
|
+
}
|
|
614
|
+
return {
|
|
615
|
+
collectOptions,
|
|
616
|
+
collectDialogVisible,
|
|
617
|
+
collecting,
|
|
618
|
+
collectFetched,
|
|
619
|
+
collectTotal,
|
|
620
|
+
collectTotalKnown,
|
|
621
|
+
collectEtaSeconds,
|
|
622
|
+
collectPercent,
|
|
623
|
+
onCollectClick,
|
|
624
|
+
doCollect,
|
|
625
|
+
cancelCollect
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
|
|
465
629
|
// src/importExcel/importExcel.ts
|
|
466
|
-
import { computed as
|
|
630
|
+
import { computed as computed6, nextTick as nextTick2, ref as ref7 } from "vue";
|
|
467
631
|
function normalizeHeader(value) {
|
|
468
632
|
return String(value ?? "").trim().toLowerCase();
|
|
469
633
|
}
|
|
@@ -504,29 +668,29 @@ function resolveColumns(columns, header) {
|
|
|
504
668
|
return { resolved, missing };
|
|
505
669
|
}
|
|
506
670
|
function useImportExcel({ columns, processor, parser }) {
|
|
507
|
-
const rows =
|
|
671
|
+
const rows = ref7([]);
|
|
508
672
|
let resolvedColumns = [];
|
|
509
|
-
const fileName =
|
|
510
|
-
const sheetName =
|
|
511
|
-
const loading =
|
|
512
|
-
const processing =
|
|
513
|
-
const stopping =
|
|
673
|
+
const fileName = ref7("");
|
|
674
|
+
const sheetName = ref7("");
|
|
675
|
+
const loading = ref7(false);
|
|
676
|
+
const processing = ref7(false);
|
|
677
|
+
const stopping = ref7(false);
|
|
514
678
|
let processController = null;
|
|
515
|
-
const processingTotal =
|
|
516
|
-
const progressDone =
|
|
517
|
-
const progressSuccess =
|
|
518
|
-
const progressFailed =
|
|
519
|
-
const hasData =
|
|
520
|
-
const invalidCount =
|
|
521
|
-
const successCount =
|
|
522
|
-
const failedCount =
|
|
523
|
-
const selectedCount =
|
|
524
|
-
const pendingCount =
|
|
679
|
+
const processingTotal = ref7(0);
|
|
680
|
+
const progressDone = ref7(0);
|
|
681
|
+
const progressSuccess = ref7(0);
|
|
682
|
+
const progressFailed = ref7(0);
|
|
683
|
+
const hasData = computed6(() => rows.value.length > 0);
|
|
684
|
+
const invalidCount = computed6(() => rows.value.filter((r) => r.status === "invalid").length);
|
|
685
|
+
const successCount = computed6(() => rows.value.filter((r) => r.status === "success").length);
|
|
686
|
+
const failedCount = computed6(() => rows.value.filter((r) => r.status === "failed").length);
|
|
687
|
+
const selectedCount = computed6(() => rows.value.filter((r) => r.selected).length);
|
|
688
|
+
const pendingCount = computed6(
|
|
525
689
|
() => rows.value.filter(
|
|
526
690
|
(r) => r.selected && (r.status === "valid" || r.status === "failed")
|
|
527
691
|
).length
|
|
528
692
|
);
|
|
529
|
-
const processedCount =
|
|
693
|
+
const processedCount = computed6(() => successCount.value + failedCount.value);
|
|
530
694
|
function mapInputs(inputs) {
|
|
531
695
|
const data = {};
|
|
532
696
|
const errors = [];
|
|
@@ -748,7 +912,7 @@ function useImportExcel({ columns, processor, parser }) {
|
|
|
748
912
|
}
|
|
749
913
|
|
|
750
914
|
// src/mainPanel/nodes.ts
|
|
751
|
-
import { ref as
|
|
915
|
+
import { ref as ref8, watch as watch5 } from "vue";
|
|
752
916
|
function isGroupNode(node) {
|
|
753
917
|
return !!(node.children && node.children.length > 0);
|
|
754
918
|
}
|
|
@@ -796,8 +960,8 @@ function filterNodesByKeyword(list, keyword) {
|
|
|
796
960
|
return walk(list);
|
|
797
961
|
}
|
|
798
962
|
function useMainPanelNodes(props) {
|
|
799
|
-
const nodes =
|
|
800
|
-
const menuLoading =
|
|
963
|
+
const nodes = ref8([]);
|
|
964
|
+
const menuLoading = ref8(false);
|
|
801
965
|
async function loadNodes() {
|
|
802
966
|
menuLoading.value = true;
|
|
803
967
|
try {
|
|
@@ -817,10 +981,10 @@ function useMainPanelNodes(props) {
|
|
|
817
981
|
}
|
|
818
982
|
|
|
819
983
|
// src/mainPanel/tabs.ts
|
|
820
|
-
import { defineAsyncComponent, ref as
|
|
984
|
+
import { defineAsyncComponent, ref as ref9 } from "vue";
|
|
821
985
|
function useMainPanelTabs(props) {
|
|
822
|
-
const openTabs =
|
|
823
|
-
const activeKey =
|
|
986
|
+
const openTabs = ref9([]);
|
|
987
|
+
const activeKey = ref9("");
|
|
824
988
|
function openTab(node) {
|
|
825
989
|
const label = (node.icon ? `${node.icon} ` : "") + node.label;
|
|
826
990
|
if (!openTabs.value.some((tab) => tab.key === node.key)) {
|
|
@@ -872,11 +1036,11 @@ function useMainPanelTabs(props) {
|
|
|
872
1036
|
}
|
|
873
1037
|
|
|
874
1038
|
// src/filter/filterPanel.ts
|
|
875
|
-
import { computed as
|
|
1039
|
+
import { computed as computed7, ref as ref10 } from "vue";
|
|
876
1040
|
import { FilterInfo, emptyFilter } from "ys.knife.query.js";
|
|
877
1041
|
var FilterPanelKey = /* @__PURE__ */ Symbol("YsFilterPanel");
|
|
878
1042
|
function useFilterPanel() {
|
|
879
|
-
const items =
|
|
1043
|
+
const items = ref10(/* @__PURE__ */ new Map());
|
|
880
1044
|
let counter = 0;
|
|
881
1045
|
const register = (api) => {
|
|
882
1046
|
const key = String(++counter);
|
|
@@ -887,7 +1051,7 @@ function useFilterPanel() {
|
|
|
887
1051
|
items.value = new Map(items.value);
|
|
888
1052
|
};
|
|
889
1053
|
};
|
|
890
|
-
const filter6 =
|
|
1054
|
+
const filter6 = computed7(() => {
|
|
891
1055
|
const nonNull = [...items.value.values()].map((a) => a.filter).filter((f) => f !== null);
|
|
892
1056
|
if (nonNull.length === 0) return emptyFilter();
|
|
893
1057
|
return FilterInfo.createAnd(...nonNull);
|
|
@@ -899,16 +1063,16 @@ function useFilterPanel() {
|
|
|
899
1063
|
}
|
|
900
1064
|
|
|
901
1065
|
// src/filter/textFilterItem.ts
|
|
902
|
-
import { computed as
|
|
1066
|
+
import { computed as computed8, ref as ref11 } from "vue";
|
|
903
1067
|
import { filter, con } from "ys.knife.query.js";
|
|
904
1068
|
function useTextFilterItem(props) {
|
|
905
|
-
const value =
|
|
1069
|
+
const value = ref11(
|
|
906
1070
|
typeof props.defaultValue === "string" ? props.defaultValue : ""
|
|
907
1071
|
);
|
|
908
1072
|
function isEmpty(v) {
|
|
909
1073
|
return v == null || v.trim() === "";
|
|
910
1074
|
}
|
|
911
|
-
const filterInfo =
|
|
1075
|
+
const filterInfo = computed8(() => {
|
|
912
1076
|
if (isEmpty(value.value)) return null;
|
|
913
1077
|
return filter(props.propertyPath, props.op, con(value.value));
|
|
914
1078
|
});
|
|
@@ -919,16 +1083,16 @@ function useTextFilterItem(props) {
|
|
|
919
1083
|
}
|
|
920
1084
|
|
|
921
1085
|
// src/filter/dateFilterItem.ts
|
|
922
|
-
import { computed as
|
|
1086
|
+
import { computed as computed9, ref as ref12 } from "vue";
|
|
923
1087
|
import { filter as filter2, con as con2 } from "ys.knife.query.js";
|
|
924
1088
|
function useDateFilterItem(props) {
|
|
925
|
-
const value =
|
|
1089
|
+
const value = ref12(
|
|
926
1090
|
typeof props.defaultValue === "string" ? props.defaultValue : ""
|
|
927
1091
|
);
|
|
928
1092
|
function isEmpty(v) {
|
|
929
1093
|
return v == null || v.trim() === "";
|
|
930
1094
|
}
|
|
931
|
-
const filterInfo =
|
|
1095
|
+
const filterInfo = computed9(() => {
|
|
932
1096
|
if (isEmpty(value.value)) return null;
|
|
933
1097
|
return filter2(props.propertyPath, props.op, con2(value.value));
|
|
934
1098
|
});
|
|
@@ -939,7 +1103,7 @@ function useDateFilterItem(props) {
|
|
|
939
1103
|
}
|
|
940
1104
|
|
|
941
1105
|
// src/filter/dateRangeFilterItem.ts
|
|
942
|
-
import { computed as
|
|
1106
|
+
import { computed as computed10, ref as ref13 } from "vue";
|
|
943
1107
|
import { filter as filter3, con as con3, Operator } from "ys.knife.query.js";
|
|
944
1108
|
function useDateRangeFilterItem(props) {
|
|
945
1109
|
function toRange(v) {
|
|
@@ -949,11 +1113,11 @@ function useDateRangeFilterItem(props) {
|
|
|
949
1113
|
return null;
|
|
950
1114
|
}
|
|
951
1115
|
const initial = toRange(props.defaultValue);
|
|
952
|
-
const value =
|
|
1116
|
+
const value = ref13(initial);
|
|
953
1117
|
function isEmpty(v) {
|
|
954
1118
|
return v == null || v.length !== 2 || !v[0] || !v[1];
|
|
955
1119
|
}
|
|
956
|
-
const filterInfo =
|
|
1120
|
+
const filterInfo = computed10(() => {
|
|
957
1121
|
if (isEmpty(value.value)) return null;
|
|
958
1122
|
const [start, end] = value.value;
|
|
959
1123
|
return filter3(props.propertyPath, Operator.Between, con3([start, end]));
|
|
@@ -965,7 +1129,7 @@ function useDateRangeFilterItem(props) {
|
|
|
965
1129
|
}
|
|
966
1130
|
|
|
967
1131
|
// src/filter/enumFilterItem.ts
|
|
968
|
-
import { computed as
|
|
1132
|
+
import { computed as computed11, ref as ref14 } from "vue";
|
|
969
1133
|
import { filter as filter4, con as con4, Operator as Operator2 } from "ys.knife.query.js";
|
|
970
1134
|
function toSingleValue(v) {
|
|
971
1135
|
if (typeof v === "string" || typeof v === "number") return v;
|
|
@@ -981,7 +1145,7 @@ function toMultiValue(v) {
|
|
|
981
1145
|
}
|
|
982
1146
|
function useEnumFilterItem(props) {
|
|
983
1147
|
const isMultiple = props.multiple === true;
|
|
984
|
-
const value =
|
|
1148
|
+
const value = ref14(
|
|
985
1149
|
isMultiple ? toMultiValue(props.defaultValue) : toSingleValue(props.defaultValue)
|
|
986
1150
|
);
|
|
987
1151
|
function isEmpty() {
|
|
@@ -993,7 +1157,7 @@ function useEnumFilterItem(props) {
|
|
|
993
1157
|
if (typeof v === "string" && v.trim() === "") return true;
|
|
994
1158
|
return false;
|
|
995
1159
|
}
|
|
996
|
-
const filterInfo =
|
|
1160
|
+
const filterInfo = computed11(() => {
|
|
997
1161
|
if (isEmpty()) return null;
|
|
998
1162
|
if (isMultiple) {
|
|
999
1163
|
const arr = value.value;
|
|
@@ -1019,7 +1183,7 @@ function useEnumFilterItem(props) {
|
|
|
1019
1183
|
}
|
|
1020
1184
|
|
|
1021
1185
|
// src/advancedFilter/advancedFilter.ts
|
|
1022
|
-
import { computed as
|
|
1186
|
+
import { computed as computed12, ref as ref15 } from "vue";
|
|
1023
1187
|
import { FilterInfo as FilterInfo2, Operator as Operator3, con as con5, emptyFilter as emptyFilter2, filter as filter5 } from "ys.knife.query.js";
|
|
1024
1188
|
import { isConditionGroup, isNullOperator } from "@ys-knife-crud/core";
|
|
1025
1189
|
import {
|
|
@@ -1034,7 +1198,7 @@ function useAdvancedFilter(props) {
|
|
|
1034
1198
|
function nextId(prefix) {
|
|
1035
1199
|
return `adv-${prefix}-${++seq}`;
|
|
1036
1200
|
}
|
|
1037
|
-
const fieldTypeMap =
|
|
1201
|
+
const fieldTypeMap = computed12(() => {
|
|
1038
1202
|
const map = /* @__PURE__ */ new Map();
|
|
1039
1203
|
for (const col of props.columns) {
|
|
1040
1204
|
map.set(
|
|
@@ -1076,7 +1240,7 @@ function useAdvancedFilter(props) {
|
|
|
1076
1240
|
children: [newLeaf()]
|
|
1077
1241
|
};
|
|
1078
1242
|
}
|
|
1079
|
-
const rootGroup =
|
|
1243
|
+
const rootGroup = ref15({
|
|
1080
1244
|
id: "root",
|
|
1081
1245
|
combinator: "and",
|
|
1082
1246
|
children: [newLeaf()]
|
|
@@ -1230,7 +1394,7 @@ function useAdvancedFilter(props) {
|
|
|
1230
1394
|
}
|
|
1231
1395
|
return buildConditionFilter(node);
|
|
1232
1396
|
}
|
|
1233
|
-
const filterInfo =
|
|
1397
|
+
const filterInfo = computed12(() => {
|
|
1234
1398
|
const f = buildNodeFilter(rootGroup.value);
|
|
1235
1399
|
return f ?? emptyFilter2();
|
|
1236
1400
|
});
|
|
@@ -1273,6 +1437,7 @@ export {
|
|
|
1273
1437
|
isGroupNode,
|
|
1274
1438
|
setDefaultModalAppContext,
|
|
1275
1439
|
useAdvancedFilter,
|
|
1440
|
+
useCollectData,
|
|
1276
1441
|
useCustomConfig,
|
|
1277
1442
|
useDateFilterItem,
|
|
1278
1443
|
useDateRangeFilterItem,
|