@lemon-fe/kits 1.4.22 → 1.4.23
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.
|
@@ -8,6 +8,8 @@ declare type ProcessStepParams<T> = {
|
|
|
8
8
|
* 上一步的额外信息,如果上一步执行成功,则没有该数据
|
|
9
9
|
*/
|
|
10
10
|
payload?: any;
|
|
11
|
+
/** 这一步的操作是否允许自动执行 */
|
|
12
|
+
skipWarning?: boolean;
|
|
11
13
|
};
|
|
12
14
|
declare type ProcessStep<T, R> = {
|
|
13
15
|
/** 在不传入render warning会自动进行二次确认 */
|
|
@@ -39,6 +41,14 @@ interface Props<RecordType extends Record<string, any> = Record<string, any>, Re
|
|
|
39
41
|
*/
|
|
40
42
|
footer?: ReactNode | ((record: RecordType[], others: {
|
|
41
43
|
results: Map<Key, Result<ResultType>>;
|
|
44
|
+
isExecuting?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 全部执行逻辑
|
|
47
|
+
* 主要功能以handle里中的skipWarning实现
|
|
48
|
+
* 使用时,注意配置process中的skipWarning
|
|
49
|
+
* 中间不配置skipWarning的步骤会停下来
|
|
50
|
+
**/
|
|
51
|
+
executeUntilBlocked: () => void;
|
|
42
52
|
}) => ReactNode);
|
|
43
53
|
/**
|
|
44
54
|
* @description 关闭时触发
|
|
@@ -91,6 +91,16 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
91
91
|
var result = typeof rowKey === 'function' ? rowKey(record) : get(record, rowKey);
|
|
92
92
|
return String(result !== null && result !== void 0 ? result : '').toString();
|
|
93
93
|
});
|
|
94
|
+
_defineProperty(_assertThisInitialized(_this), "executeUntilBlocked", function () {
|
|
95
|
+
var results = _this.state.results;
|
|
96
|
+
var params = _this.props.params;
|
|
97
|
+
results.forEach(function (result, id) {
|
|
98
|
+
if (!result.loading && result.error && result.stepIdx !== undefined) {
|
|
99
|
+
var stepIdx = result.stepIdx;
|
|
100
|
+
_this.processNode(id, stepIdx + 1, params, undefined, true);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
94
104
|
_defineProperty(_assertThisInitialized(_this), "handleClose", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
95
105
|
var _this$props, onBeforeClose, onClose, data, results, value;
|
|
96
106
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -214,40 +224,56 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
214
224
|
value: function () {
|
|
215
225
|
var _processNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id, stepIdx, payload, next) {
|
|
216
226
|
var _this2 = this;
|
|
217
|
-
var
|
|
227
|
+
var skipWarning,
|
|
228
|
+
process,
|
|
229
|
+
_this$locale,
|
|
230
|
+
continueText,
|
|
231
|
+
oprationSuccessText,
|
|
232
|
+
grid,
|
|
233
|
+
node,
|
|
234
|
+
data,
|
|
235
|
+
_process$stepIdx,
|
|
236
|
+
handler,
|
|
237
|
+
renderResult,
|
|
238
|
+
mode,
|
|
239
|
+
isFinal,
|
|
240
|
+
done,
|
|
241
|
+
_result,
|
|
242
|
+
_args2 = arguments;
|
|
218
243
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
219
244
|
while (1) switch (_context2.prev = _context2.next) {
|
|
220
245
|
case 0:
|
|
246
|
+
skipWarning = _args2.length > 4 && _args2[4] !== undefined ? _args2[4] : false;
|
|
221
247
|
process = this.state.process;
|
|
222
248
|
_this$locale = this.locale, continueText = _this$locale.continueText, oprationSuccessText = _this$locale.oprationSuccessText;
|
|
223
249
|
if (!(stepIdx >= process.length)) {
|
|
224
|
-
_context2.next =
|
|
250
|
+
_context2.next = 6;
|
|
225
251
|
break;
|
|
226
252
|
}
|
|
227
253
|
next === null || next === void 0 || next();
|
|
228
254
|
return _context2.abrupt("return");
|
|
229
|
-
case
|
|
255
|
+
case 6:
|
|
230
256
|
grid = this.grid.current;
|
|
231
257
|
if (!(!grid || !grid.ready())) {
|
|
232
|
-
_context2.next =
|
|
258
|
+
_context2.next = 9;
|
|
233
259
|
break;
|
|
234
260
|
}
|
|
235
261
|
return _context2.abrupt("return");
|
|
236
|
-
case
|
|
262
|
+
case 9:
|
|
237
263
|
node = grid.api.getRowNode(id);
|
|
238
264
|
if (node) {
|
|
239
|
-
_context2.next =
|
|
265
|
+
_context2.next = 12;
|
|
240
266
|
break;
|
|
241
267
|
}
|
|
242
268
|
return _context2.abrupt("return");
|
|
243
|
-
case
|
|
269
|
+
case 12:
|
|
244
270
|
data = node.data;
|
|
245
271
|
if (data) {
|
|
246
|
-
_context2.next =
|
|
272
|
+
_context2.next = 15;
|
|
247
273
|
break;
|
|
248
274
|
}
|
|
249
275
|
return _context2.abrupt("return");
|
|
250
|
-
case
|
|
276
|
+
case 15:
|
|
251
277
|
_process$stepIdx = process[stepIdx], handler = _process$stepIdx.handler, renderResult = _process$stepIdx.render, mode = _process$stepIdx.mode;
|
|
252
278
|
isFinal = stepIdx === process.length - 1;
|
|
253
279
|
done = function done(result, error) {
|
|
@@ -258,6 +284,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
258
284
|
result: result,
|
|
259
285
|
error: error,
|
|
260
286
|
payload: payload,
|
|
287
|
+
stepIdx: stepIdx,
|
|
261
288
|
render: function render() {
|
|
262
289
|
if (error) {
|
|
263
290
|
if (mode === 'warning') {
|
|
@@ -322,6 +349,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
322
349
|
result: result,
|
|
323
350
|
error: error,
|
|
324
351
|
payload: payload,
|
|
352
|
+
stepIdx: stepIdx,
|
|
325
353
|
render: function render() {
|
|
326
354
|
return renderResult({
|
|
327
355
|
data: data,
|
|
@@ -343,40 +371,41 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
343
371
|
});
|
|
344
372
|
}
|
|
345
373
|
} else {
|
|
346
|
-
_this2.processNode(id, stepIdx + 1, undefined, next);
|
|
374
|
+
_this2.processNode(id, stepIdx + 1, undefined, next, skipWarning);
|
|
347
375
|
}
|
|
348
376
|
};
|
|
349
|
-
_context2.prev =
|
|
377
|
+
_context2.prev = 18;
|
|
350
378
|
this.changeResult(id, {
|
|
351
379
|
loading: true
|
|
352
380
|
});
|
|
353
381
|
|
|
354
382
|
/** 这里需要将handler处理成异步函数,否则后续next拿到的this.state.paused依旧是true */
|
|
355
|
-
_context2.next =
|
|
383
|
+
_context2.next = 22;
|
|
356
384
|
return new Promise(function (res) {
|
|
357
385
|
/** 不能使用requestAnimationFrame,因为这个函数会在页面后台被浏览器阻塞,使用setTimeout至少还能执行,虽然会降低执行速度,后续可以考虑优化state的使用 */
|
|
358
386
|
setTimeout(res);
|
|
359
387
|
});
|
|
360
|
-
case
|
|
361
|
-
_context2.next =
|
|
388
|
+
case 22:
|
|
389
|
+
_context2.next = 24;
|
|
362
390
|
return handler({
|
|
363
391
|
data: data,
|
|
364
|
-
payload: payload
|
|
392
|
+
payload: payload,
|
|
393
|
+
skipWarning: skipWarning
|
|
365
394
|
});
|
|
366
|
-
case
|
|
395
|
+
case 24:
|
|
367
396
|
_result = _context2.sent;
|
|
368
397
|
done(_result);
|
|
369
|
-
_context2.next =
|
|
398
|
+
_context2.next = 31;
|
|
370
399
|
break;
|
|
371
|
-
case
|
|
372
|
-
_context2.prev =
|
|
373
|
-
_context2.t0 = _context2["catch"](
|
|
400
|
+
case 28:
|
|
401
|
+
_context2.prev = 28;
|
|
402
|
+
_context2.t0 = _context2["catch"](18);
|
|
374
403
|
done(undefined, _context2.t0);
|
|
375
|
-
case
|
|
404
|
+
case 31:
|
|
376
405
|
case "end":
|
|
377
406
|
return _context2.stop();
|
|
378
407
|
}
|
|
379
|
-
}, _callee2, this, [[
|
|
408
|
+
}, _callee2, this, [[18, 28]]);
|
|
380
409
|
}));
|
|
381
410
|
function processNode(_x, _x2, _x3, _x4) {
|
|
382
411
|
return _processNode.apply(this, arguments);
|
|
@@ -655,7 +684,9 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
655
684
|
});
|
|
656
685
|
},
|
|
657
686
|
footer: typeof footer === 'function' ? footer(data, {
|
|
658
|
-
results: this.getError()
|
|
687
|
+
results: this.getError(),
|
|
688
|
+
isExecuting: !paused,
|
|
689
|
+
executeUntilBlocked: this.executeUntilBlocked
|
|
659
690
|
}) : footer,
|
|
660
691
|
maskClosable: false,
|
|
661
692
|
afterClose: function afterClose() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/kits",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.23",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@ant-design/icons": "^4.7.0",
|
|
27
|
-
"@lemon-fe/components": "^1.4.
|
|
27
|
+
"@lemon-fe/components": "^1.4.23",
|
|
28
28
|
"@lemon-fe/hooks": "^1.4.15",
|
|
29
29
|
"@lemon-fe/utils": "^1.4.15",
|
|
30
30
|
"ag-grid-community": "29.2.0",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"registry": "https://registry.npmjs.org"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "c3d8070a21dfdb8b63295e76dd0b8484a94d372a"
|
|
51
51
|
}
|