@magicbe/antd-crud 0.0.19 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Action.js +22 -10
- package/dist/components/Add.d.ts +2 -5
- package/dist/components/Context.d.ts +3 -2
- package/dist/components/Context.js +3 -2
- package/dist/components/Edit.d.ts +2 -5
- package/dist/components/Table.js +66 -43
- package/dist/index.d.ts +1 -1
- package/dist/interface.d.ts +11 -1
- package/package.json +1 -5
|
@@ -50,9 +50,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
53
|
-
import React, { Fragment, useImperativeHandle, useState } from "react";
|
|
53
|
+
import React, { Fragment, useImperativeHandle, useMemo, useState } from "react";
|
|
54
54
|
import { Button, Drawer, Modal, Space } from "antd";
|
|
55
|
-
import { isArray, isEmpty, isFunction, isObject } from "lodash";
|
|
55
|
+
import { isArray, isEmpty, isFunction, isNumber, isObject } from "lodash";
|
|
56
56
|
import { DeleteOutlined, EditFilled, PlusOutlined } from "@ant-design/icons";
|
|
57
57
|
import createEmotion from "@emotion/css/create-instance";
|
|
58
58
|
import { useTableContext } from "./Context";
|
|
@@ -150,8 +150,7 @@ var append_action_default_children = (_jsxs(Space, { children: [_jsx(PlusOutline
|
|
|
150
150
|
export var AppendAction = function (_a) {
|
|
151
151
|
var _b = _a.children, children = _b === void 0 ? append_action_default_children : _b;
|
|
152
152
|
var _c = Modal.useModal(), modalInstance = _c[0], modalContextHolder = _c[1];
|
|
153
|
-
var
|
|
154
|
-
var _d = useTableContext(), content_ref = _d.content_ref, table_ref = _d.table_ref, filter_ref = _d.filter_ref, add = _d.add;
|
|
153
|
+
var _d = useTableContext(), content_ref = _d.content_ref, table_ref = _d.table_ref, filter_ref = _d.filter_ref, form_ref = _d.form_ref, add = _d.add, drawer = _d.drawer;
|
|
155
154
|
/**添加表单抽屉 */
|
|
156
155
|
var _e = useState(false), add_drawer_open = _e[0], setAdd_drawer_open = _e[1];
|
|
157
156
|
var _f = useState(), init_data = _f[0], setInit_data = _f[1];
|
|
@@ -181,7 +180,7 @@ export var AppendAction = function (_a) {
|
|
|
181
180
|
}); };
|
|
182
181
|
var onConfirm = function () {
|
|
183
182
|
var _a;
|
|
184
|
-
(_a =
|
|
183
|
+
(_a = form_ref === null || form_ref === void 0 ? void 0 : form_ref.current) === null || _a === void 0 ? void 0 : _a.form.validateFields().then(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
185
184
|
var keys, rows, before, handle, after, page_data, filter_data, error_1;
|
|
186
185
|
var _a, _b, _c, _d, _e;
|
|
187
186
|
return __generator(this, function (_f) {
|
|
@@ -242,7 +241,14 @@ export var AppendAction = function (_a) {
|
|
|
242
241
|
};
|
|
243
242
|
/**新增操作 */
|
|
244
243
|
var add_extra = (_jsxs(Space, { children: [_jsx(Button, __assign({ onClick: switchAddDrawer }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ type: "primary", onClick: onConfirm, loading: loading }, { children: "\u786E\u5B9A" }))] }));
|
|
245
|
-
|
|
244
|
+
var drawer_width = useMemo(function () {
|
|
245
|
+
if (isNumber(drawer))
|
|
246
|
+
return drawer;
|
|
247
|
+
if (isObject(drawer))
|
|
248
|
+
return drawer.add;
|
|
249
|
+
return 600;
|
|
250
|
+
}, [drawer]);
|
|
251
|
+
return (_jsxs(Fragment, { children: [_jsx(Button, __assign({ type: "primary", onClick: switchAddDrawer }, { children: children })), _jsx(Drawer, __assign({ title: "\u65B0\u589E", width: drawer_width, onClose: switchAddDrawer, open: add_drawer_open, closable: false, extra: add_extra, getContainer: function () { return content_ref.current; }, destroyOnClose: true }, { children: _jsx(AddForm, { ref: form_ref, default_data: init_data }) })), modalContextHolder] }));
|
|
246
252
|
};
|
|
247
253
|
var delete_action_default_children = (_jsxs(Space, { children: [_jsx(DeleteOutlined, {}), "\u5220\u9664"] }));
|
|
248
254
|
/**删除方法 */
|
|
@@ -356,8 +362,7 @@ var edit_action_default_children = (_jsxs(Space, { children: [_jsx(EditFilled, {
|
|
|
356
362
|
export var EditAction = function (_a) {
|
|
357
363
|
var _b = _a.children, children = _b === void 0 ? edit_action_default_children : _b;
|
|
358
364
|
var _c = Modal.useModal(), modalInstance = _c[0], modalContextHolder = _c[1];
|
|
359
|
-
var _d = useTableContext(), content_ref = _d.content_ref, table_ref = _d.table_ref, filter_ref = _d.filter_ref, edit = _d.edit;
|
|
360
|
-
var edit_form_ref = React.createRef();
|
|
365
|
+
var _d = useTableContext(), content_ref = _d.content_ref, table_ref = _d.table_ref, filter_ref = _d.filter_ref, form_ref = _d.form_ref, edit = _d.edit, drawer = _d.drawer;
|
|
361
366
|
/**编辑 */
|
|
362
367
|
var _e = useState(false), edit_drawer_open = _e[0], setEdit_drawer_open = _e[1];
|
|
363
368
|
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
@@ -388,7 +393,7 @@ export var EditAction = function (_a) {
|
|
|
388
393
|
}); };
|
|
389
394
|
var onConfirm = function () {
|
|
390
395
|
var _a;
|
|
391
|
-
(_a =
|
|
396
|
+
(_a = form_ref === null || form_ref === void 0 ? void 0 : form_ref.current) === null || _a === void 0 ? void 0 : _a.form.validateFields().then(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
392
397
|
var keys, rows, before, handle, after, page_data, filter_data, error_4;
|
|
393
398
|
var _a, _b, _c, _d, _e;
|
|
394
399
|
return __generator(this, function (_f) {
|
|
@@ -450,6 +455,13 @@ export var EditAction = function (_a) {
|
|
|
450
455
|
};
|
|
451
456
|
/**编辑操作 */
|
|
452
457
|
var edit_extra = (_jsxs(Space, { children: [_jsx(Button, __assign({ onClick: switchEditDrawer }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ type: "primary", onClick: onConfirm, loading: loading }, { children: "\u786E\u5B9A" }))] }));
|
|
453
|
-
|
|
458
|
+
var drawer_width = useMemo(function () {
|
|
459
|
+
if (isNumber(drawer))
|
|
460
|
+
return drawer;
|
|
461
|
+
if (isObject(drawer))
|
|
462
|
+
return drawer.add;
|
|
463
|
+
return 600;
|
|
464
|
+
}, [drawer]);
|
|
465
|
+
return (_jsxs(Fragment, { children: [_jsx(Button, __assign({ onClick: onClick }, { children: children })), _jsx(Drawer, __assign({ title: "\u7F16\u8F91", width: drawer_width, onClose: switchEditDrawer, open: edit_drawer_open, closable: false, extra: edit_extra, getContainer: function () { return content_ref.current; }, destroyOnClose: true }, { children: _jsx(EditForm, { ref: form_ref, default_data: init_data }) })), modalContextHolder] }));
|
|
454
466
|
};
|
|
455
467
|
var templateObject_1;
|
package/dist/components/Add.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { FormRef } from "../interface";
|
|
3
3
|
export interface AddFormProps {
|
|
4
4
|
default_data?: Record<string, any>;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
form: FormInstance;
|
|
8
|
-
}
|
|
9
|
-
declare const AddForm: React.ForwardRefExoticComponent<AddFormProps & React.RefAttributes<AddFormRef>>;
|
|
6
|
+
declare const AddForm: React.ForwardRefExoticComponent<AddFormProps & React.RefAttributes<FormRef>>;
|
|
10
7
|
export default AddForm;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { AnyObject, type ContentProps } from "../interface";
|
|
2
|
+
import { AnyObject, FormRef, type ContentProps } from "../interface";
|
|
3
3
|
import { type FilterRef } from "./Filter";
|
|
4
4
|
import { type ActionRef } from "./Action";
|
|
5
5
|
import { type TableRef } from "./Table";
|
|
@@ -8,7 +8,8 @@ interface TableContextProps<RecordType> extends ContentProps<RecordType> {
|
|
|
8
8
|
action_ref: React.RefObject<ActionRef>;
|
|
9
9
|
table_ref: React.RefObject<TableRef>;
|
|
10
10
|
content_ref: React.RefObject<HTMLDivElement>;
|
|
11
|
+
form_ref: React.RefObject<FormRef>;
|
|
11
12
|
}
|
|
12
|
-
export declare const TableContextProvider: <RecordType extends AnyObject = AnyObject>({ children, ...props }: React.PropsWithChildren<ContentProps<RecordType>>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const TableContextProvider: <RecordType extends AnyObject = AnyObject>({ children, drawer, ...props }: React.PropsWithChildren<ContentProps<RecordType>>) => import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export declare const useTableContext: () => Partial<TableContextProps<any>>;
|
|
14
15
|
export {};
|
|
@@ -24,11 +24,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
24
|
import React, { useContext } from "react";
|
|
25
25
|
var TableContext = React.createContext({});
|
|
26
26
|
export var TableContextProvider = function (_a) {
|
|
27
|
-
var children = _a.children, props = __rest(_a, ["children"]);
|
|
27
|
+
var children = _a.children, _b = _a.drawer, drawer = _b === void 0 ? 600 : _b, props = __rest(_a, ["children", "drawer"]);
|
|
28
28
|
var filter_ref = React.createRef();
|
|
29
29
|
var action_ref = React.createRef();
|
|
30
30
|
var table_ref = React.createRef();
|
|
31
31
|
var content_ref = React.createRef();
|
|
32
|
-
|
|
32
|
+
var form_ref = React.createRef();
|
|
33
|
+
return (_jsx(TableContext.Provider, __assign({ value: __assign(__assign({}, props), { drawer: drawer, filter_ref: filter_ref, action_ref: action_ref, table_ref: table_ref, content_ref: content_ref, form_ref: form_ref }) }, { children: children })));
|
|
33
34
|
};
|
|
34
35
|
export var useTableContext = function () { return useContext(TableContext); };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
export interface EditFormRef {
|
|
4
|
-
form: FormInstance;
|
|
5
|
-
}
|
|
2
|
+
import { FormRef } from "../interface";
|
|
6
3
|
export interface EditFormProps {
|
|
7
4
|
default_data?: Record<string, any>;
|
|
8
5
|
}
|
|
9
|
-
declare const EditForm: React.ForwardRefExoticComponent<EditFormProps & React.RefAttributes<
|
|
6
|
+
declare const EditForm: React.ForwardRefExoticComponent<EditFormProps & React.RefAttributes<FormRef>>;
|
|
10
7
|
export default EditForm;
|
package/dist/components/Table.js
CHANGED
|
@@ -60,12 +60,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
60
60
|
import { Table as AntdTable, Button, Drawer, Modal, Space } from "antd";
|
|
61
61
|
import React, { Fragment, useEffect, useImperativeHandle, useMemo, useState } from "react";
|
|
62
62
|
import { DeleteOutlined, EditFilled, PlusOutlined } from "@ant-design/icons";
|
|
63
|
-
import { get, isArray, isEmpty, isFunction, isObject } from "lodash";
|
|
63
|
+
import { get, isArray, isEmpty, isFunction, isNumber, isObject } from "lodash";
|
|
64
64
|
import { useTableContext } from "./Context";
|
|
65
65
|
import AddForm from "./Add";
|
|
66
66
|
import EditForm from "./Edit";
|
|
67
67
|
var Table = function (_a, ref) {
|
|
68
|
-
var _b = useTableContext(), getSources = _b.getSources, selectionType = _b.rowSelection, action = _b.action, content_ref = _b.content_ref, filter_ref = _b.filter_ref, props = __rest(_b, ["getSources", "rowSelection", "action", "content_ref", "filter_ref"]);
|
|
68
|
+
var _b = useTableContext(), getSources = _b.getSources, selectionType = _b.rowSelection, action = _b.action, content_ref = _b.content_ref, filter_ref = _b.filter_ref, _pagination_ = _b.pagination, props = __rest(_b, ["getSources", "rowSelection", "action", "content_ref", "filter_ref", "pagination"]);
|
|
69
69
|
var _c = useState([]), sources = _c[0], setSources = _c[1];
|
|
70
70
|
var _d = useState(), total = _d[0], setTotal = _d[1];
|
|
71
71
|
var _e = useState(), page = _e[0], setPage = _e[1];
|
|
@@ -75,10 +75,8 @@ var Table = function (_a, ref) {
|
|
|
75
75
|
var _j = useState([]), selected_rows = _j[0], setSelected_rows = _j[1];
|
|
76
76
|
var columns = useMemo(function () {
|
|
77
77
|
var _a;
|
|
78
|
-
var width = 1;
|
|
79
78
|
var default_action = {
|
|
80
79
|
title: "操作",
|
|
81
|
-
width: width,
|
|
82
80
|
render: function (value, row, index) {
|
|
83
81
|
return (_jsxs(Space, { children: [React.cloneElement(_jsx(AppendAction, {}), value, row, index), React.cloneElement(_jsx(EditAction, {}), value, row, index), React.cloneElement(_jsx(DeleteAction, {}), value, row, index)] }));
|
|
84
82
|
}
|
|
@@ -101,7 +99,6 @@ var Table = function (_a, ref) {
|
|
|
101
99
|
var Component_1 = record_1;
|
|
102
100
|
nexts === null || nexts === void 0 ? void 0 : nexts.push({
|
|
103
101
|
title: "操作",
|
|
104
|
-
width: width,
|
|
105
102
|
render: function (value, row, index) { return React.cloneElement(_jsx(Component_1, {}), { value: value, row: row, index: index }); },
|
|
106
103
|
});
|
|
107
104
|
}
|
|
@@ -109,7 +106,6 @@ var Table = function (_a, ref) {
|
|
|
109
106
|
else if (isArray(record_1)) {
|
|
110
107
|
nexts === null || nexts === void 0 ? void 0 : nexts.push({
|
|
111
108
|
title: "操作",
|
|
112
|
-
width: width,
|
|
113
109
|
render: function (value, row, index) {
|
|
114
110
|
return (_jsx(Space, { children: record_1.map(function (Component, key) { return React.cloneElement(_jsx(Component, {}, key), {
|
|
115
111
|
value: value,
|
|
@@ -127,7 +123,6 @@ var Table = function (_a, ref) {
|
|
|
127
123
|
var del_element_1 = _jsx(Fragment, {});
|
|
128
124
|
nexts === null || nexts === void 0 ? void 0 : nexts.push({
|
|
129
125
|
title: "操作",
|
|
130
|
-
width: width,
|
|
131
126
|
render: function (_, row, index) {
|
|
132
127
|
/**新增 */
|
|
133
128
|
if (add_1 === true)
|
|
@@ -157,14 +152,18 @@ var Table = function (_a, ref) {
|
|
|
157
152
|
}
|
|
158
153
|
return nexts;
|
|
159
154
|
}, [props.columns]);
|
|
160
|
-
var pagination = useMemo(function () {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
155
|
+
var pagination = useMemo(function () {
|
|
156
|
+
if (_pagination_ === false)
|
|
157
|
+
return false;
|
|
158
|
+
return ({
|
|
159
|
+
current: page,
|
|
160
|
+
total: total,
|
|
161
|
+
pageSize: size,
|
|
162
|
+
showTotal: function (totle) { return "\u5171\u8BA1 ".concat(totle, " \u6761\u6570\u636E"); },
|
|
163
|
+
showSizeChanger: true,
|
|
164
|
+
showQuickJumper: true,
|
|
165
|
+
});
|
|
166
|
+
}, [total, page, size]);
|
|
168
167
|
var onRowSelectionChange = function (keys, rows) {
|
|
169
168
|
setSelected_keys(keys);
|
|
170
169
|
setSelected_rows(rows);
|
|
@@ -201,9 +200,8 @@ export default React.forwardRef(Table);
|
|
|
201
200
|
var append_action_default_children = (_jsxs(Space, { children: [_jsx(PlusOutlined, {}), "\u65B0\u589E"] }));
|
|
202
201
|
export var AppendAction = function (_a) {
|
|
203
202
|
var _b = _a.children, children = _b === void 0 ? append_action_default_children : _b, row = _a.row;
|
|
204
|
-
var _c = useTableContext(), rowKey = _c.rowKey, content_ref = _c.content_ref, table_ref = _c.table_ref, filter_ref = _c.filter_ref, add = _c.add;
|
|
203
|
+
var _c = useTableContext(), rowKey = _c.rowKey, content_ref = _c.content_ref, table_ref = _c.table_ref, filter_ref = _c.filter_ref, form_ref = _c.form_ref, add = _c.add, drawer = _c.drawer;
|
|
205
204
|
var _d = Modal.useModal(), modalInstance = _d[0], modalContextHolder = _d[1];
|
|
206
|
-
var add_form_ref = React.createRef();
|
|
207
205
|
var _e = useState(false), add_drawer_open = _e[0], setAdd_drawer_open = _e[1];
|
|
208
206
|
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
209
207
|
var _g = useState(), init_data = _g[0], setInit_data = _g[1];
|
|
@@ -233,7 +231,7 @@ export var AppendAction = function (_a) {
|
|
|
233
231
|
}); };
|
|
234
232
|
var onConfirm = function () {
|
|
235
233
|
var _a;
|
|
236
|
-
(_a =
|
|
234
|
+
(_a = form_ref === null || form_ref === void 0 ? void 0 : form_ref.current) === null || _a === void 0 ? void 0 : _a.form.validateFields().then(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
237
235
|
var before, handle, after, page_data, filter_data, error_1;
|
|
238
236
|
var _a, _b, _c;
|
|
239
237
|
return __generator(this, function (_d) {
|
|
@@ -313,37 +311,55 @@ export var AppendAction = function (_a) {
|
|
|
313
311
|
}); };
|
|
314
312
|
/**新增操作 */
|
|
315
313
|
var add_extra = (_jsxs(Space, { children: [_jsx(Button, __assign({ onClick: switchAddDrawer }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ type: "primary", onClick: onConfirm, loading: loading }, { children: "\u786E\u5B9A" }))] }));
|
|
316
|
-
|
|
314
|
+
var drawer_width = useMemo(function () {
|
|
315
|
+
if (isNumber(drawer))
|
|
316
|
+
return drawer;
|
|
317
|
+
if (isObject(drawer))
|
|
318
|
+
return drawer.add;
|
|
319
|
+
return 600;
|
|
320
|
+
}, [drawer]);
|
|
321
|
+
return (_jsxs(Fragment, { children: [_jsx(Button, __assign({ type: "link", size: "small", onClick: onClick }, { children: children })), _jsx(Drawer, __assign({ title: "\u65B0\u589E", width: drawer_width, onClose: switchAddDrawer, open: add_drawer_open, closable: false, extra: add_extra, getContainer: function () { return content_ref.current; }, destroyOnClose: true }, { children: _jsx(AddForm, { default_data: init_data, ref: form_ref }) })), modalContextHolder] }));
|
|
317
322
|
};
|
|
318
323
|
var edit_action_default_children = (_jsxs(Space, { children: [_jsx(EditFilled, {}), "\u7F16\u8F91"] }));
|
|
319
324
|
export var EditAction = function (_a) {
|
|
320
325
|
var _b = _a.children, children = _b === void 0 ? edit_action_default_children : _b, row = _a.row;
|
|
321
|
-
var
|
|
322
|
-
var _c = useTableContext(), edit = _c.edit, rowKey = _c.rowKey, content_ref = _c.content_ref, table_ref = _c.table_ref, filter_ref = _c.filter_ref;
|
|
326
|
+
var _c = useTableContext(), edit = _c.edit, rowKey = _c.rowKey, content_ref = _c.content_ref, table_ref = _c.table_ref, filter_ref = _c.filter_ref, form_ref = _c.form_ref, drawer = _c.drawer;
|
|
323
327
|
var _d = Modal.useModal(), modalInstance = _d[0], modalContextHolder = _d[1];
|
|
324
328
|
var _e = useState(false), edit_drawer_open = _e[0], setEdit_drawer_open = _e[1];
|
|
325
329
|
var _f = useState(), init_data = _f[0], setInit_data = _f[1];
|
|
326
330
|
var _g = useState(false), loading = _g[0], setLoading = _g[1];
|
|
331
|
+
var _h = useState(false), clickLoading = _h[0], setClickLoading = _h[1];
|
|
327
332
|
var switchEditDrawer = function () { return setEdit_drawer_open(!edit_drawer_open); };
|
|
328
|
-
var
|
|
333
|
+
var _j = useMemo(function () {
|
|
329
334
|
var key = get(row, String(rowKey));
|
|
330
335
|
return ({ keys: [key], rows: [row] });
|
|
331
|
-
}, [row]), keys =
|
|
336
|
+
}, [row]), keys = _j.keys, rows = _j.rows;
|
|
332
337
|
var onClick = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
333
|
-
var init, data;
|
|
338
|
+
var init, data, error_2;
|
|
334
339
|
return __generator(this, function (_a) {
|
|
335
340
|
switch (_a.label) {
|
|
336
341
|
case 0:
|
|
337
|
-
if (!isObject(edit)) return [3 /*break*/,
|
|
342
|
+
if (!isObject(edit)) return [3 /*break*/, 5];
|
|
338
343
|
init = edit.init;
|
|
339
|
-
if (!isFunction(init)) return [3 /*break*/,
|
|
340
|
-
|
|
344
|
+
if (!isFunction(init)) return [3 /*break*/, 5];
|
|
345
|
+
setClickLoading(true);
|
|
346
|
+
_a.label = 1;
|
|
341
347
|
case 1:
|
|
348
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
349
|
+
return [4 /*yield*/, init({ rows: rows, keys: keys })];
|
|
350
|
+
case 2:
|
|
342
351
|
data = _a.sent();
|
|
343
352
|
if (data)
|
|
344
353
|
setInit_data(data);
|
|
345
|
-
|
|
346
|
-
case
|
|
354
|
+
return [3 /*break*/, 5];
|
|
355
|
+
case 3:
|
|
356
|
+
error_2 = _a.sent();
|
|
357
|
+
console.error(error_2);
|
|
358
|
+
return [3 /*break*/, 5];
|
|
359
|
+
case 4:
|
|
360
|
+
setClickLoading(false);
|
|
361
|
+
return [7 /*endfinally*/];
|
|
362
|
+
case 5:
|
|
347
363
|
switchEditDrawer();
|
|
348
364
|
return [2 /*return*/];
|
|
349
365
|
}
|
|
@@ -351,8 +367,8 @@ export var EditAction = function (_a) {
|
|
|
351
367
|
}); };
|
|
352
368
|
var onConfirm = function () {
|
|
353
369
|
var _a;
|
|
354
|
-
(_a =
|
|
355
|
-
var before, handle, after, page_data, filter_data,
|
|
370
|
+
(_a = form_ref === null || form_ref === void 0 ? void 0 : form_ref.current) === null || _a === void 0 ? void 0 : _a.form.validateFields().then(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
371
|
+
var before, handle, after, page_data, filter_data, error_3;
|
|
356
372
|
var _a, _b, _c;
|
|
357
373
|
return __generator(this, function (_d) {
|
|
358
374
|
switch (_d.label) {
|
|
@@ -391,11 +407,11 @@ export var EditAction = function (_a) {
|
|
|
391
407
|
(_c = table_ref === null || table_ref === void 0 ? void 0 : table_ref.current) === null || _c === void 0 ? void 0 : _c.loadRecords(Object.assign({}, page_data, filter_data));
|
|
392
408
|
return [3 /*break*/, 11];
|
|
393
409
|
case 9:
|
|
394
|
-
|
|
395
|
-
console.error(
|
|
410
|
+
error_3 = _d.sent();
|
|
411
|
+
console.error(error_3);
|
|
396
412
|
modalInstance.error({
|
|
397
413
|
title: "错误",
|
|
398
|
-
content: String(
|
|
414
|
+
content: String(error_3)
|
|
399
415
|
});
|
|
400
416
|
return [3 /*break*/, 11];
|
|
401
417
|
case 10:
|
|
@@ -408,7 +424,14 @@ export var EditAction = function (_a) {
|
|
|
408
424
|
};
|
|
409
425
|
/**新增操作 */
|
|
410
426
|
var edit_extra = (_jsxs(Space, { children: [_jsx(Button, __assign({ onClick: switchEditDrawer }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ type: "primary", onClick: onConfirm, loading: loading }, { children: "\u786E\u5B9A" }))] }));
|
|
411
|
-
|
|
427
|
+
var drawer_width = useMemo(function () {
|
|
428
|
+
if (isNumber(drawer))
|
|
429
|
+
return drawer;
|
|
430
|
+
if (isObject(drawer))
|
|
431
|
+
return drawer.add;
|
|
432
|
+
return 600;
|
|
433
|
+
}, [drawer]);
|
|
434
|
+
return (_jsxs(Fragment, { children: [_jsx(Button, __assign({ type: "link", size: "small", onClick: onClick, loading: clickLoading }, { children: children })), _jsx(Drawer, __assign({ title: "\u7F16\u8F91", width: drawer_width, onClose: switchEditDrawer, open: edit_drawer_open, closable: false, extra: edit_extra, getContainer: function () { return content_ref.current; }, destroyOnClose: true }, { children: _jsx(EditForm, { ref: form_ref, default_data: init_data }) })), modalContextHolder] }));
|
|
412
435
|
};
|
|
413
436
|
var delete_action_default_children = (_jsxs(Space, { children: [_jsx(DeleteOutlined, {}), "\u5220\u9664"] }));
|
|
414
437
|
export var DeleteAction = function (_a) {
|
|
@@ -421,7 +444,7 @@ export var DeleteAction = function (_a) {
|
|
|
421
444
|
return ({ keys: [key], rows: [row] });
|
|
422
445
|
}, [row]), keys = _f.keys, rows = _f.rows;
|
|
423
446
|
var onClick = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
424
|
-
var before, handle, after, res, page_data, filter_data,
|
|
447
|
+
var before, handle, after, res, page_data, filter_data, error_4;
|
|
425
448
|
var _a, _b, _c;
|
|
426
449
|
return __generator(this, function (_d) {
|
|
427
450
|
switch (_d.label) {
|
|
@@ -463,11 +486,11 @@ export var DeleteAction = function (_a) {
|
|
|
463
486
|
(_c = table_ref === null || table_ref === void 0 ? void 0 : table_ref.current) === null || _c === void 0 ? void 0 : _c.loadRecords(Object.assign({}, page_data, filter_data));
|
|
464
487
|
return [3 /*break*/, 12];
|
|
465
488
|
case 10:
|
|
466
|
-
|
|
467
|
-
console.error(
|
|
489
|
+
error_4 = _d.sent();
|
|
490
|
+
console.error(error_4);
|
|
468
491
|
modalInstance.error({
|
|
469
492
|
title: "错误",
|
|
470
|
-
content: String(
|
|
493
|
+
content: String(error_4),
|
|
471
494
|
});
|
|
472
495
|
return [3 /*break*/, 12];
|
|
473
496
|
case 11:
|
|
@@ -483,7 +506,7 @@ export var DeleteAction = function (_a) {
|
|
|
483
506
|
title: "提示",
|
|
484
507
|
content: "\u786E\u5B9A\u8981\u5220\u9664 ".concat(keys === null || keys === void 0 ? void 0 : keys.length, " \u6761\u6570\u636E\u5417?"),
|
|
485
508
|
onOk: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
486
|
-
var
|
|
509
|
+
var error_5;
|
|
487
510
|
return __generator(this, function (_a) {
|
|
488
511
|
switch (_a.label) {
|
|
489
512
|
case 0:
|
|
@@ -494,12 +517,12 @@ export var DeleteAction = function (_a) {
|
|
|
494
517
|
resolve(true);
|
|
495
518
|
return [3 /*break*/, 3];
|
|
496
519
|
case 2:
|
|
497
|
-
|
|
520
|
+
error_5 = _a.sent();
|
|
498
521
|
modalInstance.error({
|
|
499
522
|
title: "错误",
|
|
500
|
-
content: String(
|
|
523
|
+
content: String(error_5)
|
|
501
524
|
});
|
|
502
|
-
reject(
|
|
525
|
+
reject(error_5);
|
|
503
526
|
return [3 /*break*/, 3];
|
|
504
527
|
case 3: return [2 /*return*/];
|
|
505
528
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type AnyObject, type BaseColumnField, type ColumnInputField, type ColumnTextAreaField, type ColumnInputNumberField, type ColumnSelectField, type ColumnCascaderField, type ColumnCheckboxField, type ColumnCheckboxGroupField, type ColumnDatePickerField, type ColumnDatePickerYearPickerField, type ColumnDatePickerMonthPickerField, type ColumnDatePickerWeekPickerField, type ColumnDatePickerTimePickerField, type ColumnDatePickerRangePickerField, type ColumnDatePickerQuarterPickerField, type ColumnTimePickerField, type ColumnTimePickerRangePickerField, type ColumnRadioField, type ColumnRadioGroupField, type ColumnSwitchField, type ColumnField, type ColumnFieldKeys, type ColumnType, type Source, type getSourceFunction, type GetSourceFunctionParams, type add, type addHandleMap, type edit, type editHandleMap, type del, type CustomFilter, type filter, type MasterCustomActionGroup, type RecordCustomActionGroup, type CustomActionGroup, type CustomAction, type ContentProps, type ContentRef, } from "./interface";
|
|
1
|
+
export { type AnyObject, type BaseColumnField, type ColumnInputField, type ColumnTextAreaField, type ColumnInputNumberField, type ColumnSelectField, type ColumnCascaderField, type ColumnCheckboxField, type ColumnCheckboxGroupField, type ColumnDatePickerField, type ColumnDatePickerYearPickerField, type ColumnDatePickerMonthPickerField, type ColumnDatePickerWeekPickerField, type ColumnDatePickerTimePickerField, type ColumnDatePickerRangePickerField, type ColumnDatePickerQuarterPickerField, type ColumnTimePickerField, type ColumnTimePickerRangePickerField, type ColumnRadioField, type ColumnRadioGroupField, type ColumnSwitchField, type ColumnField, type ColumnFieldKeys, type ColumnType, type Source, type getSourceFunction, type GetSourceFunctionParams, type add, type addHandleMap, type edit, type editHandleMap, type del, type CustomFilter, type filter, type MasterCustomActionGroup, type RecordCustomActionGroup, type CustomActionGroup, type CustomAction, type ContentProps, type ContentRef, type FormRef, } from "./interface";
|
|
2
2
|
export { default as CrudTable, } from "./components";
|
|
3
3
|
export { TableContextProvider, useTableContext, } from "./components/Context";
|
|
4
4
|
export { default as Filter, type FilterProps, type FilterRef, } from "./components/Filter";
|
package/dist/interface.d.ts
CHANGED
|
@@ -154,18 +154,28 @@ export interface CustomAction {
|
|
|
154
154
|
}
|
|
155
155
|
/**操作 */
|
|
156
156
|
export type Action = boolean | React.FC | React.FC[] | CustomAction;
|
|
157
|
+
export interface DrawerProps {
|
|
158
|
+
add?: number;
|
|
159
|
+
edit?: number;
|
|
160
|
+
}
|
|
157
161
|
/**主体参数 */
|
|
158
162
|
export interface ContentProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, "columns" | "pagination" | "dataSource" | "loading" | "rowSelection"> {
|
|
159
163
|
columns?: ColumnType<RecordType>[];
|
|
160
|
-
getSources?: getSourceFunction
|
|
164
|
+
getSources?: getSourceFunction;
|
|
161
165
|
add?: add;
|
|
162
166
|
del?: del;
|
|
163
167
|
edit?: edit;
|
|
164
168
|
filter?: filter;
|
|
165
169
|
action?: Action;
|
|
166
170
|
rowSelection?: RowSelectionType;
|
|
171
|
+
pagination?: false;
|
|
172
|
+
drawer?: number | DrawerProps;
|
|
167
173
|
}
|
|
168
174
|
/**主体暴露 */
|
|
169
175
|
export interface ContentRef {
|
|
170
176
|
}
|
|
177
|
+
/**表单REF */
|
|
178
|
+
export interface FormRef {
|
|
179
|
+
form: FormInstance;
|
|
180
|
+
}
|
|
171
181
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicbe/antd-crud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "antd crud table",
|
|
5
5
|
"author": "wang quan",
|
|
6
6
|
"private": false,
|
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public",
|
|
22
|
-
"registry": "https://registry.npmjs.org/"
|
|
23
|
-
},
|
|
24
20
|
"dependencies": {
|
|
25
21
|
"@ant-design/icons": "^5.4.0",
|
|
26
22
|
"@emotion/css": "^11.13.0",
|