@aplus-frontend/ui 0.0.9 → 0.0.10
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/es/src/ap-table/ap-table.vue.d.ts +3 -0
- package/es/src/ap-table/ap-table.vue.mjs +106 -88
- package/es/src/ap-table/hooks/use-table-content-height.d.ts +9 -0
- package/es/src/ap-table/hooks/use-table-content-height.mjs +39 -0
- package/es/src/ap-table/interface.d.ts +4 -0
- package/es/src/ap-table/style/ap-table.css +28 -0
- package/es/src/theme/ap-table/ap-table.css +28 -0
- package/lib/src/ap-table/ap-table.vue.d.ts +3 -0
- package/lib/src/ap-table/ap-table.vue.js +1 -1
- package/lib/src/ap-table/hooks/use-table-content-height.d.ts +9 -0
- package/lib/src/ap-table/hooks/use-table-content-height.js +1 -0
- package/lib/src/ap-table/interface.d.ts +4 -0
- package/lib/src/ap-table/style/ap-table.css +28 -0
- package/lib/src/theme/ap-table/ap-table.css +28 -0
- package/package.json +1 -1
|
@@ -47,6 +47,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
47
47
|
searchForm: undefined;
|
|
48
48
|
loading: undefined;
|
|
49
49
|
manual: boolean;
|
|
50
|
+
adaptive: boolean;
|
|
50
51
|
}>, {
|
|
51
52
|
submit: () => void;
|
|
52
53
|
reset: () => void;
|
|
@@ -71,6 +72,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
71
72
|
searchForm: undefined;
|
|
72
73
|
loading: undefined;
|
|
73
74
|
manual: boolean;
|
|
75
|
+
adaptive: boolean;
|
|
74
76
|
}>>>, {
|
|
75
77
|
loading: boolean | Partial< ExtractPropTypes<{
|
|
76
78
|
prefixCls: StringConstructor;
|
|
@@ -164,6 +166,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
164
166
|
childrenColumnName: string;
|
|
165
167
|
card: boolean;
|
|
166
168
|
searchForm: false | ApFormSearchFormProps;
|
|
169
|
+
adaptive: boolean;
|
|
167
170
|
}, {}>, Partial<Record<NonNullable<keyof ApTableSlots>, (_: any) => any>> & {
|
|
168
171
|
title?(_: {}): any;
|
|
169
172
|
}>;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Typography as
|
|
3
|
-
import { ApForm as
|
|
4
|
-
import { apTableRenderItemMap as
|
|
1
|
+
import { defineComponent as U, computed as d, createVNode as s, mergeProps as f, unref as l, watch as J, openBlock as i, createElementBlock as m, normalizeClass as F, normalizeStyle as x, withCtx as g, Fragment as X, renderList as B, createBlock as Y, resolveDynamicComponent as Z, createCommentVNode as v, createElementVNode as P, renderSlot as I, createSlots as ee, toDisplayString as ae, normalizeProps as te, guardReactiveProps as oe } from "vue";
|
|
2
|
+
import { Typography as re, Table as le, Tooltip as ne } from "ant-design-vue";
|
|
3
|
+
import { ApForm as de } from "../ap-form/index.mjs";
|
|
4
|
+
import { apTableRenderItemMap as se, noRenderAsFormItemValueList as k, apTableFormItemMap as ue } from "./constants.mjs";
|
|
5
5
|
import "../config-provider/index.mjs";
|
|
6
|
-
import { useTablePaging as
|
|
7
|
-
import { isUndefined as
|
|
6
|
+
import { useTablePaging as ie } from "./hooks/use-table-paging.mjs";
|
|
7
|
+
import { isUndefined as pe, omit as ce } from "lodash-unified";
|
|
8
8
|
import "./style/ap-table.css";
|
|
9
|
-
import { QuestionCircleOutlined as
|
|
10
|
-
import { apColumnToColumn as
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
9
|
+
import { QuestionCircleOutlined as fe } from "@ant-design/icons-vue";
|
|
10
|
+
import { apColumnToColumn as me, getTableRenderType as ge, getTableRenderProps as ye, getColumnOrder as O, updateFormProps as be, getFieldProps as he, getPlaceholder as Ce } from "./utils.mjs";
|
|
11
|
+
import Fe from "./hooks/use-table-content-height.mjs";
|
|
12
|
+
import { useLocale as Se } from "../config-provider/hooks/use-locale.mjs";
|
|
13
|
+
import { useNamespace as Re } from "../config-provider/hooks/use-namespace.mjs";
|
|
14
|
+
import { useGlobalConfig as we } from "../config-provider/hooks/use-global-config.mjs";
|
|
15
|
+
const Te = {
|
|
15
16
|
key: 0
|
|
16
|
-
},
|
|
17
|
+
}, _e = /* @__PURE__ */ U({
|
|
17
18
|
name: "ApTable",
|
|
18
19
|
__name: "ap-table",
|
|
19
20
|
props: {
|
|
@@ -120,21 +121,28 @@ const Ce = {
|
|
|
120
121
|
},
|
|
121
122
|
size: {
|
|
122
123
|
default: "middle"
|
|
124
|
+
},
|
|
125
|
+
adaptive: {
|
|
126
|
+
type: Boolean,
|
|
127
|
+
default: !1
|
|
123
128
|
}
|
|
124
129
|
},
|
|
125
130
|
setup(z, {
|
|
126
131
|
expose: E
|
|
127
132
|
}) {
|
|
128
|
-
const
|
|
133
|
+
const r = z, {
|
|
129
134
|
t: L
|
|
130
|
-
} =
|
|
131
|
-
e:
|
|
132
|
-
b:
|
|
133
|
-
} =
|
|
135
|
+
} = Se(), {
|
|
136
|
+
e: y,
|
|
137
|
+
b: p
|
|
138
|
+
} = Re("ap-table"), V = we("uiMode"), {
|
|
139
|
+
height: N,
|
|
140
|
+
contentRef: D
|
|
141
|
+
} = Fe(), b = d(() => {
|
|
134
142
|
var t;
|
|
135
|
-
let e = ((t =
|
|
143
|
+
let e = ((t = r.columns) == null ? void 0 : t.filter((a) => !a.hideInTable)) || [];
|
|
136
144
|
return e = e.map((a) => ({
|
|
137
|
-
...
|
|
145
|
+
...me(a),
|
|
138
146
|
customRender({
|
|
139
147
|
value: o,
|
|
140
148
|
...n
|
|
@@ -147,24 +155,24 @@ const Ce = {
|
|
|
147
155
|
column: a
|
|
148
156
|
});
|
|
149
157
|
else {
|
|
150
|
-
const T =
|
|
158
|
+
const T = ge(a), G = se[T], Q = ye(a, {
|
|
151
159
|
value: o,
|
|
152
160
|
...n
|
|
153
161
|
});
|
|
154
|
-
u = s(
|
|
162
|
+
u = s(G, f(Q, {
|
|
155
163
|
mode: "read"
|
|
156
164
|
}), null);
|
|
157
165
|
}
|
|
158
|
-
return
|
|
166
|
+
return H(a, o, u);
|
|
159
167
|
}
|
|
160
168
|
})), e;
|
|
161
|
-
}),
|
|
169
|
+
}), S = d(() => {
|
|
162
170
|
var e, t, a;
|
|
163
|
-
return ((a = (t = (e =
|
|
171
|
+
return ((a = (t = (e = r.columns) == null ? void 0 : e.filter((o) => !o.hideInSearch && o.dataIndex && (o.valueType || o.customRenderFormItem) && !k.includes(o.valueType))) == null ? void 0 : t.sort((o, n) => {
|
|
164
172
|
let u = O(o.order);
|
|
165
173
|
return O(n.order) - u;
|
|
166
174
|
})) == null ? void 0 : a.map((o) => {
|
|
167
|
-
const n =
|
|
175
|
+
const n = be(o, he(o.fieldProps));
|
|
168
176
|
return {
|
|
169
177
|
...o,
|
|
170
178
|
fieldProps: {
|
|
@@ -172,42 +180,50 @@ const Ce = {
|
|
|
172
180
|
name: o.dataIndex,
|
|
173
181
|
...n || {},
|
|
174
182
|
// 格式化placeholder
|
|
175
|
-
placeholder:
|
|
183
|
+
placeholder: Ce(L, o.valueType, n == null ? void 0 : n.placeholder)
|
|
176
184
|
}
|
|
177
185
|
};
|
|
178
186
|
})) || [];
|
|
179
|
-
}),
|
|
180
|
-
formRef:
|
|
181
|
-
submit:
|
|
182
|
-
reset:
|
|
183
|
-
tableProps:
|
|
187
|
+
}), W = d(() => l(b).filter((e) => e.sorter === !0).map((e) => e.dataIndex)), _ = d(() => l(b).filter((e) => e.filters && !e.onFilter).map((e) => e.dataIndex)), {
|
|
188
|
+
formRef: h,
|
|
189
|
+
submit: R,
|
|
190
|
+
reset: w,
|
|
191
|
+
tableProps: c,
|
|
184
192
|
handleTableChange: j,
|
|
185
|
-
data:
|
|
186
|
-
} =
|
|
193
|
+
data: C
|
|
194
|
+
} = ie({
|
|
187
195
|
async request(e) {
|
|
188
196
|
var a, o;
|
|
189
|
-
const t = await ((a =
|
|
190
|
-
return (o =
|
|
197
|
+
const t = await ((a = r.request) == null ? void 0 : a.call(r, e));
|
|
198
|
+
return (o = r.onLoad) == null || o.call(r, (t == null ? void 0 : t.data) || []), {
|
|
191
199
|
data: (t == null ? void 0 : t.data) || [],
|
|
192
200
|
total: (t == null ? void 0 : t.total) || 0
|
|
193
201
|
};
|
|
194
202
|
},
|
|
195
|
-
filterFields:
|
|
196
|
-
sortFields:
|
|
197
|
-
defaultParams:
|
|
198
|
-
defaultData:
|
|
199
|
-
manual:
|
|
200
|
-
defaultCurrent:
|
|
201
|
-
defaultPageSize:
|
|
202
|
-
formatParams:
|
|
203
|
-
}),
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
203
|
+
filterFields: l(_),
|
|
204
|
+
sortFields: l(W),
|
|
205
|
+
defaultParams: r.params,
|
|
206
|
+
defaultData: r.defaultData,
|
|
207
|
+
manual: r.manual,
|
|
208
|
+
defaultCurrent: r.pagination ? r.pagination.defaultCurrent : void 0,
|
|
209
|
+
defaultPageSize: r.pagination ? r.pagination.defaultPageSize : void 0,
|
|
210
|
+
formatParams: r.beforeSearchSubmit
|
|
211
|
+
}), A = d(() => {
|
|
212
|
+
if (r.scroll)
|
|
213
|
+
return r.scroll;
|
|
214
|
+
if (r.adaptive && C.value.total > 0)
|
|
215
|
+
return {
|
|
216
|
+
y: l(N)
|
|
217
|
+
};
|
|
218
|
+
}), M = d(() => ({
|
|
219
|
+
...r,
|
|
220
|
+
...l(c),
|
|
221
|
+
loading: pe(r.loading) ? l(c).loading : r.loading,
|
|
222
|
+
pagination: r.pagination === !1 ? !1 : l(c).pagination,
|
|
223
|
+
scroll: l(A)
|
|
224
|
+
})), q = d(() => [r.card ? null : p("wrapper"), r.adaptive ? p("adaptive") : null].filter(Boolean));
|
|
225
|
+
function H(e, t, a) {
|
|
226
|
+
return k.includes(e.valueType) ? a : e.copyable || e.ellipsis ? s(re.Text, {
|
|
211
227
|
copyable: e.copyable ? {
|
|
212
228
|
text: t,
|
|
213
229
|
tooltip: !1
|
|
@@ -218,76 +234,78 @@ const Ce = {
|
|
|
218
234
|
content: a
|
|
219
235
|
}, null) : a;
|
|
220
236
|
}
|
|
221
|
-
|
|
237
|
+
J(() => l(C).loading, (e) => {
|
|
222
238
|
var t;
|
|
223
|
-
(t =
|
|
239
|
+
(t = r.onLoadingChange) == null || t.call(r, e);
|
|
224
240
|
});
|
|
225
|
-
function
|
|
241
|
+
function K(e) {
|
|
226
242
|
var t, a, o;
|
|
227
|
-
(o = (a = (t =
|
|
243
|
+
(o = (a = (t = h.value) == null ? void 0 : t.apForm) == null ? void 0 : a.setFieldsValue) == null || o.call(a, e);
|
|
228
244
|
}
|
|
229
|
-
function
|
|
245
|
+
function $() {
|
|
230
246
|
var e, t, a;
|
|
231
|
-
return (a = (t = (e =
|
|
247
|
+
return (a = (t = (e = h.value) == null ? void 0 : e.apForm) == null ? void 0 : t.getFieldsValue) == null ? void 0 : a.call(t, !0);
|
|
232
248
|
}
|
|
233
249
|
return E({
|
|
234
|
-
submit: () =>
|
|
235
|
-
reset: () =>
|
|
236
|
-
setSearchFormValues:
|
|
237
|
-
getSearchFormValues:
|
|
238
|
-
dataSource: d(() =>
|
|
239
|
-
}), (e, t) => (
|
|
240
|
-
class:
|
|
241
|
-
}, [e.searchForm !== !1 &&
|
|
250
|
+
submit: () => R(),
|
|
251
|
+
reset: () => w(),
|
|
252
|
+
setSearchFormValues: K,
|
|
253
|
+
getSearchFormValues: $,
|
|
254
|
+
dataSource: d(() => l(C).records)
|
|
255
|
+
}), (e, t) => (i(), m("div", {
|
|
256
|
+
class: F(q.value)
|
|
257
|
+
}, [e.searchForm !== !1 && S.value.length > 0 ? (i(), m("div", {
|
|
242
258
|
key: 0,
|
|
243
|
-
class:
|
|
259
|
+
class: F(e.card ? l(y)("search-wrapper") : null),
|
|
244
260
|
style: x(e.searchFormWrapperStyle)
|
|
245
|
-
}, [s(
|
|
261
|
+
}, [s(l(de).SearchForm, f(e.searchForm || {}, {
|
|
246
262
|
ref_key: "formRef",
|
|
247
|
-
ref:
|
|
263
|
+
ref: h,
|
|
248
264
|
"custom-reset": "",
|
|
249
|
-
onSubmit:
|
|
250
|
-
onReset:
|
|
251
|
-
"submit-loading":
|
|
265
|
+
onSubmit: l(R),
|
|
266
|
+
onReset: l(w),
|
|
267
|
+
"submit-loading": l(c).loading
|
|
252
268
|
}), {
|
|
253
|
-
default:
|
|
269
|
+
default: g(() => [(i(!0), m(X, null, B(S.value, (a) => (i(), Y(Z(a.customRenderFormItem ? a.customRenderFormItem(a) : l(ue)[a.valueType || "text"]), f({
|
|
254
270
|
key: a.dataIndex,
|
|
255
271
|
ref_for: !0
|
|
256
272
|
}, a.fieldProps || {}, {
|
|
257
273
|
span: a.span
|
|
258
274
|
}), null, 16, ["span"]))), 128))]),
|
|
259
275
|
_: 1
|
|
260
|
-
}, 16, ["onSubmit", "onReset", "submit-loading"])], 6)) :
|
|
261
|
-
|
|
276
|
+
}, 16, ["onSubmit", "onReset", "submit-loading"])], 6)) : v("", !0), P("div", {
|
|
277
|
+
ref_key: "contentRef",
|
|
278
|
+
ref: D,
|
|
279
|
+
class: F([l(y)("table-wrapper"), e.card ? l(y)("table-wrapper-card") : null]),
|
|
262
280
|
style: x(e.tableWrapperStyle)
|
|
263
|
-
}, [
|
|
264
|
-
class:
|
|
265
|
-
},
|
|
266
|
-
onChange:
|
|
267
|
-
columns:
|
|
268
|
-
}),
|
|
269
|
-
headerCell:
|
|
281
|
+
}, [I(e.$slots, "title"), s(l(le), f({
|
|
282
|
+
class: l(V) === "admin" ? l(p)("table-admin") : l(p)("table")
|
|
283
|
+
}, M.value, {
|
|
284
|
+
onChange: l(j),
|
|
285
|
+
columns: b.value
|
|
286
|
+
}), ee({
|
|
287
|
+
headerCell: g(({
|
|
270
288
|
column: a,
|
|
271
289
|
title: o
|
|
272
|
-
}) => [a.tooltip ? (
|
|
290
|
+
}) => [a.tooltip ? (i(), m("span", Te, [P("span", null, ae(o), 1), s(l(ne), {
|
|
273
291
|
title: a.tooltip,
|
|
274
292
|
placement: "bottom"
|
|
275
293
|
}, {
|
|
276
|
-
default:
|
|
294
|
+
default: g(() => [s(l(fe), {
|
|
277
295
|
style: {
|
|
278
296
|
color: "#0070ff",
|
|
279
297
|
"padding-left": "4px"
|
|
280
298
|
}
|
|
281
299
|
})]),
|
|
282
300
|
_: 2
|
|
283
|
-
}, 1032, ["title"])])) :
|
|
301
|
+
}, 1032, ["title"])])) : v("", !0)]),
|
|
284
302
|
_: 2
|
|
285
|
-
}, [B(
|
|
303
|
+
}, [B(l(ce)(e.$slots, "title"), (a, o) => ({
|
|
286
304
|
name: o,
|
|
287
|
-
fn:
|
|
305
|
+
fn: g((n) => [I(e.$slots, o, te(oe(n || {})))])
|
|
288
306
|
}))]), 1040, ["class", "onChange", "columns"])], 6)], 2));
|
|
289
307
|
}
|
|
290
308
|
});
|
|
291
309
|
export {
|
|
292
|
-
|
|
310
|
+
_e as default
|
|
293
311
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
export type TableContentHeightOptions = {
|
|
3
|
+
offset?: number;
|
|
4
|
+
};
|
|
5
|
+
declare const useTableContentHeight: (options?: TableContentHeightOptions) => {
|
|
6
|
+
contentRef: Ref<HTMLDivElement | undefined>;
|
|
7
|
+
height: ComputedRef<number>;
|
|
8
|
+
};
|
|
9
|
+
export default useTableContentHeight;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useElementSize as d } from "@vueuse/core";
|
|
2
|
+
import { ref as g, computed as H, unref as l, onUpdated as S } from "vue";
|
|
3
|
+
function f(t) {
|
|
4
|
+
if (!t)
|
|
5
|
+
return 0;
|
|
6
|
+
const e = parseFloat(t);
|
|
7
|
+
return Number.isNaN(e) ? 0 : e;
|
|
8
|
+
}
|
|
9
|
+
function h(t) {
|
|
10
|
+
if (!t)
|
|
11
|
+
return 0;
|
|
12
|
+
const e = getComputedStyle(t);
|
|
13
|
+
return t.clientHeight + f(e.marginTop) + f(e.marginBottom);
|
|
14
|
+
}
|
|
15
|
+
const v = (t) => {
|
|
16
|
+
const e = g(), { height: s } = d(e), a = g();
|
|
17
|
+
let i = !1;
|
|
18
|
+
const m = H(() => {
|
|
19
|
+
var o, u, c;
|
|
20
|
+
const r = ((u = (o = e.value) == null ? void 0 : o.querySelector(".ant-table-header")) == null ? void 0 : u.clientHeight) || 47, n = (c = e.value) == null ? void 0 : c.querySelector(".ant-pagination"), p = n ? h(n) : l(a);
|
|
21
|
+
return n && (i = !0), Math.ceil(
|
|
22
|
+
l(s) - r - (p || 0) - ((t == null ? void 0 : t.offset) || 0)
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
return S(() => {
|
|
26
|
+
var n;
|
|
27
|
+
if (i)
|
|
28
|
+
return;
|
|
29
|
+
const r = (n = e.value) == null ? void 0 : n.querySelector(".ant-pagination");
|
|
30
|
+
if (!r) {
|
|
31
|
+
a.value = 0;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
a.value = h(r), i = !0;
|
|
35
|
+
}), { contentRef: e, height: m };
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
v as default
|
|
39
|
+
};
|
|
@@ -199,6 +199,10 @@ export type ApTableProps<RecordType = any, ParamsType = any, ValueType extends k
|
|
|
199
199
|
* 表格尺寸(只支持中等大小和小尺寸)
|
|
200
200
|
*/
|
|
201
201
|
size?: 'middle' | 'small';
|
|
202
|
+
/**
|
|
203
|
+
* 表格是否自适应高度
|
|
204
|
+
*/
|
|
205
|
+
adaptive?: boolean;
|
|
202
206
|
};
|
|
203
207
|
export type ApTableExpose<SearchParamsType = Recordable, RecordType = any> = {
|
|
204
208
|
/**
|
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
padding: 16px;
|
|
3
3
|
background-color: #fff;
|
|
4
4
|
}
|
|
5
|
+
.aplus-ap-table-adaptive {
|
|
6
|
+
height: 100%;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
}
|
|
10
|
+
.aplus-ap-table-adaptive .ant-table-wrapper,
|
|
11
|
+
.aplus-ap-table-adaptive .ant-spin-nested-loading,
|
|
12
|
+
.aplus-ap-table-adaptive .ant-spin-container {
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
.aplus-ap-table-adaptive .ant-spin-container {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
}
|
|
19
|
+
.aplus-ap-table-adaptive .ant-table {
|
|
20
|
+
flex: 1;
|
|
21
|
+
}
|
|
22
|
+
.aplus-ap-table-adaptive .ant-table-container,
|
|
23
|
+
.aplus-ap-table-adaptive .ant-table-content {
|
|
24
|
+
height: 100%;
|
|
25
|
+
}
|
|
26
|
+
.aplus-ap-table-adaptive .ant-table-content > table {
|
|
27
|
+
height: 100%;
|
|
28
|
+
}
|
|
5
29
|
.aplus-ap-table__search-wrapper {
|
|
6
30
|
padding: 16px;
|
|
7
31
|
padding-bottom: 0;
|
|
@@ -9,8 +33,12 @@
|
|
|
9
33
|
margin-bottom: 16px;
|
|
10
34
|
}
|
|
11
35
|
.aplus-ap-table__table-wrapper {
|
|
36
|
+
flex: 1;
|
|
37
|
+
}
|
|
38
|
+
.aplus-ap-table__table-wrapper-card {
|
|
12
39
|
padding: 16px;
|
|
13
40
|
background-color: #fff;
|
|
41
|
+
overflow: hidden;
|
|
14
42
|
}
|
|
15
43
|
.aplus-ap-table-table .ant-pagination {
|
|
16
44
|
margin-bottom: 0 !important;
|
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
padding: 16px;
|
|
3
3
|
background-color: #fff;
|
|
4
4
|
}
|
|
5
|
+
.aplus-ap-table-adaptive {
|
|
6
|
+
height: 100%;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
}
|
|
10
|
+
.aplus-ap-table-adaptive .ant-table-wrapper,
|
|
11
|
+
.aplus-ap-table-adaptive .ant-spin-nested-loading,
|
|
12
|
+
.aplus-ap-table-adaptive .ant-spin-container {
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
.aplus-ap-table-adaptive .ant-spin-container {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
}
|
|
19
|
+
.aplus-ap-table-adaptive .ant-table {
|
|
20
|
+
flex: 1;
|
|
21
|
+
}
|
|
22
|
+
.aplus-ap-table-adaptive .ant-table-container,
|
|
23
|
+
.aplus-ap-table-adaptive .ant-table-content {
|
|
24
|
+
height: 100%;
|
|
25
|
+
}
|
|
26
|
+
.aplus-ap-table-adaptive .ant-table-content > table {
|
|
27
|
+
height: 100%;
|
|
28
|
+
}
|
|
5
29
|
.aplus-ap-table__search-wrapper {
|
|
6
30
|
padding: 16px;
|
|
7
31
|
padding-bottom: 0;
|
|
@@ -9,8 +33,12 @@
|
|
|
9
33
|
margin-bottom: 16px;
|
|
10
34
|
}
|
|
11
35
|
.aplus-ap-table__table-wrapper {
|
|
36
|
+
flex: 1;
|
|
37
|
+
}
|
|
38
|
+
.aplus-ap-table__table-wrapper-card {
|
|
12
39
|
padding: 16px;
|
|
13
40
|
background-color: #fff;
|
|
41
|
+
overflow: hidden;
|
|
14
42
|
}
|
|
15
43
|
.aplus-ap-table-table .ant-pagination {
|
|
16
44
|
margin-bottom: 0 !important;
|
|
@@ -47,6 +47,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
47
47
|
searchForm: undefined;
|
|
48
48
|
loading: undefined;
|
|
49
49
|
manual: boolean;
|
|
50
|
+
adaptive: boolean;
|
|
50
51
|
}>, {
|
|
51
52
|
submit: () => void;
|
|
52
53
|
reset: () => void;
|
|
@@ -71,6 +72,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
71
72
|
searchForm: undefined;
|
|
72
73
|
loading: undefined;
|
|
73
74
|
manual: boolean;
|
|
75
|
+
adaptive: boolean;
|
|
74
76
|
}>>>, {
|
|
75
77
|
loading: boolean | Partial< ExtractPropTypes<{
|
|
76
78
|
prefixCls: StringConstructor;
|
|
@@ -164,6 +166,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
|
|
|
164
166
|
childrenColumnName: string;
|
|
165
167
|
card: boolean;
|
|
166
168
|
searchForm: false | ApFormSearchFormProps;
|
|
169
|
+
adaptive: boolean;
|
|
167
170
|
}, {}>, Partial<Record<NonNullable<keyof ApTableSlots>, (_: any) => any>> & {
|
|
168
171
|
title?(_: {}): any;
|
|
169
172
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),y=require("ant-design-vue"),D=require("../ap-form/index.js"),c=require("./constants.js");require("../config-provider/index.js");const j=require("./hooks/use-table-paging.js"),F=require("lodash-unified");require("./style/ap-table.css");const M=require("@ant-design/icons-vue"),u=require("./utils.js"),W=require("./hooks/use-table-content-height.js"),A=require("../config-provider/hooks/use-locale.js"),H=require("../config-provider/hooks/use-namespace.js"),K=require("../config-provider/hooks/use-global-config.js"),$={key:0},G=e.defineComponent({name:"ApTable",__name:"ap-table",props:{dropdownPrefixCls:{},loading:{type:[Boolean,Object],default:void 0},bordered:{type:Boolean,default:!1},locale:{},onChange:{},onResizeColumn:{},rowSelection:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!0},prefixCls:{},rowKey:{default:"key"},tableLayout:{},rowClassName:{},title:{},footer:{},id:{},showHeader:{type:Boolean,default:!0},components:{},customRow:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean],default:!1},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean,default:!1},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean,default:!1},indentSize:{default:15},expandIconColumnIndex:{},showExpandColumn:{type:Boolean,default:!0},expandedRowClassName:{},childrenColumnName:{default:"children"},rowExpandable:{},sticky:{type:[Boolean,Object]},transformCellText:{},columns:{},card:{type:Boolean,default:!1},params:{},searchFormRender:{},request:{},onLoad:{},defaultData:{},onLoadingChange:{},searchForm:{type:[Boolean,Object],default:void 0},beforeSearchSubmit:{},pagination:{type:[Boolean,Object],default:void 0},searchFormWrapperStyle:{},tableWrapperStyle:{},manual:{type:Boolean,default:!1},size:{default:"middle"},adaptive:{type:Boolean,default:!1}},setup(R,{expose:w}){const o=R,{t:B}=A.useLocale(),{e:p,b:s}=H.useNamespace("ap-table"),T=K.useGlobalConfig("uiMode"),{height:x,contentRef:v}=W.default(),f=e.computed(()=>{var n;let a=((n=o.columns)==null?void 0:n.filter(t=>!t.hideInTable))||[];return a=a.map(t=>({...u.apColumnToColumn(t),customRender({value:r,...l}){let d;if(t.customRender)d=t.customRender({value:r,...l,column:t});else{const S=u.getTableRenderType(t),L=c.apTableRenderItemMap[S],_=u.getTableRenderProps(t,{value:r,...l});d=e.createVNode(L,e.mergeProps(_,{mode:"read"}),null)}return E(t,r,d)}})),a}),b=e.computed(()=>{var a,n,t;return((t=(n=(a=o.columns)==null?void 0:a.filter(r=>!r.hideInSearch&&r.dataIndex&&(r.valueType||r.customRenderFormItem)&&!c.noRenderAsFormItemValueList.includes(r.valueType)))==null?void 0:n.sort((r,l)=>{let d=u.getColumnOrder(r.order);return u.getColumnOrder(l.order)-d}))==null?void 0:t.map(r=>{const l=u.updateFormProps(r,u.getFieldProps(r.fieldProps));return{...r,fieldProps:{label:r.title,name:r.dataIndex,...l||{},placeholder:u.getPlaceholder(B,r.valueType,l==null?void 0:l.placeholder)}}}))||[]}),P=e.computed(()=>e.unref(f).filter(a=>a.sorter===!0).map(a=>a.dataIndex)),k=e.computed(()=>e.unref(f).filter(a=>a.filters&&!a.onFilter).map(a=>a.dataIndex)),{formRef:m,submit:h,reset:C,tableProps:i,handleTableChange:I,data:g}=j.useTablePaging({async request(a){var t,r;const n=await((t=o.request)==null?void 0:t.call(o,a));return(r=o.onLoad)==null||r.call(o,(n==null?void 0:n.data)||[]),{data:(n==null?void 0:n.data)||[],total:(n==null?void 0:n.total)||0}},filterFields:e.unref(k),sortFields:e.unref(P),defaultParams:o.params,defaultData:o.defaultData,manual:o.manual,defaultCurrent:o.pagination?o.pagination.defaultCurrent:void 0,defaultPageSize:o.pagination?o.pagination.defaultPageSize:void 0,formatParams:o.beforeSearchSubmit}),q=e.computed(()=>{if(o.scroll)return o.scroll;if(o.adaptive&&g.value.total>0)return{y:e.unref(x)}}),V=e.computed(()=>({...o,...e.unref(i),loading:F.isUndefined(o.loading)?e.unref(i).loading:o.loading,pagination:o.pagination===!1?!1:e.unref(i).pagination,scroll:e.unref(q)})),N=e.computed(()=>[o.card?null:s("wrapper"),o.adaptive?s("adaptive"):null].filter(Boolean));function E(a,n,t){return c.noRenderAsFormItemValueList.includes(a.valueType)?t:a.copyable||a.ellipsis?e.createVNode(y.Typography.Text,{copyable:a.copyable?{text:n,tooltip:!1}:!1,ellipsis:a.ellipsis?{tooltip:n}:!1,content:t},null):t}e.watch(()=>e.unref(g).loading,a=>{var n;(n=o.onLoadingChange)==null||n.call(o,a)});function O(a){var n,t,r;(r=(t=(n=m.value)==null?void 0:n.apForm)==null?void 0:t.setFieldsValue)==null||r.call(t,a)}function z(){var a,n,t;return(t=(n=(a=m.value)==null?void 0:a.apForm)==null?void 0:n.getFieldsValue)==null?void 0:t.call(n,!0)}return w({submit:()=>h(),reset:()=>C(),setSearchFormValues:O,getSearchFormValues:z,dataSource:e.computed(()=>e.unref(g).records)}),(a,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(N.value)},[a.searchForm!==!1&&b.value.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(a.card?e.unref(p)("search-wrapper"):null),style:e.normalizeStyle(a.searchFormWrapperStyle)},[e.createVNode(e.unref(D.ApForm).SearchForm,e.mergeProps(a.searchForm||{},{ref_key:"formRef",ref:m,"custom-reset":"",onSubmit:e.unref(h),onReset:e.unref(C),"submit-loading":e.unref(i).loading}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,t=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.customRenderFormItem?t.customRenderFormItem(t):e.unref(c.apTableFormItemMap)[t.valueType||"text"]),e.mergeProps({key:t.dataIndex,ref_for:!0},t.fieldProps||{},{span:t.span}),null,16,["span"]))),128))]),_:1},16,["onSubmit","onReset","submit-loading"])],6)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"contentRef",ref:v,class:e.normalizeClass([e.unref(p)("table-wrapper"),a.card?e.unref(p)("table-wrapper-card"):null]),style:e.normalizeStyle(a.tableWrapperStyle)},[e.renderSlot(a.$slots,"title"),e.createVNode(e.unref(y.Table),e.mergeProps({class:e.unref(T)==="admin"?e.unref(s)("table-admin"):e.unref(s)("table")},V.value,{onChange:e.unref(I),columns:f.value}),e.createSlots({headerCell:e.withCtx(({column:t,title:r})=>[t.tooltip?(e.openBlock(),e.createElementBlock("span",$,[e.createElementVNode("span",null,e.toDisplayString(r),1),e.createVNode(e.unref(y.Tooltip),{title:t.tooltip,placement:"bottom"},{default:e.withCtx(()=>[e.createVNode(e.unref(M.QuestionCircleOutlined),{style:{color:"#0070ff","padding-left":"4px"}})]),_:2},1032,["title"])])):e.createCommentVNode("",!0)]),_:2},[e.renderList(e.unref(F.omit)(a.$slots,"title"),(t,r)=>({name:r,fn:e.withCtx(l=>[e.renderSlot(a.$slots,r,e.normalizeProps(e.guardReactiveProps(l||{})))])}))]),1040,["class","onChange","columns"])],6)],2))}});exports.default=G;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
export type TableContentHeightOptions = {
|
|
3
|
+
offset?: number;
|
|
4
|
+
};
|
|
5
|
+
declare const useTableContentHeight: (options?: TableContentHeightOptions) => {
|
|
6
|
+
contentRef: Ref<HTMLDivElement | undefined>;
|
|
7
|
+
height: ComputedRef<number>;
|
|
8
|
+
};
|
|
9
|
+
export default useTableContentHeight;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@vueuse/core"),r=require("vue");function g(t){if(!t)return 0;const e=parseFloat(t);return Number.isNaN(e)?0:e}function s(t){if(!t)return 0;const e=getComputedStyle(t);return t.clientHeight+g(e.marginTop)+g(e.marginBottom)}const p=t=>{const e=r.ref(),{height:f}=m.useElementSize(e),u=r.ref();let a=!1;const h=r.computed(()=>{var o,c,l;const i=((c=(o=e.value)==null?void 0:o.querySelector(".ant-table-header"))==null?void 0:c.clientHeight)||47,n=(l=e.value)==null?void 0:l.querySelector(".ant-pagination"),d=n?s(n):r.unref(u);return n&&(a=!0),Math.ceil(r.unref(f)-i-(d||0)-((t==null?void 0:t.offset)||0))});return r.onUpdated(()=>{var n;if(a)return;const i=(n=e.value)==null?void 0:n.querySelector(".ant-pagination");if(!i){u.value=0;return}u.value=s(i),a=!0}),{contentRef:e,height:h}};exports.default=p;
|
|
@@ -199,6 +199,10 @@ export type ApTableProps<RecordType = any, ParamsType = any, ValueType extends k
|
|
|
199
199
|
* 表格尺寸(只支持中等大小和小尺寸)
|
|
200
200
|
*/
|
|
201
201
|
size?: 'middle' | 'small';
|
|
202
|
+
/**
|
|
203
|
+
* 表格是否自适应高度
|
|
204
|
+
*/
|
|
205
|
+
adaptive?: boolean;
|
|
202
206
|
};
|
|
203
207
|
export type ApTableExpose<SearchParamsType = Recordable, RecordType = any> = {
|
|
204
208
|
/**
|
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
padding: 16px;
|
|
3
3
|
background-color: #fff;
|
|
4
4
|
}
|
|
5
|
+
.aplus-ap-table-adaptive {
|
|
6
|
+
height: 100%;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
}
|
|
10
|
+
.aplus-ap-table-adaptive .ant-table-wrapper,
|
|
11
|
+
.aplus-ap-table-adaptive .ant-spin-nested-loading,
|
|
12
|
+
.aplus-ap-table-adaptive .ant-spin-container {
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
.aplus-ap-table-adaptive .ant-spin-container {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
}
|
|
19
|
+
.aplus-ap-table-adaptive .ant-table {
|
|
20
|
+
flex: 1;
|
|
21
|
+
}
|
|
22
|
+
.aplus-ap-table-adaptive .ant-table-container,
|
|
23
|
+
.aplus-ap-table-adaptive .ant-table-content {
|
|
24
|
+
height: 100%;
|
|
25
|
+
}
|
|
26
|
+
.aplus-ap-table-adaptive .ant-table-content > table {
|
|
27
|
+
height: 100%;
|
|
28
|
+
}
|
|
5
29
|
.aplus-ap-table__search-wrapper {
|
|
6
30
|
padding: 16px;
|
|
7
31
|
padding-bottom: 0;
|
|
@@ -9,8 +33,12 @@
|
|
|
9
33
|
margin-bottom: 16px;
|
|
10
34
|
}
|
|
11
35
|
.aplus-ap-table__table-wrapper {
|
|
36
|
+
flex: 1;
|
|
37
|
+
}
|
|
38
|
+
.aplus-ap-table__table-wrapper-card {
|
|
12
39
|
padding: 16px;
|
|
13
40
|
background-color: #fff;
|
|
41
|
+
overflow: hidden;
|
|
14
42
|
}
|
|
15
43
|
.aplus-ap-table-table .ant-pagination {
|
|
16
44
|
margin-bottom: 0 !important;
|
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
padding: 16px;
|
|
3
3
|
background-color: #fff;
|
|
4
4
|
}
|
|
5
|
+
.aplus-ap-table-adaptive {
|
|
6
|
+
height: 100%;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
}
|
|
10
|
+
.aplus-ap-table-adaptive .ant-table-wrapper,
|
|
11
|
+
.aplus-ap-table-adaptive .ant-spin-nested-loading,
|
|
12
|
+
.aplus-ap-table-adaptive .ant-spin-container {
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
.aplus-ap-table-adaptive .ant-spin-container {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
}
|
|
19
|
+
.aplus-ap-table-adaptive .ant-table {
|
|
20
|
+
flex: 1;
|
|
21
|
+
}
|
|
22
|
+
.aplus-ap-table-adaptive .ant-table-container,
|
|
23
|
+
.aplus-ap-table-adaptive .ant-table-content {
|
|
24
|
+
height: 100%;
|
|
25
|
+
}
|
|
26
|
+
.aplus-ap-table-adaptive .ant-table-content > table {
|
|
27
|
+
height: 100%;
|
|
28
|
+
}
|
|
5
29
|
.aplus-ap-table__search-wrapper {
|
|
6
30
|
padding: 16px;
|
|
7
31
|
padding-bottom: 0;
|
|
@@ -9,8 +33,12 @@
|
|
|
9
33
|
margin-bottom: 16px;
|
|
10
34
|
}
|
|
11
35
|
.aplus-ap-table__table-wrapper {
|
|
36
|
+
flex: 1;
|
|
37
|
+
}
|
|
38
|
+
.aplus-ap-table__table-wrapper-card {
|
|
12
39
|
padding: 16px;
|
|
13
40
|
background-color: #fff;
|
|
41
|
+
overflow: hidden;
|
|
14
42
|
}
|
|
15
43
|
.aplus-ap-table-table .ant-pagination {
|
|
16
44
|
margin-bottom: 0 !important;
|