@base-stone/hooks 0.9.6 → 0.9.7
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.
|
@@ -113,7 +113,7 @@ declare interface TableListResult<T> {
|
|
|
113
113
|
/** 查询参数 */
|
|
114
114
|
queryParams: QueryParamsData;
|
|
115
115
|
/** 执行查询方法 */
|
|
116
|
-
|
|
116
|
+
search: (params?: Record<string, any>) => void;
|
|
117
117
|
refresh: (params?: Record<string, any>) => void;
|
|
118
118
|
reset: (params?: Record<string, any>) => void;
|
|
119
119
|
/** 选中的行 keys */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as y, useRef as I, useMemo as A, useCallback as S, useEffect as k, useId as W } from "react";
|
|
2
2
|
import { Empty as L, App as X } from "antd";
|
|
3
3
|
import { create as K } from "zustand";
|
|
4
4
|
var T = { exports: {} }, E = {};
|
|
@@ -40,7 +40,7 @@ function ie(n) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
function le(n, r = {}) {
|
|
43
|
-
const { rowSelection: a, ...t } = r, o = R.pageSize, [s, m] =
|
|
43
|
+
const { rowSelection: a, ...t } = r, o = R.pageSize, [s, m] = y({
|
|
44
44
|
pagination: {
|
|
45
45
|
showSizeChanger: !0,
|
|
46
46
|
showQuickJumper: !0,
|
|
@@ -54,7 +54,7 @@ function le(n, r = {}) {
|
|
|
54
54
|
pageSize: o,
|
|
55
55
|
...t
|
|
56
56
|
}
|
|
57
|
-
}), { pagination: l, list: f, queryParams: e } = s, { pageNo: d, pageSize: u } = e, [i, M] =
|
|
57
|
+
}), { pagination: l, list: f, queryParams: e } = s, { pageNo: d, pageSize: u } = e, [i, M] = y(!0), g = I(e), [v, C] = y([]), b = A(() => {
|
|
58
58
|
if (a)
|
|
59
59
|
return {
|
|
60
60
|
selectedRowKeys: v,
|
|
@@ -67,16 +67,16 @@ function le(n, r = {}) {
|
|
|
67
67
|
async (c) => {
|
|
68
68
|
const { pageNo: O } = c;
|
|
69
69
|
M(!0);
|
|
70
|
-
const
|
|
71
|
-
c.pageNo === void 0 && (
|
|
72
|
-
const { data: $ } = await n(
|
|
70
|
+
const h = { ...t, pageSize: u, ...c };
|
|
71
|
+
c.pageNo === void 0 && (h.pageNo = 1), c.pageSize === void 0 && (h.pageSize = u);
|
|
72
|
+
const { data: $ } = await n(h), { list: z = [], totalCount: P = 0 } = $ || {};
|
|
73
73
|
a && C([]), m({
|
|
74
74
|
list: z,
|
|
75
|
-
queryParams:
|
|
75
|
+
queryParams: h,
|
|
76
76
|
pagination: {
|
|
77
77
|
...l,
|
|
78
78
|
current: O,
|
|
79
|
-
pageSize:
|
|
79
|
+
pageSize: h.pageSize,
|
|
80
80
|
total: P
|
|
81
81
|
}
|
|
82
82
|
}), M(!1);
|
|
@@ -98,10 +98,10 @@ function le(n, r = {}) {
|
|
|
98
98
|
},
|
|
99
99
|
[p, u]
|
|
100
100
|
), N = S(
|
|
101
|
-
(c, O,
|
|
101
|
+
(c, O, h, $) => {
|
|
102
102
|
const { action: z } = $;
|
|
103
103
|
if (["paginate", "sort"].includes(z)) {
|
|
104
|
-
const { current: P, pageSize: G } = c, { field: V, order: _ } =
|
|
104
|
+
const { current: P, pageSize: G } = c, { field: V, order: _ } = h, [Q, Y] = R.sortField, [Z, B] = R.sortOrder, U = {
|
|
105
105
|
...e,
|
|
106
106
|
[Q]: _ ? _ === "ascend" ? Z : B : void 0,
|
|
107
107
|
[Y]: V,
|
|
@@ -116,7 +116,7 @@ function le(n, r = {}) {
|
|
|
116
116
|
bordered: !0,
|
|
117
117
|
size: "middle",
|
|
118
118
|
sticky: !0,
|
|
119
|
-
rowSelection:
|
|
119
|
+
rowSelection: b,
|
|
120
120
|
pagination: { ...l, showTotal: x },
|
|
121
121
|
loading: i,
|
|
122
122
|
dataSource: f,
|
|
@@ -124,12 +124,12 @@ function le(n, r = {}) {
|
|
|
124
124
|
locale: {
|
|
125
125
|
emptyText: i ? "" : /* @__PURE__ */ oe.jsx(L, { image: L.PRESENTED_IMAGE_SIMPLE })
|
|
126
126
|
}
|
|
127
|
-
}), [
|
|
127
|
+
}), [b, l, x, i, f, N]);
|
|
128
128
|
return k(() => {
|
|
129
129
|
D(g.current);
|
|
130
130
|
}, []), {
|
|
131
131
|
queryParams: e,
|
|
132
|
-
|
|
132
|
+
search: D,
|
|
133
133
|
refresh: J,
|
|
134
134
|
reset: F,
|
|
135
135
|
selectedRowKeys: v,
|
|
@@ -211,19 +211,19 @@ function ce(n) {
|
|
|
211
211
|
}
|
|
212
212
|
const ae = (n, r = "value", a = "label") => new Map(n.map((t) => [t[r], t[a]]));
|
|
213
213
|
function de(n, r) {
|
|
214
|
-
const [a, t] =
|
|
214
|
+
const [a, t] = y({
|
|
215
215
|
options: [],
|
|
216
216
|
mapData: /* @__PURE__ */ new Map()
|
|
217
|
-
}), [o, s] =
|
|
217
|
+
}), [o, s] = y(!0), { params: m, selectKey: l, fieldNames: f } = r, e = async () => {
|
|
218
218
|
s(!0);
|
|
219
219
|
const { data: M } = await n(m), g = M || [];
|
|
220
220
|
if (f) {
|
|
221
|
-
const { label: v, value: C } = f,
|
|
221
|
+
const { label: v, value: C } = f, b = g.map((p) => ({
|
|
222
222
|
data: p,
|
|
223
223
|
label: p[v],
|
|
224
224
|
value: p[C]
|
|
225
|
-
})), x = ae(
|
|
226
|
-
t((p) => ({ ...p, options:
|
|
225
|
+
})), x = ae(b);
|
|
226
|
+
t((p) => ({ ...p, options: b, mapData: x }));
|
|
227
227
|
} else
|
|
228
228
|
t((v) => ({ ...v, options: g }));
|
|
229
229
|
s(!1);
|
|
@@ -242,7 +242,7 @@ function de(n, r) {
|
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
244
|
function ue(n, r) {
|
|
245
|
-
const [a, t] =
|
|
245
|
+
const [a, t] = y(!1), { message: o } = X.useApp(), s = S(async (m) => {
|
|
246
246
|
try {
|
|
247
247
|
t(!0);
|
|
248
248
|
const l = await n(m), { status: f, info: e } = l;
|