@quansitech/antd-admin 1.1.26 → 1.1.27
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.
|
@@ -19,11 +19,12 @@ import React, { useContext, useEffect, useState } from "react";
|
|
|
19
19
|
import { TableContext } from "../../TableContext";
|
|
20
20
|
import http from "../../../lib/http";
|
|
21
21
|
import { modalShow, routerNavigateTo } from "../../../lib/helpers";
|
|
22
|
+
import { cloneDeep } from "es-toolkit";
|
|
22
23
|
export default function (props) {
|
|
23
24
|
var tableContext = useContext(TableContext);
|
|
24
25
|
var onClick = /*#__PURE__*/function () {
|
|
25
26
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
26
|
-
var rowKey, data,
|
|
27
|
+
var rowKey, data, selectedRows, _loop, _ret, key, _tableContext$getActi;
|
|
27
28
|
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
28
29
|
while (1) switch (_context2.prev = _context2.next) {
|
|
29
30
|
case 0:
|
|
@@ -36,20 +37,20 @@ export default function (props) {
|
|
|
36
37
|
return _context2.abrupt("return");
|
|
37
38
|
case 4:
|
|
38
39
|
if (!props.request) {
|
|
39
|
-
_context2.next =
|
|
40
|
+
_context2.next = 30;
|
|
40
41
|
break;
|
|
41
42
|
}
|
|
42
43
|
setLoading(true);
|
|
43
|
-
data = props.request.data || {};
|
|
44
|
+
data = cloneDeep(props.request.data) || {};
|
|
44
45
|
if (!props.relateSelection) {
|
|
45
|
-
_context2.next =
|
|
46
|
+
_context2.next = 20;
|
|
46
47
|
break;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
selectedRows = tableContext.getSelectedRows();
|
|
50
|
+
data.selection = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (item) {
|
|
49
51
|
return item[rowKey];
|
|
50
52
|
});
|
|
51
53
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
52
|
-
var _props$selectedRows2;
|
|
53
54
|
var matches;
|
|
54
55
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
55
56
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -67,7 +68,7 @@ export default function (props) {
|
|
|
67
68
|
}
|
|
68
69
|
return _context.abrupt("return", 0);
|
|
69
70
|
case 5:
|
|
70
|
-
data[key] =
|
|
71
|
+
data[key] = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (item) {
|
|
71
72
|
return item[matches[1]];
|
|
72
73
|
});
|
|
73
74
|
case 6:
|
|
@@ -77,65 +78,65 @@ export default function (props) {
|
|
|
77
78
|
}, _loop);
|
|
78
79
|
});
|
|
79
80
|
_context2.t0 = _regeneratorRuntime().keys(data);
|
|
80
|
-
case
|
|
81
|
+
case 12:
|
|
81
82
|
if ((_context2.t1 = _context2.t0()).done) {
|
|
82
|
-
_context2.next =
|
|
83
|
+
_context2.next = 20;
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
85
86
|
key = _context2.t1.value;
|
|
86
|
-
return _context2.delegateYield(_loop(), "t2",
|
|
87
|
-
case
|
|
87
|
+
return _context2.delegateYield(_loop(), "t2", 15);
|
|
88
|
+
case 15:
|
|
88
89
|
_ret = _context2.t2;
|
|
89
90
|
if (!(_ret === 0)) {
|
|
90
|
-
_context2.next =
|
|
91
|
+
_context2.next = 18;
|
|
91
92
|
break;
|
|
92
93
|
}
|
|
93
|
-
return _context2.abrupt("continue",
|
|
94
|
-
case
|
|
95
|
-
_context2.next =
|
|
94
|
+
return _context2.abrupt("continue", 12);
|
|
95
|
+
case 18:
|
|
96
|
+
_context2.next = 12;
|
|
96
97
|
break;
|
|
97
|
-
case
|
|
98
|
-
_context2.prev =
|
|
99
|
-
_context2.next =
|
|
98
|
+
case 20:
|
|
99
|
+
_context2.prev = 20;
|
|
100
|
+
_context2.next = 23;
|
|
100
101
|
return http({
|
|
101
102
|
url: props.request.url,
|
|
102
103
|
method: props.request.method,
|
|
103
104
|
headers: props.request.headers || {},
|
|
104
105
|
data: data
|
|
105
106
|
});
|
|
106
|
-
case
|
|
107
|
-
_context2.next =
|
|
107
|
+
case 23:
|
|
108
|
+
_context2.next = 25;
|
|
108
109
|
return (_tableContext$getActi = tableContext.getActionRef()) === null || _tableContext$getActi === void 0 ? void 0 : _tableContext$getActi.reload();
|
|
109
|
-
case
|
|
110
|
+
case 25:
|
|
110
111
|
if (props.relateSelection) {
|
|
111
112
|
tableContext.getActionRef().clearSelected();
|
|
112
113
|
}
|
|
113
|
-
case
|
|
114
|
-
_context2.prev =
|
|
114
|
+
case 26:
|
|
115
|
+
_context2.prev = 26;
|
|
115
116
|
setLoading(false);
|
|
116
|
-
return _context2.finish(
|
|
117
|
-
case 28:
|
|
118
|
-
return _context2.abrupt("return");
|
|
117
|
+
return _context2.finish(26);
|
|
119
118
|
case 29:
|
|
119
|
+
return _context2.abrupt("return");
|
|
120
|
+
case 30:
|
|
120
121
|
if (!props.modal) {
|
|
121
|
-
_context2.next =
|
|
122
|
+
_context2.next = 36;
|
|
122
123
|
break;
|
|
123
124
|
}
|
|
124
125
|
setLoading(true);
|
|
125
|
-
_context2.next =
|
|
126
|
+
_context2.next = 34;
|
|
126
127
|
return modalShow(_objectSpread(_objectSpread({}, props.modal), {}, {
|
|
127
128
|
contexts: {
|
|
128
129
|
tableContext: tableContext
|
|
129
130
|
}
|
|
130
131
|
}));
|
|
131
|
-
case
|
|
132
|
+
case 34:
|
|
132
133
|
setLoading(false);
|
|
133
134
|
return _context2.abrupt("return");
|
|
134
|
-
case
|
|
135
|
+
case 36:
|
|
135
136
|
case "end":
|
|
136
137
|
return _context2.stop();
|
|
137
138
|
}
|
|
138
|
-
}, _callee, null, [[
|
|
139
|
+
}, _callee, null, [[20,, 26, 29]]);
|
|
139
140
|
}));
|
|
140
141
|
return function onClick() {
|
|
141
142
|
return _ref.apply(this, arguments);
|
|
@@ -150,12 +151,12 @@ export default function (props) {
|
|
|
150
151
|
disabled = _useState4[0],
|
|
151
152
|
setDisabled = _useState4[1];
|
|
152
153
|
useEffect(function () {
|
|
153
|
-
var
|
|
154
|
+
var _tableContext$getSele;
|
|
154
155
|
if (!props.relateSelection) {
|
|
155
156
|
return;
|
|
156
157
|
}
|
|
157
|
-
setDisabled(((
|
|
158
|
-
}, [
|
|
158
|
+
setDisabled(((_tableContext$getSele = tableContext.getSelectedRows()) === null || _tableContext$getSele === void 0 ? void 0 : _tableContext$getSele.length) === 0);
|
|
159
|
+
}, [tableContext.getSelectedRows()]);
|
|
159
160
|
var ButtonComponent = function ButtonComponent() {
|
|
160
161
|
var _props$request;
|
|
161
162
|
if ((_props$request = props.request) !== null && _props$request !== void 0 && _props$request.confirm) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -40,10 +39,6 @@ export default function (_ref) {
|
|
|
40
39
|
style: {
|
|
41
40
|
zIndex: 100
|
|
42
41
|
}
|
|
43
|
-
}, /*#__PURE__*/React.createElement(c.Component,
|
|
44
|
-
selectedRows: selectedRows
|
|
45
|
-
}))) : /*#__PURE__*/React.createElement(c.Component, _extends({}, c.props, {
|
|
46
|
-
selectedRows: selectedRows
|
|
47
|
-
})));
|
|
42
|
+
}, /*#__PURE__*/React.createElement(c.Component, c.props)) : /*#__PURE__*/React.createElement(c.Component, c.props));
|
|
48
43
|
})));
|
|
49
44
|
}
|
package/dist/components/Table.js
CHANGED
|
@@ -233,7 +233,10 @@ export default function (props) {
|
|
|
233
233
|
return formRef.current;
|
|
234
234
|
},
|
|
235
235
|
extraRenderValues: extraRenderValues,
|
|
236
|
-
dataSource: dataSource
|
|
236
|
+
dataSource: dataSource,
|
|
237
|
+
getSelectedRows: function getSelectedRows() {
|
|
238
|
+
return selectedRows;
|
|
239
|
+
}
|
|
237
240
|
}
|
|
238
241
|
}, /*#__PURE__*/React.createElement(ProTable, {
|
|
239
242
|
rowKey: props.rowKey,
|
|
@@ -308,8 +311,7 @@ export default function (props) {
|
|
|
308
311
|
toolBarRender: function toolBarRender(action) {
|
|
309
312
|
return [/*#__PURE__*/React.createElement(ToolbarActions, {
|
|
310
313
|
key: 'actions',
|
|
311
|
-
actions: props.actions
|
|
312
|
-
selectedRows: selectedRows
|
|
314
|
+
actions: props.actions
|
|
313
315
|
})];
|
|
314
316
|
},
|
|
315
317
|
editable: {
|