@aplus-frontend/ui 0.3.9 → 0.3.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-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 +58 -56
- 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/package.json +1 -1
|
@@ -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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as O, ref as r, computed as U, onMounted as W, openBlock as
|
|
1
|
+
import { defineComponent as O, ref as r, computed as U, onMounted as W, openBlock as p, createElementBlock as m, normalizeClass as a, unref as t, createVNode as d, Transition as z, withCtx as c, withDirectives as V, createElementVNode as s, toDisplayString as E, createTextVNode as $, Fragment as R, renderList as _, renderSlot as x, vShow as A, createCommentVNode as j } from "vue";
|
|
2
2
|
import "../../ap-field/index.mjs";
|
|
3
3
|
import { IconApLeftarrow as G, IconApMenu as H } from "@aplus-frontend/icon";
|
|
4
4
|
import "../../config-provider/index.mjs";
|
|
5
|
-
import { Tooltip as
|
|
5
|
+
import { Tooltip as N, TypographyText as J } from "@aplus-frontend/antdv";
|
|
6
6
|
import { debounce as K } from "lodash-unified";
|
|
7
7
|
import { useNamespace as P } from "../../config-provider/hooks/use-namespace.mjs";
|
|
8
8
|
import { ApFieldText as Q } from "../../ap-field/text/index.mjs";
|
|
@@ -12,37 +12,38 @@ const X = ["onClick"], re = /* @__PURE__ */ O({
|
|
|
12
12
|
title: {},
|
|
13
13
|
request: {},
|
|
14
14
|
onSearch: {},
|
|
15
|
-
defaultFold: { type: Boolean, default: !1 }
|
|
15
|
+
defaultFold: { type: Boolean, default: !1 },
|
|
16
|
+
defaultValue: { default: "" }
|
|
16
17
|
},
|
|
17
18
|
emits: ["onSelect", "afterEnter", "afterLeave"],
|
|
18
19
|
setup(w, { emit: B }) {
|
|
19
|
-
const { b:
|
|
20
|
-
v.value = !v.value,
|
|
21
|
-
}, F = (
|
|
22
|
-
|
|
23
|
-
}, q = K((
|
|
20
|
+
const { b: h, be: y, bem: u } = P("ap-select-layout"), o = w, C = B, g = r(), v = r(o.defaultFold), S = r(!o.defaultFold), T = r(), b = r(), k = r(), f = r(o.defaultValue), L = () => {
|
|
21
|
+
v.value = !v.value, T.value = !1, b.value = !1;
|
|
22
|
+
}, F = (l) => {
|
|
23
|
+
k.value = l, C("onSelect", l);
|
|
24
|
+
}, q = K((l) => {
|
|
24
25
|
var e;
|
|
25
|
-
|
|
26
|
+
f.value = (e = l.target) == null ? void 0 : e.value;
|
|
26
27
|
}, 500), D = U(() => {
|
|
27
|
-
var
|
|
28
|
-
return (
|
|
29
|
-
var
|
|
30
|
-
return
|
|
28
|
+
var l;
|
|
29
|
+
return (l = g.value) == null ? void 0 : l.filter((e) => {
|
|
30
|
+
var i, n;
|
|
31
|
+
return o != null && o.onSearch ? (i = o.onSearch) == null ? void 0 : i.call(o, e, f.value) : (n = e == null ? void 0 : e.name) == null ? void 0 : n.includes(f.value);
|
|
31
32
|
});
|
|
32
|
-
}), I = (
|
|
33
|
-
|
|
34
|
-
}, M = (
|
|
35
|
-
|
|
33
|
+
}), I = (l) => {
|
|
34
|
+
S.value = !0, C("afterEnter", l);
|
|
35
|
+
}, M = (l) => {
|
|
36
|
+
S.value = !1, C("afterLeave", l);
|
|
36
37
|
};
|
|
37
38
|
return W(() => {
|
|
38
|
-
|
|
39
|
+
o.request().then((l) => {
|
|
39
40
|
var e;
|
|
40
|
-
|
|
41
|
+
g.value = l, F((e = g.value) == null ? void 0 : e[0]);
|
|
41
42
|
});
|
|
42
|
-
}), (
|
|
43
|
-
var
|
|
44
|
-
return
|
|
45
|
-
class:
|
|
43
|
+
}), (l, e) => {
|
|
44
|
+
var i;
|
|
45
|
+
return p(), m("div", {
|
|
46
|
+
class: a(t(h)())
|
|
46
47
|
}, [
|
|
47
48
|
d(z, {
|
|
48
49
|
mode: "out-in",
|
|
@@ -50,22 +51,22 @@ const X = ["onClick"], re = /* @__PURE__ */ O({
|
|
|
50
51
|
onAfterLeave: M
|
|
51
52
|
}, {
|
|
52
53
|
default: c(() => [
|
|
53
|
-
|
|
54
|
-
class:
|
|
54
|
+
V(s("div", {
|
|
55
|
+
class: a(t(h)("side"))
|
|
55
56
|
}, [
|
|
56
57
|
s("div", {
|
|
57
|
-
class:
|
|
58
|
+
class: a(t(y)("side", "header"))
|
|
58
59
|
}, [
|
|
59
|
-
s("h3", null,
|
|
60
|
+
s("h3", null, E(o.title), 1),
|
|
60
61
|
s("div", {
|
|
61
|
-
class:
|
|
62
|
+
class: a(t(u)("side", "header", "imgWrap"))
|
|
62
63
|
}, [
|
|
63
|
-
d(t(
|
|
64
|
-
open:
|
|
65
|
-
"onUpdate:open": e[0] || (e[0] = (
|
|
64
|
+
d(t(N), {
|
|
65
|
+
open: T.value,
|
|
66
|
+
"onUpdate:open": e[0] || (e[0] = (n) => T.value = n)
|
|
66
67
|
}, {
|
|
67
68
|
title: c(() => e[2] || (e[2] = [
|
|
68
|
-
|
|
69
|
+
$("收起")
|
|
69
70
|
])),
|
|
70
71
|
default: c(() => [
|
|
71
72
|
d(t(G), { onClick: L })
|
|
@@ -75,57 +76,58 @@ const X = ["onClick"], re = /* @__PURE__ */ O({
|
|
|
75
76
|
], 2)
|
|
76
77
|
], 2),
|
|
77
78
|
s("div", {
|
|
78
|
-
class:
|
|
79
|
+
class: a(t(y)("side", "body"))
|
|
79
80
|
}, [
|
|
80
81
|
s("div", {
|
|
81
|
-
class:
|
|
82
|
+
class: a(t(u)("side", "body", "search"))
|
|
82
83
|
}, [
|
|
83
84
|
d(t(Q), {
|
|
84
85
|
placeholder: "请输入",
|
|
86
|
+
value: f.value,
|
|
85
87
|
onChange: t(q)
|
|
86
|
-
}, null, 8, ["onChange"])
|
|
88
|
+
}, null, 8, ["value", "onChange"])
|
|
87
89
|
], 2),
|
|
88
90
|
s("div", {
|
|
89
|
-
class:
|
|
91
|
+
class: a(t(u)("side", "body", "scroll"))
|
|
90
92
|
}, [
|
|
91
|
-
(
|
|
92
|
-
key:
|
|
93
|
-
class:
|
|
94
|
-
onClick: (Y) => F(
|
|
93
|
+
(p(!0), m(R, null, _(D.value, (n) => V((p(), m("div", {
|
|
94
|
+
key: n.value,
|
|
95
|
+
class: a(`${t(u)("side", "body", "scroll-item")} ${k.value === n ? "active" : ""}`),
|
|
96
|
+
onClick: (Y) => F(n)
|
|
95
97
|
}, [
|
|
96
|
-
|
|
98
|
+
x(l.$slots, "itemRender", { item: n }, () => [
|
|
97
99
|
d(t(J), {
|
|
98
|
-
ellipsis: { tooltip:
|
|
99
|
-
content: `${
|
|
100
|
+
ellipsis: { tooltip: n.name },
|
|
101
|
+
content: `${n.name}`
|
|
100
102
|
}, null, 8, ["ellipsis", "content"])
|
|
101
103
|
])
|
|
102
104
|
], 10, X)), [
|
|
103
|
-
[
|
|
105
|
+
[A, S.value]
|
|
104
106
|
])), 128))
|
|
105
107
|
], 2)
|
|
106
108
|
], 2)
|
|
107
109
|
], 2), [
|
|
108
|
-
[
|
|
110
|
+
[A, !v.value]
|
|
109
111
|
])
|
|
110
112
|
]),
|
|
111
113
|
_: 3
|
|
112
114
|
}),
|
|
113
115
|
s("div", {
|
|
114
|
-
class:
|
|
116
|
+
class: a(t(h)("content"))
|
|
115
117
|
}, [
|
|
116
118
|
s("div", {
|
|
117
|
-
class:
|
|
119
|
+
class: a(t(y)("content", "header"))
|
|
118
120
|
}, [
|
|
119
|
-
v.value ? (
|
|
121
|
+
v.value ? (p(), m("div", {
|
|
120
122
|
key: 0,
|
|
121
|
-
class:
|
|
123
|
+
class: a(t(u)("content", "header", "imgWrap"))
|
|
122
124
|
}, [
|
|
123
|
-
d(t(
|
|
124
|
-
open:
|
|
125
|
-
"onUpdate:open": e[1] || (e[1] = (
|
|
125
|
+
d(t(N), {
|
|
126
|
+
open: b.value,
|
|
127
|
+
"onUpdate:open": e[1] || (e[1] = (n) => b.value = n)
|
|
126
128
|
}, {
|
|
127
129
|
title: c(() => e[3] || (e[3] = [
|
|
128
|
-
|
|
130
|
+
$("展开")
|
|
129
131
|
])),
|
|
130
132
|
default: c(() => [
|
|
131
133
|
d(t(H), { onClick: L })
|
|
@@ -134,10 +136,10 @@ const X = ["onClick"], re = /* @__PURE__ */ O({
|
|
|
134
136
|
}, 8, ["open"])
|
|
135
137
|
], 2)) : j("", !0),
|
|
136
138
|
s("div", {
|
|
137
|
-
class:
|
|
138
|
-
},
|
|
139
|
+
class: a(t(u)("content", "header", "title"))
|
|
140
|
+
}, E((i = k.value) == null ? void 0 : i.name), 3)
|
|
139
141
|
], 2),
|
|
140
|
-
|
|
142
|
+
x(l.$slots, "default")
|
|
141
143
|
], 2)
|
|
142
144
|
], 2);
|
|
143
145
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=require("@aplus-frontend/antdv")
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=require("@aplus-frontend/antdv"),R=require("../ap-table/hooks/use-table-paging-ng.js");require("../config-provider/index.js");const c=require("lodash-unified"),$=require("./hooks/use-offline-list.js");require("vue-virtual-scroller/dist/vue-virtual-scroller.css");const m=require("vue-virtual-scroller"),j=require("../config-provider/hooks/use-namespace.js"),A=e.defineComponent({__name:"index",props:{dataSource:{},loading:{type:Boolean,default:void 0},onItem:{},params:{},request:{},defaultData:{},onLoadingChange:{},beforeSearchSubmit:{},pagination:{type:[Boolean,Object],default:void 0},manual:{type:Boolean},containerStyle:{type:[Boolean,null,String,Object,Array]},contentStyle:{type:[Boolean,null,String,Object,Array]},footerWarpperStyle:{type:[Boolean,null,String,Object,Array]},virtual:{default:void 0},rowKey:{}},setup(b,{expose:C}){const z=s.Empty.PRESENTED_IMAGE_SIMPLE,r=b,{b:i,e:w}=j.useNamespace("ap-list"),g=e.ref(),{formRef:p,submit:S,reset:y,handleTableChange:q,data:f,refresh:P,refreshByDelete:D,tableProps:h}=R.useTablePaging({async request(t){var a;const n=await((a=r.request)==null?void 0:a.call(r,t));return{data:(n==null?void 0:n.data)||[],total:(n==null?void 0:n.total)||0}},defaultParams:r.params,defaultData:r.defaultData,manual:r.manual,pagination:r.pagination,formatParams:r.beforeSearchSubmit}),E={form:p},{pagination:v,dataSource:N,onChange:V}=$.useOfflineList(r);function I(t,n){if(e.unref(u)){V(t,n);return}q({current:t,pageSize:n},{},{},{currentDataSource:[],action:"paginate"})}const l=e.computed(()=>e.unref(u)?e.unref(N):e.unref(f).records),d=e.computed(()=>c.isUndefined(r.loading)?e.unref(f).loading:r.loading),O=e.computed(()=>{var t,n;return r.pagination===!1||r.virtual?!1:((t=r.pagination)==null?void 0:t.hideOnSinglePage)!==!0?!0:e.unref(u)?(((n=r.dataSource)==null?void 0:n.length)||0)>e.unref(v).pageSize:e.unref(f).total>e.unref(h).pagination.pageSize}),u=e.computed(()=>!c.isUndefined(r.dataSource));e.watch(()=>e.unref(d),t=>{var n;(n=r.onLoadingChange)==null||n.call(r,t)});function T(t){var n,a;(a=(n=g.value)==null?void 0:n.querySelector(t||":first-child"))==null||a.scrollIntoView({behavior:"smooth",block:"center"})}function F(t=!1){var o;const n=(o=p.value)==null?void 0:o.apForm,a=t?n==null?void 0:n.getFieldsValueTransformed:n==null?void 0:n.getFieldsValue;return(a==null?void 0:a())||{}}return C({submit:()=>S(),reset:()=>y(),refresh:()=>P(),refreshByDelete:t=>D(t),scrollToFirstRow:T,getSearchFormValuesIfSetted:F}),(t,n)=>(e.openBlock(),e.createBlock(e.unref(s.Spin),{spinning:d.value,class:e.normalizeClass(e.unref(i)("spin"))},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(i)()),style:e.normalizeStyle(t.containerStyle)},[e.renderSlot(t.$slots,"header",{formIns:E,submit:e.unref(S),reset:e.unref(y)}),l.value.length===0?e.renderSlot(t.$slots,"empty",{key:0,loading:d.value},()=>[e.createVNode(e.unref(s.Empty),{image:e.unref(z)},null,8,["image"])]):(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"contentRef",ref:g,style:e.normalizeStyle(t.contentStyle)},[t.virtual?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.unref(c.isNumber)(t.virtual)?(e.openBlock(),e.createBlock(e.unref(m.RecycleScroller),{key:0,class:e.normalizeClass(e.unref(i)("scroll-wrapper")),items:l.value,"item-size":t.virtual,"key-field":r.rowKey||"id"},{default:e.withCtx(({item:a,index:o})=>[e.renderSlot(t.$slots,"renderItem",{item:a,index:o})]),_:3},8,["class","items","item-size","key-field"])):(e.openBlock(),e.createBlock(e.unref(m.DynamicScroller),{key:1,items:l.value,"min-item-size":t.virtual.minItemSize,class:e.normalizeClass(e.unref(i)("scroll-wrapper"))},{default:e.withCtx(({item:a,index:o,active:L})=>{var k,B;return[e.createVNode(e.unref(m.DynamicScrollerItem),{item:a,active:L,"data-index":o,"size-dependencies":(B=(k=t.virtual).sizeDependencies)==null?void 0:B.call(k,a)},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"renderItem",{item:a,index:o})]),_:2},1032,["item","active","data-index","size-dependencies"])]}),_:3},8,["items","min-item-size","class"]))],64)):e.renderSlot(t.$slots,"renderContent",{key:1,dataSource:l.value},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(a,o)=>e.renderSlot(t.$slots,"renderItem",{item:a,index:o})),256))])],4)),O.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(e.unref(w)("footer")),style:e.normalizeStyle(t.footerWarpperStyle)},[e.createVNode(e.unref(s.Pagination),e.mergeProps(u.value?e.unref(v):e.unref(c.omit)(e.unref(h).pagination,["showTotal"]),{onChange:I}),null,16)],6)):e.createCommentVNode("",!0)],6)]),_:3},8,["spinning","class"]))}});exports.default=A;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StyleValue } from 'vue';
|
|
1
|
+
import { Ref, StyleValue } from 'vue';
|
|
2
2
|
import { RequestData } from '../ap-table';
|
|
3
3
|
import { Recordable } from '../type';
|
|
4
4
|
export type ApListProps<RecordType = any, ParamsType = Recordable> = {
|
|
@@ -16,9 +16,9 @@ export type ApListProps<RecordType = any, ParamsType = Recordable> = {
|
|
|
16
16
|
*/
|
|
17
17
|
onItem?: (record: RecordType, index: number) => void;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* 依赖的额外的参数,传入响应式参数会在变更后重新执行
|
|
20
20
|
*/
|
|
21
|
-
params?: ParamsType
|
|
21
|
+
params?: ParamsType | Ref<ParamsType>;
|
|
22
22
|
/**
|
|
23
23
|
* 请求数据
|
|
24
24
|
* @param params
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),L=require("@aplus-frontend/antdv"),le=require("@aplus-frontend/antdv/es/theme/internal"),se=require("../ap-form/index.js"),O=require("./constants.js");require("../config-provider/index.js");const ue=require("./hooks/use-table-paging.js"),i=require("lodash-unified"),s=require("./utils.js"),de=require("./hooks/use-table-content-height.js"),ie=require("./hooks/use-table-row-selection.js"),ce=require("../utils/index.js");require("./components/setting/modal/index.vue.js");require("./components/paragraph-ellipsis/index.vue.js");const fe=require("./context.js"),pe=require("../config-provider/hooks/use-namespace.js"),me=require("../config-provider/hooks/use-global-config.js"),ge=require("./components/paragraph-ellipsis/index.vue2.js"),ye=require("./components/setting/modal/index.vue2.js"),Se=e.defineComponent({name:"ApTable",__name:"ap-table",props:{dropdownPrefixCls:{},loading:{type:[Boolean,Object],default:void 0},bordered:{type:Boolean,default:!1},locale:{},onChange:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!1},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:{},rowSelection:{type:[Boolean,Object]},card:{type:Boolean,default:!1},params:{},searchFormRender:{},request:{},onLoad:{},defaultData:{},dataSource:{},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},columnResizable:{type:Boolean,default:!1},settings:{type:[Boolean,Object],default:void 0}},setup(_,{expose:K}){const t=_;let R=0;const m=e.useSlots(),[,A]=le.useToken(),{e:w,b:c,be:B}=pe.useNamespace("ap-table"),T=me.useGlobalConfig("valueTypeMap"),{height:U,contentRef:D}=de.default(),b=e.ref(t.size),d=e.ref([]),x=e.ref([]);fe.useProvideApTable({columns:e.computed(()=>d.value),columnsBackup:e.computed(()=>x.value),size:e.computed(()=>b.value),updateColumns(r){d.value=r},updateSize(r){b.value=r}});const F=e.computed(()=>{var r,a,n;return R++,((n=(a=(r=t.columns)==null?void 0:r.filter(o=>!o.hideInSearch&&o.dataIndex&&(o.valueType||o.customRenderFormItem)&&!O.noRenderAsFormItemValueList.includes(o.valueType)))==null?void 0:a.sort((o,u)=>{let l=s.getColumnOrder(o.order);return s.getColumnOrder(u.order)-l}))==null?void 0:n.map(o=>{const u=s.updateFormProps(o,s.getFieldProps(o.fieldProps,{})),l={...o,fieldProps:{label:o.title,name:o.dataIndex,...u||{},_signal:R},renderNode:void 0};return l.renderNode=s.getSearchFormItemRenderNode(l,e.unref(T)),l}))||[]}),j=e.computed(()=>s.recursionApColumns(e.unref(d),r=>{if(r.sorter===!0)return r.key||r.dataIndex}).filter(Boolean)),$=e.computed(()=>s.recursionApColumns(e.unref(d),r=>{if(r.filters&&!r.onFilter)return r.key||r.dataIndex}).filter(Boolean)),W=e.computed(()=>i.isUndefined(t.dataSource)?h.value.records:t.dataSource),{rowSelection:g,selectedRows:y,...S}=ie.default({fixed:!0,...t.rowSelection===!0?{}:t.rowSelection,rowKey:t.rowKey,dataSource:W}),{formRef:C,submit:k,reset:z,tableProps:P,refresh:H,data:h,setDataSource:M,getColumnSFConfig:G}=ue.useTablePaging({async request(r){var n,o;if(!g.value.preserveSelectedRowKeys&&i.isUndefined(t.dataSource)&&S.clearAll(),!i.isUndefined(t.dataSource))return{data:t.dataSource||[],total:t.dataSource.length||0};const a=await((n=t.request)==null?void 0:n.call(t,r));return(o=t.onLoad)==null||o.call(t,(a==null?void 0:a.data)||[]),{data:(a==null?void 0:a.data)||[],total:(a==null?void 0:a.total)||0}},filterFields:$,sortFields:j,defaultParams:t.params,defaultData:t.defaultData,manual:t.manual,defaultCurrent:t.pagination?t.pagination.defaultCurrent:void 0,defaultPageSize:t.pagination?t.pagination.defaultPageSize:void 0,formatParams:t.beforeSearchSubmit,showLessItems:t.pagination?t.pagination.showLessItems:void 0,showTotal:t.pagination?t.pagination.showTotal:void 0,pagination:t.pagination!==!1}),J=()=>{var n;let r=((n=t.columns)==null?void 0:n.filter(o=>!o.hideInTable))||[];function a(o,u){return o.map(l=>({resizable:ce.isDef(l.resizable)?l.resizable:t.columnResizable,...i.omit(s.apColumnToColumn(l),["ellipsis"]),...G(l),fixed:u?u.fixed:l.fixed,title:s.getTableTitle(l,B("table-header","title"),m.headerCell,e.unref(A).colorPrimary),customRender({value:f,...p}){var V,E;const q=s.getTableRenderType(l),ne=s.getTableRenderProps({...l,valueType:q},{value:f,...p}),ae=s.getTableCellRenderNode(q,ne,p.record,e.unref(T)),I=((V=l.renderText)==null?void 0:V.call(l,{value:f,...p}))||f,oe=l.renderText?e.createVNode(e.Fragment,null,[(E=l.renderText)==null?void 0:E.call(l,{value:f,...p})]):ae;let v=Z(l,I,oe);return l.customRender&&(v=l.customRender({value:f,...p,column:l,originalNode:v,originalText:I})),v},children:a(l.children||[],u||l)}))}return a(r)};e.watchEffect(()=>{const r=J();d.value=r,x.value=r});const Q=e.computed(()=>{var a,n;if(t.adaptive&&(h.value.total>0||((a=t.dataSource)==null?void 0:a.length)))return{y:e.unref(U),x:((n=t.scroll)==null?void 0:n.x)||"100%"};if(t.scroll)return t.scroll}),X=e.computed(()=>{var r;if(t.tableLayout)return t.tableLayout;if((r=t.columns)!=null&&r.some(a=>a.ellipsis))return"fixed"}),N=e.computed(()=>{var n;const r=e.unref(P),a=e.unref(g);return{...t,...r,rowSelection:t.rowSelection===!0||((n=t.rowSelection)==null?void 0:n.mode)==="internal"?{...a,preserveSelectedRowKeys:i.isUndefined(t.dataSource)?a.preserveSelectedRowKeys:!0}:s.falseToUndefined(t.rowSelection),loading:i.isUndefined(t.loading)?r.loading:t.loading,pagination:t.pagination===!1?!1:r.pagination,scroll:e.unref(Q)}}),Y=e.computed(()=>[c(),t.card?null:c("wrapper"),t.adaptive?c("adaptive"):null].filter(Boolean));function Z(r,a,n){return O.noRenderAsFormItemValueList.includes(r.valueType)?n:r.copyable||r.ellipsis?e.createVNode(ge.default,{copyable:r.copyable,ellipsis:r.ellipsis?i.isBoolean(r.ellipsis)?{tooltip:n,rows:1}:{...r.ellipsis,tooltip:n}:!1,content:n},null):n}e.watch(()=>e.unref(h).loading,r=>{var a;(a=t.onLoadingChange)==null||a.call(t,r)}),e.watch(()=>t.dataSource,r=>{M(r)},{immediate:!0});function ee(r){var a,n,o;(o=(n=(a=C.value)==null?void 0:a.apForm)==null?void 0:n.setFieldsValue)==null||o.call(n,r)}function re(r=!1){var n,o,u;const a=r?"getFieldsValueTransformed":"getFieldsValue";return(u=(o=(n=C.value)==null?void 0:n.apForm)==null?void 0:o[a])==null?void 0:u.call(o,!0)}function te(){return e.unref(d)}return K({submit:()=>k(),reset:()=>z(),refresh:()=>H(),setSearchFormValues:ee,getSearchFormValues:re,getShownColumns:te,dataSource:e.computed(()=>e.unref(h).records),rowSelection:{selectedRows:e.computed(()=>e.unref(y)),...S}}),(r,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(Y.value)},[e.unref(i.isUndefined)(r.dataSource)&&r.searchForm!==!1&&F.value.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(r.card?e.unref(w)("search-wrapper"):null),style:e.normalizeStyle(r.searchFormWrapperStyle)},[e.createVNode(e.unref(se.ApForm).SearchForm,e.mergeProps(r.searchForm||{},{ref_key:"formRef",ref:C,"custom-reset":"","submit-loading":e.unref(P).loading,onSubmit:e.unref(k),onReset:e.unref(z)}),e.createSlots({default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,n=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.renderNode),e.mergeProps({key:n.dataIndex,ref_for:!0},n.fieldProps||{},{span:n.span}),null,16,["span"]))),128))]),_:2},[m.searchFormExtra?{name:"extra",fn:e.withCtx(()=>[e.renderSlot(r.$slots,"searchFormExtra")]),key:"0"}:void 0]),1040,["submit-loading","onSubmit","onReset"])],6)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"contentRef",ref:D,class:e.normalizeClass([e.unref(w)("table-wrapper"),r.card?e.unref(w)("table-wrapper-card"):null]),style:e.normalizeStyle(r.tableWrapperStyle)},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(c)("header-wrapper"))},[r.settings?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(c)("header"))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(B)("header","title"))},[e.renderSlot(r.$slots,"title",e.mergeProps({selectedRows:e.unref(y),selectedRowKeys:e.unref(g).selectedRowKeys,shownColumns:d.value},S))],2),m.title?(e.openBlock(),e.createBlock(e.unref(L.Divider),{key:0,type:"vertical"})):e.createCommentVNode("",!0),e.createVNode(ye.default,{config:r.settings===!0?{}:r.settings},null,8,["config"])],2)):e.renderSlot(r.$slots,"title",e.mergeProps({key:1,selectedRows:e.unref(y),selectedRowKeys:e.unref(g).selectedRowKeys,shownColumns:d.value},S))],2),e.createVNode(e.unref(L.Table),e.mergeProps({class:e.unref(c)("table")},N.value,{size:b.value,"table-layout":X.value,columns:d.value,onResizeColumn:a[0]||(a[0]=(n,o)=>o.width=n)}),e.createSlots({summary:e.withCtx(()=>[e.renderSlot(r.$slots,"summary",{columns:d.value,records:N.value.dataSource,selectedRows:e.unref(y)})]),_:2},[e.renderList(e.unref(i.omit)(m,["title","searchFormExtra","headerCell","summary"]),(n,o)=>({name:o,fn:e.withCtx(u=>[e.renderSlot(r.$slots,o,e.normalizeProps(e.guardReactiveProps(u||{})))])}))]),1040,["class","size","table-layout","columns"])],6)],2))}});exports.default=Se;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),O=require("@aplus-frontend/antdv"),le=require("@aplus-frontend/antdv/es/theme/internal"),se=require("../ap-form/index.js"),_=require("./constants.js");require("../config-provider/index.js");const ue=require("./hooks/use-table-paging-ng.js"),i=require("lodash-unified"),s=require("./utils.js"),de=require("./hooks/use-table-content-height.js"),ie=require("./hooks/use-table-row-selection.js"),ce=require("../utils/index.js");require("./components/setting/modal/index.vue.js");require("./components/paragraph-ellipsis/index.vue.js");const fe=require("./context.js"),pe=require("../config-provider/hooks/use-namespace.js"),me=require("../config-provider/hooks/use-global-config.js"),ge=require("./components/paragraph-ellipsis/index.vue2.js"),ye=require("./components/setting/modal/index.vue2.js"),Se=e.defineComponent({name:"ApTable",__name:"ap-table",props:{dropdownPrefixCls:{},loading:{type:[Boolean,Object],default:void 0},bordered:{type:Boolean,default:!1},locale:{},onChange:{},onResizeColumn:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!1},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:{},rowSelection:{type:[Boolean,Object]},card:{type:Boolean,default:!1},params:{},searchFormRender:{},request:{},onLoad:{},defaultData:{},dataSource:{},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},columnResizable:{type:Boolean,default:!1},settings:{type:[Boolean,Object],default:void 0}},setup(K,{expose:L}){const t=K;let R=0;const m=e.useSlots(),[,A]=le.useToken(),{e:w,b:c,be:B}=pe.useNamespace("ap-table"),x=me.useGlobalConfig("valueTypeMap"),{height:U,contentRef:D}=de.default(),b=e.ref(t.size),d=e.ref([]),T=e.ref([]);fe.useProvideApTable({columns:e.computed(()=>d.value),columnsBackup:e.computed(()=>T.value),size:e.computed(()=>b.value),updateColumns(r){d.value=r},updateSize(r){b.value=r}});const F=e.computed(()=>{var r,n,o;return R++,((o=(n=(r=t.columns)==null?void 0:r.filter(a=>!a.hideInSearch&&a.dataIndex&&(a.valueType||a.customRenderFormItem)&&!_.noRenderAsFormItemValueList.includes(a.valueType)))==null?void 0:n.sort((a,u)=>{let l=s.getColumnOrder(a.order);return s.getColumnOrder(u.order)-l}))==null?void 0:o.map(a=>{const u=s.updateFormProps(a,s.getFieldProps(a.fieldProps,{})),l={...a,fieldProps:{label:a.title,name:a.dataIndex,...u||{},_signal:R},renderNode:void 0};return l.renderNode=s.getSearchFormItemRenderNode(l,e.unref(x)),l}))||[]}),j=e.computed(()=>s.recursionApColumns(e.unref(d),r=>{if(r.sorter===!0)return r.key||r.dataIndex}).filter(Boolean)),$=e.computed(()=>s.recursionApColumns(e.unref(d),r=>{if(r.filters&&!r.onFilter)return r.key||r.dataIndex}).filter(Boolean)),W=e.computed(()=>i.isUndefined(t.dataSource)?h.records:t.dataSource),{rowSelection:g,selectedRows:y,...S}=ie.default({fixed:!0,...t.rowSelection===!0?{}:t.rowSelection,rowKey:t.rowKey,dataSource:W}),{formRef:C,submit:k,reset:z,tableProps:N,refresh:H,data:h,setDataSource:M,getColumnSFConfig:G}=ue.useTablePaging({async request(r){var o,a;if(!g.value.preserveSelectedRowKeys&&i.isUndefined(t.dataSource)&&S.clearAll(),!i.isUndefined(t.dataSource))return{data:t.dataSource||[],total:t.dataSource.length||0};const n=await((o=t.request)==null?void 0:o.call(t,r));return(a=t.onLoad)==null||a.call(t,(n==null?void 0:n.data)||[]),{data:(n==null?void 0:n.data)||[],total:(n==null?void 0:n.total)||0}},filterFields:$,sortFields:j,defaultParams:t.params,defaultData:t.defaultData,manual:t.manual,formatParams:t.beforeSearchSubmit,pagination:t.pagination}),J=()=>{var o;let r=((o=t.columns)==null?void 0:o.filter(a=>!a.hideInTable))||[];function n(a,u){return a.map(l=>({resizable:ce.isDef(l.resizable)?l.resizable:t.columnResizable,...i.omit(s.apColumnToColumn(l),["ellipsis"]),...G(l),fixed:u?u.fixed:l.fixed,title:s.getTableTitle(l,B("table-header","title"),m.headerCell,e.unref(A).colorPrimary),customRender({value:f,...p}){var E,I;const q=s.getTableRenderType(l),oe=s.getTableRenderProps({...l,valueType:q},{value:f,...p}),ne=s.getTableCellRenderNode(q,oe,p.record,e.unref(x)),V=((E=l.renderText)==null?void 0:E.call(l,{value:f,...p}))||f,ae=l.renderText?e.createVNode(e.Fragment,null,[(I=l.renderText)==null?void 0:I.call(l,{value:f,...p})]):ne;let v=Z(l,V,ae);return l.customRender&&(v=l.customRender({value:f,...p,column:l,originalNode:v,originalText:V})),v},children:n(l.children||[],u||l)}))}return n(r)};e.watchEffect(()=>{const r=J();d.value=r,T.value=r});const Q=e.computed(()=>{var n,o;if(t.adaptive&&(h.total>0||((n=t.dataSource)==null?void 0:n.length)))return{y:e.unref(U),x:((o=t.scroll)==null?void 0:o.x)||"100%"};if(t.scroll)return t.scroll}),X=e.computed(()=>{var r;if(t.tableLayout)return t.tableLayout;if((r=t.columns)!=null&&r.some(n=>n.ellipsis))return"fixed"}),P=e.computed(()=>{var o;const r=e.unref(N),n=e.unref(g);return{...t,...r,rowSelection:t.rowSelection===!0||((o=t.rowSelection)==null?void 0:o.mode)==="internal"?{...n,preserveSelectedRowKeys:i.isUndefined(t.dataSource)?n.preserveSelectedRowKeys:!0}:s.falseToUndefined(t.rowSelection),loading:i.isUndefined(t.loading)?r.loading:t.loading,pagination:t.pagination===!1?!1:r.pagination,scroll:e.unref(Q)}}),Y=e.computed(()=>[c(),t.card?null:c("wrapper"),t.adaptive?c("adaptive"):null].filter(Boolean));function Z(r,n,o){return _.noRenderAsFormItemValueList.includes(r.valueType)?o:r.copyable||r.ellipsis?e.createVNode(ge.default,{copyable:r.copyable,ellipsis:r.ellipsis?i.isBoolean(r.ellipsis)?{tooltip:o,rows:1}:{...r.ellipsis,tooltip:o}:!1,content:o},null):o}e.watch(()=>e.unref(h).loading,r=>{var n;(n=t.onLoadingChange)==null||n.call(t,r)}),e.watch(()=>t.dataSource,r=>{M(r)},{immediate:!0});function ee(r){var n,o,a;(a=(o=(n=C.value)==null?void 0:n.apForm)==null?void 0:o.setFieldsValue)==null||a.call(o,r)}function re(r=!1){var o,a,u;const n=r?"getFieldsValueTransformed":"getFieldsValue";return(u=(a=(o=C.value)==null?void 0:o.apForm)==null?void 0:a[n])==null?void 0:u.call(a,!0)}function te(){return e.unref(d)}return L({submit:()=>k(),reset:()=>z(),refresh:()=>H(),setSearchFormValues:ee,getSearchFormValues:re,getShownColumns:te,dataSource:e.computed(()=>e.unref(h).records),rowSelection:{selectedRows:e.computed(()=>e.unref(y)),...S}}),(r,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(Y.value)},[e.unref(i.isUndefined)(r.dataSource)&&r.searchForm!==!1&&F.value.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(r.card?e.unref(w)("search-wrapper"):null),style:e.normalizeStyle(r.searchFormWrapperStyle)},[e.createVNode(e.unref(se.ApForm).SearchForm,e.mergeProps(r.searchForm||{},{ref_key:"formRef",ref:C,"custom-reset":"","submit-loading":e.unref(N).loading,onSubmit:e.unref(k),onReset:e.unref(z)}),e.createSlots({default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,o=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.renderNode),e.mergeProps({key:o.dataIndex,ref_for:!0},o.fieldProps||{},{span:o.span}),null,16,["span"]))),128))]),_:2},[m.searchFormExtra?{name:"extra",fn:e.withCtx(()=>[e.renderSlot(r.$slots,"searchFormExtra")]),key:"0"}:void 0]),1040,["submit-loading","onSubmit","onReset"])],6)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"contentRef",ref:D,class:e.normalizeClass([e.unref(w)("table-wrapper"),r.card?e.unref(w)("table-wrapper-card"):null]),style:e.normalizeStyle(r.tableWrapperStyle)},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(c)("header-wrapper"))},[r.settings?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(c)("header"))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(B)("header","title"))},[e.renderSlot(r.$slots,"title",e.mergeProps({selectedRows:e.unref(y),selectedRowKeys:e.unref(g).selectedRowKeys,shownColumns:d.value},S))],2),m.title?(e.openBlock(),e.createBlock(e.unref(O.Divider),{key:0,type:"vertical"})):e.createCommentVNode("",!0),e.createVNode(ye.default,{config:r.settings===!0?{}:r.settings},null,8,["config"])],2)):e.renderSlot(r.$slots,"title",e.mergeProps({key:1,selectedRows:e.unref(y),selectedRowKeys:e.unref(g).selectedRowKeys,shownColumns:d.value},S))],2),e.createVNode(e.unref(O.Table),e.mergeProps({class:e.unref(c)("table")},P.value,{size:b.value,"table-layout":X.value,columns:d.value,onResizeColumn:n[0]||(n[0]=(o,a)=>a.width=o)}),e.createSlots({summary:e.withCtx(()=>[e.renderSlot(r.$slots,"summary",{columns:d.value,records:P.value.dataSource,selectedRows:e.unref(y)})]),_:2},[e.renderList(e.unref(i.omit)(m,["title","searchFormExtra","headerCell","summary"]),(o,a)=>({name:a,fn:e.withCtx(u=>[e.renderSlot(r.$slots,a,e.normalizeProps(e.guardReactiveProps(u||{})))])}))]),1040,["class","size","table-layout","columns"])],6)],2))}});exports.default=Se;
|
|
@@ -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 {};
|