@quansitech/antd-admin 1.2.9 → 1.3.1
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/Layout/New.js +5 -3
- package/dist/components/Layout/New.scss +4 -0
- package/dist/components/Layout.js +16 -13
- package/dist/components/Table/Action/Button.d.ts +1 -0
- package/dist/components/Table/Action/Button.js +132 -66
- package/dist/components/Table/Action/StartEditable.js +30 -24
- package/dist/components/Table.d.ts +1 -0
- package/dist/components/Table.js +27 -9
- package/dist/components/TableContext.d.ts +2 -1
- package/dist/lib/helpers.d.ts +1 -0
- package/dist/lib/helpers.js +32 -13
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/readme.md +663 -3
|
@@ -16,7 +16,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
16
16
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
17
|
// @ts-nocheck
|
|
18
18
|
import { PageContainer, ProLayout, ProProvider } from "@ant-design/pro-components";
|
|
19
|
-
import { Button, Dropdown, Menu, Space } from "antd";
|
|
19
|
+
import { Button, Dropdown, Menu, Space, Spin } from "antd";
|
|
20
20
|
import { LayoutContext } from "../LayoutContext";
|
|
21
21
|
import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
22
22
|
import { routerNavigateTo } from "../../lib/helpers";
|
|
@@ -161,7 +161,6 @@ export default function (_ref) {
|
|
|
161
161
|
};
|
|
162
162
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ProLayout, {
|
|
163
163
|
title: layoutProps.title,
|
|
164
|
-
loading: layoutContext.props.loading,
|
|
165
164
|
layout: "mix",
|
|
166
165
|
actionsRender: actionsRender,
|
|
167
166
|
route: route,
|
|
@@ -218,9 +217,12 @@ export default function (_ref) {
|
|
|
218
217
|
onClick: onMenuClick,
|
|
219
218
|
onOpenChange: setOpenKeys
|
|
220
219
|
}
|
|
220
|
+
}, /*#__PURE__*/React.createElement(Spin, {
|
|
221
|
+
spinning: layoutContext.props.loading
|
|
221
222
|
}, /*#__PURE__*/React.createElement(PageContainer, {
|
|
222
223
|
title: pageTitle
|
|
223
224
|
}, /*#__PURE__*/React.createElement("div", {
|
|
225
|
+
className: "page-content-wrap",
|
|
224
226
|
ref: contentRef
|
|
225
|
-
}, children))));
|
|
227
|
+
}, children)))));
|
|
226
228
|
}
|
|
@@ -19,6 +19,7 @@ import { Head, usePage } from "@inertiajs/react";
|
|
|
19
19
|
import { ProConfigProvider } from "@ant-design/pro-components";
|
|
20
20
|
import { getProValueTypeMap } from "../lib/helpers";
|
|
21
21
|
import { LayoutContext } from "./LayoutContext";
|
|
22
|
+
import _ from "lodash";
|
|
22
23
|
function ChildApp(props) {
|
|
23
24
|
var _App$useApp = App.useApp(),
|
|
24
25
|
modal = _App$useApp.modal,
|
|
@@ -38,7 +39,7 @@ function ChildApp(props) {
|
|
|
38
39
|
}, props.children));
|
|
39
40
|
}
|
|
40
41
|
export default function (props) {
|
|
41
|
-
var _pageProps$layoutProp, _pageProps$layoutProp2, _pageProps$layoutProp3, _pageProps$layoutProp4, _pageProps$layoutProp5, _pageProps$layoutProp6, _pageProps$layoutProp7, _pageProps$layoutProp8, _pageProps$
|
|
42
|
+
var _pageProps$layoutProp, _pageProps$layoutProp2, _pageProps$layoutProp3, _pageProps$layoutProp4, _pageProps$layoutProp5, _pageProps$layoutProp6, _pageProps$layoutProp7, _pageProps$layoutProp8, _pageProps$layoutProp9, _pageProps$layoutProp11;
|
|
42
43
|
var _useState = useState(false),
|
|
43
44
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
45
|
darkMode = _useState2[0],
|
|
@@ -50,15 +51,15 @@ export default function (props) {
|
|
|
50
51
|
var pageProps = usePage().props;
|
|
51
52
|
var _useState5 = useState({
|
|
52
53
|
title: ((_pageProps$layoutProp = pageProps.layoutProps) === null || _pageProps$layoutProp === void 0 ? void 0 : _pageProps$layoutProp.title) || '',
|
|
53
|
-
metaTitle: '',
|
|
54
|
-
topMenuActiveKey: (_pageProps$
|
|
55
|
-
menuActiveKey: (_pageProps$
|
|
54
|
+
metaTitle: ((_pageProps$layoutProp2 = pageProps.layoutProps) === null || _pageProps$layoutProp2 === void 0 ? void 0 : _pageProps$layoutProp2.metaTitle) || '',
|
|
55
|
+
topMenuActiveKey: (_pageProps$layoutProp3 = pageProps.layoutProps) === null || _pageProps$layoutProp3 === void 0 ? void 0 : _pageProps$layoutProp3.topMenuActiveKey,
|
|
56
|
+
menuActiveKey: (_pageProps$layoutProp4 = pageProps.layoutProps) === null || _pageProps$layoutProp4 === void 0 ? void 0 : _pageProps$layoutProp4.menuActiveKey,
|
|
56
57
|
loading: false,
|
|
57
|
-
topMenu: (_pageProps$
|
|
58
|
-
menuList: (_pageProps$
|
|
59
|
-
logo: (_pageProps$
|
|
60
|
-
userMenu: (_pageProps$
|
|
61
|
-
userName: (_pageProps$
|
|
58
|
+
topMenu: (_pageProps$layoutProp5 = pageProps.layoutProps) === null || _pageProps$layoutProp5 === void 0 ? void 0 : _pageProps$layoutProp5.topMenu,
|
|
59
|
+
menuList: (_pageProps$layoutProp6 = pageProps.layoutProps) === null || _pageProps$layoutProp6 === void 0 ? void 0 : _pageProps$layoutProp6.menuList,
|
|
60
|
+
logo: (_pageProps$layoutProp7 = pageProps.layoutProps) === null || _pageProps$layoutProp7 === void 0 ? void 0 : _pageProps$layoutProp7.logo,
|
|
61
|
+
userMenu: (_pageProps$layoutProp8 = pageProps.layoutProps) === null || _pageProps$layoutProp8 === void 0 ? void 0 : _pageProps$layoutProp8.userMenu,
|
|
62
|
+
userName: (_pageProps$layoutProp9 = pageProps.layoutProps) === null || _pageProps$layoutProp9 === void 0 ? void 0 : _pageProps$layoutProp9.userName,
|
|
62
63
|
footer: props.footer,
|
|
63
64
|
headerActions: props.headerActions
|
|
64
65
|
}),
|
|
@@ -66,12 +67,14 @@ export default function (props) {
|
|
|
66
67
|
layoutProps = _useState6[0],
|
|
67
68
|
setLayoutProps = _useState6[1];
|
|
68
69
|
var assignProps = function assignProps(newProps) {
|
|
69
|
-
setLayoutProps(
|
|
70
|
+
setLayoutProps(function (prev) {
|
|
71
|
+
return _.cloneDeep(Object.assign(prev, newProps));
|
|
72
|
+
});
|
|
70
73
|
};
|
|
71
74
|
useEffect(function () {
|
|
72
|
-
var _pageProps$
|
|
75
|
+
var _pageProps$layoutProp10;
|
|
73
76
|
console.log('props=>', pageProps);
|
|
74
|
-
if ((_pageProps$
|
|
77
|
+
if ((_pageProps$layoutProp10 = pageProps.layoutProps) !== null && _pageProps$layoutProp10 !== void 0 && _pageProps$layoutProp10.enableNewLayout) {
|
|
75
78
|
setEnableNewLayout(true);
|
|
76
79
|
}
|
|
77
80
|
var listener = function listener(e) {
|
|
@@ -126,7 +129,7 @@ export default function (props) {
|
|
|
126
129
|
dark: darkMode
|
|
127
130
|
}, /*#__PURE__*/React.createElement(AntdApp, null, /*#__PURE__*/React.createElement(ChildApp, {
|
|
128
131
|
setDarkMode: setDarkMode,
|
|
129
|
-
siteTitle: (_pageProps$
|
|
132
|
+
siteTitle: (_pageProps$layoutProp11 = pageProps.layoutProps) === null || _pageProps$layoutProp11 === void 0 ? void 0 : _pageProps$layoutProp11.siteTitle,
|
|
130
133
|
pageTitle: layoutProps.metaTitle,
|
|
131
134
|
enableNewLayout: enableNewLayout
|
|
132
135
|
}, props.children)))));
|
|
@@ -18,125 +18,191 @@ import { Button, Popconfirm } from "antd";
|
|
|
18
18
|
import React, { useContext, useEffect, useState } from "react";
|
|
19
19
|
import { TableContext } from "../../TableContext";
|
|
20
20
|
import http from "../../../lib/http";
|
|
21
|
-
import { modalShow, routerNavigateTo } from "../../../lib/helpers";
|
|
21
|
+
import { modalShow, replaceParams, replaceUrl, routerNavigateTo, treeToList } from "../../../lib/helpers";
|
|
22
22
|
import { cloneDeep } from "es-toolkit";
|
|
23
23
|
export default function (props) {
|
|
24
24
|
var tableContext = useContext(TableContext);
|
|
25
|
+
var handleRequestDataWithSelection = function handleRequestDataWithSelection(requestData) {
|
|
26
|
+
var rowKey = tableContext.getTableProps().rowKey;
|
|
27
|
+
var selectRows = tableContext.getSelectedRows();
|
|
28
|
+
var data = {};
|
|
29
|
+
selectRows.forEach(function (row) {
|
|
30
|
+
Object.keys(row).forEach(function (key) {
|
|
31
|
+
if (!data[key]) {
|
|
32
|
+
data[key] = [];
|
|
33
|
+
}
|
|
34
|
+
data[key].push(row[key]);
|
|
35
|
+
});
|
|
36
|
+
data['selection'] = selectRows.map(function (row) {
|
|
37
|
+
return row[rowKey];
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return replaceParams(requestData, data);
|
|
41
|
+
};
|
|
42
|
+
var handleSeletionRequestUrl = function handleSeletionRequestUrl(url) {
|
|
43
|
+
var selectRows = tableContext.getSelectedRows();
|
|
44
|
+
var data = {};
|
|
45
|
+
selectRows.forEach(function (row) {
|
|
46
|
+
Object.keys(row).forEach(function (key) {
|
|
47
|
+
if (!data[key]) {
|
|
48
|
+
data[key] = [];
|
|
49
|
+
}
|
|
50
|
+
data[key].push(row[key]);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
Object.keys(data).forEach(function (key) {
|
|
54
|
+
data[key] = data[key].join(',');
|
|
55
|
+
});
|
|
56
|
+
return replaceUrl(url, data);
|
|
57
|
+
};
|
|
25
58
|
var onClick = /*#__PURE__*/function () {
|
|
26
59
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
27
|
-
var
|
|
60
|
+
var data, _tableContext$getActi, _data, _tableContext$getTabl, resetData, _loop, dataKey, _tableContext$getActi2, modal;
|
|
28
61
|
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
29
62
|
while (1) switch (_context2.prev = _context2.next) {
|
|
30
63
|
case 0:
|
|
31
|
-
rowKey = tableContext.getTableProps().rowKey;
|
|
32
64
|
if (!props.link) {
|
|
33
|
-
_context2.next =
|
|
65
|
+
_context2.next = 3;
|
|
34
66
|
break;
|
|
35
67
|
}
|
|
36
68
|
routerNavigateTo(props.link.url);
|
|
37
69
|
return _context2.abrupt("return");
|
|
38
|
-
case
|
|
70
|
+
case 3:
|
|
39
71
|
if (!props.request) {
|
|
40
|
-
_context2.next =
|
|
72
|
+
_context2.next = 17;
|
|
41
73
|
break;
|
|
42
74
|
}
|
|
43
75
|
setLoading(true);
|
|
44
76
|
data = cloneDeep(props.request.data) || {};
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
break;
|
|
77
|
+
if (props.relateSelection) {
|
|
78
|
+
data = handleRequestDataWithSelection(data);
|
|
48
79
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
_context2.prev = 7;
|
|
81
|
+
_context2.next = 10;
|
|
82
|
+
return http({
|
|
83
|
+
url: props.request.url,
|
|
84
|
+
method: props.request.method,
|
|
85
|
+
headers: props.request.headers || {},
|
|
86
|
+
data: data
|
|
52
87
|
});
|
|
53
|
-
|
|
54
|
-
|
|
88
|
+
case 10:
|
|
89
|
+
_context2.next = 12;
|
|
90
|
+
return (_tableContext$getActi = tableContext.getActionRef()) === null || _tableContext$getActi === void 0 ? void 0 : _tableContext$getActi.reload();
|
|
91
|
+
case 12:
|
|
92
|
+
if (props.relateSelection) {
|
|
93
|
+
tableContext.getActionRef().clearSelected();
|
|
94
|
+
}
|
|
95
|
+
case 13:
|
|
96
|
+
_context2.prev = 13;
|
|
97
|
+
setLoading(false);
|
|
98
|
+
return _context2.finish(13);
|
|
99
|
+
case 16:
|
|
100
|
+
return _context2.abrupt("return");
|
|
101
|
+
case 17:
|
|
102
|
+
if (!props.saveRequest) {
|
|
103
|
+
_context2.next = 41;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
setLoading(true);
|
|
107
|
+
_data = tableContext.getEditedValues();
|
|
108
|
+
if (!_data.length) {
|
|
109
|
+
_data = treeToList(tableContext.getDataSource(), ((_tableContext$getTabl = tableContext.getTableProps().expandable) === null || _tableContext$getTabl === void 0 ? void 0 : _tableContext$getTabl.childrenColumnName) || 'children');
|
|
110
|
+
}
|
|
111
|
+
if (!props.saveRequest.data) {
|
|
112
|
+
_context2.next = 33;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
resetData = {};
|
|
116
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(dataKey) {
|
|
117
|
+
var match;
|
|
55
118
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
56
119
|
while (1) switch (_context.prev = _context.next) {
|
|
57
120
|
case 0:
|
|
58
|
-
|
|
59
|
-
|
|
121
|
+
resetData[dataKey] = [];
|
|
122
|
+
match = props.saveRequest.data[dataKey].match(/^__(\w+)__$/);
|
|
123
|
+
if (match) {
|
|
124
|
+
_context.next = 4;
|
|
60
125
|
break;
|
|
61
126
|
}
|
|
62
|
-
return _context.abrupt("return",
|
|
63
|
-
case
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
_context.next = 5;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
return _context.abrupt("return", 0);
|
|
70
|
-
case 5:
|
|
71
|
-
data[key] = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (item) {
|
|
72
|
-
return item[matches[1]];
|
|
127
|
+
return _context.abrupt("return", 1);
|
|
128
|
+
case 4:
|
|
129
|
+
_data.forEach(function (item) {
|
|
130
|
+
resetData[dataKey].push(item[match[1]]);
|
|
73
131
|
});
|
|
74
|
-
case
|
|
132
|
+
case 5:
|
|
75
133
|
case "end":
|
|
76
134
|
return _context.stop();
|
|
77
135
|
}
|
|
78
136
|
}, _loop);
|
|
79
137
|
});
|
|
80
|
-
_context2.t0 = _regeneratorRuntime().keys(data);
|
|
81
|
-
case
|
|
138
|
+
_context2.t0 = _regeneratorRuntime().keys(props.saveRequest.data);
|
|
139
|
+
case 25:
|
|
82
140
|
if ((_context2.t1 = _context2.t0()).done) {
|
|
83
|
-
_context2.next =
|
|
141
|
+
_context2.next = 32;
|
|
84
142
|
break;
|
|
85
143
|
}
|
|
86
|
-
|
|
87
|
-
return _context2.delegateYield(_loop(), "t2",
|
|
88
|
-
case
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
_context2.next = 18;
|
|
144
|
+
dataKey = _context2.t1.value;
|
|
145
|
+
return _context2.delegateYield(_loop(dataKey), "t2", 28);
|
|
146
|
+
case 28:
|
|
147
|
+
if (!_context2.t2) {
|
|
148
|
+
_context2.next = 30;
|
|
92
149
|
break;
|
|
93
150
|
}
|
|
94
|
-
return _context2.abrupt("continue",
|
|
95
|
-
case
|
|
96
|
-
_context2.next =
|
|
151
|
+
return _context2.abrupt("continue", 25);
|
|
152
|
+
case 30:
|
|
153
|
+
_context2.next = 25;
|
|
97
154
|
break;
|
|
98
|
-
case
|
|
99
|
-
|
|
100
|
-
|
|
155
|
+
case 32:
|
|
156
|
+
_data = resetData;
|
|
157
|
+
case 33:
|
|
158
|
+
_context2.prev = 33;
|
|
159
|
+
_context2.next = 36;
|
|
101
160
|
return http({
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
data: data
|
|
161
|
+
method: props.saveRequest.method,
|
|
162
|
+
url: props.saveRequest.url,
|
|
163
|
+
data: _data
|
|
106
164
|
});
|
|
107
|
-
case
|
|
108
|
-
_context2.next =
|
|
109
|
-
return (_tableContext$
|
|
110
|
-
case
|
|
111
|
-
|
|
112
|
-
tableContext.getActionRef().clearSelected();
|
|
113
|
-
}
|
|
114
|
-
case 26:
|
|
115
|
-
_context2.prev = 26;
|
|
165
|
+
case 36:
|
|
166
|
+
_context2.next = 38;
|
|
167
|
+
return (_tableContext$getActi2 = tableContext.getActionRef()) === null || _tableContext$getActi2 === void 0 ? void 0 : _tableContext$getActi2.reload();
|
|
168
|
+
case 38:
|
|
169
|
+
_context2.prev = 38;
|
|
116
170
|
setLoading(false);
|
|
117
|
-
return _context2.finish(
|
|
118
|
-
case
|
|
119
|
-
return _context2.abrupt("return");
|
|
120
|
-
case 30:
|
|
171
|
+
return _context2.finish(38);
|
|
172
|
+
case 41:
|
|
121
173
|
if (!props.modal) {
|
|
122
|
-
_context2.next =
|
|
174
|
+
_context2.next = 53;
|
|
123
175
|
break;
|
|
124
176
|
}
|
|
177
|
+
modal = cloneDeep(props.modal);
|
|
125
178
|
setLoading(true);
|
|
126
|
-
|
|
127
|
-
|
|
179
|
+
if (props.relateSelection && modal.content.url) {
|
|
180
|
+
modal.content.url = handleSeletionRequestUrl(modal.content.url);
|
|
181
|
+
}
|
|
182
|
+
if (props.relateSelection && modal.content.request) {
|
|
183
|
+
modal.content.request.url = handleSeletionRequestUrl(modal.content.request.url);
|
|
184
|
+
if (modal.content.request.data) {
|
|
185
|
+
modal.content.request.data = handleRequestDataWithSelection(modal.content.request.data);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
_context2.prev = 46;
|
|
189
|
+
_context2.next = 49;
|
|
190
|
+
return modalShow(_objectSpread(_objectSpread({}, modal), {}, {
|
|
128
191
|
contexts: {
|
|
129
192
|
tableContext: tableContext
|
|
130
193
|
}
|
|
131
194
|
}));
|
|
132
|
-
case
|
|
195
|
+
case 49:
|
|
196
|
+
_context2.prev = 49;
|
|
133
197
|
setLoading(false);
|
|
198
|
+
return _context2.finish(49);
|
|
199
|
+
case 52:
|
|
134
200
|
return _context2.abrupt("return");
|
|
135
|
-
case
|
|
201
|
+
case 53:
|
|
136
202
|
case "end":
|
|
137
203
|
return _context2.stop();
|
|
138
204
|
}
|
|
139
|
-
}, _callee, null, [[
|
|
205
|
+
}, _callee, null, [[7,, 13, 16], [33,, 38, 41], [46,, 49, 52]]);
|
|
140
206
|
}));
|
|
141
207
|
return function onClick() {
|
|
142
208
|
return _ref.apply(this, arguments);
|
|
@@ -13,6 +13,7 @@ import { Button, Space } from "antd";
|
|
|
13
13
|
import { TableContext } from "../../TableContext";
|
|
14
14
|
import React, { useContext, useState } from "react";
|
|
15
15
|
import http from "../../../lib/http";
|
|
16
|
+
import { treeToList } from "../../../lib/helpers";
|
|
16
17
|
export default function (props) {
|
|
17
18
|
var _tableContext$getTabl;
|
|
18
19
|
var tableContext = useContext(TableContext);
|
|
@@ -45,17 +46,20 @@ export default function (props) {
|
|
|
45
46
|
setLoading = _useState2[1];
|
|
46
47
|
var onSaveClick = /*#__PURE__*/function () {
|
|
47
48
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
48
|
-
var data, _loop, dataKey, _tableContext$getActi3;
|
|
49
|
+
var data, _tableContext$getTabl2, resetData, _loop, dataKey, _tableContext$getActi3;
|
|
49
50
|
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
50
51
|
while (1) switch (_context2.prev = _context2.next) {
|
|
51
52
|
case 0:
|
|
52
53
|
setLoading(true);
|
|
53
54
|
data = tableContext.getEditedValues();
|
|
55
|
+
if (!data.length) {
|
|
56
|
+
data = treeToList(tableContext.getDataSource(), ((_tableContext$getTabl2 = tableContext.getTableProps().expandable) === null || _tableContext$getTabl2 === void 0 ? void 0 : _tableContext$getTabl2.childrenColumnName) || 'children');
|
|
57
|
+
}
|
|
54
58
|
if (!props.saveRequest.data) {
|
|
55
|
-
_context2.next =
|
|
59
|
+
_context2.next = 15;
|
|
56
60
|
break;
|
|
57
61
|
}
|
|
58
|
-
|
|
62
|
+
resetData = {};
|
|
59
63
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(dataKey) {
|
|
60
64
|
var match;
|
|
61
65
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
@@ -69,8 +73,8 @@ export default function (props) {
|
|
|
69
73
|
}
|
|
70
74
|
return _context.abrupt("return", 1);
|
|
71
75
|
case 4:
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
data.forEach(function (item) {
|
|
77
|
+
resetData[dataKey].push(item[match[1]]);
|
|
74
78
|
});
|
|
75
79
|
case 5:
|
|
76
80
|
case "end":
|
|
@@ -79,44 +83,46 @@ export default function (props) {
|
|
|
79
83
|
}, _loop);
|
|
80
84
|
});
|
|
81
85
|
_context2.t0 = _regeneratorRuntime().keys(props.saveRequest.data);
|
|
82
|
-
case
|
|
86
|
+
case 7:
|
|
83
87
|
if ((_context2.t1 = _context2.t0()).done) {
|
|
84
|
-
_context2.next =
|
|
88
|
+
_context2.next = 14;
|
|
85
89
|
break;
|
|
86
90
|
}
|
|
87
91
|
dataKey = _context2.t1.value;
|
|
88
|
-
return _context2.delegateYield(_loop(dataKey), "t2",
|
|
89
|
-
case
|
|
92
|
+
return _context2.delegateYield(_loop(dataKey), "t2", 10);
|
|
93
|
+
case 10:
|
|
90
94
|
if (!_context2.t2) {
|
|
91
|
-
_context2.next =
|
|
95
|
+
_context2.next = 12;
|
|
92
96
|
break;
|
|
93
97
|
}
|
|
94
|
-
return _context2.abrupt("continue",
|
|
95
|
-
case
|
|
96
|
-
_context2.next =
|
|
98
|
+
return _context2.abrupt("continue", 7);
|
|
99
|
+
case 12:
|
|
100
|
+
_context2.next = 7;
|
|
97
101
|
break;
|
|
98
|
-
case
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
case 14:
|
|
103
|
+
data = resetData;
|
|
104
|
+
case 15:
|
|
105
|
+
_context2.prev = 15;
|
|
106
|
+
_context2.next = 18;
|
|
101
107
|
return http({
|
|
102
108
|
method: props.saveRequest.method,
|
|
103
109
|
url: props.saveRequest.url,
|
|
104
110
|
data: data
|
|
105
111
|
});
|
|
106
|
-
case 16:
|
|
107
|
-
_context2.next = 18;
|
|
108
|
-
return (_tableContext$getActi3 = tableContext.getActionRef()) === null || _tableContext$getActi3 === void 0 ? void 0 : _tableContext$getActi3.reload();
|
|
109
112
|
case 18:
|
|
110
|
-
_context2.
|
|
113
|
+
_context2.next = 20;
|
|
114
|
+
return (_tableContext$getActi3 = tableContext.getActionRef()) === null || _tableContext$getActi3 === void 0 ? void 0 : _tableContext$getActi3.reload();
|
|
115
|
+
case 20:
|
|
116
|
+
_context2.prev = 20;
|
|
111
117
|
setLoading(false);
|
|
112
|
-
return _context2.finish(
|
|
113
|
-
case
|
|
118
|
+
return _context2.finish(20);
|
|
119
|
+
case 23:
|
|
114
120
|
onCancelClick();
|
|
115
|
-
case
|
|
121
|
+
case 24:
|
|
116
122
|
case "end":
|
|
117
123
|
return _context2.stop();
|
|
118
124
|
}
|
|
119
|
-
}, _callee, null, [[
|
|
125
|
+
}, _callee, null, [[15,, 20, 23]]);
|
|
120
126
|
}));
|
|
121
127
|
return function onSaveClick() {
|
|
122
128
|
return _ref.apply(this, arguments);
|
package/dist/components/Table.js
CHANGED
|
@@ -17,7 +17,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
17
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
18
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
19
19
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
20
|
-
import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
20
|
+
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
21
21
|
import { ProTable } from "@ant-design/pro-components";
|
|
22
22
|
import { cloneDeep, isArray, uniqueId } from "es-toolkit/compat";
|
|
23
23
|
import { TableContext } from "./TableContext";
|
|
@@ -27,7 +27,7 @@ import http from "../lib/http";
|
|
|
27
27
|
import "./Table.scss";
|
|
28
28
|
import { ModalContext } from "./ModalContext";
|
|
29
29
|
import { commonHandler } from "../lib/schemaHandler";
|
|
30
|
-
import {
|
|
30
|
+
import { getValueByPath, routerNavigateTo, treeToList } from "../lib/helpers";
|
|
31
31
|
import qs from 'qs';
|
|
32
32
|
import { TabsContext } from "./TabsContext";
|
|
33
33
|
export default function (props) {
|
|
@@ -81,6 +81,7 @@ export default function (props) {
|
|
|
81
81
|
setDataSource(postData(props.dataSource));
|
|
82
82
|
setExtraRenderValues(props.extraRenderValues);
|
|
83
83
|
setPagination(props.pagination);
|
|
84
|
+
afterProcessData();
|
|
84
85
|
},
|
|
85
86
|
onFinish: function onFinish() {
|
|
86
87
|
setLoading(false);
|
|
@@ -105,24 +106,37 @@ export default function (props) {
|
|
|
105
106
|
setDataSource(postData(_props.dataSource));
|
|
106
107
|
setExtraRenderValues(_props.extraRenderValues);
|
|
107
108
|
setPagination(_props.pagination);
|
|
109
|
+
afterProcessData();
|
|
108
110
|
return _context.abrupt("return", {
|
|
109
111
|
data: res.data.dataSource || [],
|
|
110
112
|
success: true
|
|
111
113
|
});
|
|
112
|
-
case
|
|
113
|
-
_context.prev =
|
|
114
|
+
case 23:
|
|
115
|
+
_context.prev = 23;
|
|
114
116
|
setLoading(false);
|
|
115
|
-
return _context.finish(
|
|
116
|
-
case
|
|
117
|
+
return _context.finish(23);
|
|
118
|
+
case 26:
|
|
117
119
|
case "end":
|
|
118
120
|
return _context.stop();
|
|
119
121
|
}
|
|
120
|
-
}, _callee, null, [[10,,
|
|
122
|
+
}, _callee, null, [[10,, 23, 26]]);
|
|
121
123
|
}));
|
|
122
124
|
return function request(_x, _x2, _x3) {
|
|
123
125
|
return _ref.apply(this, arguments);
|
|
124
126
|
};
|
|
125
127
|
}();
|
|
128
|
+
var afterProcessData = useCallback(function () {
|
|
129
|
+
setTimeout(function () {
|
|
130
|
+
var _props$expandable;
|
|
131
|
+
var keys = treeToList(dataSource, ((_props$expandable = props.expandable) === null || _props$expandable === void 0 ? void 0 : _props$expandable.childrenColumnName) || 'children').map(function (r) {
|
|
132
|
+
return r[props.rowKey] + '';
|
|
133
|
+
});
|
|
134
|
+
if (props.defaultEditMode) {
|
|
135
|
+
setEditableKeys(keys);
|
|
136
|
+
console.log(555, keys);
|
|
137
|
+
}
|
|
138
|
+
}, 500);
|
|
139
|
+
}, []);
|
|
126
140
|
var postData = function postData(data) {
|
|
127
141
|
if (!isArray(data)) {
|
|
128
142
|
return data;
|
|
@@ -317,6 +331,7 @@ export default function (props) {
|
|
|
317
331
|
setSearchUrl(s);
|
|
318
332
|
}
|
|
319
333
|
setDataSource(postData(props.dataSource || []));
|
|
334
|
+
afterProcessData();
|
|
320
335
|
if (!modalContext.inModal) {
|
|
321
336
|
var query = qs.parse(window.location.search.replace(/^\?/, ''));
|
|
322
337
|
if (query && Object.keys(query).length) {
|
|
@@ -356,6 +371,9 @@ export default function (props) {
|
|
|
356
371
|
},
|
|
357
372
|
extraRenderValues: extraRenderValues,
|
|
358
373
|
dataSource: dataSource,
|
|
374
|
+
getDataSource: function getDataSource() {
|
|
375
|
+
return dataSource;
|
|
376
|
+
},
|
|
359
377
|
getSelectedRows: function getSelectedRows() {
|
|
360
378
|
return selectedRows;
|
|
361
379
|
}
|
|
@@ -447,8 +465,8 @@ export default function (props) {
|
|
|
447
465
|
editableKeys: editableKeys,
|
|
448
466
|
onChange: setEditableKeys,
|
|
449
467
|
onValuesChange: function onValuesChange(record, newDataSource) {
|
|
450
|
-
var _props$
|
|
451
|
-
setEditableValues(
|
|
468
|
+
var _props$expandable2;
|
|
469
|
+
setEditableValues(treeToList(newDataSource, ((_props$expandable2 = props.expandable) === null || _props$expandable2 === void 0 ? void 0 : _props$expandable2.childrenColumnName) || 'children'));
|
|
452
470
|
}
|
|
453
471
|
},
|
|
454
472
|
cardBordered: true,
|
|
@@ -12,7 +12,8 @@ export type TableContextValue = {
|
|
|
12
12
|
};
|
|
13
13
|
getFormRef: () => FormInstance;
|
|
14
14
|
extraRenderValues?: Record<string, any>[];
|
|
15
|
-
dataSource: any[];
|
|
16
15
|
getSelectedRows: () => any[];
|
|
16
|
+
dataSource: any[];
|
|
17
|
+
getDataSource: () => any[];
|
|
17
18
|
};
|
|
18
19
|
export declare const TableContext: React.Context<TableContextValue>;
|
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare function handleCondition(condition: Condition, data: any): any;
|
|
|
16
16
|
export declare function deepSet(obj: any, path: string, value: any): void;
|
|
17
17
|
export declare function filterObjectKeys(obj: Record<string, any>, keysToFilter: string[]): Record<string, any>;
|
|
18
18
|
export declare function diffTree(tree1: any[], tree2: any[], childKey: string): any[];
|
|
19
|
+
export declare function treeToList(tree: any[], childKey: string): any[];
|
|
19
20
|
export declare function findValuePath(obj: any, target: any, path?: string[]): string[] | null;
|
|
20
21
|
export declare function getValueByPath(obj: any, path: string[]): any;
|
|
21
22
|
export declare function renderTextarea(text: string): React.JSX.Element;
|