ds-web-all 1.0.1-beta.97 → 1.0.1-beta.98
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.
|
@@ -26,7 +26,7 @@ var _helper = require("./helper");
|
|
|
26
26
|
var _useRequest3 = _interopRequireDefault(require("../../common/use-request"));
|
|
27
27
|
require("./form.less");
|
|
28
28
|
var _events = _interopRequireDefault(require("./events"));
|
|
29
|
-
var _excluded = ["alertProps", "comsMap", "className", "controls", "actions", "onSubmit", "request", "formatParams", "dataFormatAfterInit", "customValidateFields", "dataFormatBeforeSubmit", "beforeSubmit", "initialValuesRequest", "groupIdRequest", "onFinish", "onError", "initialValuesRequestSuccess", "onValuesChange", "renderItemList", "disableSubmitWhenUnChanged", "showActionInPageFooter", "title", "toastGlobalError", "value", "initialValues", "noContainer", "labelCol", "wrapperCol", "comparision", "layout", "inlineLayoutCol", "inlineLayoutRow", "inlineFlex"],
|
|
29
|
+
var _excluded = ["alertProps", "comsMap", "className", "controls", "actions", "onSubmit", "request", "formatParams", "dataFormatAfterInit", "customValidateFields", "dataFormatBeforeSubmit", "beforeSubmit", "initialValuesRequest", "groupIdRequest", "onFinish", "onValidFail", "onError", "initialValuesRequestSuccess", "onValuesChange", "renderItemList", "disableSubmitWhenUnChanged", "showActionInPageFooter", "title", "toastGlobalError", "value", "initialValues", "noContainer", "labelCol", "wrapperCol", "comparision", "layout", "inlineLayoutCol", "inlineLayoutRow", "inlineFlex"],
|
|
30
30
|
_excluded2 = ["url", "params", "data", "search"],
|
|
31
31
|
_excluded3 = ["comparision"],
|
|
32
32
|
_excluded4 = ["onClick"],
|
|
@@ -72,6 +72,7 @@ function CFForm(_ref) {
|
|
|
72
72
|
initialValuesRequest = _ref.initialValuesRequest,
|
|
73
73
|
groupIdRequest = _ref.groupIdRequest,
|
|
74
74
|
onFinish = _ref.onFinish,
|
|
75
|
+
onValidFail = _ref.onValidFail,
|
|
75
76
|
onError = _ref.onError,
|
|
76
77
|
initialValuesRequestSuccess = _ref.initialValuesRequestSuccess,
|
|
77
78
|
_ref$onValuesChange = _ref.onValuesChange,
|
|
@@ -343,125 +344,127 @@ function CFForm(_ref) {
|
|
|
343
344
|
currentTarget = submitEvt.currentTarget;
|
|
344
345
|
setGlobalError(null);
|
|
345
346
|
if (request) {
|
|
346
|
-
_context4.next =
|
|
347
|
+
_context4.next = 32;
|
|
347
348
|
break;
|
|
348
349
|
}
|
|
349
350
|
_context4.prev = 3;
|
|
350
351
|
_context4.next = 6;
|
|
351
352
|
return form.validateFields();
|
|
352
353
|
case 6:
|
|
353
|
-
_context4.next =
|
|
354
|
+
_context4.next = 13;
|
|
354
355
|
break;
|
|
355
356
|
case 8:
|
|
356
357
|
_context4.prev = 8;
|
|
357
358
|
_context4.t0 = _context4["catch"](3);
|
|
358
359
|
console.log('form valid error', _context4.t0);
|
|
360
|
+
onValidFail === null || onValidFail === void 0 ? void 0 : onValidFail(_context4.t0);
|
|
359
361
|
return _context4.abrupt("return");
|
|
360
|
-
case
|
|
362
|
+
case 13:
|
|
361
363
|
formValue = form.getFieldsValue(); // 如果有dataFormatBeforeSubmit这个函数,先在提交之前将数据处理一下,不然之间用表单数据
|
|
362
364
|
if (!dataFormatBeforeSubmit) {
|
|
363
|
-
_context4.next =
|
|
365
|
+
_context4.next = 20;
|
|
364
366
|
break;
|
|
365
367
|
}
|
|
366
|
-
_context4.next =
|
|
368
|
+
_context4.next = 17;
|
|
367
369
|
return dataFormatBeforeSubmit(formValue);
|
|
368
|
-
case
|
|
370
|
+
case 17:
|
|
369
371
|
_context4.t1 = _context4.sent;
|
|
370
|
-
_context4.next =
|
|
372
|
+
_context4.next = 21;
|
|
371
373
|
break;
|
|
372
|
-
case 19:
|
|
373
|
-
_context4.t1 = formValue;
|
|
374
374
|
case 20:
|
|
375
|
+
_context4.t1 = formValue;
|
|
376
|
+
case 21:
|
|
375
377
|
formValue = _context4.t1;
|
|
376
378
|
if (!beforeSubmit) {
|
|
377
|
-
_context4.next =
|
|
379
|
+
_context4.next = 28;
|
|
378
380
|
break;
|
|
379
381
|
}
|
|
380
|
-
_context4.next =
|
|
382
|
+
_context4.next = 25;
|
|
381
383
|
return beforeSubmit(formValue);
|
|
382
|
-
case
|
|
384
|
+
case 25:
|
|
383
385
|
couldSubmit = _context4.sent;
|
|
384
386
|
if (couldSubmit) {
|
|
385
|
-
_context4.next =
|
|
387
|
+
_context4.next = 28;
|
|
386
388
|
break;
|
|
387
389
|
}
|
|
388
390
|
return _context4.abrupt("return");
|
|
389
|
-
case
|
|
391
|
+
case 28:
|
|
390
392
|
onValuesChange('submit', formValue, form.setFieldsValue, form);
|
|
391
393
|
onSubmit && onSubmit(formValue, currentTarget);
|
|
392
394
|
onFinish && onFinish(form, currentTarget);
|
|
393
395
|
return _context4.abrupt("return");
|
|
394
|
-
case
|
|
395
|
-
_context4.prev =
|
|
396
|
-
_context4.next =
|
|
396
|
+
case 32:
|
|
397
|
+
_context4.prev = 32;
|
|
398
|
+
_context4.next = 35;
|
|
397
399
|
return form.validateFields();
|
|
398
|
-
case
|
|
399
|
-
_context4.next =
|
|
400
|
+
case 35:
|
|
401
|
+
_context4.next = 42;
|
|
400
402
|
break;
|
|
401
|
-
case
|
|
402
|
-
_context4.prev =
|
|
403
|
-
_context4.t2 = _context4["catch"](
|
|
403
|
+
case 37:
|
|
404
|
+
_context4.prev = 37;
|
|
405
|
+
_context4.t2 = _context4["catch"](32);
|
|
404
406
|
console.log('form valid error', _context4.t2);
|
|
407
|
+
onValidFail === null || onValidFail === void 0 ? void 0 : onValidFail(_context4.t2);
|
|
405
408
|
return _context4.abrupt("return");
|
|
406
|
-
case
|
|
409
|
+
case 42:
|
|
407
410
|
// debugger;
|
|
408
411
|
isGoBack = (currentTarget === null || currentTarget === void 0 ? void 0 : (_currentTarget$datase = currentTarget.dataset) === null || _currentTarget$datase === void 0 ? void 0 : _currentTarget$datase.submitAction) === 'goBack';
|
|
409
412
|
isGoBack ? setSubmitLoadGoBack(true) : setSubmitLoadRefresh(true);
|
|
410
413
|
setSubmitDisabled(true);
|
|
411
|
-
_context4.prev =
|
|
414
|
+
_context4.prev = 45;
|
|
412
415
|
// 获取表单数据
|
|
413
416
|
_formValue = form.getFieldsValue();
|
|
414
417
|
if (!customValidateFields) {
|
|
415
|
-
_context4.next =
|
|
418
|
+
_context4.next = 52;
|
|
416
419
|
break;
|
|
417
420
|
}
|
|
418
421
|
shouldNext = customValidateFields(_formValue);
|
|
419
422
|
if (shouldNext) {
|
|
420
|
-
_context4.next =
|
|
423
|
+
_context4.next = 52;
|
|
421
424
|
break;
|
|
422
425
|
}
|
|
423
426
|
isGoBack ? setSubmitLoadGoBack(false) : setSubmitLoadRefresh(false);
|
|
424
427
|
return _context4.abrupt("return");
|
|
425
|
-
case
|
|
428
|
+
case 52:
|
|
426
429
|
if (!dataFormatBeforeSubmit) {
|
|
427
|
-
_context4.next =
|
|
430
|
+
_context4.next = 58;
|
|
428
431
|
break;
|
|
429
432
|
}
|
|
430
|
-
_context4.next =
|
|
433
|
+
_context4.next = 55;
|
|
431
434
|
return dataFormatBeforeSubmit(_formValue);
|
|
432
|
-
case
|
|
435
|
+
case 55:
|
|
433
436
|
_context4.t3 = _context4.sent;
|
|
434
|
-
_context4.next =
|
|
437
|
+
_context4.next = 59;
|
|
435
438
|
break;
|
|
436
|
-
case
|
|
439
|
+
case 58:
|
|
437
440
|
_context4.t3 = _formValue;
|
|
438
|
-
case
|
|
441
|
+
case 59:
|
|
439
442
|
_formValue = _context4.t3;
|
|
440
443
|
if (!beforeSubmit) {
|
|
441
|
-
_context4.next =
|
|
444
|
+
_context4.next = 67;
|
|
442
445
|
break;
|
|
443
446
|
}
|
|
444
|
-
_context4.next =
|
|
447
|
+
_context4.next = 63;
|
|
445
448
|
return beforeSubmit(_formValue);
|
|
446
|
-
case
|
|
449
|
+
case 63:
|
|
447
450
|
_couldSubmit = _context4.sent;
|
|
448
451
|
if (_couldSubmit) {
|
|
449
|
-
_context4.next =
|
|
452
|
+
_context4.next = 67;
|
|
450
453
|
break;
|
|
451
454
|
}
|
|
452
455
|
isGoBack ? setSubmitLoadGoBack(false) : setSubmitLoadRefresh(false);
|
|
453
456
|
return _context4.abrupt("return");
|
|
454
|
-
case
|
|
457
|
+
case 67:
|
|
455
458
|
onSubmit && onSubmit(_formValue, currentTarget);
|
|
456
459
|
// 发送请求
|
|
457
|
-
_context4.next =
|
|
460
|
+
_context4.next = 70;
|
|
458
461
|
return _services.default.request(request.url, {
|
|
459
462
|
method: request.method,
|
|
460
463
|
data: formatParams ? formatParams(_objectSpread(_objectSpread({}, _formValue), request === null || request === void 0 ? void 0 : request.params)) : _objectSpread(_objectSpread({}, _formValue), request === null || request === void 0 ? void 0 : request.params),
|
|
461
464
|
formatter: request === null || request === void 0 ? void 0 : request.formatter,
|
|
462
465
|
showError: false
|
|
463
466
|
});
|
|
464
|
-
case
|
|
467
|
+
case 70:
|
|
465
468
|
response = _context4.sent;
|
|
466
469
|
// button form 的场景不需要复杂的报错提示
|
|
467
470
|
if ((response === null || response === void 0 ? void 0 : response.code) == 200 || (response === null || response === void 0 ? void 0 : response.code) == 0) {
|
|
@@ -476,25 +479,25 @@ function CFForm(_ref) {
|
|
|
476
479
|
} else {
|
|
477
480
|
handleSubmitError(response);
|
|
478
481
|
}
|
|
479
|
-
_context4.next =
|
|
482
|
+
_context4.next = 78;
|
|
480
483
|
break;
|
|
481
|
-
case
|
|
482
|
-
_context4.prev =
|
|
483
|
-
_context4.t4 = _context4["catch"](
|
|
484
|
+
case 74:
|
|
485
|
+
_context4.prev = 74;
|
|
486
|
+
_context4.t4 = _context4["catch"](45);
|
|
484
487
|
console.log(_context4.t4);
|
|
485
488
|
_message2.default.error(_context4.t4.message || '操作失败');
|
|
486
|
-
case
|
|
487
|
-
_context4.prev =
|
|
489
|
+
case 78:
|
|
490
|
+
_context4.prev = 78;
|
|
488
491
|
setTimeout(function () {
|
|
489
492
|
isGoBack ? setSubmitLoadGoBack(false) : setSubmitLoadRefresh(false);
|
|
490
493
|
setSubmitDisabled(false);
|
|
491
494
|
}, 2000);
|
|
492
|
-
return _context4.finish(
|
|
493
|
-
case
|
|
495
|
+
return _context4.finish(78);
|
|
496
|
+
case 81:
|
|
494
497
|
case "end":
|
|
495
498
|
return _context4.stop();
|
|
496
499
|
}
|
|
497
|
-
}, _callee3, null, [[3, 8], [
|
|
500
|
+
}, _callee3, null, [[3, 8], [32, 37], [45, 74, 78, 81]]);
|
|
498
501
|
}));
|
|
499
502
|
return function handleSubmit(_x3) {
|
|
500
503
|
return _ref5.apply(this, arguments);
|