@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
@@ -0,0 +1,43 @@
1
+ import { Recordable } from '../../../../../utils/src';
2
+ import { TtSelectRowsType } from './types/table';
3
+ /** 行数据回写时读取的数据来源:完整数据或历史操作后的可见数据。 */
4
+ export type RowsCommitSource = "full" | "visible";
5
+ /**
6
+ * VXE 事件转发表:键是 camelCase 事件名(`v-on` 对象语法的键),值是转发函数。
7
+ *
8
+ * 不用 `VxeGridEventProps`:那份声明的键带 `on` 前缀(`onSortChange`),
9
+ * 而这里的键是 `v-on="gridEvents"` 需要的 `sortChange`,由 Vue 在绑定时补 `on`。
10
+ */
11
+ export type ForwardedEventMap = Record<string, (...args: Recordable[]) => void>;
12
+ /**
13
+ * VXE 事件名到转发表键名(camelCase)的映射,模块级计算一次,所有表格实例共用。
14
+ *
15
+ * `camelCase` 的结果与实例无关,改动前 `Table.vue` 与 `TableForm.vue` 各自在 setup 里
16
+ * 对 117 个事件名跑一遍,一个页面 3 张表就是 702 次重复计算。
17
+ * 转发闭包本身仍然每实例一份(闭包里绑定的是当前实例的 `emit`)。
18
+ */
19
+ export declare const forwardedEventEntries: ReadonlyArray<readonly [vxeEventName: string, forwardedKey: string]>;
20
+ /**
21
+ * 判断某个 VXE 事件是否改动了业务行数据,需要回写 v-model。
22
+ *
23
+ * 三类来源合成一个判定:固定的变更事件表、`edit-activated` 的插入行判定、
24
+ * `toolbar-button-click` 的 remove 确认框判定,与改动前 `Table.vue` 里的三段 if 逐条等价。
25
+ * @param eventName VXE 事件名
26
+ * @param args 事件参数
27
+ * @param getSelectedRows 读取事件发生前组件记录的选中行
28
+ */
29
+ export declare function isRowDataMutationEvent(eventName: string, args: Recordable[], getSelectedRows: () => TtSelectRowsType): boolean;
30
+ /**
31
+ * 判断某个 VXE 事件是否只改变展示结果(排序 / 筛选)。
32
+ *
33
+ * 排序与筛选是视图状态,不进入数据回写路径,命中时要取消本轮待提交的回写。
34
+ * @param eventName VXE 事件名
35
+ */
36
+ export declare function isDisplayOnlyEvent(eventName: string): boolean;
37
+ /**
38
+ * 取某个变更事件回写时应该读取的数据来源。
39
+ *
40
+ * 撤销/重做需要按操作后的可见数据回写,其余读完整数据。
41
+ * @param eventName VXE 事件名
42
+ */
43
+ export declare function getMutationCommitSource(eventName: string): RowsCommitSource;
@@ -0,0 +1,70 @@
1
+ import "axios";
2
+ import "element-plus";
3
+ import { isString as s, isArray as c } from "../../../packages/utils/src/is.js";
4
+ import "vue";
5
+ import u from "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 "lodash-es";
15
+ import { basicTableEmits as d } from "./emits.js";
16
+ const p = /* @__PURE__ */ new Set([
17
+ "update:data",
18
+ "cell-delete-value",
19
+ "cell-backspace-value",
20
+ "row-dragend",
21
+ "row-remove-dragend",
22
+ "row-insert-dragend",
23
+ "enter-append-row",
24
+ "tab-append-row",
25
+ "paste",
26
+ "cut",
27
+ "undo",
28
+ "redo",
29
+ "fnr-replace",
30
+ "fnr-replace-all",
31
+ "cell-area-cut",
32
+ "cell-area-paste",
33
+ "cell-area-extension-fill",
34
+ "cell-area-fill-copy"
35
+ ]), f = /* @__PURE__ */ new Set([
36
+ "sort-change",
37
+ "clear-sort",
38
+ "clear-all-sort",
39
+ "filter-change",
40
+ "clear-filter",
41
+ "clear-all-filter"
42
+ ]), m = /* @__PURE__ */ new Set(["insert", "insert_edit", "insert_actived", "remove"]), w = /* @__PURE__ */ new Set(["undo", "redo"]), _ = d.map((t) => [t, u.camelCase(t)]);
43
+ function b(t) {
44
+ var r, o;
45
+ const e = t[0];
46
+ return !!(e != null && e.row) && !!((o = (r = e == null ? void 0 : e.$table) == null ? void 0 : r.isInsertByRow) != null && o.call(r, e.row));
47
+ }
48
+ function g(t, e) {
49
+ var i, n, l;
50
+ const r = t[0], o = r == null ? void 0 : r.code;
51
+ if (!s(o) || !m.has(o)) return !1;
52
+ if (o !== "remove") return !0;
53
+ const a = e();
54
+ return (c(a) ? !a.length : !a) ? !1 : !((l = (n = (i = r == null ? void 0 : r.$grid) == null ? void 0 : i.getCheckboxRecords) == null ? void 0 : n.call(i)) != null && l.length);
55
+ }
56
+ function $(t, e, r) {
57
+ return p.has(t) ? !0 : t === "edit-activated" ? b(e) : t === "toolbar-button-click" ? g(e, r) : !1;
58
+ }
59
+ function B(t) {
60
+ return f.has(t);
61
+ }
62
+ function U(t) {
63
+ return w.has(t) ? "visible" : "full";
64
+ }
65
+ export {
66
+ _ as forwardedEventEntries,
67
+ U as getMutationCommitSource,
68
+ B as isDisplayOnlyEvent,
69
+ $ as isRowDataMutationEvent
70
+ };
@@ -1,12 +1,10 @@
1
- import { ComputedRef, CSSProperties, MaybeRef, Ref, VNode } from 'vue';
1
+ import { ComputedRef, CSSProperties, MaybeRef, Ref } from 'vue';
2
2
  import { VxeGridMethods, VxeGridProps, VxeGridPropTypes, VxeTableDefines, VxeTablePropTypes } from 'vxe-table';
3
3
  import { TableApi } from '../utils/table-api';
4
4
  import { TtExtendedFormApi } from '../../../tt-form';
5
5
  export type TtTablePagerProps = {
6
6
  /** 是否显示分页 */
7
7
  showPager?: boolean;
8
- /** 数据总数 */
9
- total?: number;
10
8
  /** 当前页数 field */
11
9
  currentPageField?: string;
12
10
  /** 当前页的大小 field */
@@ -16,9 +14,18 @@ export type TtTablePagerProps = {
16
14
  /** 数据的 field */
17
15
  dataField?: string;
18
16
  };
19
- export type TtTableColumnsProps = {
17
+ export type TtTableColumnsProps<Row = any> = {
20
18
  /** 是否显示复选框 */
21
19
  showCheckbox?: boolean;
20
+ /**
21
+ * 是否跨页保持复选框选中状态。
22
+ *
23
+ * 开启后组件会把 vxe 的 `checkboxConfig.reserve` 置为 `true`(调用方显式配置优先),
24
+ * 并让 `getSelectRows()` 合并当前页记录与跨页保留记录 —— vxe 的 `getCheckboxRecords()`
25
+ * 只返回当前页,跨页那部分要另外从 `getCheckboxReserveRecords()` 取。
26
+ * @default false
27
+ */
28
+ reserveSelection?: boolean;
22
29
  /** 是否显示展开列 */
23
30
  showExpand?: boolean;
24
31
  /** 是否显示单选框 */
@@ -29,65 +36,42 @@ export type TtTableColumnsProps = {
29
36
  showAction?: boolean;
30
37
  /** 是否显示导出按钮 */
31
38
  showExport?: boolean;
32
- /** 是否显示导入按钮 */
33
- showImport?: boolean;
34
39
  /** 操作列宽度 */
35
40
  actionWidth?: number;
36
41
  /** 操作列列名 */
37
42
  actionTitle?: string;
38
43
  /** 是否需要列宽拖拽 */
39
44
  isCellResize?: boolean;
40
- /**
41
- * 是否拖动列
42
- * @deprecated 请使用 column-config drag 配合column-drag-config配置 支持的版本看官方文档,后续不在维护列拖拽 如需用官方的设置为false
43
- * @default true
44
- */
45
- isColumnsDrag?: boolean;
46
45
  /** 是否列排序 */
47
46
  isCellSort?: boolean;
48
- /**
49
- * 是否checkbox区域选择 选中数据
50
- * @deprecated
51
- */
52
- isAreaCheckData?: boolean;
53
47
  /** 操作列Props */
54
- actionProps?: VxeTableDefines.ColumnOptions;
48
+ actionProps?: TtColumnOptions<Row>;
55
49
  /** 序号列Props */
56
- indexColumnProps?: VxeTableDefines.ColumnOptions;
50
+ indexColumnProps?: TtColumnOptions<Row>;
57
51
  /** 复选框列Props */
58
- checkboxColumnProps?: VxeTableDefines.ColumnOptions;
52
+ checkboxColumnProps?: TtColumnOptions<Row>;
59
53
  /** 展开行props */
60
- expandColumnProps?: VxeTableDefines.ColumnOptions;
54
+ expandColumnProps?: TtColumnOptions<Row>;
61
55
  /** 单选框列Props */
62
- radioColumnProps?: VxeTableDefines.ColumnOptions;
56
+ radioColumnProps?: TtColumnOptions<Row>;
63
57
  /** 表格行id */
64
58
  tableRowId?: string;
65
- /**
66
- * 是否需要行拖拽-树形表格
67
- * @deprecated 请使用 row-config drag 配合row-drag-config配置 支持的版本看官方文档,后续不在维护行拖拽
68
- * @default false
69
- */
70
- treeNode?: boolean;
71
59
  };
72
- export type TtTableFetchProps = {
60
+ export type TtTableFetchProps<Row = any> = {
73
61
  /** api请求方法 */
74
- api?: (...arg: any[]) => Promise<Recordable>;
62
+ api?: (...arg: any[]) => Promise<Recordable | Recordable[]>;
75
63
  /** filter api请求方法 */
76
- filterApi?: (...arg: any[]) => Promise<Recordable>;
77
- /** filter option api请求方法 */
78
- filterOptionApi?: (...arg: any[]) => Promise<Recordable>;
64
+ filterApi?: (...arg: any[]) => Promise<Recordable | Recordable[]>;
79
65
  /** 表格额外参数 */
80
66
  searchInfo?: Recordable;
81
67
  /** 是否初始化加载数据 */
82
68
  immediate?: boolean;
83
- /** 请求的状态码 @deprecated */
84
- resultCode?: string | number;
85
69
  /**
86
70
  * 请求后的回调
87
71
  * @param data 表格数据
88
72
  * @param res 原始结果数据
89
73
  */
90
- afterFetch?: (data: VxeTablePropTypes.Row[], res: Recordable) => Promise<VxeTablePropTypes.Row[]>;
74
+ afterFetch?: (data: Row[], res: Recordable | Recordable[]) => Promise<Row[]>;
91
75
  /**
92
76
  * 请求前的回调
93
77
  * @param params 请求参数
@@ -95,11 +79,6 @@ export type TtTableFetchProps = {
95
79
  beforeFetch?: (params: Recordable) => Promise<Recordable>;
96
80
  /** 是否滚动加载 */
97
81
  isScrollFetch?: boolean;
98
- /**
99
- * 滚动加载是否加载动画
100
- * @default true
101
- */
102
- showScrollFetchLoading?: boolean;
103
82
  };
104
83
  export type TtTableToolbarProps = {
105
84
  /** 是否显示toolbar */
@@ -114,31 +93,46 @@ export type TtTableToolbarProps = {
114
93
  showSetting?: boolean;
115
94
  /** 是否显示自定义列 */
116
95
  showSetColumn?: boolean;
117
- /** 是否显示自定义行距 */
118
- showLineHeight?: boolean;
119
96
  /** 不可自定义列数组 field数组 */
120
97
  notSetColumnField?: string[];
121
- /** 需要对不显示的字段进行过滤 主要针对于自定义 field数组 */
122
- filterNoVisibleField?: string[];
123
98
  /** 是否显示表格上方 alert */
124
99
  showTableAlert?: boolean;
125
100
  };
126
- type UseTableProps = TtTablePagerProps & TtTableColumnsProps & TtTableFetchProps & TtTableToolbarProps;
127
- export type TtTableProps = {
128
- /** 标题内容 */
129
- title?: string;
130
- /** 是否显示标题 */
131
- showTitle?: boolean;
101
+ type UseTableProps<Row = any> = TtTablePagerProps & TtTableColumnsProps<Row> & TtTableFetchProps<Row> & TtTableToolbarProps;
102
+ /**
103
+ * 列的表尾合计方式。
104
+ *
105
+ * 三种预设按列字段取值计算:`sum` 求和、`avg` 求平均、`count` 计数;
106
+ * 函数形式接收该列的全部单元格值与参与合计的行数据,返回直接显示在表尾的内容。
107
+ */
108
+ export type TtColumnSummary<Row = any> = "sum" | "avg" | "count" | ((params: {
109
+ values: unknown[];
110
+ rows: Row[];
111
+ column: VxeTableDefines.ColumnOptions<Row>;
112
+ }) => string | number);
113
+ /**
114
+ * tt-table 的列配置:vxe 原生列配置加上组件自己的字段。
115
+ *
116
+ * 只扩展不覆盖,任何 vxe 列配置都可以原样传入。传入行类型后,vxe 原生字段
117
+ * (`editRender` / `formatter` / `slots` 等)的回调参数也会跟着推断出行类型。
118
+ */
119
+ export type TtColumnOptions<Row = any> = VxeTableDefines.ColumnOptions<Row> & {
120
+ /** 表尾合计方式,声明后组件自动生成 vxe 的 footerMethod 并按运行时列顺序对齐 */
121
+ summary?: TtColumnSummary<Row>;
122
+ /** 子列 */
123
+ children?: TtColumnOptions<Row>[];
124
+ };
125
+ /**
126
+ * 表格配置。
127
+ *
128
+ * `Row` 是业务行数据类型,`useTableRender<User>()` / `useTableFormRender<User>()` 传入后,
129
+ * 列配置、`data` / `modelValue`、`afterFetch`、插槽作用域与 `tableApi` 的方法签名都会跟着推断。
130
+ * 不传时退化为 `any`,与改动前完全一致。
131
+ */
132
+ export type TtTableProps<Row = any> = {
132
133
  /** 是否自适应高度 */
133
134
  autoHeight?: boolean;
134
- /**
135
- * 额外减去的高度
136
- * @deprecated
137
- */
138
- offsetHeight?: number;
139
135
  loading?: boolean;
140
- /** loading text */
141
- loadingText?: string;
142
136
  /** 空数据的提示文字 */
143
137
  emptyText?: string;
144
138
  /** 未查询时文字 */
@@ -150,9 +144,21 @@ export type TtTableProps = {
150
144
  * @default 'no-data'
151
145
  */
152
146
  emptyImageStatus?: "no-data" | "no-search";
153
- /** 是否手动触发查询事件 */
154
- isHanderSubmit?: boolean;
155
- modelValue?: Array<Recordable>;
147
+ /**
148
+ * 表头标题是否显示 tooltip。
149
+ *
150
+ * 开启后由 vxe 负责溢出检测与弹层,只在标题真的被裁剪时才弹;可用原生 `headerTooltipConfig` 调样式。
151
+ * @default false
152
+ */
153
+ showHeaderTooltip?: boolean;
154
+ /**
155
+ * 单元格内容是否显示 tooltip。
156
+ *
157
+ * 开启后翻译成 vxe 的 `showOverflow: "tooltip"`,由它做溢出检测,只在内容真的被裁剪时才弹;
158
+ * 可用原生 `tooltipConfig` 调样式。关闭时沿用 `showOverflow` 的原有取值。
159
+ * @default false
160
+ */
161
+ showCellTooltip?: boolean;
156
162
  /** form-methods */
157
163
  formApi?: Partial<TtExtendedFormApi>;
158
164
  /** 储存的列key值,支持函数动态获取 */
@@ -171,11 +177,6 @@ export type TtTableProps = {
171
177
  leftSlotWidth?: number;
172
178
  /** 右侧插槽的宽度 */
173
179
  rightSlotWidth?: number;
174
- /**
175
- * 是否显示行高设置icon
176
- * @default true
177
- */
178
- showLineHeight?: boolean;
179
180
  /**
180
181
  * 是否显示刷新icon
181
182
  * @default true
@@ -205,26 +206,16 @@ export type TtTableProps = {
205
206
  userId: string | number;
206
207
  id: string | number;
207
208
  }) => Promise<any>;
208
- /** 外部插槽 */
209
- getSyncSlotComponent?: (column: any, row: any, type: "default" | "edit") => VNode | VNode[] | string;
210
209
  /** 自定义Column */
211
- customizeColumn?: (column: VxeTableDefines.ColumnOptions) => VxeTableDefines.ColumnOptions;
210
+ customizeColumn?: (column: TtColumnOptions<Row>) => TtColumnOptions<Row>;
212
211
  /** 是否清空树形展开的状态 */
213
212
  clearTreeExpand?: boolean;
214
- /** 是否进行国际化 */
215
- isI18n?: boolean;
216
- /**
217
- * 外部数据是否拷贝一份
218
- * 设置为 false 时,会有性能问题
219
- * @default true
220
- */
221
- isDataCloneDeep?: boolean;
222
213
  /** 是否使用搜索表单 */
223
214
  useSearchForm?: boolean;
224
215
  /** 数据源 */
225
- data?: MaybeRef<any[]>;
226
- /** */
227
- columns?: MaybeRef<VxeTableDefines.ColumnOptions[]>;
216
+ data?: MaybeRef<Row[]>;
217
+ /** 列配置 */
218
+ columns?: MaybeRef<TtColumnOptions<Row>[]>;
228
219
  /**
229
220
  * 表格 testId,用于生成测试标识
230
221
  * 如果不指定,将从 api 路径自动提取
@@ -239,7 +230,16 @@ export type TtTableProps = {
239
230
  * @default 'right'
240
231
  */
241
232
  toolTipErrorPlacement?: "top" | "bottom" | "left" | "right";
242
- } & Omit<VxeGridProps, "data" | "columns"> & UseTableProps;
233
+ } & Omit<VxeGridProps<Row>, "data" | "columns"> & UseTableProps<Row>;
234
+ /** 表格组件的 v-model 属性 */
235
+ export type TtTableModelProps<Row = any> = {
236
+ /** 双向绑定的表格数据 */
237
+ modelValue?: Row[];
238
+ /** 表格数据更新回调 */
239
+ "onUpdate:modelValue"?: (rows: Row[]) => void;
240
+ };
241
+ /** useTableRender 返回组件支持的属性 */
242
+ export type TtTableRenderProps<Row = any> = TtTableProps<Row> & TtTableModelProps<Row>;
243
243
  export type VxeTableMethods<DT> = {
244
244
  /**
245
245
  * 往表格插入临时数据,从第一行新增一行或多行新数据
@@ -261,6 +261,26 @@ export type VxeTableMethods<DT> = {
261
261
  row: DT;
262
262
  rows: DT[];
263
263
  }>;
264
+ /** 在指定行之后插入临时数据 */
265
+ insertNextAt: (records: any, row: any | -1 | null) => Promise<{
266
+ row: DT;
267
+ rows: DT[];
268
+ }>;
269
+ /** 在树节点下插入临时子数据 */
270
+ insertChild: (records: any, parentRow: any) => Promise<{
271
+ row: DT;
272
+ rows: DT[];
273
+ }>;
274
+ /** 在树节点下的指定位置插入临时子数据 */
275
+ insertChildAt: (records: any, parentRow: any, row: any | -1 | null) => Promise<{
276
+ row: DT;
277
+ rows: DT[];
278
+ }>;
279
+ /** 在树节点下的指定行之后插入临时子数据 */
280
+ insertChildNextAt: (records: any, parentRow: any, row: any | -1 | null) => Promise<{
281
+ row: DT;
282
+ rows: DT[];
283
+ }>;
264
284
  /**
265
285
  * 删除指定行数据,指定 row 或 [row, ...] 删除多条数据,如果为空则删除所有数据
266
286
  * @param rows 指定行
@@ -290,6 +310,29 @@ export type VxeTableMethods<DT> = {
290
310
  row: DT;
291
311
  rows: DT[];
292
312
  }>;
313
+ /**
314
+ * 删除所有新增的临时数据
315
+ */
316
+ removeInsertRow: () => Promise<{
317
+ row: DT;
318
+ rows: DT[];
319
+ }>;
320
+ /** 清除表格的全部数据状态 */
321
+ clearAll: () => Promise<void>;
322
+ /**
323
+ * 重新加载 VXE 当前同步数据。
324
+ * @deprecated VXE 已废弃 syncData,请使用 reloadData 或 getDataSource。
325
+ */
326
+ syncData: () => Promise<void>;
327
+ /** 重新计算 VXE 的数据视图 */
328
+ updateData: () => Promise<void>;
329
+ /** 修改指定行数据 */
330
+ setRow: (rows: any | any[], record: any) => Promise<void>;
331
+ /**
332
+ * 设置空数据提示文字
333
+ * @param text 提示文字
334
+ */
335
+ setEmptyText: (text: string) => void;
293
336
  /**
294
337
  * 清除编辑状态并重置数据
295
338
  */
@@ -324,12 +367,28 @@ export type VxeTableMethods<DT> = {
324
367
  * @param field 指定字段名
325
368
  */
326
369
  reloadRow: (rows: any | any[], record?: any, field?: string) => Promise<void>;
370
+ /** 还原 keep-source 保存的行数据 */
371
+ revertData: (rows?: any | any[], field?: string) => Promise<any>;
372
+ /** 加载树节点的子数据 */
373
+ loadTreeChildren: (row: any, children: any[]) => Promise<any[]>;
327
374
  /**
328
375
  * 手动清空单元格内容,如果不传参数,则清空整个表格内容,如果传了行则清空指定行内容,如果传了指定字段,则清空该字段内容
329
376
  * @param rows 指定行
330
377
  * @param field 字段名
331
378
  */
332
379
  clearData: (rows?: any | any[], field?: string) => Promise<any>;
380
+ /** 移动行到指定行位置 */
381
+ moveRowTo: (row: any, targetRow: any, options?: Recordable) => Promise<{
382
+ status: boolean;
383
+ }>;
384
+ /** 撤销最近一次数据操作 */
385
+ undo: () => Promise<{
386
+ status: boolean;
387
+ }>;
388
+ /** 重做最近一次数据操作 */
389
+ redo: () => Promise<{
390
+ status: boolean;
391
+ }>;
333
392
  /**
334
393
  * 重新懒加载展开行,并展开内容
335
394
  * @param row 指定行
@@ -340,9 +399,74 @@ export type VxeTableMethods<DT> = {
340
399
  * @param rows 指定行
341
400
  */
342
401
  reloadTreeExpand: (row: any) => Promise<any>;
402
+ /**
403
+ * 校验表格编辑数据
404
+ * @param isFull true 时校验全部行并收集所有错误,缺省或 false 时遇到第一个错误即停止
405
+ */
406
+ validate: (isFull?: boolean) => Promise<undefined | VxeTableDefines.ValidatorErrorMapParams>;
407
+ /**
408
+ * 校验指定行的指定字段
409
+ * @param row 行数据
410
+ * @param field 列字段名
411
+ */
412
+ validateField: (row: DT, field: string) => Promise<undefined | VxeTableDefines.ValidatorErrorMapParams>;
343
413
  };
344
414
  export type TtSelectRowKeysType = Array<string | number> | string | number | undefined | any;
345
415
  export type TtSelectRowsType = VxeTablePropTypes.Row | Array<VxeTablePropTypes.Row> | any;
416
+ /**
417
+ * `useTableRender` 返回组件的插槽类型。
418
+ *
419
+ * 列插槽(列上写 `slots: { default: 'xxx' }`)的名字是运行时字符串,类型系统看不到,
420
+ * 所以用索引签名统一给出行作用域参数 —— 插槽名拼错不会报错,但 `row` 能推断出行类型。
421
+ */
422
+ export type TtTableSlots<Row = any> = {
423
+ /** 操作列 */
424
+ action: (props: {
425
+ row: Row;
426
+ rowIndex: number;
427
+ $rowIndex: number;
428
+ column: TtColumnOptions<Row>;
429
+ }) => any;
430
+ /** 展开行内容 */
431
+ "expand-content": (props: {
432
+ row: Row;
433
+ rowIndex: number;
434
+ }) => any;
435
+ /** 空状态,不传时渲染组件默认内容 */
436
+ empty: (props: {
437
+ isLoaded: boolean;
438
+ loading?: boolean;
439
+ emptyTip?: string;
440
+ }) => any;
441
+ /** 工具栏左侧按钮 */
442
+ toolbar_buttons: () => any;
443
+ /** 工具栏右侧工具 */
444
+ toolbar_tools: () => any;
445
+ /** 表格上方 alert 内的追加内容 */
446
+ top_title: () => any;
447
+ /** 分页器左侧 */
448
+ pager_left: (props: {
449
+ selectedKeys: TtSelectRowKeysType;
450
+ }) => any;
451
+ /** 分页器左侧(追加在 pager_left 之后) */
452
+ buttom_left: () => any;
453
+ /** 表格左侧按行渲染的内容 */
454
+ tableLeft: (props: {
455
+ rowNodes: TtTableLeftRightRowNode[];
456
+ height: number;
457
+ }) => any;
458
+ /** 表格右侧按行渲染的内容 */
459
+ tableRight: (props: {
460
+ rowNodes: TtTableLeftRightRowNode[];
461
+ height: number;
462
+ }) => any;
463
+ /** 完全接管表格左侧区域 */
464
+ left: () => any;
465
+ /** 完全接管表格右侧区域 */
466
+ right: () => any;
467
+ /** 列插槽等运行时名字的插槽 */
468
+ [slotName: string]: (props: any) => any;
469
+ };
346
470
  export type TtTableMethods<DT = VxeTablePropTypes.Row> = {
347
471
  /**
348
472
  * @description: 表格重载数据, 默认重置为第一页,可全局配置 isReloadResetToFirstPage:false 不重置为第一页
@@ -376,11 +500,6 @@ export type TtTableMethods<DT = VxeTablePropTypes.Row> = {
376
500
  * @return {*}
377
501
  */
378
502
  setTableColumns: (columns: VxeGridPropTypes.Columns<DT>) => void;
379
- /**
380
- * @description: 获取表格columns
381
- * @return {VxeGridPropTypes.Columns<DT> | undefined}
382
- */
383
- emitLoading?: (loading: boolean, uid: number) => void;
384
503
  /**
385
504
  * @description: 获取表格数据
386
505
  * @return {DT[]}
@@ -484,8 +603,8 @@ export type TtTableLeftRightRowNode = {
484
603
  index?: number;
485
604
  parent?: any;
486
605
  };
487
- export type TtTableExtendedTableApi = TableApi & {
488
- useStore: <T = NoInfer<TtTableProps>>(selector?: (state: NoInfer<TtTableProps>) => T) => Readonly<Ref<T>>;
606
+ export type TtTableExtendedTableApi<Row = any> = TableApi<Row> & {
607
+ useStore: <T = NoInfer<TtTableProps<Row>>>(selector?: (state: NoInfer<TtTableProps<Row>>) => T) => Readonly<Ref<T>>;
489
608
  };
490
609
  export type RowSelectionHandlers = {
491
610
  clearSelectedRowKeys?: () => void;
@@ -1,26 +1,49 @@
1
1
  import { TipConfig } from '../../../../directives/disabled-tip';
2
2
  import { ButtonProps } from 'element-plus';
3
+ /** 工具栏支持的内置按钮组件名称 */
3
4
  export type TtActionComponentType = "TtAddButton" | "TtDelButton" | "TtUploadButton" | "TtEnableButton" | "TtDisabledButton";
5
+ /** 操作列和工具栏按钮的通用配置 */
4
6
  export type TtActionItem = {
7
+ /** 点击回调;操作列和工具栏按钮都使用该字段 */
5
8
  onClick?: Fn;
9
+ /** 历史遗留字段,当前渲染器不会调用,请使用 onClick */
6
10
  handler?: Fn;
11
+ /** 按钮文本 */
7
12
  label?: string;
13
+ /** 历史图标字段,当前渲染器不会读取,请使用 iconFont */
8
14
  icon?: string;
15
+ /** 历史图标尺寸字段,当前渲染器不会读取 */
9
16
  iconSize?: number;
17
+ /** 按钮类型 */
10
18
  type?: "" | "default" | "success" | "warning" | "info" | "text" | "primary" | "danger";
19
+ /** 历史 class 字段,普通按钮请通过 props.class 传入 */
11
20
  class?: string;
21
+ /** iconfont 图标名称 */
12
22
  iconFont?: string;
23
+ /** 预留的分割线配置,当前按钮组件不会读取 */
13
24
  divider?: boolean;
25
+ /** 按钮 loading 状态 */
14
26
  loading?: boolean;
27
+ /** 权限编码;当前组件不会自动执行权限判断 */
15
28
  auth?: string[];
29
+ /** 业务条件控制是否显示 */
16
30
  ifShow?: boolean | ((action: TtActionItem) => boolean);
31
+ /** 是否禁用按钮 */
17
32
  disabled?: boolean;
33
+ /** 禁用时显示的提示 */
18
34
  disabledTip?: Array<TipConfig> | TipConfig;
35
+ /** 按钮文字颜色 */
19
36
  color?: string;
37
+ /** 工具栏使用的已注册按钮组件名称 */
20
38
  component?: TtActionComponentType;
39
+ /** 工具栏下拉按钮的子项 */
21
40
  children?: TtActionItem[];
41
+ /** 使用同名插槽替代默认按钮 */
22
42
  slot?: string;
43
+ /** 工具栏按钮尺寸 */
23
44
  size?: "" | "default" | "small" | "large";
45
+ /** 操作列中隐藏文本但保留按钮占位 */
24
46
  isTextHide?: boolean;
47
+ /** 透传给工具栏 TtButton 的其它属性 */
25
48
  props?: Partial<ButtonProps>;
26
49
  };
@@ -1,16 +1,19 @@
1
1
  import { MaybeRef, Ref } from 'vue';
2
- import { VxeGridMethods } from 'vxe-table';
3
2
  import { TtSelectRowKeysType, TtTableMethods, TtTableProps } from '../types/table';
4
3
  import { TableFormApi } from '../utils/table-form-api';
5
4
  import { TtTableToolsProps } from './tableTools';
6
5
  import { TtExtendedFormApi, TtFormProps } from '../../../tt-form';
7
6
  export type TtTableFormRenderFormProps = Partial<TtFormProps>;
8
7
  export type TtTableRenderFormInstance = TtExtendedFormApi;
9
- export type TtTableFormProps = {
10
- /** 双向绑定的表格数据 */
11
- tableData?: Array<Recordable>;
8
+ /**
9
+ * 表单 + 表格的组合配置。
10
+ *
11
+ * `Row` 是业务行数据类型,由 `useTableFormRender<Row>()` 传入后 `table` 里的列配置、
12
+ * 数据与 `tableApi` 的方法签名都会跟着推断;不传时退化为 `any`。
13
+ */
14
+ export type TtTableFormProps<Row = any> = {
12
15
  /** 表格配置 */
13
- table?: Partial<TtTableProps>;
16
+ table?: Partial<TtTableProps<Row>>;
14
17
  /** form 配置 */
15
18
  form?: TtTableFormRenderFormProps;
16
19
  /** 是否开启form表单 */
@@ -30,35 +33,21 @@ export type TtTableFormProps = {
30
33
  */
31
34
  testId?: string;
32
35
  };
33
- export type TtTableFormInstance = {
34
- /** 获取TtTableV2实例 */
35
- tableInstance: () => Promise<TtTableMethods>;
36
- /** 获取TtForm实例 */
37
- formInstance: () => Promise<TtTableRenderFormInstance>;
38
- /** 获取VxeGrid实例 */
39
- vxeGridInstance: () => Promise<VxeGridMethods>;
40
- };
41
- export type TtTableFormActionType = {
42
- setTableProps: (props: Partial<TtTableProps>) => void;
36
+ export type TtTableFormActionType<Row = any> = {
37
+ setTableProps: (props: Partial<TtTableProps<Row>>) => void;
43
38
  setFormProps: (props: TtTableFormRenderFormProps) => void;
44
- tableMethods: TtTableMethods;
39
+ tableMethods: TtTableMethods<Row>;
45
40
  formMethods: TtTableRenderFormInstance;
46
41
  /** 设置props */
47
- setProps: (props: Partial<TtTableFormProps>) => void;
42
+ setProps: (props: Partial<TtTableFormProps<Row>>) => void;
48
43
  /** reload */
49
- reload: TtTableMethods["reload"];
44
+ reload: TtTableMethods<Row>["reload"];
50
45
  /**
51
46
  * @description: 获取表格选中数据
52
47
  * @return {TtSelectRowKeysType[]}
53
48
  */
54
49
  selectedKeys: MaybeRef<TtSelectRowKeysType>;
55
50
  };
56
- export type TtTableFormMethod = TtTableFormInstance & Omit<TtTableFormActionType, "tableMethods" | "formMethods"> & {
57
- tableMethods?: TtTableMethods;
58
- formMethods?: TtTableRenderFormInstance;
59
- };
60
- export type TableFormRegisterFn = (instance: TtTableFormActionType, uuid: string) => void;
61
- export type UseTtTableFormReturnType = [TableFormRegisterFn, TtTableFormMethod];
62
- export type TtTableExtendedTableFormApi = TableFormApi & {
63
- useStore: <T = NoInfer<TtTableFormProps>>(selector?: (state: NoInfer<TtTableFormProps>) => T) => Readonly<Ref<T>>;
51
+ export type TtTableExtendedTableFormApi<Row = any> = TableFormApi<Row> & {
52
+ useStore: <T = NoInfer<TtTableFormProps<Row>>>(selector?: (state: NoInfer<TtTableFormProps<Row>>) => T) => Readonly<Ref<T>>;
64
53
  };