@dazhicheng/ui 1.5.265 → 1.6.0

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.
Files changed (104) hide show
  1. package/dist/components/tt-area/TtArea.vue.js +1 -1
  2. package/dist/components/tt-drawer/src/components/DrawerHeader.vue.js +2 -2
  3. package/dist/components/tt-drawer/src/hooks/useResizable.js +2 -2
  4. package/dist/components/tt-form/src/components/FormElInput.vue.js +51 -38
  5. package/dist/components/tt-form/src/form-render/FormField.vue2.js +36 -36
  6. package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.d.ts +3 -3
  7. package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.js +3 -1
  8. package/dist/components/tt-icon/index.vue.js +2 -2
  9. package/dist/components/tt-loading/src/loading.vue.js +2 -2
  10. package/dist/components/tt-modal-form/index.vue.js +13 -12
  11. package/dist/components/tt-panel-select/src/components/PanelMiddle.vue.d.ts +2 -2
  12. package/dist/components/tt-panel-select/src/hooks/usePanelData.js +93 -86
  13. package/dist/components/tt-panel-select/src/index.vue.js +1 -0
  14. package/dist/components/tt-select/src/Select.vue.d.ts +4 -4
  15. package/dist/components/tt-select/src/components/Table.vue.d.ts +4 -4
  16. package/dist/components/tt-table/index.d.ts +523 -358
  17. package/dist/components/tt-table/index.js +7 -4
  18. package/dist/components/tt-table/src/Table.vue.d.ts +306 -216
  19. package/dist/components/tt-table/src/Table.vue.js +405 -618
  20. package/dist/components/tt-table/src/TableForm.vue.d.ts +384 -19
  21. package/dist/components/tt-table/src/TableForm.vue.js +219 -228
  22. package/dist/components/tt-table/src/components/TableAction.vue.js +108 -131
  23. package/dist/components/tt-table/src/components/TableButtons.js +25 -25
  24. package/dist/components/tt-table/src/components/TableColumnModal.vue2.js +88 -85
  25. package/dist/components/tt-table/src/components/TableToolbarTools.vue.d.ts +80 -0
  26. package/dist/components/tt-table/src/components/{TableToobalTools.vue.js → TableToolbarTools.vue.js} +29 -31
  27. package/dist/components/tt-table/src/components/TableToolbarTools.vue2.js +4 -0
  28. package/dist/components/tt-table/src/emits.js +2 -1
  29. package/dist/components/tt-table/src/hooks/useColumnPersistence.d.ts +19 -0
  30. package/dist/components/tt-table/src/hooks/useColumnPersistence.js +63 -0
  31. package/dist/components/tt-table/src/hooks/useColumns.d.ts +505 -21
  32. package/dist/components/tt-table/src/hooks/useColumns.js +100 -245
  33. package/dist/components/tt-table/src/hooks/useGridProps.d.ts +36 -0
  34. package/dist/components/tt-table/src/hooks/useGridProps.js +121 -0
  35. package/dist/components/tt-table/src/hooks/useKeyboardNav.d.ts +11 -0
  36. package/dist/components/tt-table/src/hooks/useKeyboardNav.js +97 -0
  37. package/dist/components/tt-table/src/hooks/usePagination.d.ts +14 -8
  38. package/dist/components/tt-table/src/hooks/usePagination.js +29 -33
  39. package/dist/components/tt-table/src/hooks/useQuery.d.ts +41 -0
  40. package/dist/components/tt-table/src/hooks/useQuery.js +147 -0
  41. package/dist/components/tt-table/src/hooks/useRowIdentity.d.ts +22 -0
  42. package/dist/components/tt-table/src/hooks/useRowIdentity.js +96 -0
  43. package/dist/components/tt-table/src/hooks/useRowSelection.d.ts +23 -7
  44. package/dist/components/tt-table/src/hooks/useRowSelection.js +95 -71
  45. package/dist/components/tt-table/src/hooks/{useLeftRightSlot.d.ts → useSideSlot.d.ts} +25 -17
  46. package/dist/components/tt-table/src/hooks/useSideSlot.js +77 -0
  47. package/dist/components/tt-table/src/hooks/useSyncProps.d.ts +12 -0
  48. package/dist/components/tt-table/src/hooks/useSyncProps.js +55 -0
  49. package/dist/components/tt-table/src/hooks/useTableData.d.ts +71 -0
  50. package/dist/components/tt-table/src/hooks/useTableData.js +307 -0
  51. package/dist/components/tt-table/src/hooks/useTableFooter.d.ts +15 -0
  52. package/dist/components/tt-table/src/hooks/useTableFooter.js +46 -0
  53. package/dist/components/tt-table/src/hooks/useTableForm.d.ts +10 -5
  54. package/dist/components/tt-table/src/hooks/useTableForm.js +55 -48
  55. package/dist/components/tt-table/src/hooks/useTableMethods.d.ts +165 -0
  56. package/dist/components/tt-table/src/hooks/useTableMethods.js +183 -0
  57. package/dist/components/tt-table/src/hooks/useTableRender.d.ts +24 -55
  58. package/dist/components/tt-table/src/props.d.ts +318 -151
  59. package/dist/components/tt-table/src/props.js +117 -270
  60. package/dist/components/tt-table/src/table-defaults.d.ts +25 -0
  61. package/dist/components/tt-table/src/table-defaults.js +71 -0
  62. package/dist/components/tt-table/src/table-mutation-events.d.ts +43 -0
  63. package/dist/components/tt-table/src/table-mutation-events.js +70 -0
  64. package/dist/components/tt-table/src/types/table.d.ts +207 -88
  65. package/dist/components/tt-table/src/types/tableAction.d.ts +23 -0
  66. package/dist/components/tt-table/src/types/tableForm.d.ts +15 -26
  67. package/dist/components/tt-table/src/utils/action-tab-index.d.ts +2 -0
  68. package/dist/components/tt-table/src/utils/action-tab-index.js +50 -0
  69. package/dist/components/tt-table/src/utils/context.js +25 -12
  70. package/dist/components/tt-table/src/utils/table-api.d.ts +136 -58
  71. package/dist/components/tt-table/src/utils/table-api.js +198 -165
  72. package/dist/components/tt-table/src/utils/table-form-api.d.ts +11 -11
  73. package/dist/components/tt-table/src/utils/table-form-api.js +41 -31
  74. package/dist/components/types.d.ts +0 -20
  75. package/dist/hooks/useSetup.js +0 -3
  76. package/dist/index.d.ts +1 -0
  77. package/dist/index.js +105 -101
  78. package/dist/packages/hooks/src/useDebounce.js +6 -6
  79. package/dist/packages/utils/src/is.js +20 -18
  80. package/dist/packages/utils/src/tool.js +76 -149
  81. package/dist/style.css +1 -1
  82. package/dist/utils/uppercaseInput.d.ts +29 -0
  83. package/dist/utils/uppercaseInput.js +16 -0
  84. package/package.json +3 -3
  85. package/dist/components/tt-table/src/components/TableToobalTools.vue.d.ts +0 -576
  86. package/dist/components/tt-table/src/components/TableToobalTools.vue2.js +0 -4
  87. package/dist/components/tt-table/src/enum.d.ts +0 -2
  88. package/dist/components/tt-table/src/hooks/useCellArea.d.ts +0 -15
  89. package/dist/components/tt-table/src/hooks/useCellArea.js +0 -15
  90. package/dist/components/tt-table/src/hooks/useCustomColumns.d.ts +0 -20
  91. package/dist/components/tt-table/src/hooks/useCustomColumns.js +0 -65
  92. package/dist/components/tt-table/src/hooks/useDataSource.d.ts +0 -29
  93. package/dist/components/tt-table/src/hooks/useDataSource.js +0 -232
  94. package/dist/components/tt-table/src/hooks/useLeftRightSlot.js +0 -64
  95. package/dist/components/tt-table/src/hooks/useTable.d.ts +0 -7
  96. package/dist/components/tt-table/src/hooks/useTableEvent.d.ts +0 -101
  97. package/dist/components/tt-table/src/hooks/useTableEvent.js +0 -197
  98. package/dist/components/tt-table/src/hooks/useTableFormEvent.d.ts +0 -10
  99. package/dist/components/tt-table/src/hooks/useTableHeight.d.ts +0 -15
  100. package/dist/components/tt-table/src/hooks/useTableSlot.d.ts +0 -11
  101. package/dist/components/tt-table/src/hooks/useTableSlot.js +0 -17
  102. package/dist/components/tt-table/src/utils/filters.d.ts +0 -109
  103. package/dist/components/tt-table/src/utils/vxeTable.d.ts +0 -28
  104. package/dist/packages/utils/src/check.js +0 -10
@@ -1,10 +1,16 @@
1
- import { VxeGridPropTypes } from 'vxe-table';
2
- import { TtTableProps } from '../types/table';
3
1
  import { ComputedRef } from 'vue';
2
+ import { VxeGridPropTypes } from 'vxe-table';
4
3
  import { VxePagerDefines, VxePagerEvents } from 'vxe-pc-ui';
5
- type PaginationProps = VxeGridPropTypes.PagerConfig;
6
- export declare function usePagination(refProps: ComputedRef<TtTableProps>, emit: (event: "page-change", data: any) => void): {
7
- configRef: import('vue').Ref<{
4
+ import { TtTableProps } from '../types/table';
5
+ /** 分页配置类型 */
6
+ type PagerConfig = VxeGridPropTypes.PagerConfig;
7
+ /**
8
+ * 表格分页状态
9
+ * @param propsRef 表格 props
10
+ * @param emit 组件 emit
11
+ */
12
+ export declare function usePagination(propsRef: ComputedRef<TtTableProps>, emit: (event: "page-change", data: any) => void): {
13
+ pagination: import('vue').Ref<{
8
14
  enabled?: boolean | undefined;
9
15
  slots?: {
10
16
  left?: string | ((params: import("vxe-pc-ui").VxePagerSlotTypes.LeftSlotParams) => import('vxe-pc-ui').VxeComponentSlotType | import('vxe-pc-ui').VxeComponentSlotType[]) | undefined;
@@ -95,9 +101,9 @@ export declare function usePagination(refProps: ComputedRef<TtTableProps>, emit:
95
101
  iconHomePage?: import("vxe-pc-ui").VxePagerPropTypes.IconHomePage | undefined;
96
102
  iconEndPage?: import("vxe-pc-ui").VxePagerPropTypes.IconEndPage | undefined;
97
103
  }>;
104
+ paginationInfo: ComputedRef<VxeGridPropTypes.PagerConfig | undefined>;
98
105
  getPagination: () => VxeGridPropTypes.PagerConfig | undefined;
99
- getPaginationInfo: ComputedRef<VxeGridPropTypes.PagerConfig | undefined>;
100
- setPagination: (info: Partial<PaginationProps>) => void;
101
- handlePageChange: (data: VxePagerDefines.PageChangeEventParams | Parameters<VxePagerEvents.PageChange>[0]) => void;
106
+ setPagination: (info: Partial<PagerConfig>) => void;
107
+ onPageChange: (data: VxePagerDefines.PageChangeEventParams | Parameters<VxePagerEvents.PageChange>[0]) => void;
102
108
  };
103
109
  export {};
@@ -1,7 +1,8 @@
1
+ import { GlobalConfig as f } from "../../../../hooks/useSetup.js";
1
2
  import "axios";
2
3
  import "element-plus";
3
4
  import "dayjs";
4
- import { ref as f, unref as e, computed as c, watch as l } from "vue";
5
+ import { ref as c, unref as e, computed as P, watch as l } from "vue";
5
6
  import "xe-utils";
6
7
  import "dayjs/plugin/utc";
7
8
  import "dayjs/plugin/timezone";
@@ -11,45 +12,40 @@ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ae
11
12
  import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
12
13
  import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
13
14
  import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
14
- import { isEqual as P } from "lodash-es";
15
- import { GlobalConfig as h } from "../../../../hooks/useSetup.js";
16
- function G(i, p) {
17
- var g;
18
- const o = f(
19
- s(e(i).pagerConfig || {}, ((g = h.table) == null ? void 0 : g.pagerConfig) || {})
20
- ), n = c(() => {
21
- const { showPager: t, pagerConfig: r } = e(i);
22
- if (!(!t && !r))
23
- return {
24
- currentPage: 1,
25
- pageSize: 300,
26
- total: 0,
27
- pageSizes: [300, 500, 1e3, 2e3],
28
- layouts: ["Total", "PrevPage", "JumpNumber", "NextPage", "Sizes", "FullJump"],
29
- // ...unref(refProps).pagerConfig,
30
- ...e(o)
31
- };
15
+ import "lodash-es";
16
+ const C = {
17
+ currentPage: 1,
18
+ pageSize: 300,
19
+ total: 0,
20
+ pageSizes: [300, 500, 1e3, 2e3],
21
+ layouts: ["Total", "PrevPage", "JumpNumber", "NextPage", "Sizes", "FullJump"]
22
+ };
23
+ function O(r, g) {
24
+ var a;
25
+ const o = c(
26
+ s(e(r).pagerConfig || {}, ((a = f.table) == null ? void 0 : a.pagerConfig) || {})
27
+ ), i = P(() => {
28
+ const { showPager: t, pagerConfig: u } = e(r);
29
+ if (!(!t && !u))
30
+ return { ...C, ...e(o) };
32
31
  });
33
- function m() {
34
- return e(n);
32
+ function p() {
33
+ return e(i);
35
34
  }
36
- function a(t) {
37
- o.value = {
38
- ...e(o),
39
- ...t
40
- };
35
+ function n(t) {
36
+ o.value = { ...e(o), ...t };
41
37
  }
42
- function u(t) {
43
- p("page-change", t);
38
+ function m(t) {
39
+ g("page-change", t);
44
40
  }
45
41
  return l(
46
- () => e(i).pagerConfig,
47
- (t, r) => {
48
- t && !P(t, r) && a(t);
42
+ () => e(r).pagerConfig,
43
+ (t) => {
44
+ t && n(t);
49
45
  },
50
46
  { deep: !0 }
51
- ), { configRef: o, getPagination: m, getPaginationInfo: n, setPagination: a, handlePageChange: u };
47
+ ), { pagination: o, paginationInfo: i, getPagination: p, setPagination: n, onPageChange: m };
52
48
  }
53
49
  export {
54
- G as usePagination
50
+ O as usePagination
55
51
  };
@@ -0,0 +1,41 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { VxeGridInstance, VxeGridPropTypes } from 'vxe-table';
3
+ import { Recordable } from '../../../../../../utils/src';
4
+ import { FetchParams, TtTableProps } from '../types/table';
5
+ /** 远程查询依赖的表格上下文 */
6
+ type QueryContext = {
7
+ grid: Ref<undefined | VxeGridInstance<Recordable>>;
8
+ /** 分页状态(可写) */
9
+ pagination: Ref<VxeGridPropTypes.PagerConfig>;
10
+ /** 分页完整信息(含默认值) */
11
+ paginationInfo: ComputedRef<undefined | VxeGridPropTypes.PagerConfig>;
12
+ setPagination: (info: Partial<VxeGridPropTypes.PagerConfig>) => void;
13
+ setLoading: (loading: boolean) => void;
14
+ /** 数据重新落表后重置选中态,关闭跨页选中时等价于清空选中 */
15
+ resetSelectionAfterFetch: () => void;
16
+ /** 已落表的数据,滚动加载时用于追加 */
17
+ rows: Ref<Recordable[]>;
18
+ /** 数据落表 */
19
+ applyRows: (rows: Recordable[], guard?: () => boolean) => Promise<boolean>;
20
+ };
21
+ /** 远程查询相关事件 */
22
+ type QueryEmit = {
23
+ (e: "fetch-success", data?: Recordable): void;
24
+ (e: "fetch-error", error?: unknown): void;
25
+ };
26
+ /**
27
+ * 表格远程数据的唯一请求入口
28
+ *
29
+ * 首次加载、分页变化、外部 reload、服务端筛选排序四类触发最终都汇聚到 query(),
30
+ * 由 queriedPage 快照避免请求自身回写分页导致的重复请求。
31
+ * @param propsRef 表格 props
32
+ * @param ctx 表格上下文
33
+ * @param emit 组件 emit
34
+ */
35
+ export declare function useQuery(propsRef: ComputedRef<TtTableProps>, ctx: QueryContext, emit: QueryEmit): {
36
+ query: (opt: FetchParams) => Promise<void>;
37
+ reload: (opt?: FetchParams) => Promise<void>;
38
+ reloadFilter: (type?: "sort" | "filter" | "page") => Promise<void>;
39
+ isLoaded: import('vue').ShallowRef<boolean, boolean>;
40
+ };
41
+ export {};
@@ -0,0 +1,147 @@
1
+ import { GlobalConfig as k } from "../../../../hooks/useSetup.js";
2
+ import "axios";
3
+ import "element-plus";
4
+ import { isFunction as b, isObject as ae, isUndefined as ne, isArray as se } from "../../../../packages/utils/src/is.js";
5
+ import { shallowRef as K, computed as oe, unref as t, watch as ce, onMounted as le, nextTick as ue, onScopeDispose as fe } from "vue";
6
+ import "xe-utils";
7
+ import "dayjs";
8
+ import "dayjs/plugin/utc";
9
+ import "dayjs/plugin/timezone";
10
+ import "../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
11
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
12
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
13
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
14
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
15
+ import { omit as me, set as R, get as x } from "lodash-es";
16
+ function Oe(s, W, O) {
17
+ const { grid: u, pagination: f, paginationInfo: d, setPagination: p, setLoading: q, resetSelectionAfterFetch: T, rows: X, applyRows: j } = W, P = K({ currentPage: 1 }), y = K(!1);
18
+ let w = !0, D = !1, S = !1, g;
19
+ const L = oe(() => {
20
+ const { showPager: e, isScrollFetch: r } = t(s);
21
+ return !!(e || r);
22
+ }), M = () => {
23
+ var e;
24
+ return !!((e = t(s).filterConfig) != null && e.remote);
25
+ };
26
+ function A(e) {
27
+ return { currentPage: (e == null ? void 0 : e.currentPage) || 1, pageSize: e == null ? void 0 : e.pageSize };
28
+ }
29
+ function Y(e) {
30
+ const r = t(s);
31
+ return g === e && !S && r.api === e.api && r.filterApi === e.filterApi;
32
+ }
33
+ function N(e, r) {
34
+ return ((e == null ? void 0 : e.currentPage) || 1) !== (r == null ? void 0 : r.currentPage) || (e == null ? void 0 : e.pageSize) !== (r == null ? void 0 : r.pageSize);
35
+ }
36
+ function Z(e) {
37
+ const { currentPageField: r, pageSizeField: i } = t(s), o = {};
38
+ return R(o, r, e.currentPage || 1), R(o, i, e.pageSize), o;
39
+ }
40
+ function _(e) {
41
+ return { ...t(d) || t(f), ...ae(e) ? e : {} };
42
+ }
43
+ function $(e) {
44
+ const r = se(e), i = r ? 0 : x(e, t(s).totalField);
45
+ return {
46
+ items: r ? e : x(e, t(s).dataField),
47
+ total: ne(i) ? 0 : Number(i)
48
+ };
49
+ }
50
+ async function ee(e, r, i) {
51
+ var n;
52
+ const { isScrollFetch: o, currentPageField: l = "" } = t(s), c = t(s).afterFetch ?? ((n = k.table) == null ? void 0 : n.afterFetch);
53
+ let a = e;
54
+ return b(c) && (a = await c(a, i) || a), o && x(r, l, 1) !== 1 && (a = [...t(X), ...a]), a;
55
+ }
56
+ async function h(e) {
57
+ var G, U, B;
58
+ const { api: r, filterApi: i, searchInfo: o, useSearchForm: l, formApi: c } = t(s);
59
+ if (S || !b(r)) return;
60
+ const a = { api: r, filterApi: i };
61
+ D = !0, g = a;
62
+ const n = () => Y(a);
63
+ try {
64
+ q(!0), t(s).immediate || (w = !1);
65
+ const m = _(e == null ? void 0 : e.tablePage), v = m.currentPage || 1, z = Z(m), te = c && l ? await c.getValues() : {};
66
+ if (!n()) return;
67
+ let F;
68
+ if (e.serverFilterParams && b(i))
69
+ F = await i({ ...e.serverFilterParams, ...t(L) ? z : {} });
70
+ else {
71
+ b(i) && ((G = t(u)) == null || G.clearSort(), (U = t(u)) == null || U.clearFilter());
72
+ let C = {
73
+ ...te,
74
+ ...o,
75
+ ...e.searchInfo,
76
+ ...t(L) ? z : {}
77
+ };
78
+ const J = t(s).beforeFetch ?? ((B = k.table) == null ? void 0 : B.beforeFetch);
79
+ if (b(J) && (C = await J(C) || C), !n()) return;
80
+ F = await r(C);
81
+ }
82
+ if (!n()) return;
83
+ const { items: re, total: E } = $(F), I = await ee(re || [], z, F);
84
+ if (!n()) return;
85
+ const H = E || I.length || 0, ie = Math.max(1, Math.ceil(H / m.pageSize));
86
+ if (v > ie) {
87
+ await Q({ tablePage: { currentPage: 1, pageSize: m.pageSize } });
88
+ return;
89
+ }
90
+ if (!await j(I, n) || !n() || (p({ total: H, currentPage: v }), P.value = A(t(d)), O("fetch-success", { items: I, total: E, rawDataSource: F }), !n()) || (T(), !n())) return;
91
+ y.value = !0;
92
+ } catch (m) {
93
+ if (!n() || (O("fetch-error", m), !n()) || !await j([], n) || !n() || (p({ total: 0 }), P.value = A(t(d)), T(), !n())) return;
94
+ y.value = !0;
95
+ } finally {
96
+ g === a && (g = void 0, q(!1));
97
+ }
98
+ }
99
+ async function Q(e) {
100
+ var i;
101
+ const r = { ...t(f) };
102
+ (i = k.table) != null && i.isReloadResetToFirstPage && (r.currentPage = 1), await h(
103
+ e ? {
104
+ tablePage: Object.hasOwn(e, "tablePage") ? e.tablePage : r,
105
+ searchInfo: Object.hasOwn(e, "searchInfo") ? e.searchInfo : me(e, ["tablePage", "serverFilterParams"])
106
+ } : { tablePage: r }
107
+ ), t(s).immediate || (w = !1);
108
+ }
109
+ async function V(e) {
110
+ var l, c;
111
+ if (!M()) return;
112
+ const r = { ...t(f) };
113
+ e !== "page" && (r.currentPage = 1);
114
+ const i = (((l = t(u)) == null ? void 0 : l.getCheckedFilters()) || []).map((a) => ({
115
+ fieldName: a.field,
116
+ checkAll: !1,
117
+ includeValues: a.datas[0],
118
+ excludeValues: []
119
+ })), o = (((c = t(u)) == null ? void 0 : c.getSortColumns()) || []).map((a) => ({
120
+ fieldName: a.field,
121
+ isAscending: a.order === "asc"
122
+ }));
123
+ await h({ serverFilterParams: { filterConditions: i, sortConditions: o }, tablePage: r });
124
+ }
125
+ return ce([() => t(f).currentPage, () => t(f).pageSize], ([e, r]) => {
126
+ var l, c;
127
+ const i = { ...t(f), currentPage: e, pageSize: r };
128
+ if (!N(i, t(P))) return;
129
+ if (w && !t(s).immediate) {
130
+ w = !1;
131
+ return;
132
+ }
133
+ const o = (((l = t(u)) == null ? void 0 : l.getSortColumns()) || []).length > 0 || (((c = t(u)) == null ? void 0 : c.getCheckedFilters()) || []).length > 0;
134
+ M() && o ? V("page") : h({ tablePage: { ...i } });
135
+ }), le(() => {
136
+ P.value = A(t(d)), ue(() => {
137
+ if (S || D) return;
138
+ const { immediate: e, pagerConfig: r } = t(s);
139
+ e && (!r || !N(r, t(P))) && h({ tablePage: t(d) });
140
+ });
141
+ }), fe(() => {
142
+ S = !0, g = void 0;
143
+ }), { query: h, reload: Q, reloadFilter: V, isLoaded: y };
144
+ }
145
+ export {
146
+ Oe as useQuery
147
+ };
@@ -0,0 +1,22 @@
1
+ import { ComputedRef } from 'vue';
2
+ import { VxeTablePropTypes } from 'vxe-table';
3
+ import { Recordable } from '../../../../../../utils/src';
4
+ import { TtTableProps } from '../types/table';
5
+ /** 表格支持的行主键值。 */
6
+ type RowKey = number | string;
7
+ /** 行主键相关的 VXE 配置。 */
8
+ type RowConfig = VxeTablePropTypes.RowConfig<Recordable>;
9
+ /**
10
+ * 表格行身份适配器。
11
+ *
12
+ * VXE 要求 keyField 指向行对象上的字段,并会在字段为空时把生成值写回该字段。
13
+ * 这里把 VXE key 改写到不可枚举的组件私有字段,业务 tableRowId 只用于派生稳定值,
14
+ * 因此新增行仍可选择、展开和拖拽,但内部 ID 不会进入 JSON payload。
15
+ * @param propsRef 表格配置
16
+ */
17
+ export declare function useRowIdentity(propsRef: ComputedRef<TtTableProps>): {
18
+ getRowKey: (row: Recordable) => RowKey | undefined;
19
+ prepareRows: (records: Recordable | Recordable[]) => void;
20
+ toVxeRowConfig: (rowConfig?: RowConfig) => RowConfig;
21
+ };
22
+ export {};
@@ -0,0 +1,96 @@
1
+ import "axios";
2
+ import "element-plus";
3
+ import { isObject as F, isFunction as x, isArray as _, isNumber as B, isString as E } from "../../../../packages/utils/src/is.js";
4
+ import { getCurrentInstance as W, unref as a, toRaw as C } from "vue";
5
+ import "xe-utils";
6
+ import "dayjs";
7
+ import "dayjs/plugin/utc";
8
+ import "dayjs/plugin/timezone";
9
+ import "../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
10
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
11
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
12
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
13
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
14
+ import { get as l } from "lodash-es";
15
+ const y = "__tt_table_internal_row_key__";
16
+ function c(o) {
17
+ return B(o) ? !0 : E(o) && !!o;
18
+ }
19
+ function X(o) {
20
+ var v;
21
+ const P = ((v = W()) == null ? void 0 : v.uid) || 0;
22
+ let m = 0;
23
+ const K = /* @__PURE__ */ new WeakSet();
24
+ function w() {
25
+ return a(o).tableRowId || "id";
26
+ }
27
+ function p(e) {
28
+ const t = l(e, w());
29
+ return c(t) ? t : void 0;
30
+ }
31
+ function g(e) {
32
+ const t = Reflect.get(e, y);
33
+ return c(t) ? t : void 0;
34
+ }
35
+ function O() {
36
+ return m += 1, `tt_row_${P}_${m}`;
37
+ }
38
+ function S(e, t) {
39
+ const r = C(e), n = Object.getOwnPropertyDescriptor(r, y), i = n && c(n.value) ? n.value : t;
40
+ if (n && !n.enumerable && c(n.value)) return i;
41
+ try {
42
+ Object.defineProperty(r, y, {
43
+ configurable: !0,
44
+ enumerable: !1,
45
+ value: i,
46
+ writable: !0
47
+ });
48
+ } catch {
49
+ K.has(r) || K.add(r);
50
+ }
51
+ return i;
52
+ }
53
+ function f({ row: e }) {
54
+ var d;
55
+ const t = g(e);
56
+ if (c(t)) return t;
57
+ const r = (d = a(o).rowConfig) == null ? void 0 : d.createKeyMethod, n = x(r) ? r({ row: e, keyField: w() }) : void 0, i = p(e), u = c(n) ? n : c(i) ? i : O();
58
+ return S(e, u);
59
+ }
60
+ function j(e = {}) {
61
+ return e.keyField ? e : {
62
+ ...e,
63
+ keyField: y,
64
+ createKeyMethod: f
65
+ };
66
+ }
67
+ function I(e) {
68
+ var i;
69
+ const t = p(e);
70
+ if (c(t)) return t;
71
+ const r = (i = a(o).rowConfig) == null ? void 0 : i.keyField;
72
+ if (r) {
73
+ const u = l(e, r);
74
+ return c(u) ? u : void 0;
75
+ }
76
+ const n = g(e);
77
+ return c(n) ? n : f({ row: e });
78
+ }
79
+ function M(e) {
80
+ var u, d, R;
81
+ if ((u = a(o).rowConfig) != null && u.keyField) return;
82
+ const t = _(e) ? e : [e], r = /* @__PURE__ */ new WeakSet(), n = ((d = a(o).treeConfig) == null ? void 0 : d.childrenField) || ((R = a(o).treeConfig) == null ? void 0 : R.children) || "children";
83
+ function i(s) {
84
+ const b = C(s);
85
+ if (r.has(b)) return;
86
+ r.add(b), f({ row: s });
87
+ const h = l(s, n);
88
+ _(h) && h.forEach((k) => F(k) && i(k));
89
+ }
90
+ t.forEach((s) => F(s) && i(s));
91
+ }
92
+ return { getRowKey: I, prepareRows: M, toVxeRowConfig: j };
93
+ }
94
+ export {
95
+ X as useRowIdentity
96
+ };
@@ -1,8 +1,9 @@
1
1
  import { ComputedRef, Ref } from 'vue';
2
2
  import { VxeGridDefines, VxeGridEvents, VxeGridInstance, VxeTableExtendCellAreaDefines } from 'vxe-table';
3
- import { TtSelectRowKeysType, TtSelectRowsType, TtTableProps } from '../types/table';
4
3
  import { Recordable } from '../../../../../../utils/src';
5
- type EmitType = {
4
+ import { TtSelectRowKeysType, TtSelectRowsType, TtTableProps } from '../types/table';
5
+ /** 行选择相关事件 */
6
+ type SelectionEmit = {
6
7
  (e: "selection-change", data?: {
7
8
  keys: TtSelectRowKeysType;
8
9
  rows: TtSelectRowsType;
@@ -12,19 +13,34 @@ type EmitType = {
12
13
  (e: "checkbox-all", data?: VxeGridDefines.CheckboxAllEventParams): void;
13
14
  (e: "checkbox-range-change", data?: VxeGridDefines.CheckboxRangeChangeEventParams): void;
14
15
  (e: "radio-change", data?: VxeGridDefines.RadioChangeEventParams): void;
16
+ (e: "cell-area-selection-end", data?: VxeTableExtendCellAreaDefines.CellAreaSelectionAllEndEventParams): void;
15
17
  };
16
- export declare function useRowSelection(propsRef: ComputedRef<TtTableProps>, emit: EmitType, xGrid: Ref<VxeGridInstance<Recordable>>): {
18
+ /** 行选择使用的行身份适配器。 */
19
+ type RowSelectionIdentity = {
20
+ /** 获取业务兼容的行主键。 */
21
+ getRowKey: (row: Recordable) => number | string | undefined;
22
+ };
23
+ /**
24
+ * 行选择状态(复选框、单选框、区域选择)
25
+ * @param propsRef 表格 props
26
+ * @param grid vxe-grid 实例
27
+ * @param emit 组件 emit
28
+ * @param identity 行身份适配器
29
+ */
30
+ export declare function useRowSelection(propsRef: ComputedRef<TtTableProps>, grid: Ref<undefined | VxeGridInstance<Recordable>>, emit: SelectionEmit, identity: RowSelectionIdentity): {
17
31
  selectedKeys: Ref<any, any>;
18
32
  selectedRows: Ref<any, any>;
33
+ selectedKeyList: ComputedRef<(string | number)[]>;
34
+ getSelectRowKeys: () => any;
35
+ getSelectRows: () => TtSelectRowsType;
36
+ syncSelection: (data?: Recordable) => void;
19
37
  setSelectedRowKeys: (rows: TtSelectRowsType, keys?: TtSelectRowKeysType) => Promise<void>;
20
- onCellAreaSelectionEndSetCheckbox: (data: VxeTableExtendCellAreaDefines.CellAreaSelectionAllEndEventParams) => Promise<void>;
21
38
  clearSelectedRowKeys: () => void;
39
+ resetSelectionAfterFetch: () => void;
22
40
  onCheckboxChange: VxeGridEvents.CheckboxChange<any>;
23
41
  onCheckboxAll: VxeGridEvents.CheckboxAll<any>;
24
- getSelectRowKeys: () => any;
25
- getSelectRows: () => TtSelectRowsType;
26
42
  onCheckboxRangeChange: VxeGridEvents.CheckboxRangeChange<any>;
27
43
  onRadioChange: (data: VxeGridDefines.RadioChangeEventParams) => void;
28
- getCheckboxSelectedKeys: ComputedRef<(string | number)[]>;
44
+ onCellAreaSelectionEnd: VxeGridEvents.CellAreaSelectionAllEnd<any>;
29
45
  };
30
46
  export {};
@@ -1,84 +1,108 @@
1
- import { isArray as b } from "lodash-es";
2
- import { ref as f, computed as I, unref as o, toValue as A } from "vue";
3
- function B(u, l, n) {
4
- const s = f([]), h = f([]), k = I(() => {
5
- const { showCheckbox: e, showRadio: c } = o(u), t = A(s);
6
- return e ? t : c ? t ? [t] : [] : [];
1
+ import { GlobalConfig as M } from "../../../../hooks/useSetup.js";
2
+ import "axios";
3
+ import "element-plus";
4
+ import { isArray as y } from "../../../../packages/utils/src/is.js";
5
+ import { ref as p, computed as P, unref as t, toValue as V, nextTick as $ } from "vue";
6
+ import "xe-utils";
7
+ import "dayjs";
8
+ import "dayjs/plugin/utc";
9
+ import "dayjs/plugin/timezone";
10
+ import "../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
11
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
12
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
13
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
14
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
15
+ import "lodash-es";
16
+ function ee(R, s, i, d) {
17
+ const { getRowKey: h } = d, a = p([]), k = p([]), K = P(() => {
18
+ const { showCheckbox: e, showRadio: o } = t(R), c = V(a);
19
+ return e ? c || [] : o ? c ? [c] : [] : [];
7
20
  });
8
- function i() {
9
- return o(s);
21
+ function x() {
22
+ return t(a);
10
23
  }
11
- function a() {
12
- const { showCheckbox: e, showRadio: c } = o(u);
13
- return e ? o(n).getCheckboxRecords(!0) : c ? o(n).getRadioRecord(!0) : [];
24
+ function v() {
25
+ var n, r, w;
26
+ const { showCheckbox: e, showRadio: o, reserveSelection: c } = t(R);
27
+ if (e) {
28
+ const C = ((n = t(s)) == null ? void 0 : n.getCheckboxRecords(!0)) || [];
29
+ if (!c) return C;
30
+ const g = ((r = t(s)) == null ? void 0 : r.getCheckboxReserveRecords(!0)) || [], f = /* @__PURE__ */ new Map();
31
+ return C.forEach((l) => f.set(h(l), l)), g.forEach((l) => {
32
+ const b = h(l);
33
+ f.has(b) || f.set(b, l);
34
+ }), [...f.values()];
35
+ }
36
+ return o ? (w = t(s)) == null ? void 0 : w.getRadioRecord(!0) : [];
37
+ }
38
+ function A() {
39
+ var e;
40
+ return ((e = t(s)) == null ? void 0 : e.getTableData().fullData) || [];
14
41
  }
15
- function r(e) {
16
- const { tableRowId: c } = o(u);
17
- h.value = a(), s.value = o(h).map((t) => t[c || "id"]), l("selection-change", {
18
- keys: i(),
19
- rows: a(),
20
- data: e
21
- });
42
+ function u(e) {
43
+ const o = v();
44
+ k.value = o, a.value = y(o) ? o.map((c) => h(c)) : o ? h(o) : void 0, i("selection-change", { keys: x(), rows: o, data: e });
22
45
  }
23
- const C = (e) => {
24
- r(e), l("checkbox-change", e);
25
- }, v = (e) => {
26
- r(e), l("checkbox-all", e);
27
- }, y = (e) => {
28
- l("checkbox-range-change", e);
29
- const { records: c } = e;
30
- c && c.length === 1 || r(e);
31
- }, d = async (e, c = []) => {
32
- const { tableRowId: t, showCheckbox: w, showRadio: R } = o(u);
33
- h.value = e, w && (b(c) && c.length === 0 && b(e) && e.length !== 0 && (c = e.map((g) => g[t || "id"])), s.value = c, o(n) && await o(n).setCheckboxRow(e, !0)), R && (e = e, s.value = e[t || "id"], o(n) && await o(n).setRadioRow(e)), setTimeout(() => {
34
- l("selection-change", {
35
- keys: i(),
36
- rows: a()
37
- });
38
- }, 200);
39
- }, S = () => {
40
- const { showCheckbox: e, showRadio: c } = o(u);
41
- e && (s.value = [], h.value = [], o(n) && o(n).clearCheckboxRow(), l("selection-change", {
42
- keys: i(),
43
- rows: a()
44
- })), c && (s.value = void 0, h.value = void 0, o(n) && o(n).clearRadioRow());
46
+ const B = (e) => {
47
+ u(e), i("checkbox-change", e);
48
+ }, E = (e) => {
49
+ u(e), i("checkbox-all", e);
50
+ }, m = (e) => {
51
+ var o;
52
+ i("checkbox-range-change", e), ((o = e.records) == null ? void 0 : o.length) !== 1 && u(e);
45
53
  };
46
- async function x(e) {
47
- const { rows: c, cols: t } = e;
48
- if (c.length !== 1 && o(n) && t.some((w) => w.type === "checkbox")) {
49
- const w = o(n).isCheckedByCheckboxRow(c[0]);
50
- await o(n).setCheckboxRow(c, !w);
51
- const { tableRowId: R } = o(u);
52
- h.value = a(), s.value = o(h).map((g) => g[R || "id"]), l("selection-change", {
53
- keys: i(),
54
- rows: a(),
55
- data: e
56
- });
57
- }
54
+ function T(e) {
55
+ k.value = e.row, a.value = e.row ? h(e.row) : void 0, i("radio-change", e), i("selection-change", { keys: x(), rows: v(), data: e });
56
+ }
57
+ async function D(e) {
58
+ const { rows: o, cols: c } = e;
59
+ if (o.length === 1) return;
60
+ const n = t(s);
61
+ !n || !c.some((r) => r.type === "checkbox") || (await n.setCheckboxRow(o, !n.isCheckedByCheckboxRow(o[0])), u(e));
58
62
  }
59
- function K(e) {
60
- var c, t;
61
- h.value = e.row, s.value = (t = e.row) == null ? void 0 : t[((c = o(u)) == null ? void 0 : c.tableRowId) || "id"], l("radio-change", e), l("selection-change", {
62
- keys: i(),
63
- rows: a(),
64
- data: e
65
- });
63
+ const F = (e) => {
64
+ var n;
65
+ const { checkboxConfig: o, showCheckbox: c } = t(R);
66
+ o != null && o.range && c ? m({ records: e.rows }) : (n = M.table) != null && n.isAreaCheckboxSelection && D(e), i("cell-area-selection-end", e);
67
+ };
68
+ async function G(e, o = []) {
69
+ var f, l;
70
+ const { showCheckbox: c, showRadio: n } = t(R), r = y(e) ? e : e ? [e] : [], w = /* @__PURE__ */ new Set([
71
+ ...r.map((b) => h(b)),
72
+ ...y(o) ? o : o == null ? [] : [o]
73
+ ]), C = A().filter((b) => w.has(h(b))), g = C.length ? C : r;
74
+ c && await ((f = t(s)) == null ? void 0 : f.setCheckboxRow(g, !0)), n && await ((l = t(s)) == null ? void 0 : l.setRadioRow(g[0])), await $(), u();
75
+ }
76
+ function S() {
77
+ var n, r, w;
78
+ const { showCheckbox: e, showRadio: o, reserveSelection: c } = t(R);
79
+ !e && !o || (e && (a.value = [], k.value = [], (n = t(s)) == null || n.clearCheckboxRow(), c && ((r = t(s)) == null || r.clearCheckboxReserve())), o && (a.value = void 0, k.value = void 0, (w = t(s)) == null || w.clearRadioRow()), i("selection-change", { keys: x(), rows: v() }));
80
+ }
81
+ function L() {
82
+ const { showCheckbox: e, reserveSelection: o } = t(R);
83
+ if (!e || !o) {
84
+ S();
85
+ return;
86
+ }
87
+ u();
66
88
  }
67
89
  return {
68
- selectedKeys: s,
69
- selectedRows: h,
70
- setSelectedRowKeys: d,
71
- onCellAreaSelectionEndSetCheckbox: x,
90
+ selectedKeys: a,
91
+ selectedRows: k,
92
+ selectedKeyList: K,
93
+ getSelectRowKeys: x,
94
+ getSelectRows: v,
95
+ syncSelection: u,
96
+ setSelectedRowKeys: G,
72
97
  clearSelectedRowKeys: S,
73
- onCheckboxChange: C,
74
- onCheckboxAll: v,
75
- getSelectRowKeys: i,
76
- getSelectRows: a,
77
- onCheckboxRangeChange: y,
78
- onRadioChange: K,
79
- getCheckboxSelectedKeys: k
98
+ resetSelectionAfterFetch: L,
99
+ onCheckboxChange: B,
100
+ onCheckboxAll: E,
101
+ onCheckboxRangeChange: m,
102
+ onRadioChange: T,
103
+ onCellAreaSelectionEnd: F
80
104
  };
81
105
  }
82
106
  export {
83
- B as useRowSelection
107
+ ee as useRowSelection
84
108
  };