@aplus-frontend/ui 0.3.9 → 0.3.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/es/index.mjs +222 -220
- package/es/src/ap-form/ap-form.vue.d.ts +1 -3
- package/es/src/ap-form/ap-form.vue2.mjs +101 -95
- package/es/src/ap-list/index.vue.mjs +37 -39
- package/es/src/ap-list/interface.d.ts +3 -3
- package/es/src/ap-table/ap-table.vue2.mjs +62 -66
- package/es/src/ap-table/hooks/use-table-paging-ng.d.ts +87 -0
- package/es/src/ap-table/hooks/use-table-paging-ng.mjs +209 -0
- package/es/src/ap-table/hooks/use-table-paging.d.ts +6 -0
- package/es/src/ap-table/interface.d.ts +4 -3
- package/es/src/business/ap-select-layout/index.d.ts +1 -0
- package/es/src/business/ap-select-layout/interface.d.ts +1 -0
- package/es/src/business/ap-select-layout/select-layout.vue2.mjs +69 -63
- package/es/src/config-provider/config-provider-props.d.ts +0 -2
- package/es/src/config-provider/config-provider-props.mjs +2 -4
- package/es/src/config-provider/config-provider.d.ts +0 -6
- package/es/src/config-provider/config-provider.mjs +26 -25
- package/es/src/config-provider/constants.d.ts +2 -0
- package/es/src/config-provider/constants.mjs +3 -1
- package/es/src/config-provider/hooks/use-global-config.d.ts +0 -2
- package/es/src/config-provider/index.d.ts +0 -12
- package/es/src/config-provider/index.mjs +17 -15
- package/es/src/index.mjs +207 -205
- package/lib/index.js +1 -1
- package/lib/src/ap-form/ap-form.vue.d.ts +1 -3
- package/lib/src/ap-form/ap-form.vue2.js +1 -1
- package/lib/src/ap-list/index.vue.js +1 -1
- package/lib/src/ap-list/interface.d.ts +3 -3
- package/lib/src/ap-table/ap-table.vue2.js +1 -1
- package/lib/src/ap-table/hooks/use-table-paging-ng.d.ts +87 -0
- package/lib/src/ap-table/hooks/use-table-paging-ng.js +1 -0
- package/lib/src/ap-table/hooks/use-table-paging.d.ts +6 -0
- package/lib/src/ap-table/interface.d.ts +4 -3
- package/lib/src/business/ap-select-layout/index.d.ts +1 -0
- package/lib/src/business/ap-select-layout/interface.d.ts +1 -0
- package/lib/src/business/ap-select-layout/select-layout.vue2.js +1 -1
- package/lib/src/config-provider/config-provider-props.d.ts +0 -2
- package/lib/src/config-provider/config-provider-props.js +1 -1
- package/lib/src/config-provider/config-provider.d.ts +0 -6
- package/lib/src/config-provider/config-provider.js +1 -1
- package/lib/src/config-provider/constants.d.ts +2 -0
- package/lib/src/config-provider/constants.js +1 -1
- package/lib/src/config-provider/hooks/use-global-config.d.ts +0 -2
- package/lib/src/config-provider/index.d.ts +0 -12
- package/lib/src/config-provider/index.js +1 -1
- package/lib/src/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent as Te, useSlots as Fe, ref as P, computed as s, unref as l, createVNode as
|
|
1
|
+
import { defineComponent as Te, useSlots as Fe, ref as P, computed as s, unref as l, createVNode as g, Fragment as q, watchEffect as xe, watch as G, openBlock as p, createElementBlock as T, normalizeClass as f, normalizeStyle as M, mergeProps as w, createSlots as _, withCtx as F, renderList as J, createBlock as Q, resolveDynamicComponent as Be, renderSlot as b, createCommentVNode as X, createElementVNode as I, normalizeProps as ke, guardReactiveProps as ze } from "vue";
|
|
2
2
|
import { Divider as Pe, Table as Ie } from "@aplus-frontend/antdv";
|
|
3
3
|
import { useToken as Ne } from "@aplus-frontend/antdv/es/theme/internal";
|
|
4
4
|
import { ApForm as Ee } from "../ap-form/index.mjs";
|
|
5
5
|
import { noRenderAsFormItemValueList as Y } from "./constants.mjs";
|
|
6
6
|
import "../config-provider/index.mjs";
|
|
7
|
-
import { useTablePaging as Ke } from "./hooks/use-table-paging.mjs";
|
|
8
|
-
import { isUndefined as m, omit as Z, isBoolean as
|
|
9
|
-
import { getColumnOrder as ee, updateFormProps as
|
|
7
|
+
import { useTablePaging as Ke } from "./hooks/use-table-paging-ng.mjs";
|
|
8
|
+
import { isUndefined as m, omit as Z, isBoolean as Oe } from "lodash-unified";
|
|
9
|
+
import { getColumnOrder as ee, updateFormProps as Le, getFieldProps as Ve, getSearchFormItemRenderNode as Ae, recursionApColumns as ae, apColumnToColumn as De, getTableTitle as je, getTableRenderType as $e, getTableRenderProps as We, getTableCellRenderNode as He, falseToUndefined as Ue } from "./utils.mjs";
|
|
10
10
|
import qe from "./hooks/use-table-content-height.mjs";
|
|
11
11
|
import Ge from "./hooks/use-table-row-selection.mjs";
|
|
12
12
|
import { isDef as Me } from "../utils/index.mjs";
|
|
@@ -17,7 +17,7 @@ import { useNamespace as Je } from "../config-provider/hooks/use-namespace.mjs";
|
|
|
17
17
|
import { useGlobalConfig as Qe } from "../config-provider/hooks/use-global-config.mjs";
|
|
18
18
|
import Xe from "./components/paragraph-ellipsis/index.vue2.mjs";
|
|
19
19
|
import Ye from "./components/setting/modal/index.vue2.mjs";
|
|
20
|
-
const
|
|
20
|
+
const ba = /* @__PURE__ */ Te({
|
|
21
21
|
name: "ApTable",
|
|
22
22
|
__name: "ap-table",
|
|
23
23
|
props: {
|
|
@@ -146,17 +146,17 @@ const ha = /* @__PURE__ */ Te({
|
|
|
146
146
|
}) {
|
|
147
147
|
const a = oe;
|
|
148
148
|
let N = 0;
|
|
149
|
-
const
|
|
149
|
+
const h = Fe(), [, re] = Ne(), {
|
|
150
150
|
e: x,
|
|
151
151
|
b: i,
|
|
152
152
|
be: E
|
|
153
153
|
} = Je("ap-table"), K = Qe("valueTypeMap"), {
|
|
154
154
|
height: le,
|
|
155
155
|
contentRef: ne
|
|
156
|
-
} = qe(), B = P(a.size), u = P([]),
|
|
156
|
+
} = qe(), B = P(a.size), u = P([]), O = P([]);
|
|
157
157
|
_e({
|
|
158
158
|
columns: s(() => u.value),
|
|
159
|
-
columnsBackup: s(() =>
|
|
159
|
+
columnsBackup: s(() => O.value),
|
|
160
160
|
size: s(() => B.value),
|
|
161
161
|
updateColumns(e) {
|
|
162
162
|
u.value = e;
|
|
@@ -165,13 +165,13 @@ const ha = /* @__PURE__ */ Te({
|
|
|
165
165
|
B.value = e;
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
|
-
const
|
|
168
|
+
const L = s(() => {
|
|
169
169
|
var e, t, o;
|
|
170
170
|
return N++, ((o = (t = (e = a.columns) == null ? void 0 : e.filter((r) => !r.hideInSearch && r.dataIndex && (r.valueType || r.customRenderFormItem) && !Y.includes(r.valueType))) == null ? void 0 : t.sort((r, d) => {
|
|
171
171
|
let n = ee(r.order);
|
|
172
172
|
return ee(d.order) - n;
|
|
173
173
|
})) == null ? void 0 : o.map((r) => {
|
|
174
|
-
const d =
|
|
174
|
+
const d = Le(r, Ve(r.fieldProps, {})), n = {
|
|
175
175
|
...r,
|
|
176
176
|
fieldProps: {
|
|
177
177
|
label: r.title,
|
|
@@ -189,10 +189,10 @@ const ha = /* @__PURE__ */ Te({
|
|
|
189
189
|
}).filter(Boolean)), de = s(() => ae(l(u), (e) => {
|
|
190
190
|
if (e.filters && !e.onFilter)
|
|
191
191
|
return e.key || e.dataIndex;
|
|
192
|
-
}).filter(Boolean)), ue = s(() => m(a.dataSource) ? v.
|
|
193
|
-
rowSelection:
|
|
194
|
-
selectedRows:
|
|
195
|
-
...
|
|
192
|
+
}).filter(Boolean)), ue = s(() => m(a.dataSource) ? v.records : a.dataSource), {
|
|
193
|
+
rowSelection: S,
|
|
194
|
+
selectedRows: R,
|
|
195
|
+
...C
|
|
196
196
|
} = Ge({
|
|
197
197
|
fixed: !0,
|
|
198
198
|
...a.rowSelection === !0 ? {} : a.rowSelection,
|
|
@@ -210,7 +210,7 @@ const ha = /* @__PURE__ */ Te({
|
|
|
210
210
|
} = Ke({
|
|
211
211
|
async request(e) {
|
|
212
212
|
var o, r;
|
|
213
|
-
if (!
|
|
213
|
+
if (!S.value.preserveSelectedRowKeys && m(a.dataSource) && C.clearAll(), !m(a.dataSource))
|
|
214
214
|
return {
|
|
215
215
|
data: a.dataSource || [],
|
|
216
216
|
total: a.dataSource.length || 0
|
|
@@ -226,12 +226,8 @@ const ha = /* @__PURE__ */ Te({
|
|
|
226
226
|
defaultParams: a.params,
|
|
227
227
|
defaultData: a.defaultData,
|
|
228
228
|
manual: a.manual,
|
|
229
|
-
defaultCurrent: a.pagination ? a.pagination.defaultCurrent : void 0,
|
|
230
|
-
defaultPageSize: a.pagination ? a.pagination.defaultPageSize : void 0,
|
|
231
229
|
formatParams: a.beforeSearchSubmit,
|
|
232
|
-
|
|
233
|
-
showTotal: a.pagination ? a.pagination.showTotal : void 0,
|
|
234
|
-
pagination: a.pagination !== !1
|
|
230
|
+
pagination: a.pagination
|
|
235
231
|
}), fe = () => {
|
|
236
232
|
var o;
|
|
237
233
|
let e = ((o = a.columns) == null ? void 0 : o.filter((r) => !r.hideInTable)) || [];
|
|
@@ -241,29 +237,29 @@ const ha = /* @__PURE__ */ Te({
|
|
|
241
237
|
...Z(De(n), ["ellipsis"]),
|
|
242
238
|
...pe(n),
|
|
243
239
|
fixed: d ? d.fixed : n.fixed,
|
|
244
|
-
title: je(n, E("table-header", "title"),
|
|
240
|
+
title: je(n, E("table-header", "title"), h.headerCell, l(re).colorPrimary),
|
|
245
241
|
customRender({
|
|
246
242
|
value: c,
|
|
247
|
-
...
|
|
243
|
+
...y
|
|
248
244
|
}) {
|
|
249
245
|
var H, U;
|
|
250
|
-
const $ = $e(n),
|
|
246
|
+
const $ = $e(n), Re = We({
|
|
251
247
|
...n,
|
|
252
248
|
valueType: $
|
|
253
249
|
}, {
|
|
254
250
|
value: c,
|
|
255
|
-
...
|
|
256
|
-
}),
|
|
251
|
+
...y
|
|
252
|
+
}), Ce = He($, Re, y.record, l(K)), W = ((H = n.renderText) == null ? void 0 : H.call(n, {
|
|
257
253
|
value: c,
|
|
258
|
-
...
|
|
259
|
-
})) || c, ve = n.renderText ?
|
|
254
|
+
...y
|
|
255
|
+
})) || c, ve = n.renderText ? g(q, null, [(U = n.renderText) == null ? void 0 : U.call(n, {
|
|
260
256
|
value: c,
|
|
261
|
-
...
|
|
262
|
-
})]) :
|
|
257
|
+
...y
|
|
258
|
+
})]) : Ce;
|
|
263
259
|
let z = we(n, W, ve);
|
|
264
260
|
return n.customRender && (z = n.customRender({
|
|
265
261
|
value: c,
|
|
266
|
-
...
|
|
262
|
+
...y,
|
|
267
263
|
column: n,
|
|
268
264
|
originalNode: z,
|
|
269
265
|
originalText: W
|
|
@@ -276,18 +272,18 @@ const ha = /* @__PURE__ */ Te({
|
|
|
276
272
|
};
|
|
277
273
|
xe(() => {
|
|
278
274
|
const e = fe();
|
|
279
|
-
u.value = e,
|
|
275
|
+
u.value = e, O.value = e;
|
|
280
276
|
});
|
|
281
277
|
const me = s(() => {
|
|
282
278
|
var t, o;
|
|
283
|
-
if (a.adaptive && (v.
|
|
279
|
+
if (a.adaptive && (v.total > 0 || ((t = a.dataSource) == null ? void 0 : t.length)))
|
|
284
280
|
return {
|
|
285
281
|
y: l(le),
|
|
286
282
|
x: ((o = a.scroll) == null ? void 0 : o.x) || "100%"
|
|
287
283
|
};
|
|
288
284
|
if (a.scroll)
|
|
289
285
|
return a.scroll;
|
|
290
|
-
}),
|
|
286
|
+
}), ye = s(() => {
|
|
291
287
|
var e;
|
|
292
288
|
if (a.tableLayout)
|
|
293
289
|
return a.tableLayout;
|
|
@@ -295,7 +291,7 @@ const ha = /* @__PURE__ */ Te({
|
|
|
295
291
|
return "fixed";
|
|
296
292
|
}), j = s(() => {
|
|
297
293
|
var o;
|
|
298
|
-
const e = l(D), t = l(
|
|
294
|
+
const e = l(D), t = l(S);
|
|
299
295
|
return {
|
|
300
296
|
...a,
|
|
301
297
|
...e,
|
|
@@ -308,11 +304,11 @@ const ha = /* @__PURE__ */ Te({
|
|
|
308
304
|
pagination: a.pagination === !1 ? !1 : e.pagination,
|
|
309
305
|
scroll: l(me)
|
|
310
306
|
};
|
|
311
|
-
}),
|
|
307
|
+
}), ge = s(() => [i(), a.card ? null : i("wrapper"), a.adaptive ? i("adaptive") : null].filter(Boolean));
|
|
312
308
|
function we(e, t, o) {
|
|
313
|
-
return Y.includes(e.valueType) ? o : e.copyable || e.ellipsis ?
|
|
309
|
+
return Y.includes(e.valueType) ? o : e.copyable || e.ellipsis ? g(Xe, {
|
|
314
310
|
copyable: e.copyable,
|
|
315
|
-
ellipsis: e.ellipsis ?
|
|
311
|
+
ellipsis: e.ellipsis ? Oe(e.ellipsis) ? {
|
|
316
312
|
tooltip: o,
|
|
317
313
|
rows: 1
|
|
318
314
|
} : {
|
|
@@ -330,37 +326,37 @@ const ha = /* @__PURE__ */ Te({
|
|
|
330
326
|
}, {
|
|
331
327
|
immediate: !0
|
|
332
328
|
});
|
|
333
|
-
function
|
|
329
|
+
function be(e) {
|
|
334
330
|
var t, o, r;
|
|
335
331
|
(r = (o = (t = k.value) == null ? void 0 : t.apForm) == null ? void 0 : o.setFieldsValue) == null || r.call(o, e);
|
|
336
332
|
}
|
|
337
|
-
function
|
|
333
|
+
function he(e = !1) {
|
|
338
334
|
var o, r, d;
|
|
339
335
|
const t = e ? "getFieldsValueTransformed" : "getFieldsValue";
|
|
340
336
|
return (d = (r = (o = k.value) == null ? void 0 : o.apForm) == null ? void 0 : r[t]) == null ? void 0 : d.call(r, !0);
|
|
341
337
|
}
|
|
342
|
-
function
|
|
338
|
+
function Se() {
|
|
343
339
|
return l(u);
|
|
344
340
|
}
|
|
345
341
|
return te({
|
|
346
342
|
submit: () => V(),
|
|
347
343
|
reset: () => A(),
|
|
348
344
|
refresh: () => ie(),
|
|
349
|
-
setSearchFormValues:
|
|
350
|
-
getSearchFormValues:
|
|
351
|
-
getShownColumns:
|
|
345
|
+
setSearchFormValues: be,
|
|
346
|
+
getSearchFormValues: he,
|
|
347
|
+
getShownColumns: Se,
|
|
352
348
|
dataSource: s(() => l(v).records),
|
|
353
349
|
rowSelection: {
|
|
354
|
-
selectedRows: s(() => l(
|
|
355
|
-
...
|
|
350
|
+
selectedRows: s(() => l(R)),
|
|
351
|
+
...C
|
|
356
352
|
}
|
|
357
353
|
}), (e, t) => (p(), T("div", {
|
|
358
|
-
class: f(
|
|
359
|
-
}, [l(m)(e.dataSource) && e.searchForm !== !1 &&
|
|
354
|
+
class: f(ge.value)
|
|
355
|
+
}, [l(m)(e.dataSource) && e.searchForm !== !1 && L.value.length > 0 ? (p(), T("div", {
|
|
360
356
|
key: 0,
|
|
361
357
|
class: f(e.card ? l(x)("search-wrapper") : null),
|
|
362
358
|
style: M(e.searchFormWrapperStyle)
|
|
363
|
-
}, [
|
|
359
|
+
}, [g(l(Ee).SearchForm, w(e.searchForm || {}, {
|
|
364
360
|
ref_key: "formRef",
|
|
365
361
|
ref: k,
|
|
366
362
|
"custom-reset": "",
|
|
@@ -368,16 +364,16 @@ const ha = /* @__PURE__ */ Te({
|
|
|
368
364
|
onSubmit: l(V),
|
|
369
365
|
onReset: l(A)
|
|
370
366
|
}), _({
|
|
371
|
-
default: F(() => [(p(!0), T(q, null, J(
|
|
367
|
+
default: F(() => [(p(!0), T(q, null, J(L.value, (o) => (p(), Q(Be(o.renderNode), w({
|
|
372
368
|
key: o.dataIndex,
|
|
373
369
|
ref_for: !0
|
|
374
370
|
}, o.fieldProps || {}, {
|
|
375
371
|
span: o.span
|
|
376
372
|
}), null, 16, ["span"]))), 128))]),
|
|
377
373
|
_: 2
|
|
378
|
-
}, [
|
|
374
|
+
}, [h.searchFormExtra ? {
|
|
379
375
|
name: "extra",
|
|
380
|
-
fn: F(() => [
|
|
376
|
+
fn: F(() => [b(e.$slots, "searchFormExtra")]),
|
|
381
377
|
key: "0"
|
|
382
378
|
} : void 0]), 1040, ["submit-loading", "onSubmit", "onReset"])], 6)) : X("", !0), I("div", {
|
|
383
379
|
ref_key: "contentRef",
|
|
@@ -391,40 +387,40 @@ const ha = /* @__PURE__ */ Te({
|
|
|
391
387
|
class: f(l(i)("header"))
|
|
392
388
|
}, [I("div", {
|
|
393
389
|
class: f(l(E)("header", "title"))
|
|
394
|
-
}, [
|
|
395
|
-
selectedRows: l(
|
|
396
|
-
selectedRowKeys: l(
|
|
390
|
+
}, [b(e.$slots, "title", w({
|
|
391
|
+
selectedRows: l(R),
|
|
392
|
+
selectedRowKeys: l(S).selectedRowKeys,
|
|
397
393
|
shownColumns: u.value
|
|
398
|
-
},
|
|
394
|
+
}, C))], 2), h.title ? (p(), Q(l(Pe), {
|
|
399
395
|
key: 0,
|
|
400
396
|
type: "vertical"
|
|
401
|
-
})) : X("", !0),
|
|
397
|
+
})) : X("", !0), g(Ye, {
|
|
402
398
|
config: e.settings === !0 ? {} : e.settings
|
|
403
|
-
}, null, 8, ["config"])], 2)) :
|
|
399
|
+
}, null, 8, ["config"])], 2)) : b(e.$slots, "title", w({
|
|
404
400
|
key: 1,
|
|
405
|
-
selectedRows: l(
|
|
406
|
-
selectedRowKeys: l(
|
|
401
|
+
selectedRows: l(R),
|
|
402
|
+
selectedRowKeys: l(S).selectedRowKeys,
|
|
407
403
|
shownColumns: u.value
|
|
408
|
-
},
|
|
404
|
+
}, C))], 2), g(l(Ie), w({
|
|
409
405
|
class: l(i)("table")
|
|
410
406
|
}, j.value, {
|
|
411
407
|
size: B.value,
|
|
412
|
-
"table-layout":
|
|
408
|
+
"table-layout": ye.value,
|
|
413
409
|
columns: u.value,
|
|
414
410
|
onResizeColumn: t[0] || (t[0] = (o, r) => r.width = o)
|
|
415
411
|
}), _({
|
|
416
|
-
summary: F(() => [
|
|
412
|
+
summary: F(() => [b(e.$slots, "summary", {
|
|
417
413
|
columns: u.value,
|
|
418
414
|
records: j.value.dataSource,
|
|
419
|
-
selectedRows: l(
|
|
415
|
+
selectedRows: l(R)
|
|
420
416
|
})]),
|
|
421
417
|
_: 2
|
|
422
|
-
}, [J(l(Z)(
|
|
418
|
+
}, [J(l(Z)(h, ["title", "searchFormExtra", "headerCell", "summary"]), (o, r) => ({
|
|
423
419
|
name: r,
|
|
424
|
-
fn: F((d) => [
|
|
420
|
+
fn: F((d) => [b(e.$slots, r, ke(ze(d || {})))])
|
|
425
421
|
}))]), 1040, ["class", "size", "table-layout", "columns"])], 6)], 2));
|
|
426
422
|
}
|
|
427
423
|
});
|
|
428
424
|
export {
|
|
429
|
-
|
|
425
|
+
ba as default
|
|
430
426
|
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { DataIndex } from '@aplus-frontend/antdv/es/vc-table/interface';
|
|
2
|
+
import { Ref, ComputedRef } from 'vue';
|
|
3
|
+
import { ApTablePaginationConfig, RequestData } from '../interface';
|
|
4
|
+
import { Recordable } from '../../type';
|
|
5
|
+
import { ApFormSearchFormExpose } from '../../ap-form';
|
|
6
|
+
import { TablePaginationConfig } from '@aplus-frontend/antdv';
|
|
7
|
+
import { FilterValue, SorterResult, TableCurrentDataSource } from '@aplus-frontend/antdv/es/table/interface';
|
|
8
|
+
import { ApColumnType } from '..';
|
|
9
|
+
export type UseTablePagingParams<DataType, ParamsType> = {
|
|
10
|
+
request: (params: any) => Promise<RequestData<DataType>>;
|
|
11
|
+
/**
|
|
12
|
+
* 是否手动执行,页面初始化后不执行网络请求,需要手动触发
|
|
13
|
+
* @param params
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
manual?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 额外的默认请求参数
|
|
19
|
+
* @description 如果传入响应式数据,将会在数据改变后重新请求
|
|
20
|
+
*/
|
|
21
|
+
defaultParams?: ParamsType | Ref<ParamsType>;
|
|
22
|
+
/**
|
|
23
|
+
* 默认的数据源(只生效一次)
|
|
24
|
+
*/
|
|
25
|
+
defaultData?: DataType[];
|
|
26
|
+
/**
|
|
27
|
+
* 数据请求前格式化请求参数
|
|
28
|
+
* @param values
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
formatParams?: (values: any) => any;
|
|
32
|
+
/**
|
|
33
|
+
* 特殊类型参数类型对照表(会根据该对照表运行默认的参数格式化)
|
|
34
|
+
*/
|
|
35
|
+
paramsValueTypeMap?: Record<string, any>;
|
|
36
|
+
/**
|
|
37
|
+
* 重设表单需要忽略的字段
|
|
38
|
+
*/
|
|
39
|
+
resetFieldsIgnores?: string[];
|
|
40
|
+
/**
|
|
41
|
+
* 需要后端筛选的字段列表
|
|
42
|
+
*/
|
|
43
|
+
filterFields?: Ref<DataIndex[]>;
|
|
44
|
+
/**
|
|
45
|
+
* 需要后端筛选的排序字段列表
|
|
46
|
+
*/
|
|
47
|
+
sortFields?: Ref<DataIndex[]>;
|
|
48
|
+
/**
|
|
49
|
+
* 分页相关
|
|
50
|
+
*/
|
|
51
|
+
pagination?: boolean | ApTablePaginationConfig;
|
|
52
|
+
};
|
|
53
|
+
type InternalDataType<DataType = Recordable> = {
|
|
54
|
+
total: number;
|
|
55
|
+
records: DataType[];
|
|
56
|
+
loading: boolean;
|
|
57
|
+
};
|
|
58
|
+
export declare const useTablePaging: <DataType = any, ParamsType = Record<string, any>>({ manual, request, defaultParams, defaultData, formatParams, paramsValueTypeMap, resetFieldsIgnores, filterFields, sortFields, pagination }: UseTablePagingParams<DataType, ParamsType>) => {
|
|
59
|
+
formRef: Ref<ApFormSearchFormExpose | undefined, ApFormSearchFormExpose | undefined>;
|
|
60
|
+
submit: () => void;
|
|
61
|
+
reset: () => void;
|
|
62
|
+
refresh: () => void;
|
|
63
|
+
refreshByDelete: (n: number) => void;
|
|
64
|
+
data: InternalDataType<DataType>;
|
|
65
|
+
current: number | undefined;
|
|
66
|
+
pageSize: number | undefined;
|
|
67
|
+
handleTableChange: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<any> | SorterResult<any>[], extra: TableCurrentDataSource<any>) => void;
|
|
68
|
+
tableProps: ComputedRef<{
|
|
69
|
+
loading: boolean;
|
|
70
|
+
pagination: {
|
|
71
|
+
current: number;
|
|
72
|
+
pageSize: number;
|
|
73
|
+
total: number;
|
|
74
|
+
showSizeChanger: boolean;
|
|
75
|
+
showQuickJumper: boolean;
|
|
76
|
+
showLessItems: boolean | undefined;
|
|
77
|
+
size: string;
|
|
78
|
+
showTotal: ((total: number) => import("vue/jsx-runtime").JSX.Element) | undefined;
|
|
79
|
+
};
|
|
80
|
+
onChange: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<any> | SorterResult<any>[], extra: TableCurrentDataSource<any>) => void;
|
|
81
|
+
dataSource: DataType[];
|
|
82
|
+
}>;
|
|
83
|
+
dataSource: ComputedRef<DataType[]>;
|
|
84
|
+
setDataSource: (dataSource?: DataType[]) => void;
|
|
85
|
+
getColumnSFConfig: (column: ApColumnType) => Recordable;
|
|
86
|
+
};
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { ref as ee, reactive as q, unref as h, nextTick as te, onMounted as re, watch as oe, computed as A, createVNode as x } from "vue";
|
|
2
|
+
import { useTableSortedAndFiltered as ne } from "./use-sorted-filtered.mjs";
|
|
3
|
+
import "../../config-provider/index.mjs";
|
|
4
|
+
import { parseFieldValue as ae, dataIndexToStr as se, isEqualCustom as ce } from "../utils.mjs";
|
|
5
|
+
import { isArray as I, isEqualWith as ie } from "lodash-unified";
|
|
6
|
+
import { useLocale as le } from "../../config-provider/hooks/use-locale.mjs";
|
|
7
|
+
import { useNamespace as ue } from "../../config-provider/hooks/use-namespace.mjs";
|
|
8
|
+
const C = 1, N = 10;
|
|
9
|
+
function fe(g) {
|
|
10
|
+
const l = {};
|
|
11
|
+
return g && (g === !0 ? (l.current = C, l.pageSize = N) : (l.current = g.defaultCurrent || C, l.pageSize = g.defaultPageSize || N)), l;
|
|
12
|
+
}
|
|
13
|
+
const Te = ({
|
|
14
|
+
manual: g = !1,
|
|
15
|
+
request: l,
|
|
16
|
+
defaultParams: L = {},
|
|
17
|
+
defaultData: v = [],
|
|
18
|
+
formatParams: y,
|
|
19
|
+
paramsValueTypeMap: D,
|
|
20
|
+
resetFieldsIgnores: R,
|
|
21
|
+
filterFields: U,
|
|
22
|
+
sortFields: B,
|
|
23
|
+
pagination: p = {
|
|
24
|
+
defaultCurrent: 1,
|
|
25
|
+
defaultPageSize: 10,
|
|
26
|
+
showLessItems: !1,
|
|
27
|
+
showTotal: !0
|
|
28
|
+
}
|
|
29
|
+
}) => {
|
|
30
|
+
let b = 0, s = {};
|
|
31
|
+
const K = p ?? {}, M = (e) => y ? y(e) : e, S = ee(), c = q(fe(p)), {
|
|
32
|
+
getColumnSFConfig: $,
|
|
33
|
+
setSF: G,
|
|
34
|
+
clearAll: J
|
|
35
|
+
} = ne(), {
|
|
36
|
+
t: z
|
|
37
|
+
} = le(), {
|
|
38
|
+
b: T
|
|
39
|
+
} = ue("ap-table"), o = q({
|
|
40
|
+
total: v.length,
|
|
41
|
+
records: v,
|
|
42
|
+
loading: !1
|
|
43
|
+
}), P = () => {
|
|
44
|
+
var e, t;
|
|
45
|
+
return ((t = (e = S.value) == null ? void 0 : e.apForm) == null ? void 0 : t.getFieldsValueTransformed(!0)) || {};
|
|
46
|
+
}, V = async (e) => {
|
|
47
|
+
var n;
|
|
48
|
+
const t = M(e), r = Date.now();
|
|
49
|
+
b = r, o.loading = !0;
|
|
50
|
+
try {
|
|
51
|
+
const a = await l({
|
|
52
|
+
...h(L),
|
|
53
|
+
...t
|
|
54
|
+
});
|
|
55
|
+
b === r && (o.total = a.total || ((n = a.data) == null ? void 0 : n.length) || 0, o.records = [...a.data || []]);
|
|
56
|
+
} catch {
|
|
57
|
+
b === r && (o.records = [], o.total = 0);
|
|
58
|
+
} finally {
|
|
59
|
+
o.loading = !1;
|
|
60
|
+
}
|
|
61
|
+
}, O = (e) => {
|
|
62
|
+
const t = {};
|
|
63
|
+
return Object.entries(e).forEach(([r, n]) => {
|
|
64
|
+
if (t[r] = n, D && n) {
|
|
65
|
+
const a = D[r];
|
|
66
|
+
a && (t[r] = ae(a, n));
|
|
67
|
+
}
|
|
68
|
+
}), t;
|
|
69
|
+
}, Q = async (e) => {
|
|
70
|
+
var n, a, u, f, d;
|
|
71
|
+
const t = P(), r = {};
|
|
72
|
+
Object.entries(t).forEach(([m, w]) => {
|
|
73
|
+
R && R.indexOf(m) > -1 && (r[m] = w);
|
|
74
|
+
}), await ((a = (n = S.value) == null ? void 0 : n.apForm) == null ? void 0 : a.resetFields()), (d = (f = (u = S.value) == null ? void 0 : u.apForm) == null ? void 0 : f.setFieldsValue) == null || d.call(f, r), te(() => {
|
|
75
|
+
e == null || e();
|
|
76
|
+
});
|
|
77
|
+
}, F = (e) => {
|
|
78
|
+
s = e;
|
|
79
|
+
const t = O(e);
|
|
80
|
+
V(t);
|
|
81
|
+
}, W = (e) => {
|
|
82
|
+
F({
|
|
83
|
+
...s,
|
|
84
|
+
...e
|
|
85
|
+
});
|
|
86
|
+
}, E = () => {
|
|
87
|
+
const e = P();
|
|
88
|
+
p && (c.current = C), F({
|
|
89
|
+
...e,
|
|
90
|
+
filter: s.filter,
|
|
91
|
+
sort: s.sort,
|
|
92
|
+
current: p ? C : void 0,
|
|
93
|
+
pageSize: p ? s.pageSize || c.pageSize : void 0
|
|
94
|
+
});
|
|
95
|
+
}, Z = () => {
|
|
96
|
+
J(), s.sort = {}, s.filter = {}, Q(E);
|
|
97
|
+
}, _ = () => {
|
|
98
|
+
F(s);
|
|
99
|
+
}, H = (e) => {
|
|
100
|
+
if (!p)
|
|
101
|
+
_();
|
|
102
|
+
else {
|
|
103
|
+
const {
|
|
104
|
+
current: t,
|
|
105
|
+
pageSize: r
|
|
106
|
+
} = c, n = o.total - e, a = Math.ceil(n / r), u = t > a ? a : t;
|
|
107
|
+
W({
|
|
108
|
+
current: u > 0 ? u : 1
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}, j = (e, t, r) => {
|
|
112
|
+
var m, w;
|
|
113
|
+
const n = P();
|
|
114
|
+
c.current = e.current, c.pageSize = e.pageSize, G(t, r);
|
|
115
|
+
const a = I(r) ? [...r] : [r], u = {};
|
|
116
|
+
for (const i of a)
|
|
117
|
+
(m = h(B)) != null && m.includes(i.columnKey || i.field) && i.order && (u[se(i.columnKey || i.field)] = i.order);
|
|
118
|
+
const f = {};
|
|
119
|
+
for (const i of Object.keys(t))
|
|
120
|
+
(w = h(U)) != null && w.includes(i) && t[i] && (f[i] = t[i]);
|
|
121
|
+
const d = {
|
|
122
|
+
...n,
|
|
123
|
+
filter: f,
|
|
124
|
+
sort: u,
|
|
125
|
+
current: e.current,
|
|
126
|
+
pageSize: e.pageSize
|
|
127
|
+
};
|
|
128
|
+
ie(s, d, ce) || F(d);
|
|
129
|
+
};
|
|
130
|
+
re(() => {
|
|
131
|
+
const e = P(), {
|
|
132
|
+
current: t,
|
|
133
|
+
pageSize: r
|
|
134
|
+
} = c;
|
|
135
|
+
if (s = {
|
|
136
|
+
current: t,
|
|
137
|
+
pageSize: r,
|
|
138
|
+
filter: {},
|
|
139
|
+
sort: {},
|
|
140
|
+
...e
|
|
141
|
+
}, !g) {
|
|
142
|
+
const n = O(s);
|
|
143
|
+
V(n);
|
|
144
|
+
}
|
|
145
|
+
}), oe(() => h(L), () => {
|
|
146
|
+
E();
|
|
147
|
+
}, {
|
|
148
|
+
deep: !0
|
|
149
|
+
});
|
|
150
|
+
const X = A(() => {
|
|
151
|
+
if (o.total === 0)
|
|
152
|
+
return "-";
|
|
153
|
+
const {
|
|
154
|
+
current: e,
|
|
155
|
+
pageSize: t
|
|
156
|
+
} = c;
|
|
157
|
+
return `${e}/${Math.ceil(o.total / t)}`;
|
|
158
|
+
});
|
|
159
|
+
function Y(e) {
|
|
160
|
+
I(e) && (o.records = e, o.total = e.length);
|
|
161
|
+
}
|
|
162
|
+
const k = A(() => {
|
|
163
|
+
const {
|
|
164
|
+
showLessItems: e,
|
|
165
|
+
showTotal: t
|
|
166
|
+
} = K;
|
|
167
|
+
return {
|
|
168
|
+
loading: o.loading,
|
|
169
|
+
pagination: {
|
|
170
|
+
current: c.current,
|
|
171
|
+
pageSize: c.pageSize,
|
|
172
|
+
total: o.total,
|
|
173
|
+
showSizeChanger: !e,
|
|
174
|
+
showQuickJumper: !e,
|
|
175
|
+
showLessItems: e,
|
|
176
|
+
size: "default",
|
|
177
|
+
showTotal: t ? (r) => x("span", {
|
|
178
|
+
class: T("pagination-total-wrapper")
|
|
179
|
+
}, [z("ap.apTable.pagination.totalLeftPrefix"), " ", x("span", {
|
|
180
|
+
class: T("pagination-count-text")
|
|
181
|
+
}, [r]), " ", z("ap.apTable.pagination.totalLeftSuffix"), x("span", {
|
|
182
|
+
class: T("pagination--total-right")
|
|
183
|
+
}, [z("ap.apTable.pagination.totalRightPrefix"), " ", x("span", {
|
|
184
|
+
class: T("pagination-count-text")
|
|
185
|
+
}, [h(X)]), " ", z("ap.apTable.pagination.totalRightSuffix")])]) : void 0
|
|
186
|
+
},
|
|
187
|
+
onChange: j,
|
|
188
|
+
dataSource: o.records
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
formRef: S,
|
|
193
|
+
submit: E,
|
|
194
|
+
reset: Z,
|
|
195
|
+
refresh: _,
|
|
196
|
+
refreshByDelete: H,
|
|
197
|
+
data: o,
|
|
198
|
+
current: c.current,
|
|
199
|
+
pageSize: c.pageSize,
|
|
200
|
+
handleTableChange: j,
|
|
201
|
+
tableProps: k,
|
|
202
|
+
dataSource: A(() => o.records),
|
|
203
|
+
setDataSource: Y,
|
|
204
|
+
getColumnSFConfig: $
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
export {
|
|
208
|
+
Te as useTablePaging
|
|
209
|
+
};
|
|
@@ -67,6 +67,12 @@ export type UseTablePagingParams<DataType, ParamsType> = {
|
|
|
67
67
|
*/
|
|
68
68
|
pagination?: boolean;
|
|
69
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* ApTable表格分页请求和管理数据实现
|
|
72
|
+
* @deprecated 已弃用,将在下一个次要版本移出,请自行实现
|
|
73
|
+
* @param param0
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
70
76
|
export declare const useTablePaging: <DataType = any, ParamsType = Record<string, any>>({ manual, defaultCurrent, defaultPageSize, request, defaultParams, defaultData, formatParams, paramsValueTypeMap, resetFieldsIgnores, filterFields, sortFields, showLessItems, showTotal, pagination }: UseTablePagingParams<DataType, ParamsType>) => {
|
|
71
77
|
formRef: Ref<ApFormSearchFormExpose | undefined, ApFormSearchFormExpose | undefined>;
|
|
72
78
|
submit: () => void;
|
|
@@ -3,7 +3,7 @@ import { CompareFn, SortOrder, TableRowSelection } from '@aplus-frontend/antdv/e
|
|
|
3
3
|
import { ApFormItemProps, ApFormSearchFormProps } from '../ap-form';
|
|
4
4
|
import { ApFormItemCheckboxProps, ApFormItemDateProps, ApFormItemDateRangeProps, ApFormItemNumberProps, ApFormItemRadioProps, ApFormItemSelectProps, ApFormItemSwitchProps, ApFormItemTextAreaProps, ApFormItemTextPasswordProps, ApFormItemTextProps } from '../ap-form/items/interface';
|
|
5
5
|
import { Recordable } from '../type';
|
|
6
|
-
import { ComputedRef, CSSProperties, VNode } from 'vue';
|
|
6
|
+
import { ComputedRef, CSSProperties, Ref, VNode } from 'vue';
|
|
7
7
|
import { ApActionGroupProps } from '../ap-action';
|
|
8
8
|
import { ApTableIndexProps } from './components/interface';
|
|
9
9
|
import { EllipsisConfig } from '@aplus-frontend/antdv/es/typography/Base';
|
|
@@ -243,9 +243,10 @@ export type ApTableProps<RecordType = any, ParamsType = any> = Omit<TableProps<R
|
|
|
243
243
|
*/
|
|
244
244
|
card?: boolean;
|
|
245
245
|
/**
|
|
246
|
-
* request
|
|
246
|
+
* request额外请求的参数
|
|
247
|
+
* 如果传入响应式数据,将会在变更后重新执行
|
|
247
248
|
*/
|
|
248
|
-
params?: ParamsType
|
|
249
|
+
params?: ParamsType | Ref<ParamsType>;
|
|
249
250
|
/**
|
|
250
251
|
* 自定义渲染搜索表单
|
|
251
252
|
* @deprecated 未实现 暂不可用
|
|
@@ -23,6 +23,7 @@ declare const ApSelectLayout: (<T extends ApSelectItem>(__VLS_props: NonNullable
|
|
|
23
23
|
request: () => Promise<T[]>;
|
|
24
24
|
onSearch?: ((item: T, val: string) => boolean) | undefined;
|
|
25
25
|
defaultFold?: boolean | undefined;
|
|
26
|
+
defaultValue?: string | undefined;
|
|
26
27
|
} & PublicProps;
|
|
27
28
|
expose(exposed: ShallowUnwrapRef<{}>): void;
|
|
28
29
|
attrs: any;
|