antd-management-fast-framework 1.12.27 → 1.12.28
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/es/framework/AuthorizationWrapper/index.js +2 -2
- package/es/framework/Base/index.d.ts +6 -0
- package/es/framework/Base/index.js +39 -0
- package/es/framework/Common/index.d.ts +1 -2
- package/es/framework/Common/index.js +24 -30
- package/es/framework/DataForm/BaseAddForm/index.js +14 -17
- package/es/framework/DataForm/BaseUpdateForm/index.js +10 -12
- package/es/framework/DataOperation/BaseWindow/index.js +10 -12
- package/es/utils/actionAssist.d.ts +7 -6
- package/es/utils/actionAssist.js +41 -20
- package/package.json +2 -2
|
@@ -90,8 +90,8 @@ var AuthorizationWrapper = /*#__PURE__*/function (_SupplementWrapper) {
|
|
|
90
90
|
|
|
91
91
|
_this.reloadCurrentOperator = function () {
|
|
92
92
|
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
|
|
94
|
+
_this.dispatchApi({
|
|
95
95
|
type: 'global/getCurrentOperator',
|
|
96
96
|
payload: {
|
|
97
97
|
force: true
|
|
@@ -37,6 +37,12 @@ declare class Base extends Component<any, any, any> {
|
|
|
37
37
|
afterDidMount: () => void;
|
|
38
38
|
beforeUnmount: () => void;
|
|
39
39
|
afterUnmount: () => void;
|
|
40
|
+
getDispatch: () => any;
|
|
41
|
+
getDispatchWrapper: () => any;
|
|
42
|
+
dispatchApi: ({ type, payload }: {
|
|
43
|
+
type: any;
|
|
44
|
+
payload: any;
|
|
45
|
+
}) => any;
|
|
40
46
|
goToPath: (path: any) => void;
|
|
41
47
|
redirectToPath: (path: any) => void;
|
|
42
48
|
checkHasMore: (pageNo: any, pageSize: any, total: any) => boolean;
|
|
@@ -13,6 +13,8 @@ var _nprogress = _interopRequireDefault(require("nprogress"));
|
|
|
13
13
|
|
|
14
14
|
var _tools = require("../../utils/tools");
|
|
15
15
|
|
|
16
|
+
var _actionAssist = require("../../utils/actionAssist");
|
|
17
|
+
|
|
16
18
|
var _defaultSettingsSpecial = require("../../utils/defaultSettingsSpecial");
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -155,6 +157,43 @@ var Base = /*#__PURE__*/function (_Component) {
|
|
|
155
157
|
|
|
156
158
|
_this.afterUnmount = function () {};
|
|
157
159
|
|
|
160
|
+
_this.getDispatch = function () {
|
|
161
|
+
if ((0, _tools.isObject)(_this.props)) {
|
|
162
|
+
var dispatch = _this.props.dispatch;
|
|
163
|
+
|
|
164
|
+
if ((0, _tools.isFunction)(dispatch)) {
|
|
165
|
+
return dispatch;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
var text = 'please override getDispatch, and return a function';
|
|
170
|
+
(0, _tools.recordError)(text);
|
|
171
|
+
throw new Error(text);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
_this.getDispatchWrapper = function () {
|
|
175
|
+
var dispatch = _this.getDispatch();
|
|
176
|
+
|
|
177
|
+
if (!(0, _tools.isFunction)(dispatch)) {
|
|
178
|
+
(0, _tools.recordError)('dispatch not a function, please check getDispatch');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return dispatch;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
_this.dispatchApi = function (_ref) {
|
|
185
|
+
var type = _ref.type,
|
|
186
|
+
payload = _ref.payload;
|
|
187
|
+
|
|
188
|
+
var dispatch = _this.getDispatchWrapper();
|
|
189
|
+
|
|
190
|
+
(0, _tools.recordDebug)("modal access: ".concat(type));
|
|
191
|
+
return dispatch({
|
|
192
|
+
type: type,
|
|
193
|
+
payload: payload
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
|
|
158
197
|
_this.goToPath = function (path) {
|
|
159
198
|
var location = {
|
|
160
199
|
pathname: path
|
|
@@ -29,7 +29,7 @@ declare class Common extends Core {
|
|
|
29
29
|
};
|
|
30
30
|
checkNeedUpdate: (preProps: any, preState: any, snapshot: any) => boolean;
|
|
31
31
|
getGlobal: () => any;
|
|
32
|
-
|
|
32
|
+
apiDataConvert: (props: any) => {
|
|
33
33
|
metaOriginalData: {
|
|
34
34
|
dataSuccess: boolean;
|
|
35
35
|
};
|
|
@@ -69,7 +69,6 @@ declare class Common extends Core {
|
|
|
69
69
|
requestData: any;
|
|
70
70
|
callback: any;
|
|
71
71
|
}) => void;
|
|
72
|
-
lastLoadParams: any;
|
|
73
72
|
pageListData: (otherState: any, callback?: null, delay?: number) => void;
|
|
74
73
|
reloadData: (otherState: any, callback?: null, delay?: number) => void;
|
|
75
74
|
searchData: (otherState: any, callback?: null, delay?: number) => void;
|
|
@@ -103,6 +103,8 @@ var _Core2 = _interopRequireDefault(require("../Core"));
|
|
|
103
103
|
|
|
104
104
|
var _index = _interopRequireDefault(require("./index.less"));
|
|
105
105
|
|
|
106
|
+
var _dataSet = require("@antv/data-set");
|
|
107
|
+
|
|
106
108
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
107
109
|
|
|
108
110
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -182,8 +184,8 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
182
184
|
return global;
|
|
183
185
|
};
|
|
184
186
|
|
|
185
|
-
_this.
|
|
186
|
-
var text = '
|
|
187
|
+
_this.apiDataConvert = function (props) {
|
|
188
|
+
var text = 'apiDataConvert 方法需要重载实现';
|
|
187
189
|
(0, _tools.showRuntimeError)({
|
|
188
190
|
message: text
|
|
189
191
|
});
|
|
@@ -346,9 +348,9 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
346
348
|
callback = _ref3.callback;
|
|
347
349
|
var loadApiPath = '';
|
|
348
350
|
|
|
349
|
-
|
|
350
|
-
var dispatch = _this.props.dispatch;
|
|
351
|
+
var that = _assertThisInitialized(_this);
|
|
351
352
|
|
|
353
|
+
try {
|
|
352
354
|
var requestingDataPre = _this.getRequestingData();
|
|
353
355
|
|
|
354
356
|
var loadApiCustomPath = _this.adjustLoadApiPath();
|
|
@@ -367,12 +369,11 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
367
369
|
type: loadApiPath,
|
|
368
370
|
payload: requestData
|
|
369
371
|
})) {
|
|
370
|
-
|
|
372
|
+
that.setRequestingData({
|
|
371
373
|
type: loadApiPath,
|
|
372
374
|
payload: requestData
|
|
373
375
|
});
|
|
374
|
-
|
|
375
|
-
dispatch({
|
|
376
|
+
that.dispatchApi({
|
|
376
377
|
type: loadApiPath,
|
|
377
378
|
payload: requestData
|
|
378
379
|
}).then(function () {
|
|
@@ -385,16 +386,14 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
385
386
|
paging: false,
|
|
386
387
|
dispatchComplete: true
|
|
387
388
|
};
|
|
388
|
-
|
|
389
|
-
var metaOriginalData = _this.getApiData(_this.props);
|
|
389
|
+
var metaOriginalData = that.apiDataConvert(that.props);
|
|
390
390
|
|
|
391
391
|
if ((0, _tools.isUndefined)(metaOriginalData)) {
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
that.setState(willSaveToState);
|
|
394
393
|
return;
|
|
395
394
|
}
|
|
396
395
|
|
|
397
|
-
|
|
396
|
+
that.lastLoadParams = requestData;
|
|
398
397
|
var dataSuccess = metaOriginalData.dataSuccess;
|
|
399
398
|
willSaveToState = _objectSpread(_objectSpread({}, willSaveToState), {
|
|
400
399
|
loadSuccess: dataSuccess
|
|
@@ -412,7 +411,7 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
412
411
|
}), willSaveToState);
|
|
413
412
|
|
|
414
413
|
try {
|
|
415
|
-
|
|
414
|
+
that.afterLoadSuccess({
|
|
416
415
|
metaData: metaData || null,
|
|
417
416
|
metaListData: metaListData || [],
|
|
418
417
|
metaExtra: metaExtra || null,
|
|
@@ -427,12 +426,11 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
427
426
|
}
|
|
428
427
|
}
|
|
429
428
|
|
|
430
|
-
var reloadingComplete =
|
|
429
|
+
var reloadingComplete = that.state.reloading;
|
|
431
430
|
|
|
432
431
|
if (reloadingComplete) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
_this.afterGetReLoadRequestResult(requestData, metaOriginalData);
|
|
432
|
+
that.afterReloadSuccess();
|
|
433
|
+
that.afterGetReLoadRequestResult(requestData, metaOriginalData);
|
|
436
434
|
}
|
|
437
435
|
|
|
438
436
|
if (!firstLoadSuccess) {
|
|
@@ -441,25 +439,23 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
441
439
|
});
|
|
442
440
|
}
|
|
443
441
|
|
|
444
|
-
|
|
442
|
+
that.setState(willSaveToState);
|
|
445
443
|
|
|
446
444
|
if (!firstLoadSuccess) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
_this.afterGetFirstRequestResult(requestData, metaOriginalData);
|
|
445
|
+
that.afterFirstLoadSuccess();
|
|
446
|
+
that.afterGetFirstRequestResult(requestData, metaOriginalData);
|
|
450
447
|
}
|
|
451
448
|
|
|
452
|
-
|
|
449
|
+
that.afterGetRequestResult(requestData, metaOriginalData);
|
|
453
450
|
|
|
454
451
|
if (typeof callback === 'function') {
|
|
455
452
|
callback();
|
|
456
453
|
}
|
|
457
454
|
|
|
458
|
-
|
|
455
|
+
that.clearRequestingData();
|
|
459
456
|
}).catch(function (res) {
|
|
460
457
|
(0, _tools.recordObject)(res);
|
|
461
|
-
|
|
462
|
-
_this.setState({
|
|
458
|
+
that.setState({
|
|
463
459
|
dataLoading: false,
|
|
464
460
|
loadSuccess: false,
|
|
465
461
|
reloading: false,
|
|
@@ -475,8 +471,7 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
475
471
|
loadApiPath: loadApiPath,
|
|
476
472
|
requestData: requestData
|
|
477
473
|
});
|
|
478
|
-
|
|
479
|
-
_this.setState({
|
|
474
|
+
that.setState({
|
|
480
475
|
dataLoading: false,
|
|
481
476
|
loadSuccess: false,
|
|
482
477
|
reloading: false,
|
|
@@ -485,7 +480,6 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
485
480
|
paging: false,
|
|
486
481
|
dispatchComplete: true
|
|
487
482
|
});
|
|
488
|
-
|
|
489
483
|
throw error;
|
|
490
484
|
}
|
|
491
485
|
};
|
|
@@ -552,8 +546,8 @@ var Common = /*#__PURE__*/function (_Core) {
|
|
|
552
546
|
|
|
553
547
|
_this.reloadGlobalData = function () {
|
|
554
548
|
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
555
|
-
|
|
556
|
-
|
|
549
|
+
|
|
550
|
+
_this.dispatchApi({
|
|
557
551
|
type: 'global/getMetaData',
|
|
558
552
|
payload: {
|
|
559
553
|
force: true
|
|
@@ -141,40 +141,38 @@ var BaseAddForm = /*#__PURE__*/function (_DataCore) {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
_this.validate = function (e) {
|
|
144
|
-
var dispatch = _this.props.dispatch;
|
|
145
|
-
|
|
146
144
|
var form = _this.getTargetForm();
|
|
147
145
|
|
|
148
146
|
var validateFields = form.validateFields;
|
|
149
|
-
|
|
147
|
+
|
|
148
|
+
var that = _assertThisInitialized(_this);
|
|
149
|
+
|
|
150
|
+
var submitApiPath = that.state.submitApiPath;
|
|
150
151
|
validateFields().then(function (values) {
|
|
151
152
|
var submitData = (0, _requestAssistor.pretreatmentRequestParams)(values);
|
|
152
|
-
submitData =
|
|
153
|
-
|
|
154
|
-
var checkResult = _this.checkSubmitData(submitData);
|
|
153
|
+
submitData = that.supplementSubmitRequestParams(submitData);
|
|
154
|
+
var checkResult = that.checkSubmitData(submitData);
|
|
155
155
|
|
|
156
156
|
if (checkResult) {
|
|
157
|
-
|
|
157
|
+
that.setState({
|
|
158
158
|
processing: true
|
|
159
159
|
}, function () {
|
|
160
|
-
|
|
160
|
+
that.setState({
|
|
161
161
|
dispatchComplete: false
|
|
162
162
|
}, function () {
|
|
163
|
-
|
|
163
|
+
that.dispatchApi({
|
|
164
164
|
type: submitApiPath,
|
|
165
165
|
payload: submitData
|
|
166
166
|
}).then(function () {
|
|
167
|
-
if (
|
|
168
|
-
var remoteData =
|
|
169
|
-
|
|
167
|
+
if (that.mounted) {
|
|
168
|
+
var remoteData = that.apiDataConvert(that.props);
|
|
170
169
|
var dataSuccess = remoteData.dataSuccess;
|
|
171
170
|
|
|
172
171
|
if (dataSuccess) {
|
|
173
172
|
var metaListData = remoteData.list,
|
|
174
173
|
metaData = remoteData.data,
|
|
175
174
|
metaExtra = remoteData.extra;
|
|
176
|
-
|
|
177
|
-
_this.afterSubmitSuccess({
|
|
175
|
+
that.afterSubmitSuccess({
|
|
178
176
|
singleData: metaData || null,
|
|
179
177
|
listData: metaListData || [],
|
|
180
178
|
extraData: metaExtra || null,
|
|
@@ -188,14 +186,13 @@ var BaseAddForm = /*#__PURE__*/function (_DataCore) {
|
|
|
188
186
|
}
|
|
189
187
|
}
|
|
190
188
|
|
|
191
|
-
|
|
189
|
+
that.setState({
|
|
192
190
|
processing: false,
|
|
193
191
|
dispatchComplete: true
|
|
194
192
|
});
|
|
195
193
|
}).catch(function (res) {
|
|
196
194
|
(0, _tools.recordObject)(res);
|
|
197
|
-
|
|
198
|
-
_this.setState({
|
|
195
|
+
that.setState({
|
|
199
196
|
processing: false,
|
|
200
197
|
dispatchComplete: true
|
|
201
198
|
});
|
|
@@ -79,7 +79,6 @@ var BaseUpdateForm = /*#__PURE__*/function (_DataSingleView) {
|
|
|
79
79
|
_this.execSubmitApi = function () {
|
|
80
80
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
81
81
|
var afterSubmitCallback = arguments.length > 1 ? arguments[1] : undefined;
|
|
82
|
-
var dispatch = _this.props.dispatch;
|
|
83
82
|
var submitApiPath = _this.state.submitApiPath;
|
|
84
83
|
|
|
85
84
|
if ((submitApiPath || '') === '') {
|
|
@@ -98,27 +97,27 @@ var BaseUpdateForm = /*#__PURE__*/function (_DataSingleView) {
|
|
|
98
97
|
submitData = _this.afterCheckSubmitRequestParams(submitData);
|
|
99
98
|
|
|
100
99
|
if (checkResult) {
|
|
101
|
-
_this
|
|
100
|
+
var that = _assertThisInitialized(_this);
|
|
101
|
+
|
|
102
|
+
that.setState({
|
|
102
103
|
processing: true
|
|
103
104
|
}, function () {
|
|
104
|
-
|
|
105
|
+
that.setState({
|
|
105
106
|
dispatchComplete: false
|
|
106
107
|
}, function () {
|
|
107
|
-
|
|
108
|
+
that.dispatchApi({
|
|
108
109
|
type: submitApiPath,
|
|
109
110
|
payload: submitData
|
|
110
111
|
}).then(function () {
|
|
111
|
-
if (
|
|
112
|
-
var remoteData =
|
|
113
|
-
|
|
112
|
+
if (that.mounted) {
|
|
113
|
+
var remoteData = that.apiDataConvert(that.props);
|
|
114
114
|
var dataSuccess = remoteData.dataSuccess;
|
|
115
115
|
|
|
116
116
|
if (dataSuccess) {
|
|
117
117
|
var metaListData = remoteData.list,
|
|
118
118
|
metaData = remoteData.data,
|
|
119
119
|
metaExtra = remoteData.extra;
|
|
120
|
-
|
|
121
|
-
_this.afterSubmitSuccess({
|
|
120
|
+
that.afterSubmitSuccess({
|
|
122
121
|
singleData: metaData || null,
|
|
123
122
|
listData: metaListData || [],
|
|
124
123
|
extraData: metaExtra || null,
|
|
@@ -131,15 +130,14 @@ var BaseUpdateForm = /*#__PURE__*/function (_DataSingleView) {
|
|
|
131
130
|
afterSubmitCallback();
|
|
132
131
|
}
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
that.setState({
|
|
135
134
|
processing: false,
|
|
136
135
|
dispatchComplete: true
|
|
137
136
|
});
|
|
138
137
|
}
|
|
139
138
|
}).catch(function (res) {
|
|
140
139
|
(0, _tools.recordObject)(res);
|
|
141
|
-
|
|
142
|
-
_this.setState({
|
|
140
|
+
that.setState({
|
|
143
141
|
processing: false,
|
|
144
142
|
dispatchComplete: true
|
|
145
143
|
});
|
|
@@ -185,7 +185,6 @@ var BaseWindow = /*#__PURE__*/function (_Base) {
|
|
|
185
185
|
_this.execSubmitApi = function () {
|
|
186
186
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
187
187
|
var afterSubmitCallback = arguments.length > 1 ? arguments[1] : undefined;
|
|
188
|
-
var dispatch = _this.props.dispatch;
|
|
189
188
|
var submitApiPath = _this.state.submitApiPath;
|
|
190
189
|
|
|
191
190
|
if ((submitApiPath || '') === '') {
|
|
@@ -204,27 +203,27 @@ var BaseWindow = /*#__PURE__*/function (_Base) {
|
|
|
204
203
|
submitData = _this.afterCheckSubmitRequestParams(submitData);
|
|
205
204
|
|
|
206
205
|
if (checkResult) {
|
|
207
|
-
_this
|
|
206
|
+
var that = _assertThisInitialized(_this);
|
|
207
|
+
|
|
208
|
+
that.setState({
|
|
208
209
|
processing: true
|
|
209
210
|
}, function () {
|
|
210
|
-
|
|
211
|
+
that.setState({
|
|
211
212
|
dispatchComplete: false
|
|
212
213
|
}, function () {
|
|
213
|
-
|
|
214
|
+
that.dispatchApi({
|
|
214
215
|
type: submitApiPath,
|
|
215
216
|
payload: submitData
|
|
216
217
|
}).then(function () {
|
|
217
|
-
if (
|
|
218
|
-
var remoteData =
|
|
219
|
-
|
|
218
|
+
if (that.mounted) {
|
|
219
|
+
var remoteData = that.apiDataConvert(that.props);
|
|
220
220
|
var dataSuccess = remoteData.dataSuccess;
|
|
221
221
|
|
|
222
222
|
if (dataSuccess) {
|
|
223
223
|
var metaListData = remoteData.list,
|
|
224
224
|
metaData = remoteData.data,
|
|
225
225
|
metaExtra = remoteData.extra;
|
|
226
|
-
|
|
227
|
-
_this.afterSubmitSuccess({
|
|
226
|
+
that.afterSubmitSuccess({
|
|
228
227
|
singleData: metaData || null,
|
|
229
228
|
listData: metaListData || [],
|
|
230
229
|
extraData: metaExtra || null,
|
|
@@ -238,14 +237,13 @@ var BaseWindow = /*#__PURE__*/function (_Base) {
|
|
|
238
237
|
}
|
|
239
238
|
}
|
|
240
239
|
|
|
241
|
-
|
|
240
|
+
that.setState({
|
|
242
241
|
processing: false,
|
|
243
242
|
dispatchComplete: true
|
|
244
243
|
});
|
|
245
244
|
}).catch(function (res) {
|
|
246
245
|
(0, _tools.recordObject)(res);
|
|
247
|
-
|
|
248
|
-
_this.setState({
|
|
246
|
+
that.setState({
|
|
249
247
|
processing: false,
|
|
250
248
|
dispatchComplete: true
|
|
251
249
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {*} param0
|
|
4
|
-
* @returns
|
|
2
|
+
* apiDataConvertCore
|
|
5
3
|
*/
|
|
6
|
-
export function
|
|
4
|
+
export function apiDataConvertCore({ props, modelName }: {
|
|
5
|
+
props: any;
|
|
6
|
+
modelName: any;
|
|
7
|
+
}): any;
|
|
7
8
|
/**
|
|
8
9
|
* 处理 actionCore 的异步请求结果
|
|
9
10
|
* @param {*} param0
|
|
@@ -13,10 +14,10 @@ export function handleItem({ target, dataId, compareDataIdHandler, handler }: an
|
|
|
13
14
|
/**
|
|
14
15
|
* remote assess core
|
|
15
16
|
*/
|
|
16
|
-
export function actionCore({ api, params,
|
|
17
|
+
export function actionCore({ api, params, apiDataConvert, target, handleData, successCallback, successMessage, successMessageBuilder, showProcessing, textProcessing, }: {
|
|
17
18
|
api: any;
|
|
18
19
|
params: any;
|
|
19
|
-
|
|
20
|
+
apiDataConvert?: null | undefined;
|
|
20
21
|
target: any;
|
|
21
22
|
handleData: any;
|
|
22
23
|
successCallback: any;
|
package/es/utils/actionAssist.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.actionCore = actionCore;
|
|
7
|
+
exports.apiDataConvertCore = apiDataConvertCore;
|
|
7
8
|
exports.confirmActionCore = confirmActionCore;
|
|
8
9
|
exports.empty = empty;
|
|
9
|
-
exports.getApiDataCore = getApiDataCore;
|
|
10
10
|
exports.handleItem = handleItem;
|
|
11
11
|
|
|
12
12
|
require("antd/es/message/style");
|
|
@@ -21,18 +21,22 @@ var _tools = require("./tools");
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
|
|
28
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
|
+
|
|
24
30
|
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); } }
|
|
25
31
|
|
|
26
32
|
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); }); }; }
|
|
27
33
|
|
|
28
34
|
var confirm = _modal.default.confirm;
|
|
29
35
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {*} param0
|
|
32
|
-
* @returns
|
|
36
|
+
* apiDataConvertCore
|
|
33
37
|
*/
|
|
34
38
|
|
|
35
|
-
function
|
|
39
|
+
function apiDataConvertCore(_ref) {
|
|
36
40
|
var props = _ref.props,
|
|
37
41
|
modelName = _ref.modelName;
|
|
38
42
|
|
|
@@ -40,16 +44,21 @@ function getApiDataCore(_ref) {
|
|
|
40
44
|
throw new Error('props is undefined, please check params.');
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
if ((0, _tools.stringIsNullOrWhiteSpace)(modelName) || !(0, _tools.isString)(modelName)) {
|
|
48
|
+
throw new Error('apiDataConvertCore params: modelName must be a string, please check.');
|
|
49
|
+
}
|
|
50
|
+
|
|
43
51
|
var m = (0, _tools.getPathValue)(props, modelName);
|
|
44
52
|
|
|
45
53
|
if ((m || null) == null) {
|
|
46
|
-
(0, _tools.
|
|
54
|
+
(0, _tools.recordObject)(props);
|
|
55
|
+
(0, _tools.recordError)("apiDataConvertCore error: model ".concat(modelName, " is null or undefined"));
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
var data = m.data;
|
|
50
59
|
|
|
51
60
|
if ((data || null) == null) {
|
|
52
|
-
(0, _tools.recordError)("
|
|
61
|
+
(0, _tools.recordError)("apiDataConvertCore error: key \u201Cdata\u201D in model ".concat(modelName, " is null or undefined"));
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
return data;
|
|
@@ -134,13 +143,13 @@ function actionCore(_x) {
|
|
|
134
143
|
|
|
135
144
|
function _actionCore() {
|
|
136
145
|
_actionCore = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref3) {
|
|
137
|
-
var api, params, _ref3$
|
|
146
|
+
var api, params, _ref3$apiDataConvert, apiDataConvert, target, handleData, successCallback, _ref3$successMessage, successMessage, _ref3$successMessageB, successMessageBuilder, _ref3$showProcessing, showProcessing, _ref3$textProcessing, textProcessing, text, dispatch, key;
|
|
138
147
|
|
|
139
148
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
140
149
|
while (1) {
|
|
141
150
|
switch (_context.prev = _context.next) {
|
|
142
151
|
case 0:
|
|
143
|
-
api = _ref3.api, params = _ref3.params, _ref3$
|
|
152
|
+
api = _ref3.api, params = _ref3.params, _ref3$apiDataConvert = _ref3.apiDataConvert, apiDataConvert = _ref3$apiDataConvert === void 0 ? null : _ref3$apiDataConvert, target = _ref3.target, handleData = _ref3.handleData, successCallback = _ref3.successCallback, _ref3$successMessage = _ref3.successMessage, successMessage = _ref3$successMessage === void 0 ? '数据已经操作成功,请进行后续操作。' : _ref3$successMessage, _ref3$successMessageB = _ref3.successMessageBuilder, successMessageBuilder = _ref3$successMessageB === void 0 ? null : _ref3$successMessageB, _ref3$showProcessing = _ref3.showProcessing, showProcessing = _ref3$showProcessing === void 0 ? true : _ref3$showProcessing, _ref3$textProcessing = _ref3.textProcessing, textProcessing = _ref3$textProcessing === void 0 ? '处理中,请稍后' : _ref3$textProcessing;
|
|
144
153
|
|
|
145
154
|
if ((handleData || null) == null) {
|
|
146
155
|
text = 'actionCore : handleData not allow null';
|
|
@@ -203,6 +212,7 @@ function _actionCore() {
|
|
|
203
212
|
}, function () {
|
|
204
213
|
// 延迟一定时间,优化界面呈现
|
|
205
214
|
setTimeout(function () {
|
|
215
|
+
(0, _tools.recordDebug)("modal access: ".concat(api));
|
|
206
216
|
dispatch({
|
|
207
217
|
type: api,
|
|
208
218
|
payload: params
|
|
@@ -213,24 +223,32 @@ function _actionCore() {
|
|
|
213
223
|
}, 200);
|
|
214
224
|
}
|
|
215
225
|
|
|
216
|
-
if (!(0, _tools.isFunction)(
|
|
217
|
-
throw new Error('actionCore:
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
var data = getApiData(target.props);
|
|
221
|
-
|
|
222
|
-
if ((data || null) == null) {
|
|
223
|
-
throw new Error('actionCore: getApiData result not allow null');
|
|
226
|
+
if (!(0, _tools.isFunction)(apiDataConvert)) {
|
|
227
|
+
throw new Error('actionCore params: apiDataConvert must be function');
|
|
224
228
|
}
|
|
225
229
|
|
|
230
|
+
var data = apiDataConvert(target.props);
|
|
226
231
|
var dataSuccess = data.dataSuccess;
|
|
227
232
|
|
|
228
233
|
if (dataSuccess) {
|
|
229
|
-
var
|
|
234
|
+
var _list$data$extra$data = _objectSpread(_objectSpread({}, {
|
|
235
|
+
list: [],
|
|
236
|
+
data: null,
|
|
237
|
+
extra: null
|
|
238
|
+
}), data),
|
|
239
|
+
remoteListData = _list$data$extra$data.list,
|
|
240
|
+
remoteData = _list$data$extra$data.data,
|
|
241
|
+
remoteExtraData = _list$data$extra$data.data;
|
|
242
|
+
|
|
230
243
|
var messageText = successMessage;
|
|
231
244
|
|
|
232
245
|
if ((0, _tools.isFunction)(successMessageBuilder)) {
|
|
233
|
-
messageText = successMessageBuilder(
|
|
246
|
+
messageText = successMessageBuilder({
|
|
247
|
+
remoteListData: remoteListData || [],
|
|
248
|
+
remoteData: remoteData || null,
|
|
249
|
+
remoteExtraData: remoteExtraData || null,
|
|
250
|
+
remoteOriginal: data
|
|
251
|
+
});
|
|
234
252
|
}
|
|
235
253
|
|
|
236
254
|
(0, _tools.notifySuccess)(messageText);
|
|
@@ -239,7 +257,10 @@ function _actionCore() {
|
|
|
239
257
|
successCallback({
|
|
240
258
|
target: target,
|
|
241
259
|
handleData: handleData,
|
|
242
|
-
|
|
260
|
+
remoteListData: remoteListData || [],
|
|
261
|
+
remoteData: remoteData || null,
|
|
262
|
+
remoteExtraData: remoteExtraData || null,
|
|
263
|
+
remoteOriginal: data
|
|
243
264
|
});
|
|
244
265
|
}
|
|
245
266
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-management-fast-framework",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.28",
|
|
4
4
|
"description": "antd-management-fast-framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antd-management-fast-framework"
|
|
@@ -170,5 +170,5 @@
|
|
|
170
170
|
"bugs": {
|
|
171
171
|
"url": "https://github.com/kityandhero/antd-management-fast-framework/issues"
|
|
172
172
|
},
|
|
173
|
-
"gitHead": "
|
|
173
|
+
"gitHead": "8e09a22466fdcce909277789782bdf5bfb514b32"
|
|
174
174
|
}
|