@dazhicheng/ui 1.5.266 → 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 (96) 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/form-render/array-register/FormArrayRegister.d.ts +3 -3
  5. package/dist/components/tt-icon/index.vue.js +2 -2
  6. package/dist/components/tt-loading/src/loading.vue.js +2 -2
  7. package/dist/components/tt-panel-select/src/components/PanelMiddle.vue.d.ts +2 -2
  8. package/dist/components/tt-panel-select/src/hooks/usePanelData.js +93 -86
  9. package/dist/components/tt-panel-select/src/index.vue.js +1 -0
  10. package/dist/components/tt-select/src/Select.vue.d.ts +4 -4
  11. package/dist/components/tt-select/src/components/Table.vue.d.ts +4 -4
  12. package/dist/components/tt-table/index.d.ts +523 -358
  13. package/dist/components/tt-table/index.js +6 -4
  14. package/dist/components/tt-table/src/Table.vue.d.ts +306 -216
  15. package/dist/components/tt-table/src/Table.vue.js +405 -618
  16. package/dist/components/tt-table/src/TableForm.vue.d.ts +384 -19
  17. package/dist/components/tt-table/src/TableForm.vue.js +218 -228
  18. package/dist/components/tt-table/src/components/TableAction.vue.js +108 -131
  19. package/dist/components/tt-table/src/components/TableButtons.js +25 -25
  20. package/dist/components/tt-table/src/components/TableColumnModal.vue2.js +88 -85
  21. package/dist/components/tt-table/src/components/TableToolbarTools.vue.d.ts +80 -0
  22. package/dist/components/tt-table/src/components/{TableToobalTools.vue.js → TableToolbarTools.vue.js} +29 -31
  23. package/dist/components/tt-table/src/components/TableToolbarTools.vue2.js +4 -0
  24. package/dist/components/tt-table/src/emits.js +2 -1
  25. package/dist/components/tt-table/src/hooks/useColumnPersistence.d.ts +19 -0
  26. package/dist/components/tt-table/src/hooks/useColumnPersistence.js +63 -0
  27. package/dist/components/tt-table/src/hooks/useColumns.d.ts +505 -21
  28. package/dist/components/tt-table/src/hooks/useColumns.js +100 -245
  29. package/dist/components/tt-table/src/hooks/useGridProps.d.ts +36 -0
  30. package/dist/components/tt-table/src/hooks/useGridProps.js +121 -0
  31. package/dist/components/tt-table/src/hooks/useKeyboardNav.d.ts +11 -0
  32. package/dist/components/tt-table/src/hooks/useKeyboardNav.js +97 -0
  33. package/dist/components/tt-table/src/hooks/usePagination.d.ts +14 -8
  34. package/dist/components/tt-table/src/hooks/usePagination.js +29 -33
  35. package/dist/components/tt-table/src/hooks/useQuery.d.ts +41 -0
  36. package/dist/components/tt-table/src/hooks/useQuery.js +147 -0
  37. package/dist/components/tt-table/src/hooks/useRowIdentity.d.ts +22 -0
  38. package/dist/components/tt-table/src/hooks/useRowIdentity.js +96 -0
  39. package/dist/components/tt-table/src/hooks/useRowSelection.d.ts +23 -7
  40. package/dist/components/tt-table/src/hooks/useRowSelection.js +95 -71
  41. package/dist/components/tt-table/src/hooks/{useLeftRightSlot.d.ts → useSideSlot.d.ts} +25 -17
  42. package/dist/components/tt-table/src/hooks/useSideSlot.js +77 -0
  43. package/dist/components/tt-table/src/hooks/useSyncProps.d.ts +12 -0
  44. package/dist/components/tt-table/src/hooks/useSyncProps.js +55 -0
  45. package/dist/components/tt-table/src/hooks/useTableData.d.ts +71 -0
  46. package/dist/components/tt-table/src/hooks/useTableData.js +307 -0
  47. package/dist/components/tt-table/src/hooks/useTableFooter.d.ts +15 -0
  48. package/dist/components/tt-table/src/hooks/useTableFooter.js +46 -0
  49. package/dist/components/tt-table/src/hooks/useTableForm.d.ts +10 -5
  50. package/dist/components/tt-table/src/hooks/useTableForm.js +55 -48
  51. package/dist/components/tt-table/src/hooks/useTableMethods.d.ts +165 -0
  52. package/dist/components/tt-table/src/hooks/useTableMethods.js +183 -0
  53. package/dist/components/tt-table/src/hooks/useTableRender.d.ts +24 -55
  54. package/dist/components/tt-table/src/props.d.ts +318 -151
  55. package/dist/components/tt-table/src/props.js +117 -270
  56. package/dist/components/tt-table/src/table-defaults.d.ts +25 -0
  57. package/dist/components/tt-table/src/table-defaults.js +71 -0
  58. package/dist/components/tt-table/src/table-mutation-events.d.ts +43 -0
  59. package/dist/components/tt-table/src/table-mutation-events.js +70 -0
  60. package/dist/components/tt-table/src/types/table.d.ts +207 -88
  61. package/dist/components/tt-table/src/types/tableAction.d.ts +23 -0
  62. package/dist/components/tt-table/src/types/tableForm.d.ts +15 -26
  63. package/dist/components/tt-table/src/utils/action-tab-index.d.ts +2 -0
  64. package/dist/components/tt-table/src/utils/action-tab-index.js +50 -0
  65. package/dist/components/tt-table/src/utils/context.js +25 -12
  66. package/dist/components/tt-table/src/utils/table-api.d.ts +136 -58
  67. package/dist/components/tt-table/src/utils/table-api.js +198 -165
  68. package/dist/components/tt-table/src/utils/table-form-api.d.ts +11 -11
  69. package/dist/components/tt-table/src/utils/table-form-api.js +41 -31
  70. package/dist/components/types.d.ts +0 -20
  71. package/dist/hooks/useSetup.js +0 -3
  72. package/dist/packages/hooks/src/useDebounce.js +6 -6
  73. package/dist/packages/utils/src/is.js +20 -18
  74. package/dist/packages/utils/src/tool.js +76 -149
  75. package/dist/style.css +1 -1
  76. package/package.json +1 -1
  77. package/dist/components/tt-table/src/components/TableToobalTools.vue.d.ts +0 -576
  78. package/dist/components/tt-table/src/components/TableToobalTools.vue2.js +0 -4
  79. package/dist/components/tt-table/src/enum.d.ts +0 -2
  80. package/dist/components/tt-table/src/hooks/useCellArea.d.ts +0 -15
  81. package/dist/components/tt-table/src/hooks/useCellArea.js +0 -15
  82. package/dist/components/tt-table/src/hooks/useCustomColumns.d.ts +0 -20
  83. package/dist/components/tt-table/src/hooks/useCustomColumns.js +0 -65
  84. package/dist/components/tt-table/src/hooks/useDataSource.d.ts +0 -29
  85. package/dist/components/tt-table/src/hooks/useDataSource.js +0 -232
  86. package/dist/components/tt-table/src/hooks/useLeftRightSlot.js +0 -64
  87. package/dist/components/tt-table/src/hooks/useTable.d.ts +0 -7
  88. package/dist/components/tt-table/src/hooks/useTableEvent.d.ts +0 -101
  89. package/dist/components/tt-table/src/hooks/useTableEvent.js +0 -197
  90. package/dist/components/tt-table/src/hooks/useTableFormEvent.d.ts +0 -10
  91. package/dist/components/tt-table/src/hooks/useTableHeight.d.ts +0 -15
  92. package/dist/components/tt-table/src/hooks/useTableSlot.d.ts +0 -11
  93. package/dist/components/tt-table/src/hooks/useTableSlot.js +0 -17
  94. package/dist/components/tt-table/src/utils/filters.d.ts +0 -109
  95. package/dist/components/tt-table/src/utils/vxeTable.d.ts +0 -28
  96. package/dist/packages/utils/src/check.js +0 -10
@@ -0,0 +1,46 @@
1
+ import "axios";
2
+ import "element-plus";
3
+ import { isFunction as s, isNumber as d } from "../../../../packages/utils/src/is.js";
4
+ import { computed as p, unref as a } 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 c = "合计";
16
+ function h(i, m, f) {
17
+ const r = f.map((t) => l(t, m.field));
18
+ if (s(i)) return i({ values: r, rows: f, column: m });
19
+ if (i === "count") return f.length;
20
+ const e = r.filter(d), o = e.reduce((t, n) => t + n, 0);
21
+ return i === "avg" ? e.length ? o / e.length : 0 : o;
22
+ }
23
+ function x(i) {
24
+ const m = p(() => {
25
+ const r = /* @__PURE__ */ new Map(), e = (o) => {
26
+ o.forEach((t) => {
27
+ var n;
28
+ t.field && t.summary && r.set(t.field, t.summary), (n = t.children) != null && n.length && e(t.children);
29
+ });
30
+ };
31
+ return e(a(i)), r;
32
+ });
33
+ return { footerSummaryMethod: p(() => {
34
+ const r = a(m);
35
+ if (r.size)
36
+ return ({ columns: e, data: o }) => [
37
+ e.map((t, n) => {
38
+ const u = t.field ? r.get(t.field) : void 0;
39
+ return u ? h(u, t, o) : n === 0 ? c : "";
40
+ })
41
+ ];
42
+ }) };
43
+ }
44
+ export {
45
+ x as useTableFooter
46
+ };
@@ -1,15 +1,20 @@
1
1
  import { ComputedRef } from 'vue';
2
2
  import { TtFormProps } from '../../../tt-form';
3
3
  import { VxeGridPropTypes } from 'vxe-table';
4
+ import { Recordable } from '../../../../../../utils/src';
4
5
  import { FetchParams, TtTableProps } from '../types/table';
5
6
  import { TtTableFormProps } from '../types/tableForm';
6
7
  import { TtTableToolsProps } from '../types/tableTools';
7
- export declare function useTableForm(propsRef: ComputedRef<TtTableFormProps>, fetch: (opt?: FetchParams | undefined) => Promise<void>, getLoading: ComputedRef<boolean | undefined> | undefined, getPagination: () => VxeGridPropTypes.PagerConfig | undefined, emit: {
8
- (e: "update:table-data", data?: Recordable): void;
9
- }): {
10
- tableData: import('vue').Ref<Recordable<any>[], Recordable<any>[]>;
8
+ /**
9
+ * TableForm form / table 配置计算
10
+ * @param propsRef 表单+表格 props
11
+ * @param fetch 表格数据请求
12
+ * @param getLoading 表格 loading 状态
13
+ * @param getPagination 获取分页信息
14
+ */
15
+ export declare function useTableForm(propsRef: ComputedRef<TtTableFormProps>, fetch: (opt?: FetchParams | undefined) => Promise<void>, getLoading: ComputedRef<boolean | undefined> | undefined, getPagination: () => VxeGridPropTypes.PagerConfig | undefined): {
11
16
  getFormProps: ComputedRef<TtFormProps<Record<string, any>>>;
12
- handleSearchInfoChange: (info: Recordable) => Promise<void>;
17
+ submitSearchQuery: (info: Recordable) => Promise<void>;
13
18
  getTableProps: ComputedRef<Partial<TtTableProps>>;
14
19
  getTableToolProps: ComputedRef<TtTableToolsProps>;
15
20
  };
@@ -1,60 +1,67 @@
1
- import { omit as p, cloneDeep as y, isFunction as d, isEqual as T } from "lodash-es";
2
- import { ref as C, computed as f, unref as n, toValue as m, watch as D, watchEffect as E } from "vue";
3
- function B(o, w, g, F, I) {
4
- const r = C([]), b = f(() => {
5
- const { form: t } = n(o), { submitButtonOptions: e = {} } = t || {};
6
- return Object.assign(e, { loading: n(g) }), {
1
+ import "axios";
2
+ import "element-plus";
3
+ import { isFunction as m } from "../../../../packages/utils/src/is.js";
4
+ import { computed as c, unref as i, toValue as u } 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 { omit as p } from "lodash-es";
15
+ function V(n, h, l, d) {
16
+ const f = c(() => {
17
+ const { form: t } = i(n), o = {
18
+ ...t == null ? void 0 : t.submitButtonOptions,
19
+ loading: i(l)
20
+ };
21
+ return {
7
22
  ...t,
8
- submitButtonOptions: e
23
+ submitButtonOptions: o
9
24
  };
10
25
  });
11
- async function S(t) {
12
- const e = F(), a = { currentPage: 1, pageSize: e == null ? void 0 : e.pageSize };
13
- await w({ tablePage: a, searchInfo: t });
26
+ async function b(t) {
27
+ const o = d(), r = { currentPage: 1, pageSize: o == null ? void 0 : o.pageSize };
28
+ await h({ tablePage: r, searchInfo: t });
14
29
  }
15
- const P = f(() => {
16
- const { table: t = {}, tableRowId: e, useSearchForm: a, testId: s } = m(o), u = p(n(l), ["tableRowId"]);
17
- return y({
18
- useSearchForm: a || !1,
19
- // TODO: getProps 使用toRaw会导致堆栈溢出问题后续优化
20
- ...t,
21
- ...u,
22
- tableRowId: (t == null ? void 0 : t.tableRowId) || e,
23
- // 继承外层的 testId,如果 table.testId 未设置则使用外层的 testId
24
- testId: (t == null ? void 0 : t.testId) || s,
25
- beforeFetch: async (i) => {
26
- const { handleSearchInfoFn: h } = m(o);
27
- let c = i;
28
- return h && d(h) && (c = await h(c)), t != null && t.beforeFetch && d(t == null ? void 0 : t.beforeFetch) && (c = await (t == null ? void 0 : t.beforeFetch(c))), c;
29
- }
30
- });
31
- }), l = f(() => {
32
- const { columnsKey: t, showSetting: e, showSetColumn: a, showRefresh: s, showExport: u } = n(o).table || {}, { toolConfig: i } = n(o);
30
+ async function w(t) {
31
+ const { handleSearchInfoFn: o, table: r } = u(n);
32
+ let e = t;
33
+ return m(o) && (e = await o(e) || e), m(r == null ? void 0 : r.beforeFetch) && (e = await r.beforeFetch(e) || e), e;
34
+ }
35
+ const a = c(() => {
36
+ const { columnsKey: t, showSetting: o, showSetColumn: r, showRefresh: e, showExport: s } = i(n).table || {}, { toolConfig: F } = i(n);
33
37
  return {
34
38
  columnsKey: t,
35
- showSetting: e,
36
- showRefresh: s,
37
- showSetColumn: a,
38
- showExport: u,
39
- ...i
39
+ showSetting: o,
40
+ showRefresh: e,
41
+ showSetColumn: r,
42
+ showExport: s,
43
+ ...F
44
+ };
45
+ }), g = c(() => {
46
+ const { table: t = {}, tableRowId: o, useSearchForm: r, testId: e } = u(n), s = p(i(a), ["tableRowId"]);
47
+ return {
48
+ useSearchForm: r || !1,
49
+ // 数据由 TableForm 单独绑定,不进入表格配置。
50
+ ...p(t, ["data"]),
51
+ ...s,
52
+ tableRowId: (t == null ? void 0 : t.tableRowId) || o,
53
+ // 继承外层的 testId,如果 table.testId 未设置则使用外层的 testId
54
+ testId: (t == null ? void 0 : t.testId) || e,
55
+ beforeFetch: w
40
56
  };
41
57
  });
42
- return D(
43
- () => r.value,
44
- (t, e) => {
45
- T(t, e) || I("update:table-data", t);
46
- },
47
- { deep: !0 }
48
- ), E(() => {
49
- r.value = n(o).tableData || [];
50
- }), {
51
- tableData: r,
52
- getFormProps: b,
53
- handleSearchInfoChange: S,
54
- getTableProps: P,
55
- getTableToolProps: l
58
+ return {
59
+ getFormProps: f,
60
+ submitSearchQuery: b,
61
+ getTableProps: g,
62
+ getTableToolProps: a
56
63
  };
57
64
  }
58
65
  export {
59
- B as useTableForm
66
+ V as useTableForm
60
67
  };
@@ -0,0 +1,165 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { VxeGridInstance, VxeTableDefines, VxeTablePropTypes } from 'vxe-table';
3
+ import { Recordable } from '../../../../../../utils/src';
4
+ import { InsertReturnData, TtTableExtendedTableApi, TtTableProps } from '../types/table';
5
+ /**
6
+ * 表格数据与编辑相关的实例方法
7
+ *
8
+ * 所有会改动表格数据的方法都经过 runDataOperation:操作完成后把表格内数据抛给 v-model,
9
+ * 外部原样回传时由 useTableData 的事件版本跳过重复落表。
10
+ * @param propsRef 表格 props
11
+ * @param grid vxe-grid 实例
12
+ * @param tableApi 表格 api
13
+ * @param ctx 表格上下文
14
+ * @param ctx.clearSelectedRowKeys 清除行选择
15
+ * @param ctx.getTableInstance 获取带变更桥接的 VXE 公共实例
16
+ * @param ctx.runDataOperation 统一执行内部数据变更
17
+ * @param ctx.isActive 判断表格作用域是否仍然有效
18
+ * @param ctx.prepareRows 数据进入 VXE 前的行身份预处理
19
+ */
20
+ export declare function useTableMethods(propsRef: ComputedRef<TtTableProps>, grid: Ref<undefined | VxeGridInstance<Recordable>>, tableApi: TtTableExtendedTableApi, { clearSelectedRowKeys, getTableInstance, runDataOperation, isActive, prepareRows, }: {
21
+ clearSelectedRowKeys: () => void;
22
+ getTableInstance: () => VxeGridInstance<Recordable>;
23
+ runDataOperation: <T>(operation: () => Promise<T> | T, source?: "full" | "visible") => Promise<T>;
24
+ isActive: () => boolean;
25
+ prepareRows: (rows: Recordable | Recordable[]) => void;
26
+ }): {
27
+ /**
28
+ * 从第一行插入临时数据
29
+ * @param records 新数据
30
+ */
31
+ insert: (records: VxeTablePropTypes.Row) => Promise<InsertReturnData>;
32
+ /**
33
+ * 在指定行插入临时数据
34
+ * @param records 新数据
35
+ * @param row 指定行,-1 表示插入到底部
36
+ */
37
+ insertAt: (records: VxeTablePropTypes.Row, row: any) => Promise<InsertReturnData>;
38
+ /** 在指定行之后插入临时数据 */
39
+ insertNextAt: (records: VxeTablePropTypes.Row, row: any) => Promise<InsertReturnData>;
40
+ /** 在树节点下插入临时子数据 */
41
+ insertChild: (records: VxeTablePropTypes.Row, parentRow: any) => Promise<InsertReturnData>;
42
+ /** 在树节点下的指定位置插入临时子数据 */
43
+ insertChildAt: (records: VxeTablePropTypes.Row, parentRow: any, row: any) => Promise<InsertReturnData>;
44
+ /** 在树节点下的指定行之后插入临时子数据 */
45
+ insertChildNextAt: (records: VxeTablePropTypes.Row, parentRow: any, row: any) => Promise<InsertReturnData>;
46
+ /**
47
+ * 删除指定行
48
+ * @param rows 指定行
49
+ */
50
+ remove: (rows: VxeTablePropTypes.Row) => Promise<InsertReturnData>;
51
+ /** 删除复选框选中的行 */
52
+ removeCheckboxRow: () => Promise<InsertReturnData>;
53
+ /** 删除单选框选中的行 */
54
+ removeRadioRow: () => Promise<InsertReturnData>;
55
+ /** 删除当前行 */
56
+ removeCurrentRow: () => Promise<InsertReturnData>;
57
+ /** 删除所有新增的临时数据 */
58
+ removeInsertRow: () => Promise<InsertReturnData>;
59
+ /** 清除表格的全部数据状态。该操作不改变业务行数据,无需触发 v-model 回写。 */
60
+ clearAll: () => Promise<void>;
61
+ /**
62
+ * 重新加载 VXE 当前同步数据,兼容旧的 syncData 入口。
63
+ * @deprecated VXE 已废弃 syncData,请使用 reloadData 或 getDataSource。
64
+ */
65
+ syncData: () => Promise<void>;
66
+ /** 重新计算 VXE 的排序、筛选数据视图。该操作不改变业务行数据。 */
67
+ updateData: () => Promise<void>;
68
+ /** 修改指定行数据 */
69
+ setRow: (rows: VxeTablePropTypes.Row | VxeTablePropTypes.Row[], record: VxeTablePropTypes.Row) => Promise<void>;
70
+ /**
71
+ * 退出编辑并还原行数据
72
+ * @param row 指定行
73
+ */
74
+ clearEditRevertData: (row: VxeTablePropTypes.Row) => Promise<void>;
75
+ /**
76
+ * 指定行激活编辑
77
+ * @param row 指定行
78
+ * @param fieldOrColumn 指定列
79
+ */
80
+ setEditRow: (row: VxeTablePropTypes.Row, fieldOrColumn?: boolean | string | VxeTableDefines.ColumnInfo) => Promise<void>;
81
+ /**
82
+ * 指定单元格激活编辑
83
+ * @param row 指定行
84
+ * @param fieldOrColumn 指定列
85
+ */
86
+ setEditCell: (row: VxeTablePropTypes.Row, fieldOrColumn: string | VxeTableDefines.ColumnInfo) => Promise<void>;
87
+ /**
88
+ * 加载数据
89
+ * @param rows 数据
90
+ */
91
+ loadData: (rows: VxeTablePropTypes.Row[]) => Promise<any>;
92
+ /**
93
+ * 加载数据并恢复到初始状态
94
+ * @param rows 数据
95
+ */
96
+ reloadData: (rows: VxeTablePropTypes.Row[]) => Promise<void>;
97
+ /**
98
+ * 重新加载列
99
+ * @param columns 列配置
100
+ */
101
+ reloadColumn: (columns: (VxeTableDefines.ColumnOptions<any> | VxeTableDefines.ColumnInfo<any>)[]) => Promise<any>;
102
+ /**
103
+ * 局部加载行数据并恢复到初始状态
104
+ * @param rows 行
105
+ * @param record 新数据
106
+ * @param field 指定字段名
107
+ */
108
+ reloadRow: (rows: VxeTablePropTypes.Row | VxeTablePropTypes.Row[], record?: VxeTablePropTypes.Row, field?: string) => Promise<void>;
109
+ /** 还原 keep-source 保存的行数据 */
110
+ revertData: (rows?: VxeTablePropTypes.Row | VxeTablePropTypes.Row[], field?: string) => Promise<any>;
111
+ /** 加载树节点的子数据 */
112
+ loadTreeChildren: (row: VxeTablePropTypes.Row, children: VxeTablePropTypes.Row[]) => Promise<any[]>;
113
+ /**
114
+ * 清空单元格内容
115
+ * @param rows 指定行,为空表示整个表格
116
+ * @param field 指定字段名
117
+ */
118
+ clearData: (rows: VxeTablePropTypes.Row | VxeTablePropTypes.Row[], field?: string) => Promise<any>;
119
+ /** 移动行到指定行位置 */
120
+ moveRowTo: (row: any, targetRow: any, options?: Recordable) => Promise<{
121
+ status: boolean;
122
+ }>;
123
+ /** 撤销最近一次数据操作 */
124
+ undo: () => Promise<{
125
+ status: boolean;
126
+ }>;
127
+ /** 重做最近一次数据操作 */
128
+ redo: () => Promise<{
129
+ status: boolean;
130
+ }>;
131
+ /**
132
+ * 重新懒加载展开行并展开内容
133
+ * @param rows 指定行
134
+ */
135
+ reloadRowExpand: (rows: VxeTablePropTypes.Row) => Promise<void>;
136
+ /**
137
+ * 重新懒加载树节点并展开该节点
138
+ * @param rows 指定行
139
+ */
140
+ reloadTreeExpand: (rows: VxeTablePropTypes.Row) => Promise<any>;
141
+ /**
142
+ * 设置空数据提示文字
143
+ * @param text 提示文字
144
+ */
145
+ setEmptyText: (text: string) => void;
146
+ /**
147
+ * 校验表格编辑数据。
148
+ *
149
+ * 只是 vxe 校验能力的门面,不加组件自己的校验逻辑,也不改动校验提示的渲染。
150
+ * 两个分支都传 `true`(校验当前表格全部数据):不传时 vxe 只校验临时变动过的行,
151
+ * 而这个方法的用途是提交前的整表校验。
152
+ * @param isFull `true` 走 vxe 的 fullValidate,逐行校验并收集所有错误;
153
+ * 缺省或 `false` 走 validate,遇到第一个不通过的记录即停止
154
+ * @returns 全部通过时为 `undefined`;否则为 vxe 原生形状 —— 以列字段为键,
155
+ * 值是该字段上每条违规的 `{ rules, row, rowIndex, column, columnIndex, field }`
156
+ */
157
+ validate: (isFull?: boolean) => Promise<undefined | VxeTableDefines.ValidatorErrorMapParams>;
158
+ /**
159
+ * 校验指定行的指定字段。
160
+ * @param row 行数据
161
+ * @param field 列字段名
162
+ * @returns 通过时为 `undefined`,否则为以列字段为键的错误映射
163
+ */
164
+ validateField: (row: VxeTablePropTypes.Row, field: string) => Promise<undefined | VxeTableDefines.ValidatorErrorMapParams>;
165
+ };
@@ -0,0 +1,183 @@
1
+ import { unref as t, nextTick as c } from "vue";
2
+ import { withTreeExpand as x } from "./useTableData.js";
3
+ function h(r, l, w, {
4
+ clearSelectedRowKeys: d,
5
+ getTableInstance: C,
6
+ runDataOperation: s,
7
+ isActive: n,
8
+ prepareRows: m
9
+ }) {
10
+ const v = () => {
11
+ var e;
12
+ return (e = t(r).treeConfig) == null ? void 0 : e.reserve;
13
+ };
14
+ function R(e, o) {
15
+ return m(e), s(o);
16
+ }
17
+ return {
18
+ /**
19
+ * 从第一行插入临时数据
20
+ * @param records 新数据
21
+ */
22
+ insert: (e) => s(() => t(l).insert(e)),
23
+ /**
24
+ * 在指定行插入临时数据
25
+ * @param records 新数据
26
+ * @param row 指定行,-1 表示插入到底部
27
+ */
28
+ insertAt: (e, o) => s(() => t(l).insertAt(e, o)),
29
+ /** 在指定行之后插入临时数据 */
30
+ insertNextAt: (e, o) => s(() => t(l).insertNextAt(e, o)),
31
+ /** 在树节点下插入临时子数据 */
32
+ insertChild: (e, o) => s(() => t(l).insertChild(e, o)),
33
+ /** 在树节点下的指定位置插入临时子数据 */
34
+ insertChildAt: (e, o, a) => s(() => t(l).insertChildAt(e, o, a)),
35
+ /** 在树节点下的指定行之后插入临时子数据 */
36
+ insertChildNextAt: (e, o, a) => s(() => t(l).insertChildNextAt(e, o, a)),
37
+ /**
38
+ * 删除指定行
39
+ * @param rows 指定行
40
+ */
41
+ remove: (e) => s(() => t(l).remove(e)),
42
+ /** 删除复选框选中的行 */
43
+ removeCheckboxRow: () => s(async () => {
44
+ const e = await t(l).removeCheckboxRow();
45
+ return d(), e;
46
+ }),
47
+ /** 删除单选框选中的行 */
48
+ removeRadioRow: () => s(async () => {
49
+ const e = await t(l).removeRadioRow();
50
+ return d(), e;
51
+ }),
52
+ /** 删除当前行 */
53
+ removeCurrentRow: () => s(() => t(l).removeCurrentRow()),
54
+ /** 删除所有新增的临时数据 */
55
+ removeInsertRow: () => s(() => t(l).removeInsertRow()),
56
+ /** 清除表格的全部数据状态。该操作不改变业务行数据,无需触发 v-model 回写。 */
57
+ clearAll: async () => {
58
+ const e = await t(l).clearAll();
59
+ return d(), e;
60
+ },
61
+ /**
62
+ * 重新加载 VXE 当前同步数据,兼容旧的 syncData 入口。
63
+ * @deprecated VXE 已废弃 syncData,请使用 reloadData 或 getDataSource。
64
+ */
65
+ syncData: () => s(() => t(l).updateData()),
66
+ /** 重新计算 VXE 的排序、筛选数据视图。该操作不改变业务行数据。 */
67
+ updateData: () => t(l).updateData(),
68
+ /** 修改指定行数据 */
69
+ setRow: (e, o) => s(() => t(l).setRow(e, o)),
70
+ /**
71
+ * 退出编辑并还原行数据
72
+ * @param row 指定行
73
+ */
74
+ clearEditRevertData: (e) => s(async () => {
75
+ var o, a;
76
+ await ((o = t(l)) == null ? void 0 : o.clearEdit()), await ((a = t(l)) == null ? void 0 : a.revertData(e));
77
+ }),
78
+ /**
79
+ * 指定行激活编辑
80
+ * @param row 指定行
81
+ * @param fieldOrColumn 指定列
82
+ */
83
+ setEditRow: async (e, o) => {
84
+ var a;
85
+ await ((a = t(l)) == null ? void 0 : a.setEditRow(e, o));
86
+ },
87
+ /**
88
+ * 指定单元格激活编辑
89
+ * @param row 指定行
90
+ * @param fieldOrColumn 指定列
91
+ */
92
+ setEditCell: async (e, o) => {
93
+ var a;
94
+ await ((a = t(l)) == null ? void 0 : a.setEditCell(e, o));
95
+ },
96
+ /**
97
+ * 加载数据
98
+ * @param rows 数据
99
+ */
100
+ loadData: (e) => R(
101
+ e,
102
+ () => x(t(l), v(), () => t(l).loadData(e), n)
103
+ ),
104
+ /**
105
+ * 加载数据并恢复到初始状态
106
+ * @param rows 数据
107
+ */
108
+ reloadData: (e) => R(
109
+ e,
110
+ () => x(t(l), v(), () => t(l).reloadData(e), n)
111
+ ),
112
+ /**
113
+ * 重新加载列
114
+ * @param columns 列配置
115
+ */
116
+ reloadColumn: async (e) => {
117
+ const o = t(l).getTreeExpandRecords();
118
+ w.setTableColumns(e), await c(), await c();
119
+ const a = t(l);
120
+ return a && n() && v() && o.length && await a.setTreeExpand(o, !0), w.getTableColumns();
121
+ },
122
+ /**
123
+ * 局部加载行数据并恢复到初始状态
124
+ * @param rows 行
125
+ * @param record 新数据
126
+ * @param field 指定字段名
127
+ */
128
+ reloadRow: (e, o, a) => s(() => t(l).reloadRow(e, o, a)),
129
+ /** 还原 keep-source 保存的行数据 */
130
+ revertData: (e, o) => s(() => t(l).revertData(e, o)),
131
+ /** 加载树节点的子数据 */
132
+ loadTreeChildren: (e, o) => (m(o), C().loadTreeChildren(e, o)),
133
+ /**
134
+ * 清空单元格内容
135
+ * @param rows 指定行,为空表示整个表格
136
+ * @param field 指定字段名
137
+ */
138
+ clearData: (e, o) => s(() => t(l).clearData(e, o)),
139
+ /** 移动行到指定行位置 */
140
+ moveRowTo: (e, o, a) => s(() => t(l).moveRowTo(e, o, a)),
141
+ /** 撤销最近一次数据操作 */
142
+ undo: () => s(() => t(l).undo(), "visible"),
143
+ /** 重做最近一次数据操作 */
144
+ redo: () => s(() => t(l).redo(), "visible"),
145
+ /**
146
+ * 重新懒加载展开行并展开内容
147
+ * @param rows 指定行
148
+ */
149
+ reloadRowExpand: (e) => t(l).reloadRowExpand(e),
150
+ /**
151
+ * 重新懒加载树节点并展开该节点
152
+ * @param rows 指定行
153
+ */
154
+ reloadTreeExpand: (e) => s(() => t(l).reloadTreeExpand(e)),
155
+ /**
156
+ * 设置空数据提示文字
157
+ * @param text 提示文字
158
+ */
159
+ setEmptyText: (e) => w.setState({ emptyText: e }),
160
+ /**
161
+ * 校验表格编辑数据。
162
+ *
163
+ * 只是 vxe 校验能力的门面,不加组件自己的校验逻辑,也不改动校验提示的渲染。
164
+ * 两个分支都传 `true`(校验当前表格全部数据):不传时 vxe 只校验临时变动过的行,
165
+ * 而这个方法的用途是提交前的整表校验。
166
+ * @param isFull `true` 走 vxe 的 fullValidate,逐行校验并收集所有错误;
167
+ * 缺省或 `false` 走 validate,遇到第一个不通过的记录即停止
168
+ * @returns 全部通过时为 `undefined`;否则为 vxe 原生形状 —— 以列字段为键,
169
+ * 值是该字段上每条违规的 `{ rules, row, rowIndex, column, columnIndex, field }`
170
+ */
171
+ validate: (e = !1) => e ? t(l).fullValidate(!0) : t(l).validate(!0),
172
+ /**
173
+ * 校验指定行的指定字段。
174
+ * @param row 行数据
175
+ * @param field 列字段名
176
+ * @returns 通过时为 `undefined`,否则为以列字段为键的错误映射
177
+ */
178
+ validateField: (e, o) => t(l).validateField(e, o)
179
+ };
180
+ }
181
+ export {
182
+ h as useTableMethods
183
+ };
@@ -1,7 +1,24 @@
1
- import { DefineSetupFnComponent } from 'vue';
2
- import { TtTableExtendedTableApi, TtTableProps } from '../types/table';
1
+ import { DefineSetupFnComponent, SlotsType } from 'vue';
2
+ import { TtTableExtendedTableApi, TtTableProps, TtTableRenderProps, TtTableSlots } from '../types/table';
3
3
  import { TtTableExtendedTableFormApi, TtTableFormProps } from '../types/tableForm';
4
- export type TtUseTableFormRenderReturnType = [DefineSetupFnComponent<TtTableFormProps>, TtTableExtendedTableFormApi];
4
+ /**
5
+ * useTableFormRender 的返回值
6
+ *
7
+ * `Row` 是业务行数据类型,传入后表格插槽作用域与 `tableFormApi.tableApi` 的方法签名跟着推断。
8
+ */
9
+ export type TtUseTableFormRenderReturnType<Row = any> = [
10
+ DefineSetupFnComponent<TtTableFormProps<Row>, Record<string, any>, SlotsType<TtTableSlots<Row>>>,
11
+ TtTableExtendedTableFormApi<Row>
12
+ ];
13
+ /**
14
+ * useTableRender 的返回值
15
+ *
16
+ * `Row` 是业务行数据类型,传入后组件的 `modelValue`、插槽作用域与 `tableApi` 的方法签名跟着推断。
17
+ */
18
+ export type TtUseTableRenderReturnType<Row = any> = [
19
+ DefineSetupFnComponent<TtTableRenderProps<Row>, Record<string, any>, SlotsType<TtTableSlots<Row>>>,
20
+ TtTableExtendedTableApi<Row>
21
+ ];
5
22
  /**
6
23
  * 用于渲染表单和表格的 hooks。
7
24
  *
@@ -22,10 +39,12 @@ export type TtUseTableFormRenderReturnType = [DefineSetupFnComponent<TtTableForm
22
39
  * // 在模板中使用
23
40
  * <FormTable />
24
41
  */
25
- export declare function useTableFormRender(options: TtTableFormProps): TtUseTableFormRenderReturnType;
42
+ export declare function useTableFormRender<Row = any>(options: TtTableFormProps<Row>): TtUseTableFormRenderReturnType<Row>;
26
43
  /**
27
44
  * 用于渲染表格的 hooks,返回 [TableRender 组件, 表格API]。
28
45
  *
46
+ * options 只接受表格配置;单向数据使用 data,双向数据绑定到返回的 TableRender 组件。
47
+ *
29
48
  * @param options 表格渲染配置项
30
49
  * @returns [TableRender组件, 表格API]
31
50
  *
@@ -40,54 +59,4 @@ export declare function useTableFormRender(options: TtTableFormProps): TtUseTabl
40
59
  * // 在模板中使用
41
60
  * <TableRender />
42
61
  */
43
- export declare function useTableRender(options: TtTableProps): readonly [DefineSetupFnComponent<TtTableProps, {}, {}, {
44
- title?: string;
45
- showTitle?: boolean;
46
- autoHeight?: boolean;
47
- offsetHeight?: number;
48
- loading?: boolean;
49
- loadingText?: string;
50
- emptyText?: string;
51
- noSearchText?: string;
52
- emptyImageStyle?: import('vue').CSSProperties;
53
- emptyImageStatus?: "no-data" | "no-search";
54
- isHanderSubmit?: boolean;
55
- modelValue?: Array<Recordable>;
56
- formApi?: Partial<import('../../../tt-form').TtExtendedFormApi>;
57
- columnsKey?: string | (() => string);
58
- showSetting?: boolean;
59
- showSetColumn?: boolean;
60
- leftSlotWidth?: number;
61
- rightSlotWidth?: number;
62
- showLineHeight?: boolean;
63
- showRefresh?: boolean;
64
- useHttpCache?: boolean;
65
- defaultDisplayFields?: string[];
66
- getColumnsApi?: (params: {
67
- permissionOnlyCode: string;
68
- userId: string | number;
69
- }) => Promise<{
70
- data: any;
71
- }>;
72
- setColumnsApi?: (params: {
73
- permissionOnlyCode: string;
74
- json: string;
75
- userId: string | number;
76
- }) => Promise<any>;
77
- updateColumnsApi?: (params: {
78
- permissionOnlyCode: string;
79
- json: string;
80
- userId: string | number;
81
- id: string | number;
82
- }) => Promise<any>;
83
- getSyncSlotComponent?: (column: any, row: any, type: "default" | "edit") => import('vue').VNode | import('vue').VNode[] | string;
84
- customizeColumn?: (column: import("vxe-table").VxeTableDefines.ColumnOptions) => import("vxe-table").VxeTableDefines.ColumnOptions;
85
- clearTreeExpand?: boolean;
86
- isI18n?: boolean;
87
- isDataCloneDeep?: boolean;
88
- useSearchForm?: boolean;
89
- data?: import('vue').MaybeRef<any[]>;
90
- columns?: import('vue').MaybeRef<import("vxe-table").VxeTableDefines.ColumnOptions[]>;
91
- testId?: string;
92
- toolTipErrorPlacement?: "top" | "bottom" | "left" | "right";
93
- } & Omit<import('vxe-table').VxeGridProps<any>, "data" | "columns"> & import('../..').TtTablePagerProps & import('../..').TtTableColumnsProps & import('../..').TtTableFetchProps & import('../..').TtTableToolbarProps & {}, import('vue').PublicProps>, TtTableExtendedTableApi];
62
+ export declare function useTableRender<Row = any>(options: TtTableProps<Row>): TtUseTableRenderReturnType<Row>;