@quansitech/antd-admin 1.2.8 → 1.3.0
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/Column/Readonly/Cascader.js +4 -4
- 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 +101 -30
- 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 +11 -0
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ export default function (props) {
|
|
|
24
24
|
var findValue = function findValue(options, value) {
|
|
25
25
|
for (var i = 0; i < options.length; i++) {
|
|
26
26
|
var option = options[i];
|
|
27
|
-
if (option.value
|
|
27
|
+
if (option.value == value) {
|
|
28
28
|
return [option.label];
|
|
29
29
|
} else if (option.children) {
|
|
30
30
|
return [option.label].concat(_toConsumableArray(findValue(option.children, value)));
|
|
@@ -33,8 +33,8 @@ export default function (props) {
|
|
|
33
33
|
};
|
|
34
34
|
useEffect(function () {
|
|
35
35
|
var _props$fieldProps, _props$fieldProps2, _props$fieldProps3;
|
|
36
|
-
setText(props.
|
|
37
|
-
var value = props.
|
|
36
|
+
setText(props.text);
|
|
37
|
+
var value = props.text;
|
|
38
38
|
var extraData;
|
|
39
39
|
if ((_props$fieldProps = props.fieldProps) !== null && _props$fieldProps !== void 0 && _props$fieldProps.extraRenderValue) {
|
|
40
40
|
extraData = props.fieldProps.extraRenderValue;
|
|
@@ -53,7 +53,7 @@ export default function (props) {
|
|
|
53
53
|
}
|
|
54
54
|
extraData = (_props$fieldProps$ext = props.fieldProps.extraRenderValues[index]) !== null && _props$fieldProps$ext !== void 0 ? _props$fieldProps$ext : [];
|
|
55
55
|
}
|
|
56
|
-
if (extraData) {
|
|
56
|
+
if (extraData && value && value != '-') {
|
|
57
57
|
setText(findValue(extraData.options, value).join(' / '));
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
@@ -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,32 +18,32 @@ 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, 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
25
|
var onClick = /*#__PURE__*/function () {
|
|
26
26
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
27
|
-
var rowKey, data, selectedRows, _loop, _ret, key, _tableContext$getActi;
|
|
28
|
-
return _regeneratorRuntime().wrap(function _callee$(
|
|
29
|
-
while (1) switch (
|
|
27
|
+
var rowKey, data, selectedRows, _loop, _ret, key, _tableContext$getActi, _data, _tableContext$getTabl, resetData, _loop2, dataKey, _tableContext$getActi2;
|
|
28
|
+
return _regeneratorRuntime().wrap(function _callee$(_context3) {
|
|
29
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
30
30
|
case 0:
|
|
31
31
|
rowKey = tableContext.getTableProps().rowKey;
|
|
32
32
|
if (!props.link) {
|
|
33
|
-
|
|
33
|
+
_context3.next = 4;
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
36
|
routerNavigateTo(props.link.url);
|
|
37
|
-
return
|
|
37
|
+
return _context3.abrupt("return");
|
|
38
38
|
case 4:
|
|
39
39
|
if (!props.request) {
|
|
40
|
-
|
|
40
|
+
_context3.next = 30;
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
43
|
setLoading(true);
|
|
44
44
|
data = cloneDeep(props.request.data) || {};
|
|
45
45
|
if (!props.relateSelection) {
|
|
46
|
-
|
|
46
|
+
_context3.next = 20;
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
selectedRows = tableContext.getSelectedRows();
|
|
@@ -77,27 +77,27 @@ export default function (props) {
|
|
|
77
77
|
}
|
|
78
78
|
}, _loop);
|
|
79
79
|
});
|
|
80
|
-
|
|
80
|
+
_context3.t0 = _regeneratorRuntime().keys(data);
|
|
81
81
|
case 12:
|
|
82
|
-
if ((
|
|
83
|
-
|
|
82
|
+
if ((_context3.t1 = _context3.t0()).done) {
|
|
83
|
+
_context3.next = 20;
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
|
-
key =
|
|
87
|
-
return
|
|
86
|
+
key = _context3.t1.value;
|
|
87
|
+
return _context3.delegateYield(_loop(), "t2", 15);
|
|
88
88
|
case 15:
|
|
89
|
-
_ret =
|
|
89
|
+
_ret = _context3.t2;
|
|
90
90
|
if (!(_ret === 0)) {
|
|
91
|
-
|
|
91
|
+
_context3.next = 18;
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
|
-
return
|
|
94
|
+
return _context3.abrupt("continue", 12);
|
|
95
95
|
case 18:
|
|
96
|
-
|
|
96
|
+
_context3.next = 12;
|
|
97
97
|
break;
|
|
98
98
|
case 20:
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
_context3.prev = 20;
|
|
100
|
+
_context3.next = 23;
|
|
101
101
|
return http({
|
|
102
102
|
url: props.request.url,
|
|
103
103
|
method: props.request.method,
|
|
@@ -105,38 +105,109 @@ export default function (props) {
|
|
|
105
105
|
data: data
|
|
106
106
|
});
|
|
107
107
|
case 23:
|
|
108
|
-
|
|
108
|
+
_context3.next = 25;
|
|
109
109
|
return (_tableContext$getActi = tableContext.getActionRef()) === null || _tableContext$getActi === void 0 ? void 0 : _tableContext$getActi.reload();
|
|
110
110
|
case 25:
|
|
111
111
|
if (props.relateSelection) {
|
|
112
112
|
tableContext.getActionRef().clearSelected();
|
|
113
113
|
}
|
|
114
114
|
case 26:
|
|
115
|
-
|
|
115
|
+
_context3.prev = 26;
|
|
116
116
|
setLoading(false);
|
|
117
|
-
return
|
|
117
|
+
return _context3.finish(26);
|
|
118
118
|
case 29:
|
|
119
|
-
return
|
|
119
|
+
return _context3.abrupt("return");
|
|
120
120
|
case 30:
|
|
121
|
+
if (!props.saveRequest) {
|
|
122
|
+
_context3.next = 54;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
setLoading(true);
|
|
126
|
+
_data = tableContext.getEditedValues();
|
|
127
|
+
if (!_data.length) {
|
|
128
|
+
_data = treeToList(tableContext.getDataSource(), ((_tableContext$getTabl = tableContext.getTableProps().expandable) === null || _tableContext$getTabl === void 0 ? void 0 : _tableContext$getTabl.childrenColumnName) || 'children');
|
|
129
|
+
}
|
|
130
|
+
if (!props.saveRequest.data) {
|
|
131
|
+
_context3.next = 46;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
resetData = {};
|
|
135
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2(dataKey) {
|
|
136
|
+
var match;
|
|
137
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context2) {
|
|
138
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
resetData[dataKey] = [];
|
|
141
|
+
match = props.saveRequest.data[dataKey].match(/^__(\w+)__$/);
|
|
142
|
+
if (match) {
|
|
143
|
+
_context2.next = 4;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
return _context2.abrupt("return", 1);
|
|
147
|
+
case 4:
|
|
148
|
+
_data.forEach(function (item) {
|
|
149
|
+
resetData[dataKey].push(item[match[1]]);
|
|
150
|
+
});
|
|
151
|
+
case 5:
|
|
152
|
+
case "end":
|
|
153
|
+
return _context2.stop();
|
|
154
|
+
}
|
|
155
|
+
}, _loop2);
|
|
156
|
+
});
|
|
157
|
+
_context3.t3 = _regeneratorRuntime().keys(props.saveRequest.data);
|
|
158
|
+
case 38:
|
|
159
|
+
if ((_context3.t4 = _context3.t3()).done) {
|
|
160
|
+
_context3.next = 45;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
dataKey = _context3.t4.value;
|
|
164
|
+
return _context3.delegateYield(_loop2(dataKey), "t5", 41);
|
|
165
|
+
case 41:
|
|
166
|
+
if (!_context3.t5) {
|
|
167
|
+
_context3.next = 43;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
return _context3.abrupt("continue", 38);
|
|
171
|
+
case 43:
|
|
172
|
+
_context3.next = 38;
|
|
173
|
+
break;
|
|
174
|
+
case 45:
|
|
175
|
+
_data = resetData;
|
|
176
|
+
case 46:
|
|
177
|
+
_context3.prev = 46;
|
|
178
|
+
_context3.next = 49;
|
|
179
|
+
return http({
|
|
180
|
+
method: props.saveRequest.method,
|
|
181
|
+
url: props.saveRequest.url,
|
|
182
|
+
data: _data
|
|
183
|
+
});
|
|
184
|
+
case 49:
|
|
185
|
+
_context3.next = 51;
|
|
186
|
+
return (_tableContext$getActi2 = tableContext.getActionRef()) === null || _tableContext$getActi2 === void 0 ? void 0 : _tableContext$getActi2.reload();
|
|
187
|
+
case 51:
|
|
188
|
+
_context3.prev = 51;
|
|
189
|
+
setLoading(false);
|
|
190
|
+
return _context3.finish(51);
|
|
191
|
+
case 54:
|
|
121
192
|
if (!props.modal) {
|
|
122
|
-
|
|
193
|
+
_context3.next = 60;
|
|
123
194
|
break;
|
|
124
195
|
}
|
|
125
196
|
setLoading(true);
|
|
126
|
-
|
|
197
|
+
_context3.next = 58;
|
|
127
198
|
return modalShow(_objectSpread(_objectSpread({}, props.modal), {}, {
|
|
128
199
|
contexts: {
|
|
129
200
|
tableContext: tableContext
|
|
130
201
|
}
|
|
131
202
|
}));
|
|
132
|
-
case
|
|
203
|
+
case 58:
|
|
133
204
|
setLoading(false);
|
|
134
|
-
return
|
|
135
|
-
case
|
|
205
|
+
return _context3.abrupt("return");
|
|
206
|
+
case 60:
|
|
136
207
|
case "end":
|
|
137
|
-
return
|
|
208
|
+
return _context3.stop();
|
|
138
209
|
}
|
|
139
|
-
}, _callee, null, [[20,, 26, 29]]);
|
|
210
|
+
}, _callee, null, [[20,, 26, 29], [46,, 51, 54]]);
|
|
140
211
|
}));
|
|
141
212
|
return function onClick() {
|
|
142
213
|
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;
|
package/dist/lib/helpers.js
CHANGED
|
@@ -250,6 +250,17 @@ export function diffTree(tree1, tree2, childKey) {
|
|
|
250
250
|
}
|
|
251
251
|
return res;
|
|
252
252
|
}
|
|
253
|
+
export function treeToList(tree, childKey) {
|
|
254
|
+
var res = [];
|
|
255
|
+
for (var key in tree) {
|
|
256
|
+
var item = tree[key];
|
|
257
|
+
res.push(filterObjectKeys(item, ['children']));
|
|
258
|
+
if (item[childKey]) {
|
|
259
|
+
res.push.apply(res, _toConsumableArray(treeToList(item[childKey], childKey)));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return res;
|
|
263
|
+
}
|
|
253
264
|
export function findValuePath(obj, target) {
|
|
254
265
|
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
255
266
|
for (var key in obj) {
|