@gx-design-vue/pro-table 0.2.0-alpha.1 → 0.2.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProTable.d.ts +14 -493
- package/dist/ProTable.js +818 -512
- package/dist/components/ScrollBar/Bar.d.ts +81 -0
- package/dist/components/ScrollBar/Bar.js +84 -0
- package/dist/components/ScrollBar/Thumb.d.ts +52 -0
- package/dist/components/ScrollBar/{Thumb/index.js → Thumb.js} +67 -58
- package/dist/components/ScrollBar/context.d.ts +3 -4
- package/dist/components/ScrollBar/context.js +3 -5
- package/dist/components/ScrollBar/util.d.ts +6 -5
- package/dist/components/ScrollBar/util.js +1 -14
- package/dist/components/SearchForm/CollapseToggle.d.ts +55 -0
- package/dist/components/SearchForm/CollapseToggle.js +47 -0
- package/dist/components/SearchForm/FormItemContainer.d.ts +75 -0
- package/dist/components/SearchForm/FormItemContainer.js +225 -0
- package/dist/components/SearchForm/FormItemWrapper.d.ts +82 -0
- package/dist/components/SearchForm/FormItemWrapper.js +62 -0
- package/dist/components/SearchForm/SearchForm.d.ts +130 -0
- package/dist/components/SearchForm/SearchForm.js +319 -0
- package/dist/components/SearchForm/index.d.ts +2 -0
- package/dist/components/SearchForm/index.js +2 -0
- package/dist/components/Toolbar/FullscreenIcon.d.ts +26 -0
- package/dist/components/Toolbar/FullscreenIcon.js +22 -0
- package/dist/components/Toolbar/ListToolBar.d.ts +111 -0
- package/dist/components/Toolbar/ListToolBar.js +101 -0
- package/dist/components/Toolbar/index.d.ts +103 -0
- package/dist/components/Toolbar/index.js +101 -0
- package/dist/components/Toolbar/style.d.ts +8 -0
- package/dist/components/{ListToolBar → Toolbar}/style.js +32 -27
- package/dist/context/TableContext.d.ts +15 -27
- package/dist/context/TableContext.js +3 -5
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/useBreakpoints.d.ts +13 -0
- package/dist/hooks/useBreakpoints.js +57 -0
- package/dist/hooks/useCellRender.d.ts +13 -0
- package/dist/hooks/useCellRender.js +28 -0
- package/dist/hooks/useColumnResize.d.ts +30 -0
- package/dist/hooks/useColumnResize.js +110 -0
- package/dist/hooks/useColumns.d.ts +35 -24
- package/dist/hooks/useColumns.js +89 -58
- package/dist/hooks/useFetchData.d.ts +40 -65
- package/dist/hooks/useFetchData.js +157 -174
- package/dist/hooks/useFitPage.d.ts +19 -0
- package/dist/hooks/useFitPage.js +90 -0
- package/dist/hooks/useKeepAliveReload.d.ts +21 -0
- package/dist/hooks/useKeepAliveReload.js +24 -0
- package/dist/hooks/useLoading.d.ts +18 -7
- package/dist/hooks/useLoading.js +27 -11
- package/dist/hooks/usePagination.d.ts +10 -7
- package/dist/hooks/usePagination.js +38 -29
- package/dist/hooks/useRequestOptions.d.ts +18 -0
- package/dist/hooks/useRequestOptions.js +39 -0
- package/dist/hooks/useRowSelection.d.ts +27 -15
- package/dist/hooks/useRowSelection.js +93 -80
- package/dist/hooks/useTable.d.ts +35 -77
- package/dist/hooks/useTable.js +72 -50
- package/dist/hooks/useTableForm.d.ts +15 -82
- package/dist/hooks/useTableForm.js +93 -55
- package/dist/hooks/useTableScroll.d.ts +33 -31
- package/dist/hooks/useTableScroll.js +71 -28
- package/dist/hooks/useTableSize.d.ts +17 -7
- package/dist/hooks/useTableSize.js +21 -9
- package/dist/index.d.ts +10 -7
- package/dist/index.js +9 -4
- package/dist/interface.d.ts +499 -0
- package/dist/interface.js +1 -0
- package/dist/pro-table.esm.js +3536 -3799
- package/dist/pro-table.js +1 -1
- package/dist/style/fit-page.d.ts +4 -2
- package/dist/style/fit-page.js +10 -5
- package/dist/style/index.d.ts +4 -6
- package/dist/style/index.js +24 -76
- package/dist/style/list.d.ts +4 -2
- package/dist/style/list.js +2 -12
- package/dist/style/resizable.d.ts +8 -0
- package/dist/style/resizable.js +18 -0
- package/dist/style/scroll.d.ts +4 -2
- package/dist/style/scroll.js +9 -9
- package/dist/style/search.d.ts +8 -0
- package/dist/{components/Form/style.js → style/search.js} +22 -9
- package/dist/theme/augment.d.ts +8 -0
- package/dist/theme/augment.js +1 -0
- package/dist/theme/interface/components.d.ts +8 -0
- package/dist/theme/interface/components.js +1 -0
- package/dist/utils/dateFormat.d.ts +9 -0
- package/dist/utils/dateFormat.js +29 -0
- package/dist/utils/formConstants.d.ts +9 -0
- package/dist/utils/formConstants.js +29 -0
- package/dist/utils/valueFormat.d.ts +9 -0
- package/dist/utils/valueFormat.js +27 -0
- package/package.json +10 -9
- package/dist/components/Form/components/RequestSelect.d.ts +0 -50
- package/dist/components/Form/components/RequestSelect.js +0 -58
- package/dist/components/Form/hooks/useForm.d.ts +0 -11
- package/dist/components/Form/hooks/useForm.js +0 -32
- package/dist/components/Form/index.d.ts +0 -33
- package/dist/components/Form/index.js +0 -479
- package/dist/components/Form/style.d.ts +0 -6
- package/dist/components/Form/utils/config.d.ts +0 -9
- package/dist/components/Form/utils/config.js +0 -30
- package/dist/components/Form/utils/dateFormat.d.ts +0 -22
- package/dist/components/Form/utils/dateFormat.js +0 -45
- package/dist/components/ListToolBar/index.d.ts +0 -60
- package/dist/components/ListToolBar/index.js +0 -123
- package/dist/components/ListToolBar/style.d.ts +0 -6
- package/dist/components/ScrollBar/Bar/index.d.ts +0 -49
- package/dist/components/ScrollBar/Bar/index.js +0 -71
- package/dist/components/ScrollBar/Bar/props.d.ts +0 -25
- package/dist/components/ScrollBar/Bar/props.js +0 -18
- package/dist/components/ScrollBar/Thumb/index.d.ts +0 -40
- package/dist/components/ScrollBar/Thumb/props.d.ts +0 -20
- package/dist/components/ScrollBar/Thumb/props.js +0 -18
- package/dist/components/TableCell/index.d.ts +0 -37
- package/dist/components/TableCell/index.js +0 -72
- package/dist/components/ToolBar/FullscreenIcon.d.ts +0 -7
- package/dist/components/ToolBar/FullscreenIcon.js +0 -14
- package/dist/components/ToolBar/index.d.ts +0 -34
- package/dist/components/ToolBar/index.js +0 -100
- package/dist/hooks/tryOnActivated.d.ts +0 -6
- package/dist/hooks/tryOnActivated.js +0 -14
- package/dist/hooks/useDebounceFn.d.ts +0 -8
- package/dist/hooks/useDebounceFn.js +0 -34
- package/dist/hooks/useScrollArea.d.ts +0 -24
- package/dist/hooks/useScrollArea.js +0 -104
- package/dist/props.d.ts +0 -340
- package/dist/props.js +0 -251
- package/dist/types/ColumnTypings.d.ts +0 -127
- package/dist/types/ColumnTypings.js +0 -1
- package/dist/types/SlotsTypings.d.ts +0 -63
- package/dist/types/SlotsTypings.js +0 -13
- package/dist/types/TableTypings.d.ts +0 -359
- package/dist/types/TableTypings.js +0 -1
- package/dist/types/index.d.ts +0 -9
- package/dist/types/index.js +0 -1
- package/dist/utils/utils.d.ts +0 -10
- package/dist/utils/utils.js +0 -91
package/dist/ProTable.js
CHANGED
|
@@ -1,533 +1,839 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import Bar_default from "./components/ScrollBar/Bar.js";
|
|
2
|
+
import { useProBreakpoints } from "./hooks/useBreakpoints.js";
|
|
3
|
+
import ProTableSearchForm from "./components/SearchForm/SearchForm.js";
|
|
4
|
+
import "./components/SearchForm/index.js";
|
|
5
|
+
import { useProvideTableContext } from "./context/TableContext.js";
|
|
6
|
+
import { Toolbar } from "./components/Toolbar/index.js";
|
|
7
|
+
import { useCellRender } from "./hooks/useCellRender.js";
|
|
8
|
+
import { applyIndexColumn, useColumns } from "./hooks/useColumns.js";
|
|
9
|
+
import { useColumnResize } from "./hooks/useColumnResize.js";
|
|
10
|
+
import { useFetchData } from "./hooks/useFetchData.js";
|
|
11
|
+
import { useFitPage } from "./hooks/useFitPage.js";
|
|
12
|
+
import { useKeepAliveReload } from "./hooks/useKeepAliveReload.js";
|
|
11
13
|
import { useLoading } from "./hooks/useLoading.js";
|
|
12
14
|
import { usePagination } from "./hooks/usePagination.js";
|
|
13
15
|
import { useRowSelection } from "./hooks/useRowSelection.js";
|
|
14
|
-
import { getCurrentData, valueFormat } from "./utils/utils.js";
|
|
15
|
-
import { useScrollArea } from "./hooks/useScrollArea.js";
|
|
16
16
|
import { useTableForm } from "./hooks/useTableForm.js";
|
|
17
17
|
import { useTableScroll } from "./hooks/useTableScroll.js";
|
|
18
18
|
import { useTableSize } from "./hooks/useTableSize.js";
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import { genProTableStyle } from "./style/index.js";
|
|
23
|
-
import { Fragment, Teleport, cloneVNode, computed, createVNode, defineComponent, h, isVNode, mergeProps, ref, toRaw, toRef, unref, watchEffect } from "vue";
|
|
19
|
+
import "./hooks/index.js";
|
|
20
|
+
import style_default from "./style/index.js";
|
|
21
|
+
import { Fragment, Teleport, computed, createVNode, defineComponent, mergeDefaults, mergeProps, ref, toRef, watch } from "vue";
|
|
24
22
|
import { useProAppContext } from "@gx-design-vue/pro-app";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import
|
|
30
|
-
import { omit, pick } from "es-toolkit";
|
|
31
|
-
|
|
23
|
+
import { classNames, getSlotVNode } from "@gx-design-vue/pro-utils";
|
|
24
|
+
import { useFullscreen } from "@vueuse/core";
|
|
25
|
+
import { Pagination, Spin, Table } from "antdv-next";
|
|
26
|
+
import { useBaseConfig } from "antdv-next/config-provider/context";
|
|
27
|
+
import useCSSVarCls from "antdv-next/config-provider/hooks/useCSSVarCls";
|
|
32
28
|
//#region src/ProTable.tsx
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
29
|
+
const defaults = {
|
|
30
|
+
rowKey: "id",
|
|
31
|
+
align: "left",
|
|
32
|
+
columns: [],
|
|
33
|
+
dataSource: [],
|
|
34
|
+
pagination: void 0,
|
|
35
|
+
params: {},
|
|
36
|
+
waitRequest: false,
|
|
37
|
+
immediate: true,
|
|
38
|
+
autoRequest: true,
|
|
39
|
+
debounceTime: 10,
|
|
40
|
+
polling: false,
|
|
41
|
+
pollingTime: 2e3,
|
|
42
|
+
showLoading: true,
|
|
43
|
+
keepAliveReload: false
|
|
44
|
+
};
|
|
45
|
+
const TABLE_PASSTHROUGH_KEYS = [
|
|
46
|
+
"bordered",
|
|
47
|
+
"expandable",
|
|
48
|
+
"showHeader",
|
|
49
|
+
"showSorterTooltip",
|
|
50
|
+
"sortDirections",
|
|
51
|
+
"sticky",
|
|
52
|
+
"tableLayout",
|
|
53
|
+
"virtual",
|
|
54
|
+
"locale",
|
|
55
|
+
"getPopupContainer",
|
|
56
|
+
"dropdownPrefixCls",
|
|
57
|
+
"rowClassName",
|
|
58
|
+
"rowHoverable",
|
|
59
|
+
"rootClass",
|
|
60
|
+
"prefixCls",
|
|
61
|
+
"classes",
|
|
62
|
+
"styles"
|
|
63
|
+
];
|
|
64
|
+
const ForwardProTable = /* @__PURE__ */ defineComponent((props, { attrs, slots, emit, expose }) => {
|
|
65
|
+
const { prefixCls } = useBaseConfig("pro-table", props);
|
|
66
|
+
const rootCls = useCSSVarCls(prefixCls);
|
|
67
|
+
const [hashId, cssVarCls] = style_default(prefixCls, rootCls);
|
|
68
|
+
const appContext = useProAppContext();
|
|
69
|
+
const rootEl = ref();
|
|
70
|
+
const { toggle: toggleFullscreen, isFullscreen } = useFullscreen(rootEl);
|
|
71
|
+
watch(isFullscreen, (val) => {
|
|
72
|
+
emit("fullscreenChange", val);
|
|
73
|
+
});
|
|
74
|
+
const rootClassNames = computed(() => {
|
|
75
|
+
return classNames(prefixCls.value, hashId.value, cssVarCls.value, rootCls.value, attrs.class, props.proClasses?.root, fullPageClass.value);
|
|
76
|
+
});
|
|
77
|
+
const mergedStyle = computed(() => {
|
|
78
|
+
return [props.proStyles?.root, attrs.style];
|
|
79
|
+
});
|
|
80
|
+
const { isMobile, screenWidth, screens } = useProBreakpoints();
|
|
81
|
+
const { paginationInfo, paginationAlign, requestPagination, setPagination } = usePagination({ pagination: toRef(props, "pagination") });
|
|
82
|
+
const { tableSize, setTableSize } = useTableSize({
|
|
83
|
+
size: computed(() => props.size),
|
|
84
|
+
onChange: (s) => emit("sizeChange", s)
|
|
85
|
+
});
|
|
86
|
+
const { loading: internalLoading, setLoading } = useLoading({
|
|
87
|
+
loading: computed(() => props.loading),
|
|
88
|
+
onChange: (val) => props.onLoadingChange?.(val)
|
|
89
|
+
});
|
|
90
|
+
const { selectedRowKeys, selectedItems, mergedRowSelection, select: selectRow, selectAll: selectAllRows, remove: removeSelectedKeys, clear: clearSelectedKeys, sync: syncSelectedRows } = useRowSelection({
|
|
91
|
+
rowKey: computed(() => props.rowKey),
|
|
92
|
+
rowSelection: computed(() => props.rowSelection),
|
|
93
|
+
dataSource: computed(() => props.dataSource ?? [])
|
|
94
|
+
});
|
|
95
|
+
const columnsForScroll = computed(() => {
|
|
96
|
+
return applyIndexColumn(props.columns ?? [], props.indexColumn, props.align ?? "left");
|
|
97
|
+
});
|
|
98
|
+
const { tableScroll: policyTableScroll, shouldFixActionColumn } = useTableScroll({
|
|
99
|
+
scroll: computed(() => props.scroll),
|
|
100
|
+
columns: columnsForScroll,
|
|
101
|
+
rowSelection: computed(() => props.rowSelection),
|
|
102
|
+
screens,
|
|
103
|
+
screenWidth,
|
|
104
|
+
scrollPolicy: computed(() => props.scrollPolicy)
|
|
105
|
+
});
|
|
106
|
+
const { tableColumns, cacheColumns, setColumns } = useColumns({
|
|
107
|
+
columns: computed(() => props.columns ?? []),
|
|
108
|
+
align: computed(() => props.align ?? "left"),
|
|
109
|
+
indexColumn: computed(() => props.indexColumn),
|
|
110
|
+
shouldFixActionColumn,
|
|
111
|
+
wrapColumnRender: useCellRender({
|
|
112
|
+
columnEmptyText: computed(() => props.columnEmptyText),
|
|
113
|
+
prefixCls
|
|
114
|
+
}).wrapColumnRender
|
|
115
|
+
});
|
|
116
|
+
const { resizableColumns, resizableComponents } = useColumnResize({
|
|
117
|
+
columns: tableColumns,
|
|
118
|
+
onResize: (w, col) => emit("resizeColumn", w, col)
|
|
119
|
+
});
|
|
120
|
+
const formConfig = computed(() => props.form === false ? void 0 : props.form);
|
|
121
|
+
const formAutoRequest = computed(() => {
|
|
122
|
+
if (props.form === false) return props.autoRequest ?? true;
|
|
123
|
+
return props.form?.autoRequest ?? props.autoRequest ?? true;
|
|
124
|
+
});
|
|
125
|
+
const formActions = computed(() => {
|
|
126
|
+
if (props.form === false) return void 0;
|
|
127
|
+
return props.form?.actions;
|
|
128
|
+
});
|
|
129
|
+
const { formColumns, defaultFormSearch, formState, getFormSearch, resetFormState } = useTableForm({
|
|
130
|
+
searchMap: computed(() => props.searchMap ?? []),
|
|
131
|
+
columns: computed(() => props.columns ?? [])
|
|
132
|
+
});
|
|
133
|
+
const { dataSource, setTableDataList, operateTableDataRow, handleTableChange, reload, run } = useFetchData({
|
|
134
|
+
rowKey: computed(() => props.rowKey),
|
|
135
|
+
polling: computed(() => props.polling ?? false),
|
|
136
|
+
pollingTime: computed(() => props.pollingTime ?? 2e3),
|
|
137
|
+
request: props.request,
|
|
138
|
+
postData: props.postData,
|
|
139
|
+
dataSource: computed(() => props.dataSource),
|
|
140
|
+
immediate: computed(() => props.immediate ?? true),
|
|
141
|
+
waitRequest: computed(() => props.waitRequest ?? false),
|
|
142
|
+
autoRequest: computed(() => props.autoRequest ?? true),
|
|
143
|
+
debounceTime: computed(() => props.debounceTime ?? 10),
|
|
144
|
+
params: computed(() => props.params),
|
|
145
|
+
defaultFormSearch,
|
|
146
|
+
onLoadingChange: props.onLoadingChange,
|
|
147
|
+
onRequestError: props.onRequestError,
|
|
148
|
+
onBeforeSearchSubmit: props.onBeforeSearchSubmit
|
|
149
|
+
}, {
|
|
150
|
+
pageInfo: requestPagination,
|
|
151
|
+
paginationInfo,
|
|
152
|
+
setPagination,
|
|
153
|
+
setLoading,
|
|
154
|
+
setColumns,
|
|
155
|
+
removeRowKeys: removeSelectedKeys,
|
|
156
|
+
syncSelectedRows,
|
|
157
|
+
columns: cacheColumns
|
|
158
|
+
});
|
|
159
|
+
useKeepAliveReload({
|
|
160
|
+
enabled: computed(() => props.keepAliveReload ?? false),
|
|
161
|
+
reload
|
|
162
|
+
});
|
|
163
|
+
const cardEl = ref();
|
|
164
|
+
const { scrollY: fitPageScrollY, overflowHidden, fullPageClass, scrollEl, barRef } = useFitPage({
|
|
165
|
+
fitPage: computed(() => !policyTableScroll.value?.y && !!props.fitPage),
|
|
166
|
+
cardEl,
|
|
167
|
+
prefixCls
|
|
168
|
+
});
|
|
169
|
+
const tableScroll = computed(() => ({
|
|
170
|
+
...policyTableScroll.value ?? {},
|
|
171
|
+
...fitPageScrollY.value > 0 ? { y: fitPageScrollY.value } : {}
|
|
172
|
+
}));
|
|
173
|
+
useProvideTableContext({
|
|
174
|
+
reload,
|
|
175
|
+
setPagination,
|
|
176
|
+
tableSize,
|
|
177
|
+
setTableSize,
|
|
178
|
+
formAutoRequest,
|
|
179
|
+
formConfig,
|
|
180
|
+
formActions,
|
|
181
|
+
isMobile,
|
|
182
|
+
screenWidth,
|
|
183
|
+
toggleFullscreen,
|
|
184
|
+
isFullscreen
|
|
185
|
+
});
|
|
186
|
+
const isCustomRenderMode = computed(() => !!(props.customRender || slots.customRender));
|
|
187
|
+
const shouldRenderForm = computed(() => {
|
|
188
|
+
if (props.form === false) return false;
|
|
189
|
+
return formColumns.value.length > 0 || !!slots.form;
|
|
190
|
+
});
|
|
191
|
+
function handleTableSubmit(params, action) {
|
|
192
|
+
if (formAutoRequest.value) {
|
|
193
|
+
reload({ params });
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (action === "reset") {
|
|
197
|
+
emit("reset", params);
|
|
198
|
+
if (props.request && formActions.value?.resetReload) reload({ params });
|
|
199
|
+
} else if (props.request) {
|
|
200
|
+
emit("submit", params);
|
|
201
|
+
reload({ params });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function sliceCurrentPageData(fullData) {
|
|
205
|
+
const pagination = paginationInfo.value;
|
|
206
|
+
if (!pagination) return fullData;
|
|
207
|
+
const { current = 1, pageSize = 10 } = pagination;
|
|
208
|
+
return fullData.filter((_, index) => index >= (current - 1) * pageSize && index < current * pageSize);
|
|
209
|
+
}
|
|
210
|
+
function renderCustomContent() {
|
|
211
|
+
const customRenderFn = props.customRender || slots.customRender;
|
|
212
|
+
if (!customRenderFn) return null;
|
|
213
|
+
const tableData = dataSource.value;
|
|
214
|
+
if (!tableData?.length) return renderEmptyText();
|
|
215
|
+
if (typeof customRenderFn === "function") return customRenderFn({
|
|
216
|
+
dataSource: tableData,
|
|
217
|
+
currentData: sliceCurrentPageData(tableData)
|
|
109
218
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
loading: toRef(props, "loading"),
|
|
118
|
-
onChange: (value) => {
|
|
119
|
-
props.onLoadingChange && props.onLoadingChange(value);
|
|
120
|
-
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
function renderEmptyText() {
|
|
222
|
+
const emptyTextSlot = getSlotVNode({
|
|
223
|
+
slots,
|
|
224
|
+
props,
|
|
225
|
+
key: "emptyText"
|
|
121
226
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
227
|
+
if (emptyTextSlot !== false && appContext?.emptyText?.value !== false) return emptyTextSlot || appContext?.emptyText?.value;
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
function onCustomPaginationChange(currentPage, currentPageSize) {
|
|
231
|
+
onTableChange({
|
|
232
|
+
current: currentPage,
|
|
233
|
+
pageSize: currentPageSize
|
|
234
|
+
}, {}, {}, {});
|
|
235
|
+
}
|
|
236
|
+
const loadingState = computed(() => {
|
|
237
|
+
if (props.showLoading === false) return false;
|
|
238
|
+
return internalLoading.value;
|
|
239
|
+
});
|
|
240
|
+
const passThroughProps = computed(() => {
|
|
241
|
+
const result = {};
|
|
242
|
+
for (const key of TABLE_PASSTHROUGH_KEYS) {
|
|
243
|
+
if (key === "classes") {
|
|
244
|
+
const userClasses = props.classes;
|
|
245
|
+
const tableClass = props.proClasses?.table;
|
|
246
|
+
if (userClasses || tableClass) result.classes = {
|
|
247
|
+
...userClasses ?? {},
|
|
248
|
+
...tableClass ? { root: classNames(userClasses?.root, tableClass) } : {}
|
|
249
|
+
};
|
|
250
|
+
continue;
|
|
132
251
|
}
|
|
252
|
+
const val = props[key];
|
|
253
|
+
if (val !== void 0) result[key] = val;
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
});
|
|
257
|
+
function onTableChange(paginationConfig, filters, sorter, extra) {
|
|
258
|
+
handleTableChange(paginationConfig, filters, sorter, extra);
|
|
259
|
+
props.onChange?.(paginationConfig, filters, sorter, extra);
|
|
260
|
+
}
|
|
261
|
+
function onTableExpandedRowKeysChange(keys) {
|
|
262
|
+
emit("update:expandedRowKeys", keys);
|
|
263
|
+
}
|
|
264
|
+
function onTableScroll(e) {
|
|
265
|
+
emit("scroll", e);
|
|
266
|
+
}
|
|
267
|
+
const passthroughSlotKeys = [
|
|
268
|
+
"title",
|
|
269
|
+
"footer",
|
|
270
|
+
"summary",
|
|
271
|
+
"expandIcon",
|
|
272
|
+
"expandedRowRender",
|
|
273
|
+
"filterDropdown",
|
|
274
|
+
"filterIcon"
|
|
275
|
+
];
|
|
276
|
+
const tableSlots = computed(() => {
|
|
277
|
+
const result = {};
|
|
278
|
+
for (const key of passthroughSlotKeys) if (slots[key]) result[key] = slots[key];
|
|
279
|
+
if (slots.bodyCell) result.bodyCell = (ctx) => slots.bodyCell(ctx);
|
|
280
|
+
if (slots.headerCell) result.headerCell = (ctx) => slots.headerCell(ctx);
|
|
281
|
+
const emptyTextRender = getSlotVNode({
|
|
282
|
+
slots,
|
|
283
|
+
props,
|
|
284
|
+
key: "emptyText"
|
|
133
285
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
pagination: toRef(props, "pagination"),
|
|
142
|
-
pageItemRender: getSlot({
|
|
143
|
-
slots,
|
|
144
|
-
props,
|
|
145
|
-
key: "pageItemRender"
|
|
146
|
-
})
|
|
147
|
-
});
|
|
148
|
-
/**
|
|
149
|
-
* @Author gx12358
|
|
150
|
-
* @DateTime 2022/1/21
|
|
151
|
-
* @lastTime 2022/1/21
|
|
152
|
-
* @description Table-scroll hooks 方法
|
|
153
|
-
*/
|
|
154
|
-
const { proScroll, breakpoint } = useTableScroll({
|
|
155
|
-
scroll: toRef(props, "scroll"),
|
|
156
|
-
autoScroll: toRef(props, "autoScroll"),
|
|
157
|
-
modalScroll: toRef(props, "modalScroll"),
|
|
158
|
-
neverScroll: toRef(props, "neverScroll"),
|
|
159
|
-
rowSelection: toRef(props, "rowSelection"),
|
|
160
|
-
scrollBreakpoint: toRef(props, "scrollBreakpoint"),
|
|
161
|
-
innerWidth: screenWidth,
|
|
162
|
-
columns: cacheColumns,
|
|
163
|
-
screens
|
|
164
|
-
});
|
|
165
|
-
/**
|
|
166
|
-
* @Author gx12358
|
|
167
|
-
* @DateTime 2022/1/21
|
|
168
|
-
* @lastTime 2022/1/21
|
|
169
|
-
* @description Table-columns hooks 方法
|
|
170
|
-
*/
|
|
171
|
-
const { proColumns, setColumns, resizeColumnWidth } = useColumns({
|
|
172
|
-
draggable: toRef(props, "draggable"),
|
|
173
|
-
neverScroll: toRef(props, "neverScroll"),
|
|
174
|
-
autoScroll: toRef(props, "autoScroll"),
|
|
175
|
-
breakpoint,
|
|
176
|
-
scroll: proScroll,
|
|
177
|
-
columns: cacheColumns
|
|
178
|
-
});
|
|
179
|
-
/**
|
|
180
|
-
* @Author gx12358
|
|
181
|
-
* @DateTime 2022/1/21
|
|
182
|
-
* @lastTime 2022/1/21
|
|
183
|
-
* @description Table-setting columns hooks 方法
|
|
184
|
-
*/
|
|
185
|
-
/**
|
|
186
|
-
* @Author gx12358
|
|
187
|
-
* @DateTime 2022/1/21
|
|
188
|
-
* @lastTime 2022/1/21
|
|
189
|
-
* @description Table-Form(搜索) hooks 方法
|
|
190
|
-
*/
|
|
191
|
-
const { formCols, defaultFormSearch } = useTableForm({
|
|
192
|
-
searchMap: toRef(props, "searchMap"),
|
|
193
|
-
columns: cacheColumns
|
|
194
|
-
});
|
|
195
|
-
const { selectedKeys, selectedItems, changeRowKey, selectRowKey, selectAllRowKey, syncSelectedRows, removeRowKeys, clearAllRowKeys } = useRowSelection(toRef(props, "rowKey"), toRef(props, "rowSelection"));
|
|
196
|
-
const { run, setTableDataList, operateTableDataRow, isTreeDataRef, dataSource, handleTableChange } = useFetchData({
|
|
197
|
-
...useConfigFetchData(props),
|
|
198
|
-
waitRequest
|
|
199
|
-
}, {
|
|
200
|
-
loading,
|
|
201
|
-
paginationInfo,
|
|
286
|
+
if (emptyTextRender || appContext?.emptyText?.value) result.emptyText = () => emptyTextRender || appContext?.emptyText?.value;
|
|
287
|
+
return result;
|
|
288
|
+
});
|
|
289
|
+
expose({
|
|
290
|
+
actionRef: () => ({
|
|
291
|
+
loading: internalLoading,
|
|
292
|
+
dataSource,
|
|
202
293
|
pageInfo: requestPagination,
|
|
294
|
+
reload,
|
|
295
|
+
reloadAndReset: (options) => {
|
|
296
|
+
setPagination({ current: 1 });
|
|
297
|
+
resetFormState();
|
|
298
|
+
run();
|
|
299
|
+
options?.callBack?.();
|
|
300
|
+
},
|
|
203
301
|
setPagination,
|
|
204
|
-
|
|
205
|
-
|
|
302
|
+
setPageInfo: (pagination, filters, sorter, extra) => {
|
|
303
|
+
setPagination(pagination);
|
|
304
|
+
handleTableChange(pagination, filters ?? {}, sorter ?? {}, extra ?? {});
|
|
305
|
+
},
|
|
306
|
+
setTableDataList,
|
|
307
|
+
operateTableDataRow,
|
|
206
308
|
setLoading,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const { tableCardEl, tableScrollYHeight, tableListToolsHeight, tableScrollEl, tableOverHidden, barRef } = useScrollArea({
|
|
216
|
-
hashId,
|
|
217
|
-
scroll: proScroll,
|
|
218
|
-
baseClassName,
|
|
219
|
-
fitPage: toRef(props, "fitPage")
|
|
220
|
-
});
|
|
221
|
-
const tableScrollState = computed(() => {
|
|
222
|
-
const fitScrollY = tableScrollYHeight.value && props.fitPage ? { y: tableScrollYHeight.value } : {};
|
|
223
|
-
return {
|
|
224
|
-
...unref(proScroll),
|
|
225
|
-
...fitScrollY
|
|
226
|
-
};
|
|
227
|
-
});
|
|
228
|
-
const tablePropsValues = computed(() => {
|
|
229
|
-
return {
|
|
230
|
-
...omit(props, Object.keys(tableProps).concat([
|
|
231
|
-
"style",
|
|
232
|
-
"class",
|
|
233
|
-
"loading",
|
|
234
|
-
"rowKey",
|
|
235
|
-
"transformCellText",
|
|
236
|
-
"rowSelection",
|
|
237
|
-
"onChange",
|
|
238
|
-
"onExpandedRowsChange",
|
|
239
|
-
"onExpand",
|
|
240
|
-
"onResizeColumn"
|
|
241
|
-
])),
|
|
242
|
-
size: unref(tableSize),
|
|
243
|
-
scroll: unref(tableScrollState),
|
|
244
|
-
dataSource: unref(dataSource),
|
|
245
|
-
pagination: unref(paginationInfo),
|
|
246
|
-
columns: unref(proColumns).filter((column) => column.show || column.show === void 0)
|
|
247
|
-
};
|
|
248
|
-
});
|
|
249
|
-
const loadingState = computed(() => {
|
|
250
|
-
const spinningProps = isObject(props.loading) ? omit(props.loading, ["spinning"]) : {};
|
|
251
|
-
if (!spinningProps.indicator && appContext?.indicator?.value) spinningProps.indicator = appContext?.indicator?.value;
|
|
252
|
-
return {
|
|
253
|
-
spinning: props.showLoading ? convertValueBoolean(loading.value) : false,
|
|
254
|
-
...spinningProps
|
|
255
|
-
};
|
|
256
|
-
});
|
|
257
|
-
const paginationPosition = computed(() => {
|
|
258
|
-
let positionClass;
|
|
259
|
-
const defaultPosition = props.direction === "rtl" ? "bottomLeft" : "right";
|
|
260
|
-
const tablePosition = unref(paginationInfo)?.position;
|
|
261
|
-
if (tablePosition !== null && Array.isArray(tablePosition)) {
|
|
262
|
-
const topPos = tablePosition.find((p) => p.includes("top"));
|
|
263
|
-
const bottomPos = tablePosition.find((p) => p.includes("bottom"));
|
|
264
|
-
const isDisable = tablePosition.every((p) => `${p}` === "none");
|
|
265
|
-
if (!topPos && !bottomPos && !isDisable) positionClass = defaultPosition;
|
|
266
|
-
if (topPos) positionClass = topPos.toLowerCase().replace("top", "");
|
|
267
|
-
if (bottomPos) positionClass = bottomPos.toLowerCase().replace("bottom", "");
|
|
268
|
-
} else positionClass = defaultPosition;
|
|
269
|
-
return positionClass;
|
|
270
|
-
});
|
|
271
|
-
function getFormSearch() {
|
|
272
|
-
return {
|
|
273
|
-
...unref(defaultFormSearch),
|
|
274
|
-
...tableFormRef.value?.getFormSearch(),
|
|
275
|
-
...props.params
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
tryOnActivated(() => {
|
|
279
|
-
if (activated.value) {
|
|
280
|
-
if (props.keepAliveReload) run({ params: getFormSearch() });
|
|
281
|
-
} else activated.value = true;
|
|
282
|
-
});
|
|
283
|
-
const handleTableSubmit = async (value, action) => {
|
|
284
|
-
if (formAutoRequest.value) {
|
|
285
|
-
run({ params: value });
|
|
286
|
-
return;
|
|
309
|
+
selectedKeys: selectedRowKeys,
|
|
310
|
+
selectedItems,
|
|
311
|
+
rowsSelection: {
|
|
312
|
+
clear: clearSelectedKeys,
|
|
313
|
+
select: selectRow,
|
|
314
|
+
selectAll: selectAllRows,
|
|
315
|
+
remove: removeSelectedKeys,
|
|
316
|
+
sync: syncSelectedRows
|
|
287
317
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
318
|
+
}),
|
|
319
|
+
formRef: () => ({
|
|
320
|
+
getFormSearch,
|
|
321
|
+
getFormInnerState: () => formState.value,
|
|
322
|
+
restFormState: (callback) => {
|
|
323
|
+
resetFormState();
|
|
324
|
+
callback?.();
|
|
294
325
|
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
props.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
326
|
+
})
|
|
327
|
+
});
|
|
328
|
+
return () => {
|
|
329
|
+
const actionsRender = slots.actions?.() || props.actionProps?.actions;
|
|
330
|
+
return createVNode("div", {
|
|
331
|
+
"ref": rootEl,
|
|
332
|
+
"class": rootClassNames.value,
|
|
333
|
+
"style": mergedStyle.value
|
|
334
|
+
}, [createVNode("div", {
|
|
335
|
+
"class": classNames(props.proClasses?.content, `${prefixCls.value}-content`),
|
|
336
|
+
"style": props.proStyles?.content
|
|
337
|
+
}, [shouldRenderForm.value && createVNode(ProTableSearchForm, {
|
|
338
|
+
"prefixCls": prefixCls.value,
|
|
339
|
+
"formColumns": formColumns.value,
|
|
340
|
+
"formState": formState.value,
|
|
341
|
+
"defaultFormSearch": defaultFormSearch.value,
|
|
342
|
+
"formConfig": formConfig.value,
|
|
343
|
+
"formAutoRequest": formAutoRequest.value,
|
|
344
|
+
"formActions": formActions.value,
|
|
345
|
+
"loading": loadingState.value,
|
|
346
|
+
"cardBordered": props.cardBordered,
|
|
347
|
+
"proClasses": props.proClasses ?? {},
|
|
348
|
+
"proStyles": props.proStyles ?? {},
|
|
349
|
+
"onSearch": handleTableSubmit,
|
|
350
|
+
"onReset": (params) => emit("reset", params)
|
|
351
|
+
}, { default: () => [slots.form?.()] }), createVNode("div", {
|
|
352
|
+
"ref": cardEl,
|
|
353
|
+
"class": classNames(props.proClasses?.card, `${prefixCls.value}-card`, props.cardBordered && `${prefixCls.value}-card-border`),
|
|
354
|
+
"style": props.proStyles?.card
|
|
355
|
+
}, [createVNode(Toolbar, {
|
|
356
|
+
"prefixCls": prefixCls.value,
|
|
357
|
+
"options": props.options,
|
|
358
|
+
"titleTipText": props.titleTipText,
|
|
359
|
+
"actionsPlacement": props.actionProps?.placement,
|
|
360
|
+
"actions": actionsRender,
|
|
361
|
+
"headerTitle": slots.headerTitle?.() ?? props.headerTitle,
|
|
362
|
+
"headerTitleTip": slots.headerTitleTip?.() ?? props.headerTitleTip,
|
|
363
|
+
"listToolAfter": slots.listToolAfter?.() ?? props.listToolAfter,
|
|
364
|
+
"proClasses": props.proClasses ?? {},
|
|
365
|
+
"proStyles": props.proStyles ?? {}
|
|
366
|
+
}, null), isCustomRenderMode.value ? createVNode(Spin, { "spinning": !!loadingState.value }, { default: () => [createVNode("div", { "class": classNames(`${prefixCls.value}-list`, props.proClasses?.list) }, [createVNode("div", {
|
|
367
|
+
"class": classNames(`${prefixCls.value}-list-content`, props.proClasses?.listContent),
|
|
368
|
+
"style": props.proStyles?.listContent
|
|
369
|
+
}, [renderCustomContent()]), paginationInfo.value !== false && dataSource.value?.length > 0 && createVNode(Pagination, mergeProps(paginationInfo.value, {
|
|
370
|
+
"align": paginationAlign.value,
|
|
371
|
+
"class": classNames(`${prefixCls.value}-pagination`, props.proClasses?.pagination),
|
|
372
|
+
"style": props.proStyles?.pagination,
|
|
373
|
+
"onChange": onCustomPaginationChange
|
|
374
|
+
}), null)])] }) : createVNode(Fragment, null, [createVNode(Table, mergeProps(passThroughProps.value, {
|
|
375
|
+
"scroll": tableScroll.value,
|
|
376
|
+
"dataSource": dataSource.value,
|
|
377
|
+
"columns": props.draggable ? resizableColumns.value : tableColumns.value,
|
|
378
|
+
"components": props.draggable ? resizableComponents.value : passThroughProps.value.components,
|
|
379
|
+
"rowKey": props.rowKey,
|
|
380
|
+
"size": tableSize.value,
|
|
381
|
+
"pagination": paginationInfo.value,
|
|
382
|
+
"loading": loadingState.value,
|
|
383
|
+
"rowSelection": mergedRowSelection.value,
|
|
384
|
+
"onChange": onTableChange,
|
|
385
|
+
"onUpdate:expandedRowKeys": onTableExpandedRowKeysChange,
|
|
386
|
+
"onScroll": onTableScroll,
|
|
387
|
+
"classes": {
|
|
388
|
+
...passThroughProps.value.classes,
|
|
389
|
+
...overflowHidden.value ? { root: `${prefixCls.value}-overflow-hidden` } : {}
|
|
327
390
|
}
|
|
328
|
-
|
|
391
|
+
}), tableSlots.value), scrollEl.value && createVNode(Teleport, { "to": scrollEl.value }, { default: () => [createVNode(Bar_default, {
|
|
392
|
+
"ref": barRef,
|
|
393
|
+
"hasScrollY": !!tableScroll.value.y
|
|
394
|
+
}, null)] })])])])]);
|
|
395
|
+
};
|
|
396
|
+
}, {
|
|
397
|
+
props: /* @__PURE__ */ mergeDefaults({
|
|
398
|
+
loading: {
|
|
399
|
+
type: [Boolean, Object],
|
|
400
|
+
required: false,
|
|
401
|
+
default: void 0
|
|
402
|
+
},
|
|
403
|
+
rowKey: { required: false },
|
|
404
|
+
columns: {
|
|
405
|
+
type: Array,
|
|
406
|
+
required: false
|
|
407
|
+
},
|
|
408
|
+
indexColumn: {
|
|
409
|
+
type: [Boolean, Object],
|
|
410
|
+
required: false,
|
|
411
|
+
default: void 0
|
|
412
|
+
},
|
|
413
|
+
scrollPolicy: {
|
|
414
|
+
type: [Boolean, Object],
|
|
415
|
+
required: false,
|
|
416
|
+
default: void 0
|
|
417
|
+
},
|
|
418
|
+
fitPage: {
|
|
419
|
+
type: Boolean,
|
|
420
|
+
required: false,
|
|
421
|
+
default: void 0
|
|
422
|
+
},
|
|
423
|
+
dataSource: {
|
|
424
|
+
type: Array,
|
|
425
|
+
required: false
|
|
426
|
+
},
|
|
427
|
+
proClasses: {
|
|
428
|
+
type: Object,
|
|
429
|
+
required: false
|
|
430
|
+
},
|
|
431
|
+
proStyles: {
|
|
432
|
+
type: Object,
|
|
433
|
+
required: false
|
|
434
|
+
},
|
|
435
|
+
cardBordered: {
|
|
436
|
+
type: Boolean,
|
|
437
|
+
required: false,
|
|
438
|
+
default: void 0
|
|
439
|
+
},
|
|
440
|
+
align: {
|
|
441
|
+
type: String,
|
|
442
|
+
required: false
|
|
443
|
+
},
|
|
444
|
+
waitRequest: {
|
|
445
|
+
type: Boolean,
|
|
446
|
+
required: false,
|
|
447
|
+
default: void 0
|
|
448
|
+
},
|
|
449
|
+
polling: {
|
|
450
|
+
type: Boolean,
|
|
451
|
+
required: false,
|
|
452
|
+
default: void 0
|
|
453
|
+
},
|
|
454
|
+
pollingTime: {
|
|
455
|
+
type: Number,
|
|
456
|
+
required: false
|
|
457
|
+
},
|
|
458
|
+
request: {
|
|
459
|
+
type: Function,
|
|
460
|
+
required: false
|
|
461
|
+
},
|
|
462
|
+
immediate: {
|
|
463
|
+
type: Boolean,
|
|
464
|
+
required: false,
|
|
465
|
+
default: void 0
|
|
466
|
+
},
|
|
467
|
+
autoRequest: {
|
|
468
|
+
type: Boolean,
|
|
469
|
+
required: false,
|
|
470
|
+
default: void 0
|
|
471
|
+
},
|
|
472
|
+
debounceTime: {
|
|
473
|
+
type: Number,
|
|
474
|
+
required: false
|
|
475
|
+
},
|
|
476
|
+
showLoading: {
|
|
477
|
+
type: Boolean,
|
|
478
|
+
required: false,
|
|
479
|
+
default: void 0
|
|
480
|
+
},
|
|
481
|
+
params: { required: false },
|
|
482
|
+
postData: {
|
|
483
|
+
type: Function,
|
|
484
|
+
required: false
|
|
485
|
+
},
|
|
486
|
+
form: {
|
|
487
|
+
type: [Object, Boolean],
|
|
488
|
+
required: false,
|
|
489
|
+
default: void 0
|
|
490
|
+
},
|
|
491
|
+
searchMap: {
|
|
492
|
+
type: Array,
|
|
493
|
+
required: false
|
|
494
|
+
},
|
|
495
|
+
pagination: {
|
|
496
|
+
type: [Object, Boolean],
|
|
497
|
+
required: false,
|
|
498
|
+
default: void 0
|
|
499
|
+
},
|
|
500
|
+
onChange: {
|
|
501
|
+
type: Function,
|
|
502
|
+
required: false
|
|
503
|
+
},
|
|
504
|
+
onReset: {
|
|
505
|
+
type: Function,
|
|
506
|
+
required: false
|
|
507
|
+
},
|
|
508
|
+
onReload: {
|
|
509
|
+
type: Function,
|
|
510
|
+
required: false
|
|
511
|
+
},
|
|
512
|
+
onSubmit: {
|
|
513
|
+
type: Function,
|
|
514
|
+
required: false
|
|
515
|
+
},
|
|
516
|
+
onLoadingChange: {
|
|
517
|
+
type: Function,
|
|
518
|
+
required: false
|
|
519
|
+
},
|
|
520
|
+
onRequestError: {
|
|
521
|
+
type: Function,
|
|
522
|
+
required: false
|
|
523
|
+
},
|
|
524
|
+
onSizeChange: {
|
|
525
|
+
type: Function,
|
|
526
|
+
required: false
|
|
527
|
+
},
|
|
528
|
+
onBeforeSearchSubmit: {
|
|
529
|
+
type: Function,
|
|
530
|
+
required: false
|
|
531
|
+
},
|
|
532
|
+
onResizeColumn: {
|
|
533
|
+
type: Function,
|
|
534
|
+
required: false
|
|
535
|
+
},
|
|
536
|
+
draggable: {
|
|
537
|
+
type: Boolean,
|
|
538
|
+
required: false,
|
|
539
|
+
default: void 0
|
|
540
|
+
},
|
|
541
|
+
keepAliveReload: {
|
|
542
|
+
type: Boolean,
|
|
543
|
+
required: false,
|
|
544
|
+
default: void 0
|
|
545
|
+
},
|
|
546
|
+
columnEmptyText: {
|
|
547
|
+
type: [String, Function],
|
|
548
|
+
required: false
|
|
549
|
+
},
|
|
550
|
+
options: {
|
|
551
|
+
type: [Object, Boolean],
|
|
552
|
+
required: false,
|
|
553
|
+
default: void 0
|
|
554
|
+
},
|
|
555
|
+
titleTipText: {
|
|
556
|
+
type: String,
|
|
557
|
+
required: false
|
|
558
|
+
},
|
|
559
|
+
actionProps: {
|
|
560
|
+
type: Object,
|
|
561
|
+
required: false
|
|
562
|
+
},
|
|
563
|
+
onFullscreenChange: {
|
|
564
|
+
type: Function,
|
|
565
|
+
required: false
|
|
566
|
+
},
|
|
567
|
+
emptyText: {
|
|
568
|
+
type: [
|
|
569
|
+
Function,
|
|
570
|
+
Object,
|
|
571
|
+
String,
|
|
572
|
+
Number,
|
|
573
|
+
Boolean,
|
|
574
|
+
null,
|
|
575
|
+
Array
|
|
576
|
+
],
|
|
577
|
+
required: false,
|
|
578
|
+
default: void 0
|
|
579
|
+
},
|
|
580
|
+
headerTitle: {
|
|
581
|
+
type: [
|
|
582
|
+
Function,
|
|
583
|
+
Object,
|
|
584
|
+
String,
|
|
585
|
+
Number,
|
|
586
|
+
Boolean,
|
|
587
|
+
null,
|
|
588
|
+
Array
|
|
589
|
+
],
|
|
590
|
+
required: false,
|
|
591
|
+
default: void 0
|
|
592
|
+
},
|
|
593
|
+
headerTitleTip: {
|
|
594
|
+
type: [
|
|
595
|
+
Function,
|
|
596
|
+
Object,
|
|
597
|
+
String,
|
|
598
|
+
Number,
|
|
599
|
+
Boolean,
|
|
600
|
+
null,
|
|
601
|
+
Array
|
|
602
|
+
],
|
|
603
|
+
required: false,
|
|
604
|
+
default: void 0
|
|
605
|
+
},
|
|
606
|
+
listToolAfter: {
|
|
607
|
+
type: [
|
|
608
|
+
Function,
|
|
609
|
+
Object,
|
|
610
|
+
String,
|
|
611
|
+
Number,
|
|
612
|
+
Boolean,
|
|
613
|
+
null,
|
|
614
|
+
Array
|
|
615
|
+
],
|
|
616
|
+
required: false,
|
|
617
|
+
default: void 0
|
|
618
|
+
},
|
|
619
|
+
customRender: {
|
|
620
|
+
type: Boolean,
|
|
621
|
+
required: false,
|
|
622
|
+
skipCheck: true,
|
|
623
|
+
default: void 0
|
|
624
|
+
},
|
|
625
|
+
pageItemRender: {
|
|
626
|
+
type: Boolean,
|
|
627
|
+
required: false,
|
|
628
|
+
skipCheck: true,
|
|
629
|
+
default: void 0
|
|
630
|
+
},
|
|
631
|
+
classes: {
|
|
632
|
+
type: [Object, Function],
|
|
633
|
+
required: false
|
|
634
|
+
},
|
|
635
|
+
styles: {
|
|
636
|
+
type: [Object, Function],
|
|
637
|
+
required: false
|
|
638
|
+
},
|
|
639
|
+
dropdownPrefixCls: {
|
|
640
|
+
type: String,
|
|
641
|
+
required: false
|
|
642
|
+
},
|
|
643
|
+
size: {
|
|
644
|
+
type: [String, null],
|
|
645
|
+
required: false
|
|
646
|
+
},
|
|
647
|
+
bordered: {
|
|
648
|
+
type: Boolean,
|
|
649
|
+
required: false,
|
|
650
|
+
default: void 0
|
|
651
|
+
},
|
|
652
|
+
locale: {
|
|
653
|
+
type: Object,
|
|
654
|
+
required: false
|
|
655
|
+
},
|
|
656
|
+
rowSelection: {
|
|
657
|
+
type: Object,
|
|
658
|
+
required: false
|
|
659
|
+
},
|
|
660
|
+
getPopupContainer: {
|
|
661
|
+
type: Function,
|
|
662
|
+
required: false
|
|
663
|
+
},
|
|
664
|
+
scroll: {
|
|
665
|
+
type: Object,
|
|
666
|
+
required: false
|
|
667
|
+
},
|
|
668
|
+
sortDirections: {
|
|
669
|
+
type: Array,
|
|
670
|
+
required: false
|
|
671
|
+
},
|
|
672
|
+
showSorterTooltip: {
|
|
673
|
+
type: [Boolean, Object],
|
|
674
|
+
required: false,
|
|
675
|
+
default: void 0
|
|
676
|
+
},
|
|
677
|
+
virtual: {
|
|
678
|
+
type: Boolean,
|
|
679
|
+
required: false,
|
|
680
|
+
default: void 0
|
|
681
|
+
},
|
|
682
|
+
rootClass: {
|
|
683
|
+
type: String,
|
|
684
|
+
required: false
|
|
685
|
+
},
|
|
686
|
+
prefixCls: {
|
|
687
|
+
type: String,
|
|
688
|
+
required: false
|
|
689
|
+
},
|
|
690
|
+
tableLayout: {
|
|
691
|
+
type: String,
|
|
692
|
+
required: false
|
|
693
|
+
},
|
|
694
|
+
expandable: {
|
|
695
|
+
type: Object,
|
|
696
|
+
required: false
|
|
697
|
+
},
|
|
698
|
+
indentSize: {
|
|
699
|
+
type: Number,
|
|
700
|
+
required: false
|
|
701
|
+
},
|
|
702
|
+
rowClassName: {
|
|
703
|
+
type: [String, Function],
|
|
704
|
+
required: false
|
|
705
|
+
},
|
|
706
|
+
title: {
|
|
707
|
+
type: Function,
|
|
708
|
+
required: false
|
|
709
|
+
},
|
|
710
|
+
footer: {
|
|
711
|
+
type: Function,
|
|
712
|
+
required: false
|
|
713
|
+
},
|
|
714
|
+
summary: {
|
|
715
|
+
type: Function,
|
|
716
|
+
required: false
|
|
717
|
+
},
|
|
718
|
+
headerCell: {
|
|
719
|
+
type: Function,
|
|
720
|
+
required: false
|
|
721
|
+
},
|
|
722
|
+
bodyCell: {
|
|
723
|
+
type: Function,
|
|
724
|
+
required: false
|
|
725
|
+
},
|
|
726
|
+
caption: { required: false },
|
|
727
|
+
id: {
|
|
728
|
+
type: String,
|
|
729
|
+
required: false
|
|
730
|
+
},
|
|
731
|
+
showHeader: {
|
|
732
|
+
type: Boolean,
|
|
733
|
+
required: false,
|
|
734
|
+
default: void 0
|
|
735
|
+
},
|
|
736
|
+
components: {
|
|
737
|
+
type: Object,
|
|
738
|
+
required: false
|
|
739
|
+
},
|
|
740
|
+
onRow: {
|
|
741
|
+
type: Function,
|
|
742
|
+
required: false
|
|
743
|
+
},
|
|
744
|
+
onHeaderRow: {
|
|
745
|
+
type: Function,
|
|
746
|
+
required: false
|
|
747
|
+
},
|
|
748
|
+
direction: {
|
|
749
|
+
type: String,
|
|
750
|
+
required: false
|
|
751
|
+
},
|
|
752
|
+
sticky: {
|
|
753
|
+
type: [Boolean, Object],
|
|
754
|
+
required: false,
|
|
755
|
+
default: void 0
|
|
756
|
+
},
|
|
757
|
+
rowHoverable: {
|
|
758
|
+
type: Boolean,
|
|
759
|
+
required: false,
|
|
760
|
+
default: void 0
|
|
761
|
+
},
|
|
762
|
+
tailor: {
|
|
763
|
+
type: Boolean,
|
|
764
|
+
required: false,
|
|
765
|
+
default: void 0
|
|
766
|
+
},
|
|
767
|
+
getContainerWidth: {
|
|
768
|
+
type: Function,
|
|
769
|
+
required: false
|
|
770
|
+
},
|
|
771
|
+
measureRowRender: {
|
|
772
|
+
type: Function,
|
|
773
|
+
required: false
|
|
774
|
+
},
|
|
775
|
+
expandedRowKeys: {
|
|
776
|
+
type: Array,
|
|
777
|
+
required: false
|
|
778
|
+
},
|
|
779
|
+
defaultExpandedRowKeys: {
|
|
780
|
+
type: Array,
|
|
781
|
+
required: false
|
|
782
|
+
},
|
|
783
|
+
expandedRowRender: {
|
|
784
|
+
type: Function,
|
|
785
|
+
required: false
|
|
786
|
+
},
|
|
787
|
+
expandRowByClick: {
|
|
788
|
+
type: Boolean,
|
|
789
|
+
required: false,
|
|
790
|
+
default: void 0
|
|
791
|
+
},
|
|
792
|
+
expandIcon: {
|
|
793
|
+
type: Function,
|
|
794
|
+
required: false
|
|
795
|
+
},
|
|
796
|
+
onExpand: {
|
|
797
|
+
type: Function,
|
|
798
|
+
required: false
|
|
799
|
+
},
|
|
800
|
+
onExpandedRowsChange: {
|
|
801
|
+
type: Function,
|
|
802
|
+
required: false
|
|
803
|
+
},
|
|
804
|
+
defaultExpandAllRows: {
|
|
805
|
+
type: Boolean,
|
|
806
|
+
required: false,
|
|
807
|
+
default: void 0
|
|
808
|
+
},
|
|
809
|
+
expandIconColumnIndex: {
|
|
810
|
+
type: Number,
|
|
811
|
+
required: false
|
|
812
|
+
},
|
|
813
|
+
expandedRowClassName: {
|
|
814
|
+
type: Function,
|
|
815
|
+
required: false
|
|
816
|
+
},
|
|
817
|
+
childrenColumnName: {
|
|
818
|
+
type: String,
|
|
819
|
+
required: false
|
|
329
820
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
return createVNode(Fragment, null, null);
|
|
347
|
-
};
|
|
348
|
-
provideTableContext({
|
|
349
|
-
hashId,
|
|
350
|
-
prefixCls: baseClassName,
|
|
351
|
-
tableScrollState,
|
|
352
|
-
tableSize,
|
|
353
|
-
columns: proColumns,
|
|
354
|
-
cacheColumns,
|
|
355
|
-
isMobile,
|
|
356
|
-
formConfig,
|
|
357
|
-
formAutoRequest,
|
|
358
|
-
formActions,
|
|
359
|
-
screenWidth,
|
|
360
|
-
tableListToolsHeight,
|
|
361
|
-
styles: toRef(props, "styles"),
|
|
362
|
-
classNames: toRef(props, "classNames"),
|
|
363
|
-
action: {
|
|
364
|
-
setTableSize,
|
|
365
|
-
reload: (info) => run(info),
|
|
366
|
-
toggle
|
|
367
|
-
},
|
|
368
|
-
setPagination
|
|
369
|
-
});
|
|
370
|
-
expose({
|
|
371
|
-
formRef: () => ({
|
|
372
|
-
getFormSearch,
|
|
373
|
-
getFormInnerState: () => tableFormRef.value?.getFormSearch() || {},
|
|
374
|
-
restFormState: (callBack) => {
|
|
375
|
-
waitRequest.value = true;
|
|
376
|
-
callBack && callBack?.();
|
|
377
|
-
tableFormRef.value?.resetForm(false);
|
|
378
|
-
waitRequest.value = false;
|
|
379
|
-
}
|
|
380
|
-
}),
|
|
381
|
-
actionRef: () => ({
|
|
382
|
-
loading,
|
|
383
|
-
dataSource,
|
|
384
|
-
pageInfo: requestPagination,
|
|
385
|
-
pagination: paginationInfo.value,
|
|
386
|
-
selectedKeys: computed(() => selectedKeys.value),
|
|
387
|
-
selectedItems: computed(() => selectedItems.value),
|
|
388
|
-
rowsSelection: {
|
|
389
|
-
clear: clearAllRowKeys,
|
|
390
|
-
select: selectRowKey,
|
|
391
|
-
remove: removeRowKeys,
|
|
392
|
-
sync: syncSelectedRows,
|
|
393
|
-
selectAll: selectAllRowKey
|
|
394
|
-
},
|
|
395
|
-
reload: run,
|
|
396
|
-
getLoadingStatus: () => unref(loading),
|
|
397
|
-
reloadAndReset: async (options) => {
|
|
398
|
-
waitRequest.value = true;
|
|
399
|
-
setPagination({
|
|
400
|
-
current: 1,
|
|
401
|
-
pageSize: requestPagination?.pageSize || 10
|
|
402
|
-
});
|
|
403
|
-
if (options && options?.callBack) if (options.wait) await options.callBack();
|
|
404
|
-
else options.callBack();
|
|
405
|
-
tableFormRef.value?.resetForm(true);
|
|
406
|
-
waitRequest.value = false;
|
|
407
|
-
},
|
|
408
|
-
setPageInfo: changePage,
|
|
409
|
-
setTableDataList,
|
|
410
|
-
setPagination,
|
|
411
|
-
operateTableDataRow,
|
|
412
|
-
setLoading
|
|
413
|
-
})
|
|
414
|
-
});
|
|
415
|
-
return () => {
|
|
416
|
-
const hasCustom = convertValueBoolean(props.customRender || slots.customRender);
|
|
417
|
-
const actionsRender = slots.actions?.() || props.actionProps?.actions;
|
|
418
|
-
const slotsPropsVNode = getSlotsProps({
|
|
419
|
-
slots,
|
|
420
|
-
props,
|
|
421
|
-
keys: [
|
|
422
|
-
"headerTitle",
|
|
423
|
-
"headerTitleTip",
|
|
424
|
-
"listToolAfter"
|
|
425
|
-
],
|
|
426
|
-
render: true
|
|
427
|
-
});
|
|
428
|
-
return wrapSSR(createVNode("div", {
|
|
429
|
-
"ref": tableRef,
|
|
430
|
-
"class": classNames(baseClassName, hashId.value, props.class, props.classNames?.root, [{
|
|
431
|
-
[`${baseClassName}-no-scroll`]: !Object.keys(unref(proScroll) || {}).length,
|
|
432
|
-
[`${baseClassName}-table-tree`]: isTreeDataRef.value,
|
|
433
|
-
[`${baseClassName}-full-page`]: props.fitPage,
|
|
434
|
-
[`${baseClassName}-full-screen`]: isFullscreen.value
|
|
435
|
-
}]),
|
|
436
|
-
"style": {
|
|
437
|
-
...props.style,
|
|
438
|
-
...props.styles?.root || {}
|
|
439
|
-
}
|
|
440
|
-
}, [createVNode("div", {
|
|
441
|
-
"class": classNames(`${baseClassName}-content`, hashId.value, props.classNames?.content),
|
|
442
|
-
"style": props.styles?.content
|
|
443
|
-
}, [(formCols.value.length > 0 || !!slots.form) && props.form !== false && createVNode(Form_default, {
|
|
444
|
-
"ref": tableFormRef,
|
|
445
|
-
"modalScroll": props.modalScroll,
|
|
446
|
-
"cardBordered": props.cardBordered,
|
|
447
|
-
"formCols": formCols.value,
|
|
448
|
-
"prefixCls": baseClassName,
|
|
449
|
-
"loading": unref(loading),
|
|
450
|
-
"onSearch": handleTableSubmit,
|
|
451
|
-
"defaultFormSearch": defaultFormSearch.value
|
|
452
|
-
}, { default: slots.form ? () => slots.form?.() : null }), createVNode("div", {
|
|
453
|
-
"ref": tableCardEl,
|
|
454
|
-
"class": classNames(props.classNames?.card, hashId.value, `${baseClassName}-card`, props.cardBordered && `${baseClassName}-card-border`),
|
|
455
|
-
"style": props.styles?.card
|
|
456
|
-
}, [createVNode(ToolBar_default, {
|
|
457
|
-
"options": props.options ? isObject(props.options) ? props.options : {} : false,
|
|
458
|
-
"titleTipText": props.titleTipText,
|
|
459
|
-
"actionsPlacement": props.actionProps?.placement,
|
|
460
|
-
"actionsRender": actionsRender,
|
|
461
|
-
"headerTitle": slotsPropsVNode.headerTitle,
|
|
462
|
-
"listToolAfter": slotsPropsVNode.listToolAfter,
|
|
463
|
-
"headerTitleTip": slotsPropsVNode.headerTitleTip
|
|
464
|
-
}, null), hasCustom ? createVNode(Spin, loadingState.value, { default: () => [createVNode("div", {
|
|
465
|
-
"class": classNames(`${baseClassName}-list ${hashId.value}`, props.classNames?.list),
|
|
466
|
-
"style": props.styles?.list
|
|
467
|
-
}, [createVNode("div", {
|
|
468
|
-
"class": classNames(`${baseClassName}-list-content`, hashId.value, props.classNames?.listContent),
|
|
469
|
-
"style": {
|
|
470
|
-
...props.styles?.listContent || {},
|
|
471
|
-
height: tableScrollYHeight.value ? unit(tableScrollYHeight.value) : props.styles?.listContent?.height
|
|
472
|
-
}
|
|
473
|
-
}, [renderCustomize()]), props.pagination !== false && dataSource.value?.length > 0 && createVNode(Pagination, mergeProps(toRaw(unref(paginationInfo)), {
|
|
474
|
-
"class": classNames(hashId.value, `${baseClassName}-pagination`, `${baseClassName}-pagination-${paginationPosition.value}`, props.classNames?.pagination),
|
|
475
|
-
"style": props.styles?.pagination,
|
|
476
|
-
"onChange": (current, pageSize) => changePage({
|
|
477
|
-
current,
|
|
478
|
-
pageSize
|
|
479
|
-
})
|
|
480
|
-
}), null)])] }) : createVNode(Fragment, null, [createVNode(Table, mergeProps(pick(props, Object.keys(tableProps)), unref(tablePropsValues), {
|
|
481
|
-
"style": props.styles?.table,
|
|
482
|
-
"class": classNames(props.classNames?.table, hashId.value, tableOverHidden.value && `${baseClassName}-overflow-hidden`),
|
|
483
|
-
"loading": loadingState.value,
|
|
484
|
-
"rowKey": (record) => record[props.rowKey],
|
|
485
|
-
"transformCellText": (options) => {
|
|
486
|
-
if (props.transformCellText && typeof props.transformCellText === "function") props.transformCellText?.(options);
|
|
487
|
-
const { column, record } = options;
|
|
488
|
-
if (!column) return options.text;
|
|
489
|
-
const key = column?.key || column?.dataIndex;
|
|
490
|
-
let text = options.text;
|
|
491
|
-
if (isArray(text)) {
|
|
492
|
-
if (text.length === 0 || text.length === 1 && !isVNode(text[0])) text = text?.[0];
|
|
493
|
-
else if (text[0]?.type === "template") text = text[0]?.children;
|
|
494
|
-
}
|
|
495
|
-
text = valueFormat(text, column?.valueType || props.columns?.find((item) => (item.key || item.dataIndex) === key)?.valueType, baseClassName, hashId.value);
|
|
496
|
-
const columnEmptyText = column?.columnEmptyText || props?.columnEmptyText;
|
|
497
|
-
const { value, success } = handleEmptyField(text, columnEmptyText ? typeof columnEmptyText === "function" ? columnEmptyText(record) : columnEmptyText : "");
|
|
498
|
-
if (success && column?.ellipsis && text) return createVNode(TableCell_default, {
|
|
499
|
-
"text": value,
|
|
500
|
-
"column": column,
|
|
501
|
-
"className": baseClassName,
|
|
502
|
-
"hashId": hashId.value
|
|
503
|
-
}, null);
|
|
504
|
-
return value;
|
|
505
|
-
},
|
|
506
|
-
"rowSelection": props.rowSelection ? {
|
|
507
|
-
...omit(props.rowSelection, [
|
|
508
|
-
"onSelect",
|
|
509
|
-
"onSelectAll",
|
|
510
|
-
"onChange",
|
|
511
|
-
"selectedRowKeys"
|
|
512
|
-
]),
|
|
513
|
-
selectedRowKeys: selectedKeys.value || [],
|
|
514
|
-
onSelect: selectRowKey,
|
|
515
|
-
onSelectAll: selectAllRowKey,
|
|
516
|
-
onChange: changeRowKey
|
|
517
|
-
} : void 0,
|
|
518
|
-
"rowClassName": () => "aaa",
|
|
519
|
-
"onChange": changePage,
|
|
520
|
-
"onExpandedRowsChange": expandedRowsChange,
|
|
521
|
-
"onExpand": expand,
|
|
522
|
-
"onResizeColumn": (w, col) => handleResizeColumn(w, col)
|
|
523
|
-
}), {
|
|
524
|
-
...slots,
|
|
525
|
-
emptyText: () => renderEmptyText()
|
|
526
|
-
}), tableScrollEl.value && !hasCustom && createVNode(Teleport, { "to": tableScrollEl.value }, { default: () => [createVNode(Bar_default, { "ref": barRef }, null)] })])])])]));
|
|
527
|
-
};
|
|
528
|
-
}
|
|
821
|
+
}, defaults),
|
|
822
|
+
emits: [
|
|
823
|
+
"change",
|
|
824
|
+
"reset",
|
|
825
|
+
"reload",
|
|
826
|
+
"submit",
|
|
827
|
+
"loadingChange",
|
|
828
|
+
"requestError",
|
|
829
|
+
"sizeChange",
|
|
830
|
+
"resizeColumn",
|
|
831
|
+
"fullscreenChange",
|
|
832
|
+
"update:expandedRowKeys",
|
|
833
|
+
"scroll"
|
|
834
|
+
],
|
|
835
|
+
name: "GProTable",
|
|
836
|
+
inheritAttrs: false
|
|
529
837
|
});
|
|
530
|
-
var ProTable_default = ProTable;
|
|
531
|
-
|
|
532
838
|
//#endregion
|
|
533
|
-
export {
|
|
839
|
+
export { ForwardProTable as default };
|