@dazhicheng/ui 1.5.266 → 1.6.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.
Files changed (182) hide show
  1. package/dist/components/tt-api-component/index.js +4 -3
  2. package/dist/components/tt-api-component/index.vue2.js +4 -3
  3. package/dist/components/tt-area/TtArea.vue.js +1 -1
  4. package/dist/components/tt-area/TtArea.vue3.js +8 -7
  5. package/dist/components/tt-button/index.js +5 -4
  6. package/dist/components/tt-button/index.vue2.js +4 -3
  7. package/dist/components/tt-checkbox/index.js +4 -3
  8. package/dist/components/tt-checkbox/index.vue.js +4 -3
  9. package/dist/components/tt-drawer/index.js +4 -3
  10. package/dist/components/tt-drawer/src/RenderDrawer.vue.js +4 -3
  11. package/dist/components/tt-drawer/src/components/DrawerFooter.vue.js +8 -7
  12. package/dist/components/tt-drawer/src/components/DrawerHeader.vue.js +2 -2
  13. package/dist/components/tt-drawer/src/components/DrawerHeader.vue2.js +3 -2
  14. package/dist/components/tt-drawer/src/hooks/useResizable.js +2 -2
  15. package/dist/components/tt-drawer/src/props.js +3 -2
  16. package/dist/components/tt-drawer/src/utils/drawer-api.js +4 -2
  17. package/dist/components/tt-empty/index.js +9 -8
  18. package/dist/components/tt-form/index.js +10 -9
  19. package/dist/components/tt-form/src/components/ExpandableArrow.vue2.js +3 -2
  20. package/dist/components/tt-form/src/components/FormActions.vue2.js +4 -2
  21. package/dist/components/tt-form/src/form/FormDescription.vue.js +3 -2
  22. package/dist/components/tt-form/src/form/FormItem.vue.js +6 -5
  23. package/dist/components/tt-form/src/form/FormLabel.vue.js +8 -7
  24. package/dist/components/tt-form/src/form/RenderContent.vue.js +4 -3
  25. package/dist/components/tt-form/src/form-render/FormField.vue2.js +30 -28
  26. package/dist/components/tt-form/src/form-render/FormLabel.vue2.js +4 -2
  27. package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.d.ts +3 -3
  28. package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.js +1 -0
  29. package/dist/components/tt-form/src/form-render/array-register/utils.js +6 -4
  30. package/dist/components/tt-form/src/form-render/dependencies.js +19 -18
  31. package/dist/components/tt-form/src/form-render/form.vue2.js +4 -2
  32. package/dist/components/tt-form/src/form-render/helper.js +15 -14
  33. package/dist/components/tt-form/src/form-render/rootWrapperClass.js +3 -2
  34. package/dist/components/tt-form/src/formApi.js +3 -2
  35. package/dist/components/tt-form/src/group-form/GroupForm.vue2.js +4 -3
  36. package/dist/components/tt-form/src/group-form/GroupSection.vue2.js +2 -0
  37. package/dist/components/tt-form/src/group-form/LazyFormField.vue.js +4 -2
  38. package/dist/components/tt-form/src/group-form/groupFormApi.js +4 -3
  39. package/dist/components/tt-form/src/hooks/useForwardPriorityValues.js +3 -2
  40. package/dist/components/tt-form/src/hooks/useSelectCollapse.js +28 -27
  41. package/dist/components/tt-form/src/index.vue2.js +3 -2
  42. package/dist/components/tt-form/src/useFormContext.js +11 -10
  43. package/dist/components/tt-form-item-error-tooltip/index.js +5 -4
  44. package/dist/components/tt-form-item-error-tooltip/index.vue.js +4 -3
  45. package/dist/components/tt-icon/index.js +6 -5
  46. package/dist/components/tt-icon/index.vue.js +2 -2
  47. package/dist/components/tt-image/index.js +6 -5
  48. package/dist/components/tt-image/src/components/ImageViewer.js +7 -6
  49. package/dist/components/tt-loading/index.js +4 -3
  50. package/dist/components/tt-loading/src/directive.js +24 -23
  51. package/dist/components/tt-loading/src/loading.vue.js +2 -2
  52. package/dist/components/tt-log/index.js +4 -3
  53. package/dist/components/tt-log/index.vue.js +3 -2
  54. package/dist/components/tt-modal/index.js +3 -2
  55. package/dist/components/tt-modal/src/RenderModal.vue.js +3 -2
  56. package/dist/components/tt-modal/src/components/ModalFooter.vue2.js +3 -2
  57. package/dist/components/tt-modal/src/components/ModalHeader.vue2.js +3 -2
  58. package/dist/components/tt-modal/src/components/ModalWrapper.vue.js +15 -14
  59. package/dist/components/tt-modal/src/props.js +3 -2
  60. package/dist/components/tt-modal/src/utils/modal-api.js +4 -2
  61. package/dist/components/tt-modal-form/index.vue.js +4 -3
  62. package/dist/components/tt-nav-anchor/index.js +4 -3
  63. package/dist/components/tt-nav-anchor/src/TtNavAnchor.vue.js +15 -14
  64. package/dist/components/tt-panel-select/index.js +4 -3
  65. package/dist/components/tt-panel-select/src/components/PanelMiddle.vue.d.ts +2 -2
  66. package/dist/components/tt-panel-select/src/hooks/usePanelData.js +95 -87
  67. package/dist/components/tt-panel-select/src/index.vue.js +4 -2
  68. package/dist/components/tt-radio-group/index.js +4 -3
  69. package/dist/components/tt-radio-group/index.vue.js +7 -6
  70. package/dist/components/tt-select/index.js +4 -3
  71. package/dist/components/tt-select/src/Select.vue.d.ts +12 -12
  72. package/dist/components/tt-select/src/Select.vue.js +4 -3
  73. package/dist/components/tt-select/src/components/SelectTable.vue.d.ts +116 -7
  74. package/dist/components/tt-select/src/components/SelectTable.vue.js +3 -2
  75. package/dist/components/tt-select/src/components/Table.vue.d.ts +8 -8
  76. package/dist/components/tt-select/src/components/Table.vue.js +3 -2
  77. package/dist/components/tt-select/src/hooks/useDataSource.js +4 -3
  78. package/dist/components/tt-select/src/hooks/useKeyboard.d.ts +7 -1
  79. package/dist/components/tt-select/src/hooks/useSelect.js +3 -2
  80. package/dist/components/tt-select/src/hooks/useSelectTableEvent.d.ts +1 -1
  81. package/dist/components/tt-select/src/hooks/useSelectTableEvent.js +28 -27
  82. package/dist/components/tt-select/src/props.d.ts +2 -2
  83. package/dist/components/tt-table/index.d.ts +526 -361
  84. package/dist/components/tt-table/index.js +7 -5
  85. package/dist/components/tt-table/src/Table.vue.d.ts +308 -218
  86. package/dist/components/tt-table/src/Table.vue.js +406 -618
  87. package/dist/components/tt-table/src/TableForm.vue.d.ts +384 -19
  88. package/dist/components/tt-table/src/TableForm.vue.js +219 -229
  89. package/dist/components/tt-table/src/components/TableAction.vue.js +110 -131
  90. package/dist/components/tt-table/src/components/TableButtons.js +30 -29
  91. package/dist/components/tt-table/src/components/TableColumnModal.vue2.js +88 -84
  92. package/dist/components/tt-table/src/components/TableToolbarTools.vue.d.ts +80 -0
  93. package/dist/components/tt-table/src/components/{TableToobalTools.vue.js → TableToolbarTools.vue.js} +34 -35
  94. package/dist/components/tt-table/src/components/TableToolbarTools.vue2.js +4 -0
  95. package/dist/components/tt-table/src/emits.d.ts +10 -1
  96. package/dist/components/tt-table/src/emits.js +2 -1
  97. package/dist/components/tt-table/src/hooks/useColumnPersistence.d.ts +19 -0
  98. package/dist/components/tt-table/src/hooks/useColumnPersistence.js +64 -0
  99. package/dist/components/tt-table/src/hooks/useColumns.d.ts +505 -21
  100. package/dist/components/tt-table/src/hooks/useColumns.js +101 -245
  101. package/dist/components/tt-table/src/hooks/useGridProps.d.ts +36 -0
  102. package/dist/components/tt-table/src/hooks/useGridProps.js +121 -0
  103. package/dist/components/tt-table/src/hooks/useKeyboardNav.d.ts +11 -0
  104. package/dist/components/tt-table/src/hooks/useKeyboardNav.js +98 -0
  105. package/dist/components/tt-table/src/hooks/usePagination.d.ts +14 -8
  106. package/dist/components/tt-table/src/hooks/usePagination.js +30 -33
  107. package/dist/components/tt-table/src/hooks/useQuery.d.ts +41 -0
  108. package/dist/components/tt-table/src/hooks/useQuery.js +148 -0
  109. package/dist/components/tt-table/src/hooks/useRowIdentity.d.ts +22 -0
  110. package/dist/components/tt-table/src/hooks/useRowIdentity.js +97 -0
  111. package/dist/components/tt-table/src/hooks/useRowSelection.d.ts +24 -12
  112. package/dist/components/tt-table/src/hooks/useRowSelection.js +95 -70
  113. package/dist/components/tt-table/src/hooks/{useLeftRightSlot.d.ts → useSideSlot.d.ts} +25 -17
  114. package/dist/components/tt-table/src/hooks/useSideSlot.js +78 -0
  115. package/dist/components/tt-table/src/hooks/useSyncProps.d.ts +12 -0
  116. package/dist/components/tt-table/src/hooks/useSyncProps.js +56 -0
  117. package/dist/components/tt-table/src/hooks/useTableData.d.ts +71 -0
  118. package/dist/components/tt-table/src/hooks/useTableData.js +308 -0
  119. package/dist/components/tt-table/src/hooks/useTableFooter.d.ts +15 -0
  120. package/dist/components/tt-table/src/hooks/useTableFooter.js +47 -0
  121. package/dist/components/tt-table/src/hooks/useTableForm.d.ts +10 -5
  122. package/dist/components/tt-table/src/hooks/useTableForm.js +56 -48
  123. package/dist/components/tt-table/src/hooks/useTableMethods.d.ts +165 -0
  124. package/dist/components/tt-table/src/hooks/useTableMethods.js +183 -0
  125. package/dist/components/tt-table/src/hooks/useTableRender.d.ts +57 -55
  126. package/dist/components/tt-table/src/props.d.ts +326 -153
  127. package/dist/components/tt-table/src/props.js +125 -271
  128. package/dist/components/tt-table/src/table-defaults.d.ts +25 -0
  129. package/dist/components/tt-table/src/table-defaults.js +71 -0
  130. package/dist/components/tt-table/src/table-mutation-events.d.ts +43 -0
  131. package/dist/components/tt-table/src/table-mutation-events.js +71 -0
  132. package/dist/components/tt-table/src/types/table.d.ts +223 -88
  133. package/dist/components/tt-table/src/types/tableAction.d.ts +23 -0
  134. package/dist/components/tt-table/src/types/tableForm.d.ts +15 -26
  135. package/dist/components/tt-table/src/utils/action-tab-index.d.ts +2 -0
  136. package/dist/components/tt-table/src/utils/action-tab-index.js +51 -0
  137. package/dist/components/tt-table/src/utils/context.js +26 -12
  138. package/dist/components/tt-table/src/utils/table-api.d.ts +136 -58
  139. package/dist/components/tt-table/src/utils/table-api.js +200 -165
  140. package/dist/components/tt-table/src/utils/table-form-api.d.ts +11 -11
  141. package/dist/components/tt-table/src/utils/table-form-api.js +35 -23
  142. package/dist/components/tt-text/index.js +4 -3
  143. package/dist/components/tt-upload/index.js +6 -5
  144. package/dist/components/tt-upload/src/TtUpload.vue.js +4 -3
  145. package/dist/components/types.d.ts +0 -20
  146. package/dist/directives/disabled-tip/index.js +9 -8
  147. package/dist/hooks/useFormSchemasLink.js +4 -3
  148. package/dist/hooks/useFormat.d.ts +35 -71
  149. package/dist/hooks/useFormat.js +28 -39
  150. package/dist/hooks/usePanelSelectSchemas.js +4 -3
  151. package/dist/hooks/useScreenshotOss.js +16 -15
  152. package/dist/hooks/useSetup.js +0 -3
  153. package/dist/packages/hooks/src/useDebounce.js +6 -5
  154. package/dist/packages/hooks/src/useElementScreenshot.js +4 -3
  155. package/dist/packages/hooks/src/usePriorityValue.js +5 -4
  156. package/dist/packages/utils/src/format.js +48 -0
  157. package/dist/packages/utils/src/is.js +20 -18
  158. package/dist/packages/utils/src/tool.js +76 -149
  159. package/dist/plugins/default/renderCellContent.js +4 -3
  160. package/dist/plugins/vxeTable/switchStatus.js +14 -13
  161. package/dist/style.css +1 -1
  162. package/package.json +3 -3
  163. package/dist/components/tt-table/src/components/TableToobalTools.vue.d.ts +0 -576
  164. package/dist/components/tt-table/src/components/TableToobalTools.vue2.js +0 -4
  165. package/dist/components/tt-table/src/enum.d.ts +0 -2
  166. package/dist/components/tt-table/src/hooks/useCellArea.d.ts +0 -15
  167. package/dist/components/tt-table/src/hooks/useCellArea.js +0 -15
  168. package/dist/components/tt-table/src/hooks/useCustomColumns.d.ts +0 -20
  169. package/dist/components/tt-table/src/hooks/useCustomColumns.js +0 -65
  170. package/dist/components/tt-table/src/hooks/useDataSource.d.ts +0 -29
  171. package/dist/components/tt-table/src/hooks/useDataSource.js +0 -232
  172. package/dist/components/tt-table/src/hooks/useLeftRightSlot.js +0 -64
  173. package/dist/components/tt-table/src/hooks/useTable.d.ts +0 -7
  174. package/dist/components/tt-table/src/hooks/useTableEvent.d.ts +0 -101
  175. package/dist/components/tt-table/src/hooks/useTableEvent.js +0 -197
  176. package/dist/components/tt-table/src/hooks/useTableFormEvent.d.ts +0 -10
  177. package/dist/components/tt-table/src/hooks/useTableHeight.d.ts +0 -15
  178. package/dist/components/tt-table/src/hooks/useTableSlot.d.ts +0 -11
  179. package/dist/components/tt-table/src/hooks/useTableSlot.js +0 -17
  180. package/dist/components/tt-table/src/utils/filters.d.ts +0 -109
  181. package/dist/components/tt-table/src/utils/vxeTable.d.ts +0 -28
  182. 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,9 @@
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 o, computed as P, watch as l } from "vue";
6
+ import "numeral";
5
7
  import "xe-utils";
6
8
  import "dayjs/plugin/utc";
7
9
  import "dayjs/plugin/timezone";
@@ -11,45 +13,40 @@ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ae
11
13
  import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
12
14
  import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
13
15
  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
- };
16
+ import "lodash-es";
17
+ const C = {
18
+ currentPage: 1,
19
+ pageSize: 300,
20
+ total: 0,
21
+ pageSizes: [300, 500, 1e3, 2e3],
22
+ layouts: ["Total", "PrevPage", "JumpNumber", "NextPage", "Sizes", "FullJump"]
23
+ };
24
+ function T(e, g) {
25
+ var a;
26
+ const r = c(
27
+ s(o(e).pagerConfig || {}, ((a = f.table) == null ? void 0 : a.pagerConfig) || {})
28
+ ), i = P(() => {
29
+ const { showPager: t, pagerConfig: u } = o(e);
30
+ if (!(!t && !u))
31
+ return { ...C, ...o(r) };
32
32
  });
33
- function m() {
34
- return e(n);
33
+ function p() {
34
+ return o(i);
35
35
  }
36
- function a(t) {
37
- o.value = {
38
- ...e(o),
39
- ...t
40
- };
36
+ function n(t) {
37
+ r.value = { ...o(r), ...t };
41
38
  }
42
- function u(t) {
43
- p("page-change", t);
39
+ function m(t) {
40
+ g("page-change", t);
44
41
  }
45
42
  return l(
46
- () => e(i).pagerConfig,
47
- (t, r) => {
48
- t && !P(t, r) && a(t);
43
+ () => o(e).pagerConfig,
44
+ (t) => {
45
+ t && n(t);
49
46
  },
50
47
  { deep: !0 }
51
- ), { configRef: o, getPagination: m, getPaginationInfo: n, setPagination: a, handlePageChange: u };
48
+ ), { pagination: r, paginationInfo: i, getPagination: p, setPagination: n, onPageChange: m };
52
49
  }
53
50
  export {
54
- G as usePagination
51
+ T as usePagination
55
52
  };
@@ -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,148 @@
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 "dayjs";
7
+ import "numeral";
8
+ import "xe-utils";
9
+ import "dayjs/plugin/utc";
10
+ import "dayjs/plugin/timezone";
11
+ import "../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
12
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
13
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
14
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
15
+ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
16
+ import { omit as me, set as R, get as x } from "lodash-es";
17
+ function Oe(s, W, p) {
18
+ const { grid: u, pagination: f, paginationInfo: d, setPagination: O, setLoading: q, resetSelectionAfterFetch: T, rows: X, applyRows: j } = W, P = K({ currentPage: 1 }), y = K(!1);
19
+ let w = !0, D = !1, S = !1, g;
20
+ const L = oe(() => {
21
+ const { showPager: e, isScrollFetch: r } = t(s);
22
+ return !!(e || r);
23
+ }), M = () => {
24
+ var e;
25
+ return !!((e = t(s).filterConfig) != null && e.remote);
26
+ };
27
+ function A(e) {
28
+ return { currentPage: (e == null ? void 0 : e.currentPage) || 1, pageSize: e == null ? void 0 : e.pageSize };
29
+ }
30
+ function Y(e) {
31
+ const r = t(s);
32
+ return g === e && !S && r.api === e.api && r.filterApi === e.filterApi;
33
+ }
34
+ function N(e, r) {
35
+ 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);
36
+ }
37
+ function Z(e) {
38
+ const { currentPageField: r, pageSizeField: i } = t(s), o = {};
39
+ return R(o, r, e.currentPage || 1), R(o, i, e.pageSize), o;
40
+ }
41
+ function _(e) {
42
+ return { ...t(d) || t(f), ...ae(e) ? e : {} };
43
+ }
44
+ function $(e) {
45
+ const r = se(e), i = r ? 0 : x(e, t(s).totalField);
46
+ return {
47
+ items: r ? e : x(e, t(s).dataField),
48
+ total: ne(i) ? 0 : Number(i)
49
+ };
50
+ }
51
+ async function ee(e, r, i) {
52
+ var n;
53
+ const { isScrollFetch: o, currentPageField: l = "" } = t(s), c = t(s).afterFetch ?? ((n = k.table) == null ? void 0 : n.afterFetch);
54
+ let a = e;
55
+ return b(c) && (a = await c(a, i) || a), o && x(r, l, 1) !== 1 && (a = [...t(X), ...a]), a;
56
+ }
57
+ async function h(e) {
58
+ var G, U, B;
59
+ const { api: r, filterApi: i, searchInfo: o, useSearchForm: l, formApi: c } = t(s);
60
+ if (S || !b(r)) return;
61
+ const a = { api: r, filterApi: i };
62
+ D = !0, g = a;
63
+ const n = () => Y(a);
64
+ try {
65
+ q(!0), t(s).immediate || (w = !1);
66
+ const m = _(e == null ? void 0 : e.tablePage), v = m.currentPage || 1, z = Z(m), te = c && l ? await c.getValues() : {};
67
+ if (!n()) return;
68
+ let F;
69
+ if (e.serverFilterParams && b(i))
70
+ F = await i({ ...e.serverFilterParams, ...t(L) ? z : {} });
71
+ else {
72
+ b(i) && ((G = t(u)) == null || G.clearSort(), (U = t(u)) == null || U.clearFilter());
73
+ let C = {
74
+ ...te,
75
+ ...o,
76
+ ...e.searchInfo,
77
+ ...t(L) ? z : {}
78
+ };
79
+ const J = t(s).beforeFetch ?? ((B = k.table) == null ? void 0 : B.beforeFetch);
80
+ if (b(J) && (C = await J(C) || C), !n()) return;
81
+ F = await r(C);
82
+ }
83
+ if (!n()) return;
84
+ const { items: re, total: E } = $(F), I = await ee(re || [], z, F);
85
+ if (!n()) return;
86
+ const H = E || I.length || 0, ie = Math.max(1, Math.ceil(H / m.pageSize));
87
+ if (v > ie) {
88
+ await Q({ tablePage: { currentPage: 1, pageSize: m.pageSize } });
89
+ return;
90
+ }
91
+ if (!await j(I, n) || !n() || (O({ total: H, currentPage: v }), P.value = A(t(d)), p("fetch-success", { items: I, total: E, rawDataSource: F }), !n()) || (T(), !n())) return;
92
+ y.value = !0;
93
+ } catch (m) {
94
+ if (!n() || (p("fetch-error", m), !n()) || !await j([], n) || !n() || (O({ total: 0 }), P.value = A(t(d)), T(), !n())) return;
95
+ y.value = !0;
96
+ } finally {
97
+ g === a && (g = void 0, q(!1));
98
+ }
99
+ }
100
+ async function Q(e) {
101
+ var i;
102
+ const r = { ...t(f) };
103
+ (i = k.table) != null && i.isReloadResetToFirstPage && (r.currentPage = 1), await h(
104
+ e ? {
105
+ tablePage: Object.hasOwn(e, "tablePage") ? e.tablePage : r,
106
+ searchInfo: Object.hasOwn(e, "searchInfo") ? e.searchInfo : me(e, ["tablePage", "serverFilterParams"])
107
+ } : { tablePage: r }
108
+ ), t(s).immediate || (w = !1);
109
+ }
110
+ async function V(e) {
111
+ var l, c;
112
+ if (!M()) return;
113
+ const r = { ...t(f) };
114
+ e !== "page" && (r.currentPage = 1);
115
+ const i = (((l = t(u)) == null ? void 0 : l.getCheckedFilters()) || []).map((a) => ({
116
+ fieldName: a.field,
117
+ checkAll: !1,
118
+ includeValues: a.datas[0],
119
+ excludeValues: []
120
+ })), o = (((c = t(u)) == null ? void 0 : c.getSortColumns()) || []).map((a) => ({
121
+ fieldName: a.field,
122
+ isAscending: a.order === "asc"
123
+ }));
124
+ await h({ serverFilterParams: { filterConditions: i, sortConditions: o }, tablePage: r });
125
+ }
126
+ return ce([() => t(f).currentPage, () => t(f).pageSize], ([e, r]) => {
127
+ var l, c;
128
+ const i = { ...t(f), currentPage: e, pageSize: r };
129
+ if (!N(i, t(P))) return;
130
+ if (w && !t(s).immediate) {
131
+ w = !1;
132
+ return;
133
+ }
134
+ const o = (((l = t(u)) == null ? void 0 : l.getSortColumns()) || []).length > 0 || (((c = t(u)) == null ? void 0 : c.getCheckedFilters()) || []).length > 0;
135
+ M() && o ? V("page") : h({ tablePage: { ...i } });
136
+ }), le(() => {
137
+ P.value = A(t(d)), ue(() => {
138
+ if (S || D) return;
139
+ const { immediate: e, pagerConfig: r } = t(s);
140
+ e && (!r || !N(r, t(P))) && h({ tablePage: t(d) });
141
+ });
142
+ }), fe(() => {
143
+ S = !0, g = void 0;
144
+ }), { query: h, reload: Q, reloadFilter: V, isLoaded: y };
145
+ }
146
+ export {
147
+ Oe as useQuery
148
+ };
@@ -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,97 @@
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 "dayjs";
6
+ import "numeral";
7
+ import "xe-utils";
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 { get as l } from "lodash-es";
16
+ const y = "__tt_table_internal_row_key__";
17
+ function c(o) {
18
+ return B(o) ? !0 : E(o) && !!o;
19
+ }
20
+ function Y(o) {
21
+ var v;
22
+ const P = ((v = W()) == null ? void 0 : v.uid) || 0;
23
+ let m = 0;
24
+ const K = /* @__PURE__ */ new WeakSet();
25
+ function w() {
26
+ return a(o).tableRowId || "id";
27
+ }
28
+ function p(e) {
29
+ const t = l(e, w());
30
+ return c(t) ? t : void 0;
31
+ }
32
+ function g(e) {
33
+ const t = Reflect.get(e, y);
34
+ return c(t) ? t : void 0;
35
+ }
36
+ function O() {
37
+ return m += 1, `tt_row_${P}_${m}`;
38
+ }
39
+ function S(e, t) {
40
+ const r = C(e), n = Object.getOwnPropertyDescriptor(r, y), i = n && c(n.value) ? n.value : t;
41
+ if (n && !n.enumerable && c(n.value)) return i;
42
+ try {
43
+ Object.defineProperty(r, y, {
44
+ configurable: !0,
45
+ enumerable: !1,
46
+ value: i,
47
+ writable: !0
48
+ });
49
+ } catch {
50
+ K.has(r) || K.add(r);
51
+ }
52
+ return i;
53
+ }
54
+ function f({ row: e }) {
55
+ var d;
56
+ const t = g(e);
57
+ if (c(t)) return t;
58
+ 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();
59
+ return S(e, u);
60
+ }
61
+ function j(e = {}) {
62
+ return e.keyField ? e : {
63
+ ...e,
64
+ keyField: y,
65
+ createKeyMethod: f
66
+ };
67
+ }
68
+ function I(e) {
69
+ var i;
70
+ const t = p(e);
71
+ if (c(t)) return t;
72
+ const r = (i = a(o).rowConfig) == null ? void 0 : i.keyField;
73
+ if (r) {
74
+ const u = l(e, r);
75
+ return c(u) ? u : void 0;
76
+ }
77
+ const n = g(e);
78
+ return c(n) ? n : f({ row: e });
79
+ }
80
+ function M(e) {
81
+ var u, d, R;
82
+ if ((u = a(o).rowConfig) != null && u.keyField) return;
83
+ 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";
84
+ function i(s) {
85
+ const b = C(s);
86
+ if (r.has(b)) return;
87
+ r.add(b), f({ row: s });
88
+ const h = l(s, n);
89
+ _(h) && h.forEach((k) => F(k) && i(k));
90
+ }
91
+ t.forEach((s) => F(s) && i(s));
92
+ }
93
+ return { getRowKey: I, prepareRows: M, toVxeRowConfig: j };
94
+ }
95
+ export {
96
+ Y as useRowIdentity
97
+ };
@@ -1,30 +1,42 @@
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 = {
6
- (e: "selection-change", data?: {
7
- keys: TtSelectRowKeysType;
8
- rows: TtSelectRowsType;
9
- data?: Recordable;
10
- }): void;
4
+ import { TtSelectRowKeysType, TtSelectRowsType, TtTableProps, TtTableSelectionPayload } from '../types/table';
5
+ /** 行选择相关事件 */
6
+ type SelectionEmit = {
7
+ (e: "selection-change", data?: TtTableSelectionPayload): void;
11
8
  (e: "checkbox-change", data?: VxeGridDefines.CheckboxChangeEventParams): void;
12
9
  (e: "checkbox-all", data?: VxeGridDefines.CheckboxAllEventParams): void;
13
10
  (e: "checkbox-range-change", data?: VxeGridDefines.CheckboxRangeChangeEventParams): void;
14
11
  (e: "radio-change", data?: VxeGridDefines.RadioChangeEventParams): void;
12
+ (e: "cell-area-selection-end", data?: VxeTableExtendCellAreaDefines.CellAreaSelectionAllEndEventParams): void;
15
13
  };
16
- export declare function useRowSelection(propsRef: ComputedRef<TtTableProps>, emit: EmitType, xGrid: Ref<VxeGridInstance<Recordable>>): {
14
+ /** 行选择使用的行身份适配器。 */
15
+ type RowSelectionIdentity = {
16
+ /** 获取业务兼容的行主键。 */
17
+ getRowKey: (row: Recordable) => number | string | undefined;
18
+ };
19
+ /**
20
+ * 行选择状态(复选框、单选框、区域选择)
21
+ * @param propsRef 表格 props
22
+ * @param grid vxe-grid 实例
23
+ * @param emit 组件 emit
24
+ * @param identity 行身份适配器
25
+ */
26
+ export declare function useRowSelection(propsRef: ComputedRef<TtTableProps>, grid: Ref<undefined | VxeGridInstance<Recordable>>, emit: SelectionEmit, identity: RowSelectionIdentity): {
17
27
  selectedKeys: Ref<any, any>;
18
28
  selectedRows: Ref<any, any>;
29
+ selectedKeyList: ComputedRef<(string | number)[]>;
30
+ getSelectRowKeys: () => any;
31
+ getSelectRows: () => TtSelectRowsType;
32
+ syncSelection: (data?: Recordable) => void;
19
33
  setSelectedRowKeys: (rows: TtSelectRowsType, keys?: TtSelectRowKeysType) => Promise<void>;
20
- onCellAreaSelectionEndSetCheckbox: (data: VxeTableExtendCellAreaDefines.CellAreaSelectionAllEndEventParams) => Promise<void>;
21
34
  clearSelectedRowKeys: () => void;
35
+ resetSelectionAfterFetch: () => void;
22
36
  onCheckboxChange: VxeGridEvents.CheckboxChange<any>;
23
37
  onCheckboxAll: VxeGridEvents.CheckboxAll<any>;
24
- getSelectRowKeys: () => any;
25
- getSelectRows: () => TtSelectRowsType;
26
38
  onCheckboxRangeChange: VxeGridEvents.CheckboxRangeChange<any>;
27
39
  onRadioChange: (data: VxeGridDefines.RadioChangeEventParams) => void;
28
- getCheckboxSelectedKeys: ComputedRef<(string | number)[]>;
40
+ onCellAreaSelectionEnd: VxeGridEvents.CellAreaSelectionAllEnd<any>;
29
41
  };
30
42
  export {};